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.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +55 -0
  3. data/README.md +1127 -65
  4. data/VERSION +1 -1
  5. data/examples/area_gallery.rb +50 -0
  6. data/examples/area_gallery2.rb +111 -0
  7. data/examples/area_gallery3.rb +52 -0
  8. data/examples/area_gallery4.rb +113 -0
  9. data/examples/basic_area2.rb +1 -1
  10. data/examples/basic_button.rb +2 -2
  11. data/examples/basic_entry.rb +2 -2
  12. data/examples/basic_table_progress_bar.rb +13 -3
  13. data/examples/basic_transform.rb +27 -0
  14. data/examples/control_gallery.rb +3 -3
  15. data/examples/dynamic_area.rb +1 -1
  16. data/examples/form.rb +2 -2
  17. data/examples/histogram.rb +118 -0
  18. data/examples/meta_example.rb +71 -20
  19. data/examples/midi_player.rb +8 -10
  20. data/glimmer-dsl-libui.gemspec +0 -0
  21. data/lib/glimmer/dsl/libui/control_expression.rb +1 -3
  22. data/lib/glimmer/dsl/libui/dsl.rb +1 -0
  23. data/lib/glimmer/dsl/libui/file_expression.rb +5 -1
  24. data/lib/glimmer/dsl/libui/property_expression.rb +5 -1
  25. data/lib/glimmer/{libui/box.rb → dsl/libui/shape_expression.rb} +26 -29
  26. data/lib/glimmer/dsl/libui/tab_item_expression.rb +2 -2
  27. data/lib/glimmer/libui/control_proxy/area_proxy.rb +117 -0
  28. data/lib/glimmer/libui/{menu_item_proxy.rb → control_proxy/box/horizontal_box_proxy.rb} +9 -12
  29. data/lib/glimmer/libui/{vertical_box_proxy.rb → control_proxy/box/vertical_box_proxy.rb} +10 -6
  30. data/lib/glimmer/libui/control_proxy/box.rb +61 -0
  31. data/lib/glimmer/libui/{button_proxy.rb → control_proxy/button_proxy.rb} +14 -12
  32. data/lib/glimmer/libui/{checkbox_proxy.rb → control_proxy/checkbox_proxy.rb} +14 -12
  33. data/lib/glimmer/libui/control_proxy/color_button_proxy.rb +118 -0
  34. data/lib/glimmer/libui/control_proxy/column/button_column_proxy.rb +76 -0
  35. data/lib/glimmer/libui/control_proxy/column/checkbox_column_proxy.rb +46 -0
  36. data/lib/glimmer/libui/control_proxy/column/checkbox_text_column_proxy.rb +80 -0
  37. data/lib/glimmer/libui/{radio_buttons_proxy.rb → control_proxy/column/image_column_proxy.rb} +14 -13
  38. data/lib/glimmer/libui/control_proxy/column/image_text_column_proxy.rb +48 -0
  39. data/lib/glimmer/libui/{progress_bar_column_proxy.rb → control_proxy/column/progress_bar_column_proxy.rb} +14 -10
  40. data/lib/glimmer/libui/control_proxy/column/text_column_proxy.rb +46 -0
  41. data/lib/glimmer/libui/control_proxy/column.rb +55 -0
  42. data/lib/glimmer/libui/{checkbox_column_proxy.rb → control_proxy/combobox_proxy.rb} +16 -13
  43. data/lib/glimmer/libui/control_proxy/date_time_picker_proxy/date_picker_proxy.rb +43 -0
  44. data/lib/glimmer/libui/control_proxy/date_time_picker_proxy/time_picker_proxy.rb +43 -0
  45. data/lib/glimmer/libui/control_proxy/date_time_picker_proxy.rb +72 -0
  46. data/lib/glimmer/libui/control_proxy/dual_column.rb +40 -0
  47. data/lib/glimmer/libui/control_proxy/editable_column.rb +46 -0
  48. data/lib/glimmer/libui/control_proxy/editable_combobox_proxy.rb +45 -0
  49. data/lib/glimmer/libui/{dual_column.rb → control_proxy/enableable_column.rb} +18 -10
  50. data/lib/glimmer/libui/control_proxy/font_button_proxy.rb +70 -0
  51. data/lib/glimmer/libui/{form_proxy.rb → control_proxy/form_proxy.rb} +26 -24
  52. data/lib/glimmer/libui/{grid_proxy.rb → control_proxy/grid_proxy.rb} +29 -27
  53. data/lib/glimmer/libui/{group_proxy.rb → control_proxy/group_proxy.rb} +24 -22
  54. data/lib/glimmer/libui/{image_part_proxy.rb → control_proxy/image_part_proxy.rb} +20 -18
  55. data/lib/glimmer/libui/{image_proxy.rb → control_proxy/image_proxy.rb} +32 -30
  56. data/lib/glimmer/libui/{combobox_proxy.rb → control_proxy/label_proxy.rb} +13 -13
  57. data/lib/glimmer/libui/control_proxy/matrix_proxy.rb +147 -0
  58. data/lib/glimmer/libui/{editable_column.rb → control_proxy/menu_item_proxy/about_menu_item_proxy.rb} +13 -16
  59. data/lib/glimmer/libui/control_proxy/menu_item_proxy/check_menu_item_proxy.rb +41 -0
  60. data/lib/glimmer/libui/{preferences_menu_item_proxy.rb → control_proxy/menu_item_proxy/preferences_menu_item_proxy.rb} +11 -9
  61. data/lib/glimmer/libui/control_proxy/menu_item_proxy/quit_menu_item_proxy.rb +66 -0
  62. data/lib/glimmer/libui/control_proxy/menu_item_proxy/separator_menu_item_proxy.rb +41 -0
  63. data/lib/glimmer/libui/control_proxy/menu_item_proxy.rb +45 -0
  64. data/lib/glimmer/libui/{editable_combobox_proxy.rb → control_proxy/menu_proxy.rb} +13 -13
  65. data/lib/glimmer/libui/{horizontal_box_proxy.rb → control_proxy/message_box/msg_box_error_proxy.rb} +9 -6
  66. data/lib/glimmer/libui/{multiline_entry_proxy.rb → control_proxy/message_box/msg_box_proxy.rb} +8 -6
  67. data/lib/glimmer/libui/{check_menu_item_proxy.rb → control_proxy/message_box.rb} +11 -10
  68. data/lib/glimmer/libui/control_proxy/multiline_entry_proxy/non_wrapping_multiline_entry_proxy.rb +34 -0
  69. data/lib/glimmer/libui/{image_column_proxy.rb → control_proxy/multiline_entry_proxy.rb} +10 -11
  70. data/lib/glimmer/libui/control_proxy/path_proxy.rb +169 -0
  71. data/lib/glimmer/libui/control_proxy/radio_buttons_proxy.rb +45 -0
  72. data/lib/glimmer/libui/{button_column_proxy.rb → control_proxy/tab_item_proxy.rb} +37 -40
  73. data/lib/glimmer/libui/control_proxy/table_proxy.rb +182 -0
  74. data/lib/glimmer/libui/control_proxy/transformable.rb +74 -0
  75. data/lib/glimmer/libui/control_proxy/window_proxy.rb +128 -0
  76. data/lib/glimmer/libui/control_proxy.rb +41 -22
  77. data/lib/glimmer/libui/{enableable_column.rb → parent.rb} +7 -15
  78. data/lib/glimmer/libui/shape/arc.rb +43 -0
  79. data/lib/glimmer/libui/{date_picker_proxy.rb → shape/bezier.rb} +8 -9
  80. data/lib/glimmer/libui/{quit_menu_item_proxy.rb → shape/figure.rb} +24 -32
  81. data/lib/glimmer/libui/{non_wrapping_multiline_entry_proxy.rb → shape/line.rb} +11 -5
  82. data/lib/glimmer/libui/{time_picker_proxy.rb → shape/rectangle.rb} +8 -9
  83. data/lib/glimmer/libui/{about_menu_item_proxy.rb → shape/square.rb} +9 -8
  84. data/lib/glimmer/libui/shape.rb +145 -0
  85. data/lib/glimmer/libui.rb +92 -0
  86. data/lib/glimmer-dsl-libui.rb +2 -0
  87. metadata +82 -48
  88. data/lib/glimmer/libui/area_proxy.rb +0 -105
  89. data/lib/glimmer/libui/checkbox_text_column_proxy.rb +0 -76
  90. data/lib/glimmer/libui/color_button_proxy.rb +0 -64
  91. data/lib/glimmer/libui/column.rb +0 -51
  92. data/lib/glimmer/libui/date_time_picker_proxy.rb +0 -68
  93. data/lib/glimmer/libui/font_button_proxy.rb +0 -68
  94. data/lib/glimmer/libui/image_text_column_proxy.rb +0 -44
  95. data/lib/glimmer/libui/label_proxy.rb +0 -41
  96. data/lib/glimmer/libui/menu_proxy.rb +0 -41
  97. data/lib/glimmer/libui/path_proxy.rb +0 -167
  98. data/lib/glimmer/libui/rectangle_proxy.rb +0 -100
  99. data/lib/glimmer/libui/separator_menu_item_proxy.rb +0 -37
  100. data/lib/glimmer/libui/tab_item_proxy.rb +0 -67
  101. data/lib/glimmer/libui/table_proxy.rb +0 -180
  102. data/lib/glimmer/libui/text_column_proxy.rb +0 -42
  103. data/lib/glimmer/libui/window_proxy.rb +0 -119
