glimmer-dsl-libui 0.0.4 → 0.0.8
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 +41 -0
- data/README.md +540 -41
- data/VERSION +1 -1
- data/examples/basic_button.rb +1 -1
- data/examples/basic_entry.rb +3 -3
- data/examples/basic_window.rb +1 -1
- data/examples/basic_window2.rb +14 -0
- data/examples/control_gallery.rb +168 -0
- data/examples/midi_player.rb +2 -2
- data/examples/simple_notepad.rb +1 -1
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/dsl.rb +1 -1
- data/lib/glimmer/dsl/libui/file_expression.rb +33 -0
- data/lib/glimmer/dsl/libui/open_file_expression.rb +33 -0
- data/lib/glimmer/dsl/libui/save_file_expression.rb +33 -0
- data/lib/glimmer/dsl/libui/tab_item_expression.rb +35 -0
- data/lib/glimmer/libui/about_menu_item_proxy.rb +37 -0
- data/lib/glimmer/libui/box.rb +16 -2
- data/lib/glimmer/libui/check_menu_item_proxy.rb +37 -0
- data/lib/glimmer/libui/combobox_proxy.rb +4 -3
- data/lib/glimmer/libui/control_proxy.rb +135 -29
- data/lib/glimmer/libui/date_picker_proxy.rb +32 -0
- data/lib/glimmer/libui/date_time_picker_proxy.rb +35 -0
- data/lib/glimmer/libui/editable_combobox_proxy.rb +43 -0
- data/lib/glimmer/libui/group_proxy.rb +43 -0
- data/lib/glimmer/libui/menu_item_proxy.rb +4 -1
- data/lib/glimmer/libui/multiline_entry_proxy.rb +35 -0
- data/lib/glimmer/libui/non_wrapping_multiline_entry_proxy.rb +32 -0
- data/lib/glimmer/libui/preferences_menu_item_proxy.rb +37 -0
- data/lib/glimmer/libui/quit_menu_item_proxy.rb +62 -0
- data/lib/glimmer/libui/radio_buttons_proxy.rb +43 -0
- data/lib/glimmer/libui/separator_menu_item_proxy.rb +37 -0
- data/lib/glimmer/libui/tab_item_proxy.rb +67 -0
- data/lib/glimmer/libui/time_picker_proxy.rb +32 -0
- data/lib/glimmer/libui/window_proxy.rb +15 -3
- metadata +25 -5
@@ -33,7 +33,7 @@ module Glimmer
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def create(keyword, parent, args, &block)
|
36
|
-
widget_proxy_class(keyword).new(keyword, parent, args, &block)
|
36
|
+
widget_proxy_class(keyword).new(keyword, parent, args, &block).tap {|c| all_control_proxies << c}
|
37
37
|
end
|
38
38
|
|
39
39
|
def widget_proxy_class(keyword)
|
@@ -44,8 +44,41 @@ module Glimmer
|
|
44
44
|
Glimmer::LibUI::ControlProxy
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
# autosave all controls in this array to avoid garbage collection
|
49
|
+
def all_control_proxies
|
50
|
+
@@all_control_proxies = [] unless defined?(@@all_control_proxies)
|
51
|
+
@@all_control_proxies
|
52
|
+
end
|
53
|
+
|
54
|
+
def main_window_proxy
|
55
|
+
all_control_proxies.find {|c| c.is_a?(WindowProxy)}
|
56
|
+
end
|
57
|
+
|
58
|
+
def integer_to_boolean(int)
|
59
|
+
int.nil? ? nil : int == 1
|
60
|
+
end
|
61
|
+
|
62
|
+
def boolean_to_integer(bool)
|
63
|
+
bool.nil? ? nil : (bool ? 1 : 0)
|
64
|
+
end
|
47
65
|
end
|
48
66
|
|
67
|
+
BOOLEAN_PROPERTIES = %w[
|
68
|
+
padded
|
69
|
+
checked
|
70
|
+
enabled toplevel visible
|
71
|
+
read_only
|
72
|
+
margined
|
73
|
+
borderless fullscreen
|
74
|
+
stretchy
|
75
|
+
]
|
76
|
+
|
77
|
+
STRING_PROPERTIES = %w[
|
78
|
+
text
|
79
|
+
title
|
80
|
+
]
|
81
|
+
|
49
82
|
# libui returns the contained LibUI object
|
50
83
|
attr_reader :parent_proxy, :libui, :args, :keyword
|
51
84
|
|
@@ -54,10 +87,8 @@ module Glimmer
|
|
54
87
|
@parent_proxy = parent
|
55
88
|
@args = args
|
56
89
|
@block = block
|
90
|
+
@enabled = true
|
57
91
|
build_control
|
58
|
-
if @parent_proxy.class.constants.include?(:APPEND_PROPERTIES)
|
59
|
-
@parent_proxy.class::APPEND_PROPERTIES
|
60
|
-
end
|
61
92
|
post_add_content if @block.nil?
|
62
93
|
end
|
63
94
|
|
@@ -70,36 +101,53 @@ module Glimmer
|
|
70
101
|
def post_initialize_child(child)
|
71
102
|
# No Op by default
|
72
103
|
end
|
104
|
+
|
105
|
+
def window_proxy
|
106
|
+
found_proxy = self
|
107
|
+
until found_proxy.nil? || found_proxy.is_a?(WindowProxy)
|
108
|
+
found_proxy = found_proxy.parent_proxy
|
109
|
+
end
|
110
|
+
found_proxy
|
111
|
+
end
|
73
112
|
|
74
113
|
def can_handle_listener?(listener_name)
|
75
|
-
::LibUI.respond_to?("
|
114
|
+
::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}") ||
|
115
|
+
::LibUI.respond_to?("control_#{listener_name}")
|
76
116
|
end
|
77
117
|
|
78
118
|
def handle_listener(listener_name, &listener)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
119
|
+
safe_listener = Proc.new { listener.call(self) }
|
120
|
+
if ::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}")
|
121
|
+
::LibUI.send("#{libui_api_keyword}_#{listener_name}", @libui, &safe_listener)
|
122
|
+
elsif ::LibUI.respond_to?("control_#{listener_name}")
|
123
|
+
::LibUI.send("control_#{listener_name}", @libui, &safe_listener)
|
83
124
|
end
|
84
125
|
end
|
85
126
|
|
86
127
|
def respond_to?(method_name, *args, &block)
|
87
128
|
respond_to_libui?(method_name, *args, &block) ||
|
88
|
-
(
|
89
|
-
|
129
|
+
(
|
130
|
+
append_properties.include?(method_name.to_s) ||
|
131
|
+
(append_properties.include?(method_name.to_s.sub(/\?$/, '')) && BOOLEAN_PROPERTIES.include?(method_name.to_s.sub(/\?$/, ''))) ||
|
132
|
+
append_properties.include?(method_name.to_s.sub(/=$/, ''))
|
133
|
+
) ||
|
134
|
+
super(method_name, true)
|
90
135
|
end
|
91
136
|
|
92
137
|
def respond_to_libui?(method_name, *args, &block)
|
93
138
|
::LibUI.respond_to?("control_#{method_name}") ||
|
94
|
-
::LibUI.respond_to?("#{
|
95
|
-
::LibUI.respond_to?("#{
|
96
|
-
::LibUI.respond_to?("#{
|
139
|
+
(::LibUI.respond_to?("control_#{method_name.to_s.sub(/\?$/, '')}") && BOOLEAN_PROPERTIES.include?(method_name.to_s.sub(/\?$/, '')) ) ||
|
140
|
+
::LibUI.respond_to?("control_set_#{method_name.to_s.sub(/=$/, '')}") ||
|
141
|
+
::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") ||
|
142
|
+
(::LibUI.respond_to?("#{libui_api_keyword}_#{method_name.to_s.sub(/\?$/, '')}") && BOOLEAN_PROPERTIES.include?(method_name.to_s.sub(/\?$/, '')) ) ||
|
143
|
+
::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}")
|
97
144
|
end
|
98
145
|
|
99
146
|
def method_missing(method_name, *args, &block)
|
100
147
|
if respond_to_libui?(method_name, *args, &block)
|
101
148
|
send_to_libui(method_name, *args, &block)
|
102
|
-
elsif
|
149
|
+
elsif append_properties.include?(method_name.to_s) ||
|
150
|
+
append_properties.include?(method_name.to_s.sub(/(=|\?)$/, ''))
|
103
151
|
append_property(method_name, *args)
|
104
152
|
else
|
105
153
|
super
|
@@ -107,18 +155,26 @@ module Glimmer
|
|
107
155
|
end
|
108
156
|
|
109
157
|
def send_to_libui(method_name, *args, &block)
|
110
|
-
if ::LibUI.respond_to?("
|
158
|
+
if ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name.to_s.sub(/\?$/, '')}") && args.empty?
|
159
|
+
property = method_name.to_s.sub(/\?$/, '')
|
160
|
+
value = ::LibUI.send("#{libui_api_keyword}_#{property}", @libui, *args)
|
161
|
+
handle_string_property(property, handle_boolean_property(property, value))
|
162
|
+
elsif ::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}") && !args.empty?
|
163
|
+
property = method_name.to_s.sub(/=$/, '')
|
164
|
+
args[0] = ControlProxy.boolean_to_integer(args.first) if BOOLEAN_PROPERTIES.include?(property) && (args.first.is_a?(TrueClass) || args.first.is_a?(FalseClass))
|
165
|
+
::LibUI.send("#{libui_api_keyword}_set_#{property}", @libui, *args)
|
166
|
+
elsif ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") && !args.empty?
|
167
|
+
::LibUI.send("#{libui_api_keyword}_#{method_name}", @libui, *args)
|
168
|
+
elsif ::LibUI.respond_to?("control_#{method_name.to_s.sub(/\?$/, '')}") && args.empty?
|
169
|
+
property = method_name.to_s.sub(/\?$/, '')
|
170
|
+
value = ::LibUI.send("control_#{method_name.to_s.sub(/\?$/, '')}", @libui, *args)
|
171
|
+
handle_string_property(property, handle_boolean_property(property, value))
|
172
|
+
elsif ::LibUI.respond_to?("control_set_#{method_name.to_s.sub(/=$/, '')}")
|
173
|
+
property = method_name.to_s.sub(/=$/, '')
|
174
|
+
args[0] = ControlProxy.boolean_to_integer(args.first) if BOOLEAN_PROPERTIES.include?(property) && (args.first.is_a?(TrueClass) || args.first.is_a?(FalseClass))
|
175
|
+
::LibUI.send("control_set_#{method_name.to_s.sub(/=$/, '')}", @libui, *args)
|
176
|
+
elsif ::LibUI.respond_to?("control_#{method_name}") && !args.empty?
|
111
177
|
::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
178
|
end
|
123
179
|
end
|
124
180
|
|
@@ -127,25 +183,75 @@ module Glimmer
|
|
127
183
|
end
|
128
184
|
|
129
185
|
def append_property(property, value = nil)
|
130
|
-
property = property.to_s.sub(
|
186
|
+
property = property.to_s.sub(/(=|\?)$/, '')
|
131
187
|
@append_property_hash ||= {}
|
132
188
|
if value.nil?
|
133
|
-
@append_property_hash[property]
|
189
|
+
value = @append_property_hash[property]
|
190
|
+
handle_string_property(property, handle_boolean_property(property, value))
|
134
191
|
else
|
192
|
+
value = ControlProxy.boolean_to_integer(value) if BOOLEAN_PROPERTIES.include?(property) && (value.is_a?(TrueClass) || value.is_a?(FalseClass))
|
135
193
|
@append_property_hash[property] = value
|
136
194
|
end
|
137
195
|
end
|
138
196
|
|
197
|
+
def libui_api_keyword
|
198
|
+
@keyword
|
199
|
+
end
|
200
|
+
|
201
|
+
def enabled(value = nil)
|
202
|
+
if value.nil?
|
203
|
+
@enabled
|
204
|
+
elsif value != @enabled
|
205
|
+
if value == 1 || value
|
206
|
+
send_to_libui('enable')
|
207
|
+
else
|
208
|
+
send_to_libui('disable')
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
alias enabled? enabled
|
213
|
+
alias set_enabled enabled
|
214
|
+
alias enabled= enabled
|
215
|
+
|
216
|
+
def visible(value = nil)
|
217
|
+
current_value = send_to_libui('visible')
|
218
|
+
if value.nil?
|
219
|
+
current_value
|
220
|
+
elsif value != current_value
|
221
|
+
if value == 1 || value
|
222
|
+
send_to_libui('show')
|
223
|
+
else
|
224
|
+
send_to_libui('hide')
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
228
|
+
alias visible? visible
|
229
|
+
alias set_visible visible
|
230
|
+
alias visible= visible
|
231
|
+
|
232
|
+
def destroy
|
233
|
+
send_to_libui('destroy')
|
234
|
+
self.class.all_control_proxies.delete(self)
|
235
|
+
end
|
236
|
+
|
139
237
|
private
|
140
238
|
|
141
239
|
def build_control
|
142
|
-
@libui
|
240
|
+
@libui = if ::LibUI.respond_to?("new_#{keyword}")
|
143
241
|
::LibUI.send("new_#{@keyword}", *@args)
|
144
242
|
elsif ::LibUI.respond_to?(keyword)
|
145
243
|
@args[0] = @args.first.libui if @args.first.is_a?(ControlProxy)
|
146
244
|
::LibUI.send(@keyword, *@args)
|
147
245
|
end
|
148
246
|
end
|
247
|
+
|
248
|
+
def handle_boolean_property(property, value)
|
249
|
+
BOOLEAN_PROPERTIES.include?(property) ? ControlProxy.integer_to_boolean(value) : value
|
250
|
+
end
|
251
|
+
|
252
|
+
def handle_string_property(property, value)
|
253
|
+
STRING_PROPERTIES.include?(property) ? value.to_s : value
|
254
|
+
end
|
149
255
|
end
|
150
256
|
end
|
151
257
|
end
|
@@ -0,0 +1,32 @@
|
|
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/date_time_picker_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
# Proxy for LibUI date picker objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class DatePickerProxy < DateTimePickerProxy
|
30
|
+
end
|
31
|
+
end
|
32
|
+
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 date time picker objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class DateTimePickerProxy < ControlProxy
|
30
|
+
def libui_api_keyword
|
31
|
+
'date_time_picker'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
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'
|
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)
|
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 }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
alias set_items items
|
40
|
+
alias items= items
|
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'
|
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
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def build_control
|
37
|
+
super.tap do
|
38
|
+
self.margined = true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
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
|
37
|
+
@libui = @parent_proxy.append_item(*@args)
|
35
38
|
end
|
36
39
|
end
|
37
40
|
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 multiline entry objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class MultilineEntryProxy < ControlProxy
|
30
|
+
def libui_api_keyword
|
31
|
+
'multiline_entry'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
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/multiline_entry_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
# Proxy for LibUI non wrapping multiline entry objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class NonWrappingMultilineEntryProxy < MultilineEntryProxy
|
30
|
+
end
|
31
|
+
end
|
32
|
+
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
|
@@ -0,0 +1,62 @@
|
|
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 quit menu item object
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class QuitMenuItemProxy < MenuItemProxy
|
30
|
+
def can_handle_listener?(listener_name)
|
31
|
+
listener_name == 'on_clicked' || super
|
32
|
+
end
|
33
|
+
|
34
|
+
def handle_listener(listener_name, &listener)
|
35
|
+
if listener_name == 'on_clicked'
|
36
|
+
@default_behavior_listener = Proc.new do
|
37
|
+
return_value = listener.call(self)
|
38
|
+
if return_value.is_a?(Numeric)
|
39
|
+
return_value
|
40
|
+
else
|
41
|
+
destroy
|
42
|
+
::LibUI.quit
|
43
|
+
0
|
44
|
+
end
|
45
|
+
end
|
46
|
+
::LibUI.on_should_quit(&@default_behavior_listener)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def build_control
|
53
|
+
@libui = @parent_proxy.append_quit_item(*@args)
|
54
|
+
handle_listener('on_clicked') do
|
55
|
+
ControlProxy.main_window_proxy&.destroy
|
56
|
+
::LibUI.quit
|
57
|
+
0
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
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'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
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 }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
alias set_items items
|
40
|
+
alias items= items
|
41
|
+
end
|
42
|
+
end
|
43
|
+
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 separator menu item object
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class SeparatorMenuItemProxy < MenuItemProxy
|
30
|
+
private
|
31
|
+
|
32
|
+
def build_control
|
33
|
+
@libui = @parent_proxy.append_separator(*@args)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|