glimmer-dsl-libui 0.0.4 → 0.0.5

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.
@@ -0,0 +1,184 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'glimmer-dsl-libui'
4
+
5
+ include Glimmer
6
+
7
+ menu('File') {
8
+ menu_item('Open') {
9
+ on_clicked do
10
+ file = open_file(MAIN_WINDOW)
11
+ puts file unless file.nil?
12
+ end
13
+ }
14
+
15
+ menu_item('Save') {
16
+ on_clicked do
17
+ file = save_file(MAIN_WINDOW)
18
+ puts file unless file.nil?
19
+ end
20
+ }
21
+
22
+ quit_menu_item {
23
+ on_clicked do
24
+ puts 'Bye Bye'
25
+ end
26
+ }
27
+
28
+ preferences_menu_item # Can optionally contain an on_clicked listener
29
+ }
30
+
31
+ menu('Edit') {
32
+ check_menu_item('Checkable Item_')
33
+ separator_menu_item
34
+ menu_item('Disabled Item_') { |mi|
35
+ enabled 0
36
+ }
37
+ }
38
+
39
+ menu('Help') {
40
+ menu_item('Help')
41
+
42
+ about_menu_item # Can optionally contain an on_clicked listener
43
+ }
44
+
45
+ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
46
+ margined 1
47
+
48
+ on_closing do
49
+ puts 'Bye Bye'
50
+ end
51
+
52
+ vertical_box { |vb|
53
+ padded 1
54
+
55
+ horizontal_box {
56
+ padded 1
57
+
58
+ group('Basic Controls') {
59
+ margined 1
60
+
61
+ vertical_box {
62
+ padded 1
63
+
64
+ button('Button') {
65
+ stretchy 0
66
+
67
+ on_clicked do
68
+ msg_box(MAIN_WINDOW, 'Information', 'You clicked the button')
69
+ end
70
+ }
71
+
72
+ checkbox('Checkbox') { |c|
73
+ stretchy 0
74
+
75
+ on_toggled do
76
+ checked = c.checked == 1
77
+ MAIN_WINDOW.title = "Checkbox is #{checked}"
78
+ c.text = "I am the checkbox (#{checked})"
79
+ end
80
+ }
81
+
82
+ label('Label') { stretchy 0 }
83
+
84
+ horizontal_separator { stretchy 0 }
85
+
86
+ date_picker { stretchy 0 }
87
+
88
+ time_picker { stretchy 0 }
89
+
90
+ date_time_picker { stretchy 0 }
91
+
92
+ font_button { stretchy 0 }
93
+
94
+ color_button { stretchy 0 }
95
+ }
96
+ }
97
+
98
+ vertical_box {
99
+ padded 1
100
+
101
+ group('Numbers') {
102
+ stretchy 0
103
+ margined 1
104
+
105
+ vertical_box {
106
+ padded 1
107
+
108
+ spinbox(0, 100) { |s|
109
+ stretchy 0
110
+ value 42
111
+
112
+ on_changed do
113
+ puts "New Spinbox value: #{s.value}"
114
+ end
115
+ }
116
+
117
+ slider(0, 100) { |s|
118
+ stretchy 0
119
+
120
+ on_changed do
121
+ v = s.value
122
+ puts "New Slider value: #{v}"
123
+ @progress_bar.value = v
124
+ end
125
+ }
126
+
127
+ @progress_bar = progress_bar { stretchy 0 }
128
+ }
129
+ }
130
+
131
+ group('Lists') {
132
+ stretchy 0
133
+ margined 1
134
+
135
+ vertical_box {
136
+ padded 1
137
+
138
+ combobox { |c|
139
+ stretchy 0
140
+ items ['combobox Item 1', 'combobox Item 2', 'combobox Item 3']
141
+
142
+ on_selected do
143
+ puts "New combobox selection: #{c.selected}"
144
+ end
145
+ }
146
+
147
+ editable_combobox {
148
+ stretchy 0
149
+ items ['Editable Item 1', 'Editable Item 2', 'Editable Item 3']
150
+ }
151
+
152
+ radio_buttons {
153
+ items ['Radio Button 1', 'Radio Button 2', 'Radio Button 3']
154
+ }
155
+ }
156
+ }
157
+
158
+ tab {
159
+ tab_item('Page 1') {
160
+ horizontal_box {
161
+ entry { |e|
162
+ text 'Please enter your feelings'
163
+
164
+ on_changed do
165
+ puts "Current textbox data: '#{e.text}'"
166
+ end
167
+ }
168
+ }
169
+ }
170
+
171
+ tab_item('Page 2') {
172
+ horizontal_box
173
+ }
174
+
175
+ tab_item('Page 3') {
176
+ horizontal_box
177
+ }
178
+ }
179
+ }
180
+ }
181
+ }
182
+ }
183
+
184
+ MAIN_WINDOW.show
Binary file
@@ -20,7 +20,7 @@
20
20
  # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
 