@@ -0,0 +1,118 @@
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 color button objects
28
+ #
29
+ # Follows the Proxy Design Pattern
30
+ class ColorButtonProxy < ControlProxy
31
+ def color(value = nil)
32
+ # TODO support hex color value
33
+ if value.nil?
34
+ @red ||= Fiddle::Pointer.malloc(8) # double
35
+ @green ||= Fiddle::Pointer.malloc(8) # double
36
+ @blue ||= Fiddle::Pointer.malloc(8) # double
37
+ @alpha ||= Fiddle::Pointer.malloc(8) # double
38
+ ::LibUI.color_button_color(@libui, @red, @green, @blue, @alpha)
39
+ {
40
+ r: @red[0, 8].unpack1('d') * 255.0,
41
+ g: @green[0, 8].unpack1('d') * 255.0,
42
+ b: @blue[0, 8].unpack1('d') * 255.0,
43
+ a: @alpha[0, 8].unpack1('d')
44
+ }
45
+ else
46
+ current_color = color
47
+ value = Glimmer::LibUI.interpret_color(value)
48
+ value[:r] ||= current_color[:r]
49
+ value[:g] ||= current_color[:g]
50
+ value[:b] ||= current_color[:b]
51
+ value[:a] ||= current_color[:a]
52
+ ::LibUI.color_button_set_color(@libui, value[:r].to_f / 255.0, value[:g].to_f / 255.0, value[:b].to_f / 255.0, value[:a])
53
+ end
54
+ end
55
+
56
+ def red(value = nil)
57
+ if value.nil?
58
+ color[:r]
59
+ else
60
+ self.color = {r: value}
61
+ end
62
+ end
63
+ alias red= red
64
+ alias set_red red
65
+ alias r red
66
+ alias r= red
67
+ alias set_r red
68
+
69
+ def green(value = nil)
70
+ if value.nil?
71
+ color[:g]
72
+ else
73
+ self.color = {g: value}
74
+ end
75
+ end
76
+ alias green= green
77
+ alias set_green green
78
+ alias g green
79
+ alias g= green
80
+ alias set_g green
81
+
82
+ def blue(value = nil)
83
+ if value.nil?
84
+ color[:b]
85
+ else
86
+ self.color = {b: value}
87
+ end
88
+ end
89
+ alias blue= blue
90
+ alias set_blue blue
91
+ alias b blue
92
+ alias b= blue
93
+ alias set_b blue
94
+
95
+ def alpha(value = nil)
96
+ if value.nil?
97
+ color[:a]
98
+ else
99
+ self.color = {a: value}
100
+ end
101
+ end
102
+ alias alpha= alpha
103
+ alias set_alpha alpha
104
+ alias a alpha
105
+ alias a= alpha
106
+ alias set_a alpha
107
+
108
+ def destroy
109
+ Fiddle.free @red unless @red.nil?
110
+ Fiddle.free @green unless @green.nil?
111
+ Fiddle.free @blue unless @blue.nil?
112
+ Fiddle.free @alpha unless @alpha.nil?
113
+ super
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,76 @@
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
+ require 'glimmer/libui/control_proxy/column'
24
+ require 'glimmer/libui/control_proxy/enableable_column'
25
+
26
+ module Glimmer
27
+ module LibUI
28
+ class ControlProxy
29
+ module Column
30
+ # Proxy for LibUI button column objects
31
+ #
32
+ # Follows the Proxy Design Pattern
33
+ class ButtonColumnProxy < ControlProxy
34
+ include Column
35
+ include EnableableColumn
36
+
37
+ def on_clicked(&block)
38
+ # TODO consider generalizing into custom listeners and moving to ControlProxy
39
+ @on_clicked_procs ||= []
40
+ if block.nil?
41
+ @on_clicked_procs
42
+ else
43
+ @on_clicked_procs << block
44
+ block
45
+ end
46
+ end
47
+
48
+ def can_handle_listener?(listener_name)
49
+ listener_name == 'on_clicked' || super
50
+ end
51
+
52
+ def handle_listener(listener_name, &listener)
53
+ case listener_name
54
+ when 'on_clicked'
55
+ on_clicked(&listener)
56
+ else
57
+ super
58
+ end
59
+ end
60
+
61
+ def notify_listeners(listener_name, *args)
62
+ @on_clicked_procs&.each do |on_clicked_proc|
63
+ on_clicked_proc.call(*args)
64
+ end
65
+ end
66
+
67
+ private
68
+
69
+ def build_control
70
+ @parent_proxy.append_button_column(name, column_index, enabled_value)
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ 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
+ require 'glimmer/libui/control_proxy'
23
+ require 'glimmer/libui/control_proxy/column'
24
+ require 'glimmer/libui/control_proxy/editable_column'
25
+
26
+ module Glimmer
27
+ module LibUI
28
+ class ControlProxy
29
+ module Column
30
+ # Proxy for LibUI checkbox column objects
31
+ #
32
+ # Follows the Proxy Design Pattern
33
+ class CheckboxColumnProxy < ControlProxy
34
+ include Column
35
+ include EditableColumn
36
+
37
+ private
38
+
39
+ def build_control
40
+ @parent_proxy.append_checkbox_column(name, column_index, editable_value)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,80 @@
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
+ require 'glimmer/libui/control_proxy/column'
24
+ require 'glimmer/libui/control_proxy/dual_column'
25
+ require 'glimmer/libui/control_proxy/editable_column'
26
+
27
+ module Glimmer
28
+ module LibUI
29
+ class ControlProxy
30
+ module Column
31
+ # Proxy for LibUI checkbox text column objects
32
+ #
33
+ # Follows the Proxy Design Pattern
34
+ class CheckboxTextColumnProxy < ControlProxy
35
+ include Column
36
+ include DualColumn
37
+ include EditableColumn
38
+
39
+ def editable_checkbox(value = nil)
40
+ if value.nil?
41
+ @editable_checkbox = false if @editable_checkbox.nil?
42
+ @editable_checkbox
43
+ else
44
+ @editable_checkbox = !!value
45
+ end
46
+ end
47
+ alias editable_checkbox= editable_checkbox
48
+ alias set_editable_checkbox editable_checkbox
49
+ alias editable_checkbox? editable_checkbox
50
+
51
+ def editable_text(value = nil)
52
+ if value.nil?
53
+ @editable_text = false if @editable_text.nil?
54
+ @editable_text
55
+ else
56
+ @editable_text = !!value
57
+ end
58
+ end
59
+ alias editable_text= editable_text
60
+ alias set_editable_text editable_text
61
+ alias editable_text? editable_text
62
+
63
+ private
64
+
65
+ def build_control
66
+ @parent_proxy.append_checkbox_text_column(name, column_index, editable_checkbox_value, second_column_index, editable_text_value)
67
+ end
68
+
69
+ def editable_checkbox_value
70
+ (@parent_proxy.editable? || editable? || editable_checkbox?) ? -2 : -1
71
+ end
72
+
73
+ def editable_text_value
74
+ (@parent_proxy.editable? || editable? || editable_text?) ? -2 : -1
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -20,24 +20,25 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer/libui/control_proxy'
23
+ require 'glimmer/libui/control_proxy/column'
23
24
 
