glimmer-dsl-libui 0.1.2 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +55 -0
- data/README.md +1127 -65
- data/VERSION +1 -1
- data/examples/area_gallery.rb +50 -0
- data/examples/area_gallery2.rb +111 -0
- data/examples/area_gallery3.rb +52 -0
- data/examples/area_gallery4.rb +113 -0
- data/examples/basic_area2.rb +1 -1
- data/examples/basic_button.rb +2 -2
- data/examples/basic_entry.rb +2 -2
- data/examples/basic_table_progress_bar.rb +13 -3
- data/examples/basic_transform.rb +27 -0
- data/examples/control_gallery.rb +3 -3
- data/examples/dynamic_area.rb +1 -1
- data/examples/form.rb +2 -2
- data/examples/histogram.rb +118 -0
- data/examples/meta_example.rb +71 -20
- data/examples/midi_player.rb +8 -10
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/control_expression.rb +1 -3
- data/lib/glimmer/dsl/libui/dsl.rb +1 -0
- data/lib/glimmer/dsl/libui/file_expression.rb +5 -1
- data/lib/glimmer/dsl/libui/property_expression.rb +5 -1
- data/lib/glimmer/{libui/box.rb → dsl/libui/shape_expression.rb} +26 -29
- data/lib/glimmer/dsl/libui/tab_item_expression.rb +2 -2
- data/lib/glimmer/libui/control_proxy/area_proxy.rb +117 -0
- data/lib/glimmer/libui/{menu_item_proxy.rb → control_proxy/box/horizontal_box_proxy.rb} +9 -12
- data/lib/glimmer/libui/{vertical_box_proxy.rb → control_proxy/box/vertical_box_proxy.rb} +10 -6
- data/lib/glimmer/libui/control_proxy/box.rb +61 -0
- data/lib/glimmer/libui/{button_proxy.rb → control_proxy/button_proxy.rb} +14 -12
- data/lib/glimmer/libui/{checkbox_proxy.rb → control_proxy/checkbox_proxy.rb} +14 -12
- data/lib/glimmer/libui/control_proxy/color_button_proxy.rb +118 -0
- data/lib/glimmer/libui/control_proxy/column/button_column_proxy.rb +76 -0
- data/lib/glimmer/libui/control_proxy/column/checkbox_column_proxy.rb +46 -0
- data/lib/glimmer/libui/control_proxy/column/checkbox_text_column_proxy.rb +80 -0
- data/lib/glimmer/libui/{radio_buttons_proxy.rb → control_proxy/column/image_column_proxy.rb} +14 -13
- data/lib/glimmer/libui/control_proxy/column/image_text_column_proxy.rb +48 -0
- data/lib/glimmer/libui/{progress_bar_column_proxy.rb → control_proxy/column/progress_bar_column_proxy.rb} +14 -10
- data/lib/glimmer/libui/control_proxy/column/text_column_proxy.rb +46 -0
- data/lib/glimmer/libui/control_proxy/column.rb +55 -0
- data/lib/glimmer/libui/{checkbox_column_proxy.rb → control_proxy/combobox_proxy.rb} +16 -13
- data/lib/glimmer/libui/control_proxy/date_time_picker_proxy/date_picker_proxy.rb +43 -0
- data/lib/glimmer/libui/control_proxy/date_time_picker_proxy/time_picker_proxy.rb +43 -0
- data/lib/glimmer/libui/control_proxy/date_time_picker_proxy.rb +72 -0
- data/lib/glimmer/libui/control_proxy/dual_column.rb +40 -0
- data/lib/glimmer/libui/control_proxy/editable_column.rb +46 -0
- data/lib/glimmer/libui/control_proxy/editable_combobox_proxy.rb +45 -0
- data/lib/glimmer/libui/{dual_column.rb → control_proxy/enableable_column.rb} +18 -10
- data/lib/glimmer/libui/control_proxy/font_button_proxy.rb +70 -0
- data/lib/glimmer/libui/{form_proxy.rb → control_proxy/form_proxy.rb} +26 -24
- data/lib/glimmer/libui/{grid_proxy.rb → control_proxy/grid_proxy.rb} +29 -27
- data/lib/glimmer/libui/{group_proxy.rb → control_proxy/group_proxy.rb} +24 -22
- data/lib/glimmer/libui/{image_part_proxy.rb → control_proxy/image_part_proxy.rb} +20 -18
- data/lib/glimmer/libui/{image_proxy.rb → control_proxy/image_proxy.rb} +32 -30
- data/lib/glimmer/libui/{combobox_proxy.rb → control_proxy/label_proxy.rb} +13 -13
- data/lib/glimmer/libui/control_proxy/matrix_proxy.rb +147 -0
- data/lib/glimmer/libui/{editable_column.rb → control_proxy/menu_item_proxy/about_menu_item_proxy.rb} +13 -16
- data/lib/glimmer/libui/control_proxy/menu_item_proxy/check_menu_item_proxy.rb +41 -0
- data/lib/glimmer/libui/{preferences_menu_item_proxy.rb → control_proxy/menu_item_proxy/preferences_menu_item_proxy.rb} +11 -9
- data/lib/glimmer/libui/control_proxy/menu_item_proxy/quit_menu_item_proxy.rb +66 -0
- data/lib/glimmer/libui/control_proxy/menu_item_proxy/separator_menu_item_proxy.rb +41 -0
- data/lib/glimmer/libui/control_proxy/menu_item_proxy.rb +45 -0
- data/lib/glimmer/libui/{editable_combobox_proxy.rb → control_proxy/menu_proxy.rb} +13 -13
- data/lib/glimmer/libui/{horizontal_box_proxy.rb → control_proxy/message_box/msg_box_error_proxy.rb} +9 -6
- data/lib/glimmer/libui/{multiline_entry_proxy.rb → control_proxy/message_box/msg_box_proxy.rb} +8 -6
- data/lib/glimmer/libui/{check_menu_item_proxy.rb → control_proxy/message_box.rb} +11 -10
- data/lib/glimmer/libui/control_proxy/multiline_entry_proxy/non_wrapping_multiline_entry_proxy.rb +34 -0
- data/lib/glimmer/libui/{image_column_proxy.rb → control_proxy/multiline_entry_proxy.rb} +10 -11
- data/lib/glimmer/libui/control_proxy/path_proxy.rb +169 -0
- data/lib/glimmer/libui/control_proxy/radio_buttons_proxy.rb +45 -0
- data/lib/glimmer/libui/{button_column_proxy.rb → control_proxy/tab_item_proxy.rb} +37 -40
- data/lib/glimmer/libui/control_proxy/table_proxy.rb +182 -0
- data/lib/glimmer/libui/control_proxy/transformable.rb +74 -0
- data/lib/glimmer/libui/control_proxy/window_proxy.rb +128 -0
- data/lib/glimmer/libui/control_proxy.rb +41 -22
- data/lib/glimmer/libui/{enableable_column.rb → parent.rb} +7 -15
- data/lib/glimmer/libui/shape/arc.rb +43 -0
- data/lib/glimmer/libui/{date_picker_proxy.rb → shape/bezier.rb} +8 -9
- data/lib/glimmer/libui/{quit_menu_item_proxy.rb → shape/figure.rb} +24 -32
- data/lib/glimmer/libui/{non_wrapping_multiline_entry_proxy.rb → shape/line.rb} +11 -5
- data/lib/glimmer/libui/{time_picker_proxy.rb → shape/rectangle.rb} +8 -9
- data/lib/glimmer/libui/{about_menu_item_proxy.rb → shape/square.rb} +9 -8
- data/lib/glimmer/libui/shape.rb +145 -0
- data/lib/glimmer/libui.rb +92 -0
- data/lib/glimmer-dsl-libui.rb +2 -0
- metadata +82 -48
- data/lib/glimmer/libui/area_proxy.rb +0 -105
- data/lib/glimmer/libui/checkbox_text_column_proxy.rb +0 -76
- data/lib/glimmer/libui/color_button_proxy.rb +0 -64
- data/lib/glimmer/libui/column.rb +0 -51
- data/lib/glimmer/libui/date_time_picker_proxy.rb +0 -68
- data/lib/glimmer/libui/font_button_proxy.rb +0 -68
- data/lib/glimmer/libui/image_text_column_proxy.rb +0 -44
- data/lib/glimmer/libui/label_proxy.rb +0 -41
- data/lib/glimmer/libui/menu_proxy.rb +0 -41
- data/lib/glimmer/libui/path_proxy.rb +0 -167
- data/lib/glimmer/libui/rectangle_proxy.rb +0 -100
- data/lib/glimmer/libui/separator_menu_item_proxy.rb +0 -37
- data/lib/glimmer/libui/tab_item_proxy.rb +0 -67
- data/lib/glimmer/libui/table_proxy.rb +0 -180
- data/lib/glimmer/libui/text_column_proxy.rb +0 -42
- data/lib/glimmer/libui/window_proxy.rb +0 -119
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Copyright (c) 2021 Andy Maleh
|
|
2
|
+
#
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
# a copy of this software and associated documentation files (the
|
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
# the following conditions:
|
|
10
|
+
#
|
|
11
|
+
# The above copyright notice and this permission notice shall be
|
|
12
|
+
# included in all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
require 'glimmer/libui/control_proxy'
|
|
23
|
+
|
|
24
|
+
module Glimmer
|
|
25
|
+
module LibUI
|
|
26
|
+
class ControlProxy
|
|
27
|
+
# Proxy for LibUI date time picker objects
|
|
28
|
+
#
|
|
29
|
+
# Follows the Proxy Design Pattern
|
|
30
|
+
class DateTimePickerProxy < ControlProxy
|
|
31
|
+
def libui_api_keyword
|
|
32
|
+
'date_time_picker'
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def time(value = nil)
|
|
36
|
+
@time ||= ::LibUI::FFI::TM.malloc
|
|
37
|
+
::LibUI.date_time_picker_time(@libui, @time)
|
|
38
|
+
if value.nil?
|
|
39
|
+
{
|
|
40
|
+
sec: @time.tm_sec,
|
|
41
|
+
min: @time.tm_min,
|
|
42
|
+
hour: @time.tm_hour,
|
|
43
|
+
mday: @time.tm_mday,
|
|
44
|
+
mon: @time.tm_mon + 1,
|
|
45
|
+
year: @time.tm_year + 1900,
|
|
46
|
+
wday: @time.tm_wday + 1,
|
|
47
|
+
yday: @time.tm_yday + 1,
|
|
48
|
+
dst: @time.tm_isdst == 1
|
|
49
|
+
}
|
|
50
|
+
else
|
|
51
|
+
@time.tm_sec = value[:sec] unless value[:sec].nil?
|
|
52
|
+
@time.tm_min = value[:min] unless value[:min].nil?
|
|
53
|
+
@time.tm_hour = value[:hour] unless value[:hour].nil?
|
|
54
|
+
@time.tm_mday = value[:mday] unless value[:mday].nil?
|
|
55
|
+
@time.tm_mon = value[:mon] - 1 unless value[:mon].nil?
|
|
56
|
+
@time.tm_year = value[:year] - 1900 unless value[:year].nil?
|
|
57
|
+
::LibUI.date_time_picker_set_time(@libui, @time)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
alias set_time time
|
|
61
|
+
alias time= time
|
|
62
|
+
|
|
63
|
+
def destroy
|
|
64
|
+
Fiddle.free @time unless @time.nil?
|
|
65
|
+
super
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
Dir[File.expand_path("./#{File.basename(__FILE__, '.rb')}/*.rb", __dir__)].each {|f| require f}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Copyright (c) 2021 Andy Maleh
|
|
2
|
+
#
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
# a copy of this software and associated documentation files (the
|
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
# the following conditions:
|
|
10
|
+
#
|
|
11
|
+
# The above copyright notice and this permission notice shall be
|
|
12
|
+
# included in all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
module Glimmer
|
|
23
|
+
module LibUI
|
|
24
|
+
class ControlProxy
|
|
25
|
+
# A dual column is one that represents two values (e.g. image and text or checkbox and text)
|
|
26
|
+
# It is meant to be included in a column proxy class that already includes Column
|
|
27
|
+
module DualColumn
|
|
28
|
+
def second_column_index
|
|
29
|
+
column_index + 1
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def column_index
|
|
33
|
+
@column_index ||= @parent_proxy.send(:next_column_index).tap do
|
|
34
|
+
@parent_proxy.send(:next_column_index)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Copyright (c) 2021 Andy Maleh
|
|
2
|
+
#
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
# a copy of this software and associated documentation files (the
|
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
# the following conditions:
|
|
10
|
+
#
|
|
11
|
+
# The above copyright notice and this permission notice shall be
|
|
12
|
+
# included in all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
module Glimmer
|
|
23
|
+
module LibUI
|
|
24
|
+
class ControlProxy
|
|
25
|
+
module EditableColumn
|
|
26
|
+
def editable(value = nil)
|
|
27
|
+
if value.nil?
|
|
28
|
+
@editable = false if @editable.nil?
|
|
29
|
+
@editable
|
|
30
|
+
else
|
|
31
|
+
@editable = !!value
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
alias editable= editable
|
|
35
|
+
alias set_editable editable
|
|
36
|
+
alias editable? editable
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def editable_value
|
|
41
|
+
(@parent_proxy.editable? || editable?) ? -2 : -1
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Copyright (c) 2021 Andy Maleh
|
|
2
|
+
#
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
# a copy of this software and associated documentation files (the
|
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
# the following conditions:
|
|
10
|
+
#
|
|
11
|
+
# The above copyright notice and this permission notice shall be
|
|
12
|
+
# included in all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
require 'glimmer/libui/control_proxy'
|
|
23
|
+
|
|
24
|
+
module Glimmer
|
|
25
|
+
module LibUI
|
|
26
|
+
class ControlProxy
|
|
27
|
+
# Proxy for LibUI editable combobox objects
|
|
28
|
+
#
|
|
29
|
+
# Follows the Proxy Design Pattern
|
|
30
|
+
class EditableComboboxProxy < ControlProxy
|
|
31
|
+
def items(*values)
|
|
32
|
+
values = values.first if values.first.is_a?(Array)
|
|
33
|
+
if values.empty?
|
|
34
|
+
@values
|
|
35
|
+
else
|
|
36
|
+
@values = values
|
|
37
|
+
@values.each { |value| append value }
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
alias set_items items
|
|
41
|
+
alias items= items
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -21,16 +21,24 @@
|
|
|
21
21
|
|
|
22
22
|
module Glimmer
|
|
23
23
|
module LibUI
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
class ControlProxy
|
|
25
|
+
module EnableableColumn
|
|
26
|
+
def enabled(value = nil)
|
|
27
|
+
if value.nil?
|
|
28
|
+
@enabled = true if @enabled.nil?
|
|
29
|
+
@enabled
|
|
30
|
+
else
|
|
31
|
+
@enabled = !!value
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
alias enabled= enabled
|
|
35
|
+
alias set_enabled enabled
|
|
36
|
+
alias enabled? enabled
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def enabled_value
|
|
41
|
+
enabled? ? -2 : -1
|
|
34
42
|
end
|
|
35
43
|
end
|
|
36
44
|
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Copyright (c) 2021 Andy Maleh
|
|
2
|
+
#
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
# a copy of this software and associated documentation files (the
|
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
# the following conditions:
|
|
10
|
+
#
|
|
11
|
+
# The above copyright notice and this permission notice shall be
|
|
12
|
+
# included in all copies or substantial portions of the Software.
|
|
13
|
+
#
|
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
require 'glimmer/libui/control_proxy'
|
|
23
|
+
|
|
24
|
+
module Glimmer
|
|
25
|
+
module LibUI
|
|
26
|
+
class ControlProxy
|
|
27
|
+
# Proxy for LibUI font button objects
|
|
28
|
+
#
|
|
29
|
+
# Follows the Proxy Design Pattern
|
|
30
|
+
class FontButtonProxy < ControlProxy
|
|
31
|
+
def font
|
|
32
|
+
@font_descriptor ||= ::LibUI::FFI::FontDescriptor.malloc
|
|
33
|
+
::LibUI.font_button_font(@libui, @font_descriptor)
|
|
34
|
+
{
|
|
35
|
+
family: @font_descriptor.Family.to_s,
|
|
36
|
+
size: @font_descriptor.Size,
|
|
37
|
+
weight: @font_descriptor.Weight,
|
|
38
|
+
italic: @font_descriptor.Italic,
|
|
39
|
+
stretch: @font_descriptor.Stretch
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def family
|
|
44
|
+
font[:family]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def size
|
|
48
|
+
font[:size]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def weight
|
|
52
|
+
font[:weight]
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def italic
|
|
56
|
+
font[:italic]
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def stretch
|
|
60
|
+
font[:stretch]
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def destroy
|
|
64
|
+
::LibUI.free_font_button_font(@font_descriptor) unless @font_descriptor.nil?
|
|
65
|
+
super
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
@@ -23,30 +23,32 @@ require 'glimmer/libui/control_proxy'
|
|
|
23
23
|
|
|
24
24
|
module Glimmer
|
|
25
25
|
module LibUI
|
|
26
|
-
class
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
26
|
+
class ControlProxy
|
|
27
|
+
class FormProxy < ControlProxy
|
|
28
|
+
APPEND_PROPERTIES = %w[label stretchy]
|
|
29
|
+
|
|
30
|
+
def post_initialize_child(child)
|
|
31
|
+
child.label = '' if child.label.nil?
|
|
32
|
+
child.stretchy = true if child.stretchy.nil?
|
|
33
|
+
::LibUI.form_append(@libui, child.label, child.libui, Glimmer::LibUI.boolean_to_integer(child.stretchy))
|
|
34
|
+
children << child
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def children
|
|
38
|
+
@children ||= []
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def destroy_child(child)
|
|
42
|
+
::LibUI.send("form_delete", @libui, children.index(child))
|
|
43
|
+
ControlProxy.control_proxies.delete(child)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def build_control
|
|
49
|
+
super.tap do
|
|
50
|
+
self.padded = true
|
|
51
|
+
end
|
|
50
52
|
end
|
|
51
53
|
end
|
|
52
54
|
end
|
|
@@ -23,33 +23,35 @@ require 'glimmer/libui/control_proxy'
|
|
|
23
23
|
|
|
24
24
|
module Glimmer
|
|
25
25
|
module LibUI
|
|
26
|
-
class
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
26
|
+
class ControlProxy
|
|
27
|
+
class GridProxy < ControlProxy
|
|
28
|
+
APPEND_PROPERTIES = %w[left top xspan yspan hexpand halign vexpand valign]
|
|
29
|
+
|
|
30
|
+
def post_initialize_child(child)
|
|
31
|
+
child.left = 0 if child.left.nil?
|
|
32
|
+
child.top = 0 if child.top.nil?
|
|
33
|
+
child.xspan = 1 if child.xspan.nil?
|
|
34
|
+
child.yspan = 1 if child.yspan.nil?
|
|
35
|
+
child.hexpand = false if child.hexpand.nil?
|
|
36
|
+
child.halign = 0 if child.halign.nil?
|
|
37
|
+
child.vexpand = false if child.vexpand.nil?
|
|
38
|
+
child.valign = 0 if child.valign.nil?
|
|
39
|
+
::LibUI.grid_append(@libui, child.libui, child.left, child.top, child.xspan, child.yspan, Glimmer::LibUI.boolean_to_integer(child.hexpand), child.halign, Glimmer::LibUI.boolean_to_integer(child.vexpand), child.valign)
|
|
40
|
+
children << child
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def children
|
|
44
|
+
@children ||= []
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Note that there is no proper destroy_child(child) method for GridProxy due to libui not offering any API for it (no grid_delete)
|
|
48
|
+
|
|
49
|
+
private
|
|
50
|
+
|
|
51
|
+
def build_control
|
|
52
|
+
super.tap do
|
|
53
|
+
self.padded = true
|
|
54
|
+
end
|
|
53
55
|
end
|
|
54
56
|
end
|
|
55
57
|
end
|
|
@@ -23,29 +23,31 @@ require 'glimmer/libui/control_proxy'
|
|
|
23
23
|
|
|
24
24
|
module Glimmer
|
|
25
25
|
module LibUI
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
private
|
|
26
|
+
class ControlProxy
|
|
27
|
+
# Proxy for LibUI group objects
|
|
28
|
+
#
|
|
29
|
+
# Follows the Proxy Design Pattern
|
|
30
|
+
class GroupProxy < ControlProxy
|
|
31
|
+
DEFAULT_TITLE = ''
|
|
32
|
+
|
|
33
|
+
def post_initialize_child(child)
|
|
34
|
+
::LibUI.group_set_child(@libui, child.libui)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def destroy_child(child)
|
|
38
|
+
::LibUI.send("group_set_child", @libui, nil)
|
|
39
|
+
super
|
|
40
|
+
end
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def build_control
|
|
45
|
+
construction_args = @args.dup
|
|
46
|
+
construction_args[0] = DEFAULT_TITLE if construction_args.size == 0
|
|
47
|
+
@libui = ControlProxy.new_control(@keyword, construction_args)
|
|
48
|
+
@libui.tap do
|
|
49
|
+
self.margined = true
|
|
50
|
+
end
|
|
49
51
|
end
|
|
50
52
|
end
|
|
51
53
|
end
|
|
@@ -23,24 +23,26 @@ require 'glimmer/libui/control_proxy'
|
|
|
23
23
|
|
|
24
24
|
module Glimmer
|
|
25
25
|
module LibUI
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
26
|
+
class ControlProxy
|
|
27
|
+
# Proxy for LibUI image part objects
|
|
28
|
+
#
|
|
29
|
+
# Follows the Proxy Design Pattern
|
|
30
|
+
class ImagePartProxy < ControlProxy
|
|
31
|
+
def initialize(keyword, parent, args, &block)
|
|
32
|
+
@keyword = keyword
|
|
33
|
+
@parent_proxy = parent
|
|
34
|
+
@args = args
|
|
35
|
+
@block = block
|
|
36
|
+
@enabled = true
|
|
37
|
+
@children = []
|
|
38
|
+
post_add_content if @block.nil?
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
private
|
|
42
|
+
|
|
43
|
+
def build_control
|
|
44
|
+
@libui = @parent_proxy.append(*@args)
|
|
45
|
+
end
|
|
44
46
|
end
|
|
45
47
|
end
|
|
46
48
|
end
|
|
@@ -26,36 +26,38 @@ using ArrayIncludeMethods
|
|
|
26
26
|
|
|
27
27
|
module Glimmer
|
|
28
28
|
module LibUI
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
@
|
|
29
|
+
class ControlProxy
|
|
30
|
+
# Proxy for LibUI image objects
|
|
31
|
+
#
|
|
32
|
+
# Follows the Proxy Design Pattern
|
|
33
|
+
class ImageProxy < ControlProxy
|
|
34
|
+
def initialize(keyword, parent, args, &block)
|
|
35
|
+
@keyword = keyword
|
|
36
|
+
@parent_proxy = parent
|
|
37
|
+
@args = args
|
|
38
|
+
@block = block
|
|
39
|
+
@enabled = true
|
|
40
|
+
@children = []
|
|
41
|
+
post_add_content if @block.nil?
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def post_add_content
|
|
45
|
+
build_control
|
|
46
|
+
super
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def post_initialize_child(child)
|
|
50
|
+
@children << child
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def build_control
|
|
56
|
+
@args = [@children.first.args[1], @children.first.args[2]] if @children.size == 1 && (@args[0].nil? || @args[1].nil?)
|
|
57
|
+
super
|
|
58
|
+
@libui.tap do
|
|
59
|
+
@children.each {|child| child&.send(:build_control) }
|
|
60
|
+
end
|
|
59
61
|
end
|
|
60
62
|
end
|
|
61
63
|
end
|
|
@@ -23,21 +23,21 @@ require 'glimmer/libui/control_proxy'
|
|
|
23
23
|
|
|
24
24
|
module Glimmer
|
|
25
25
|
module LibUI
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
@
|
|
26
|
+
class ControlProxy
|
|
27
|
+
# Proxy for LibUI label objects
|
|
28
|
+
#
|
|
29
|
+
# Follows the Proxy Design Pattern
|
|
30
|
+
class LabelProxy < ControlProxy
|
|
31
|
+
DEFAULT_TEXT = ''
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def build_control
|
|
36
|
+
construction_args = @args.dup
|
|
37
|
+
construction_args[0] = DEFAULT_TEXT if construction_args.size == 0
|
|
38
|
+
@libui = ControlProxy.new_control(@keyword, construction_args)
|
|
37
39
|
end
|
|
38
40
|
end
|
|
39
|
-
alias set_items items
|
|
40
|
-
alias items= items
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
end
|