22
22
  require 'glimmer/dsl/engine'
23
- Dir[File.expand_path('../*_expression.rb', __FILE__)].each {|f| require f}
23
+ Dir[File.expand_path('*_expression.rb', __dir__)].each {|f| require f}
24
24
 
25
25
  # Glimmer DSL expression configuration module
26
26
  #
@@ -0,0 +1,33 @@
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 DSL
24
+ module Libui
25
+ module FileExpression
26
+ def interpret(parent, keyword, *args, &block)
27
+ file_pointer = ::LibUI.send(self.class.name.underscore.split('::').last.sub(/_expression$/, ''), args.first.libui)
28
+ file_pointer.to_s unless file_pointer.null?
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
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/dsl/static_expression'
23
+ require 'glimmer/dsl/libui/file_expression'
24
+
25
+ module Glimmer
26
+ module DSL
27
+ module Libui
28
+ class OpenFileExpression < StaticExpression
29
+ include FileExpression
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
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/dsl/static_expression'
23
+ require 'glimmer/dsl/libui/file_expression'
24
+
25
+ module Glimmer
26
+ module DSL
27
+ module Libui
28
+ class SaveFileExpression < StaticExpression
29
+ include FileExpression
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,35 @@
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/dsl/static_expression'
23
+ require 'glimmer/libui/tab_item_proxy'
24
+
25
+ module Glimmer
26
+ module DSL
27
+ module Libui
28
+ class TabItemExpression < StaticExpression
29
+ def interpret(parent, keyword, *args, &block)
30
+ Glimmer::LibUI::TabItemProxy.new(keyword, parent, args, &block)
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,37 @@
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/menu_item_proxy'
23
+
24
+ module Glimmer
25
+ module LibUI
26
+ # Proxy for LibUI about menu item object
27
+ #
28
+ # Follows the Proxy Design Pattern
29
+ class AboutMenuItemProxy < MenuItemProxy
30
+ private
31
+
32
+ def build_control
33
+ @libui = @parent_proxy.append_about_item(*@args)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -28,6 +28,10 @@ module Glimmer
28
28
  child.stretchy = 1 if child.stretchy.nil?
29
29
  ::LibUI.box_append(@libui, child.libui, child.stretchy)
30
30
  end
31
+
32
+ def libui_api_keyword
33
+ 'box'
34
+ end
31
35
  end
32
36
  end
33
37
  end
@@ -0,0 +1,37 @@
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/menu_item_proxy'
23
+
24
+ module Glimmer
25
+ module LibUI
26
+ # Proxy for LibUI check menu item object
27
+ #
28
+ # Follows the Proxy Design Pattern
29
+ class CheckMenuItemProxy < MenuItemProxy
30
+ private
31
+
32
+ def build_control
33
+ @libui = @parent_proxy.append_check_item(*@args)
34
+ end
35
+ end
36
+ end
37
+ end
@@ -23,7 +23,7 @@ require 'glimmer/libui/control_proxy'
23
23
 