24
25
  module Glimmer
25
26
  module LibUI
26
- # Proxy for LibUI radio buttons objects
27
- #
28
- # Follows the Proxy Design Pattern
29
- class RadioButtonsProxy < ControlProxy
30
- def items(*values)
31
- values = values.first if values.first.is_a?(Array)
32
- if values.empty?
33
- @values
34
- else
35
- @values = values
36
- @values.each { |value| append value }
27
+ class ControlProxy
28
+ module Column
29
+ # Proxy for LibUI image column objects
30
+ #
31
+ # Follows the Proxy Design Pattern
32
+ class ImageColumnProxy < ControlProxy
33
+ include Column
34
+
35
+ private
36
+
37
+ def build_control
38
+ @parent_proxy.append_image_column(name, column_index)
39
+ end
37
40
  end
38
41
  end
39
- alias set_items items
40
- alias items= items
41
42
  end
42
43
  end
43
44
  end
@@ -0,0 +1,48 @@
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
+ require 'glimmer/libui/control_proxy/column'
24
+ require 'glimmer/libui/control_proxy/dual_column'
25
+ require 'glimmer/libui/control_proxy/editable_column'
26
+
27
+ module Glimmer
28
+ module LibUI
29
+ class ControlProxy
30
+ module Column
31
+ # Proxy for LibUI image text column objects
32
+ #
33
+ # Follows the Proxy Design Pattern
34
+ class ImageTextColumnProxy < ControlProxy
35
+ include Column
36
+ include DualColumn
37
+ include EditableColumn
38
+
39
+ private
40
+
41
+ def build_control
42
+ @parent_proxy.append_image_text_column(name, column_index, second_column_index, editable_value)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -20,20 +20,24 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer/libui/control_proxy'
23
- require 'glimmer/libui/column'
23
+ require 'glimmer/libui/control_proxy/column'
24
24
 