24
24
  module Glimmer
25
25
  module LibUI
26
- # Proxy for LibUI window objects
26
+ # Proxy for LibUI combobox objects
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
29
  class ComboboxProxy < ControlProxy
@@ -54,6 +54,7 @@ module Glimmer
54
54
  @parent_proxy = parent
55
55
  @args = args
56
56
  @block = block
57
+ @enabled = 1
57
58
  build_control
58
59
  if @parent_proxy.class.constants.include?(:APPEND_PROPERTIES)
59
60
  @parent_proxy.class::APPEND_PROPERTIES
@@ -72,14 +73,14 @@ module Glimmer
72
73
  end
73
74
 
74
75
  def can_handle_listener?(listener_name)
75
- ::LibUI.respond_to?("control_#{listener_name}") || ::LibUI.respond_to?("#{@keyword}_#{listener_name}")
76
+ ::LibUI.respond_to?("control_#{listener_name}") || ::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}")
76
77
  end
77
78
 
78
79
  def handle_listener(listener_name, &listener)
79
80
  if ::LibUI.respond_to?("control_#{listener_name}")
80
81
  ::LibUI.send("control_#{listener_name}", @libui, &listener)
81
- elsif ::LibUI.respond_to?("#{@keyword}_#{listener_name}")
82
- ::LibUI.send("#{@keyword}_#{listener_name}", @libui, &listener)
82
+ elsif ::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}")
83
+ ::LibUI.send("#{libui_api_keyword}_#{listener_name}", @libui, &listener)
83
84
  end
84
85
  end
85
86
 
@@ -91,9 +92,9 @@ module Glimmer
91
92
 
92
93
  def respond_to_libui?(method_name, *args, &block)
93
94
  ::LibUI.respond_to?("control_#{method_name}") ||
94
- ::LibUI.respond_to?("#{@keyword}_#{method_name}") ||
95
- ::LibUI.respond_to?("#{@keyword}_set_#{method_name}") ||
96
- ::LibUI.respond_to?("#{@keyword}_set_#{method_name.to_s.sub(/=$/, '')}")
95
+ ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") ||
96
+ ::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name}") ||
97
+ ::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}")
97
98
  end
98
99
 
99
100
  def method_missing(method_name, *args, &block)
@@ -107,18 +108,18 @@ module Glimmer
107
108
  end
108
109
 
109
110
  def send_to_libui(method_name, *args, &block)
110
- if ::LibUI.respond_to?("control_#{method_name}")
111
+ if ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") && args.empty?
112
+ ::LibUI.send("#{libui_api_keyword}_#{method_name}", @libui, *args)
113
+ elsif ::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name}") && !args.empty?
114
+ ::LibUI.send("#{libui_api_keyword}_set_#{method_name}", @libui, *args)
115
+ elsif ::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}") && !args.empty?
116
+ ::LibUI.send("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}", @libui, *args)
117
+ elsif ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") && method_name.start_with?('set_') && !args.empty?
118
+ ::LibUI.send("#{libui_api_keyword}_#{method_name}", @libui, *args)
119
+ elsif ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") && !args.empty?
120
+ ::LibUI.send("#{libui_api_keyword}_#{method_name}", @libui, *args)
121
+ elsif ::LibUI.respond_to?("control_#{method_name}")
111
122
  ::LibUI.send("control_#{method_name}", @libui, *args)
112
- elsif ::LibUI.respond_to?("#{@keyword}_#{method_name}") && args.empty?
113
- ::LibUI.send("#{@keyword}_#{method_name}", @libui, *args)
114
- elsif ::LibUI.respond_to?("#{@keyword}_set_#{method_name}") && !args.empty?
115
- ::LibUI.send("#{@keyword}_set_#{method_name}", @libui, *args)
116
- elsif ::LibUI.respond_to?("#{@keyword}_set_#{method_name.to_s.sub(/=$/, '')}") && !args.empty?
117
- ::LibUI.send("#{@keyword}_set_#{method_name.to_s.sub(/=$/, '')}", @libui, *args)
118
- elsif ::LibUI.respond_to?("#{@keyword}_#{method_name}") && method_name.start_with?('set_') && !args.empty?
119
- ::LibUI.send("#{@keyword}_#{method_name}", @libui, *args)
120
- elsif ::LibUI.respond_to?("#{@keyword}_#{method_name}") && !args.empty?
121
- ::LibUI.send("#{@keyword}_#{method_name}", @libui, *args)
122
123
  end
123
124
  end
124
125
 
@@ -136,10 +137,45 @@ module Glimmer
136
137
  end
137
138
  end
138
139
 
140
+ def libui_api_keyword
141
+ @keyword
142
+ end
143
+
144
+ def enabled(value = nil)
145
+ if value.nil?
146
+ @enabled
147
+ elsif value != @enabled
148
+ if value == 1
149
+ send_to_libui('enable')
150
+ else
151
+ send_to_libui('disable')
152
+ end
153
+ end
154
+ end
155
+ alias enabled? enabled
156
+ alias set_enabled enabled
157
+ alias enabled= enabled
158
+
159
+ def visible(value = nil)
160
+ current_value = send_to_libui('visible')
161
+ if value.nil?
162
+ current_value
163
+ elsif value != current_value
164
+ if value == 1
165
+ send_to_libui('show')
166
+ else
167
+ send_to_libui('hide')
168
+ end
169
+ end
170
+ end
171
+ alias visible? visible
172
+ alias set_visible visible
173
+ alias visible= visible
174
+
139
175
  private
140
176
 
141
177
  def build_control
142
- @libui ||= if ::LibUI.respond_to?("new_#{keyword}")
178
+ @libui = if ::LibUI.respond_to?("new_#{keyword}")
143
179
  ::LibUI.send("new_#{@keyword}", *@args)
144
180
  elsif ::LibUI.respond_to?(keyword)
145
181
  @args[0] = @args.first.libui if @args.first.is_a?(ControlProxy)
@@ -0,0 +1,42 @@
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
+ # Proxy for LibUI editable combobox objects
27
+ #
28
+ # Follows the Proxy Design Pattern
29
+ class EditableComboboxProxy < ControlProxy
30
+ def items(values = nil)
31
+ if values.nil?
32
+ @values
33
+ else
34
+ @values = values
35
+ @values.each { |value| append value }
36
+ end
37
+ end
38
+ alias set_items items
39
+ alias items= items
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,35 @@
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
+ # Proxy for LibUI group objects
27
+ #
28
+ # Follows the Proxy Design Pattern
29
+ class GroupProxy < ControlProxy
30
+ def post_initialize_child(child)
31
+ ::LibUI.group_set_child(@libui, child.libui)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -27,11 +27,14 @@ module Glimmer
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
29
  class MenuItemProxy < ControlProxy
30
+ def libui_api_keyword
31
+ 'menu_item'
32
+ end
30
33
 
31
34
  private
32
35
 
33
36
  def build_control
34
- @libui ||= @parent_proxy.append_item('Version')
37
+ @libui = @parent_proxy.append_item(*@args)
35
38
  end
36
39
  end
37
40
  end
@@ -0,0 +1,37 @@
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/menu_item_proxy'
23
+
24
+ module Glimmer
25
+ module LibUI
26
+ # Proxy for LibUI preferences menu item object
27
+ #
28
+ # Follows the Proxy Design Pattern
29
+ class PreferencesMenuItemProxy < MenuItemProxy
30
+ private
31
+
32
+ def build_control
33
+ @libui = @parent_proxy.append_preferences_item(*@args)
34
+ end
35
+ end
36
+ end
37
+ end