25
25
  module Glimmer
26
26
  module LibUI
27
- # Proxy for LibUI progress bar column objects
28
- #
29
- # Follows the Proxy Design Pattern
30
- class ProgressBarColumnProxy < ControlProxy
31
- include Column
27
+ class ControlProxy
28
+ module Column
29
+ # Proxy for LibUI progress bar column objects
30
+ #
31
+ # Follows the Proxy Design Pattern
32
+ class ProgressBarColumnProxy < ControlProxy
33
+ include Column
34
+
35
+ private
32
36
 
33
- private
34
-
35
- def build_control
36
- @parent_proxy.append_progress_bar_column(name, column_index)
37
+ def build_control
38
+ @parent_proxy.append_progress_bar_column(name, column_index)
39
+ end
40
+ end
37
41
  end
38
42
  end
39
43
  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
+ require 'glimmer/libui/control_proxy'
23
+ require 'glimmer/libui/control_proxy/column'
24
+ require 'glimmer/libui/control_proxy/editable_column'
25
+
26
+ module Glimmer
27
+ module LibUI
28
+ class ControlProxy
29
+ module Column
30
+ # Proxy for LibUI text column objects
31
+ #
32
+ # Follows the Proxy Design Pattern
33
+ class TextColumnProxy < ControlProxy
34
+ include Column
35
+ include EditableColumn
36
+
37
+ private
38
+
39
+ def build_control
40
+ @parent_proxy.append_text_column(name, column_index, editable_value)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,55 @@
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
+ # Common logic for all column proxy objects
26
+ module Column
27
+ def initialize(keyword, parent, args, &block)
28
+ @keyword = keyword
29
+ @parent_proxy = parent
30
+ @args = args
31
+ @block = block
32
+ @enabled = true
33
+ post_add_content if @block.nil?
34
+ end
35
+
36
+ def name
37
+ @args.first
38
+ end
39
+
40
+ # column index used in table append column API call
41
+ # expanded to ensure DualColumn index accounts for two columns acting as one
42
+ def column_index
43
+ @column_index ||= @parent_proxy.send(:next_column_index)
44
+ end
45
+
46
+ # actual index within table columns (disregarding nil fillings that account for DualColumn instances)
47
+ def index
48
+ @parent_proxy.columns.compact.index(self)
49
+ end
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ Dir[File.expand_path("./#{File.basename(__FILE__, '.rb')}/*.rb", __dir__)].each {|f| require f}
@@ -20,22 +20,25 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer/libui/control_proxy'
23
- require 'glimmer/libui/column'
24
- require 'glimmer/libui/editable_column'
25
23
 
26
24
  module Glimmer
27
25
  module LibUI
28
- # Proxy for LibUI checkbox column objects
29
- #
30
- # Follows the Proxy Design Pattern
31
- class CheckboxColumnProxy < ControlProxy
32
- include Column
33
- include EditableColumn
34
-
35
- private
36
-
37
- def build_control
38
- @parent_proxy.append_checkbox_column(name, column_index, editable_value)
26
+ class ControlProxy
27
+ # Proxy for LibUI combobox objects
28
+ #
29
+ # Follows the Proxy Design Pattern
30
+ class ComboboxProxy < 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
39
42
  end
40
43
  end
41
44
  end
@@ -0,0 +1,43 @@
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/date_time_picker_proxy'
23
+
24
+ module Glimmer
25
+ module LibUI
26
+ class ControlProxy
27
+ class DateTimePickerProxy < ControlProxy
28
+ # Proxy for LibUI date picker objects
29
+ #
30
+ # Follows the Proxy Design Pattern
31
+ class DatePickerProxy < DateTimePickerProxy
32
+ def time(value = nil)
33
+ if value.nil?
34
+ super.slice(:mday, :mon, :year, :wday, :yday)
35
+ else
36
+ super
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,43 @@
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/date_time_picker_proxy'
23
+
24
+ module Glimmer
25
+ module LibUI
26
+ class ControlProxy
27
+ class DateTimePickerProxy < ControlProxy
28
+ # Proxy for LibUI time picker objects
29
+ #
30
+ # Follows the Proxy Design Pattern
31
+ class TimePickerProxy < DateTimePickerProxy
32
+ def time(value = nil)
33
+ if value.nil?
34
+ super.slice(:sec, :min, :hour)
35
+ else
36
+ super
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end