glimmer-dsl-libui 0.0.3 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +37 -0
- data/README.md +758 -24
- data/VERSION +1 -1
- data/examples/control_gallery.rb +168 -0
- data/examples/midi_player.rb +90 -0
- 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 -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 +12 -0
- data/lib/glimmer/libui/check_menu_item_proxy.rb +37 -0
- data/lib/glimmer/libui/combobox_proxy.rb +43 -0
- data/lib/glimmer/libui/control_proxy.rb +87 -22
- data/lib/glimmer/libui/editable_combobox_proxy.rb +43 -0
- data/lib/glimmer/libui/group_proxy.rb +43 -0
- data/lib/glimmer/libui/horizontal_box_proxy.rb +1 -1
- data/lib/glimmer/libui/menu_item_proxy.rb +41 -0
- 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 +66 -0
- data/lib/glimmer/libui/vertical_box_proxy.rb +1 -1
- data/lib/glimmer/libui/window_proxy.rb +3 -3
- data/lib/glimmer-dsl-libui.rb +2 -0
- metadata +24 -5
@@ -21,17 +21,19 @@
|
|
21
21
|
|
22
22
|
module Glimmer
|
23
23
|
module LibUI
|
24
|
-
# Proxy for LibUI
|
24
|
+
# Proxy for LibUI control objects
|
25
25
|
#
|
26
26
|
# Follows the Proxy Design Pattern
|
27
27
|
class ControlProxy
|
28
28
|
class << self
|
29
29
|
def control_exists?(keyword)
|
30
|
-
::LibUI.respond_to?("new_#{keyword}") ||
|
30
|
+
::LibUI.respond_to?("new_#{keyword}") ||
|
31
|
+
::LibUI.respond_to?(keyword) ||
|
32
|
+
Glimmer::LibUI.constants.include?("#{keyword.camelcase(:upper)}Proxy".to_sym)
|
31
33
|
end
|
32
34
|
|
33
35
|
def create(keyword, parent, args, &block)
|
34
|
-
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}
|
35
37
|
end
|
36
38
|
|
37
39
|
def widget_proxy_class(keyword)
|
@@ -42,6 +44,16 @@ module Glimmer
|
|
42
44
|
Glimmer::LibUI::ControlProxy
|
43
45
|
end
|
44
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
|
45
57
|
end
|
46
58
|
|
47
59
|
# libui returns the contained LibUI object
|
@@ -52,6 +64,7 @@ module Glimmer
|
|
52
64
|
@parent_proxy = parent
|
53
65
|
@args = args
|
54
66
|
@block = block
|
67
|
+
@enabled = 1
|
55
68
|
build_control
|
56
69
|
if @parent_proxy.class.constants.include?(:APPEND_PROPERTIES)
|
57
70
|
@parent_proxy.class::APPEND_PROPERTIES
|
@@ -68,30 +81,40 @@ module Glimmer
|
|
68
81
|
def post_initialize_child(child)
|
69
82
|
# No Op by default
|
70
83
|
end
|
84
|
+
|
85
|
+
def window_proxy
|
86
|
+
found_proxy = self
|
87
|
+
until found_proxy.nil? || found_proxy.is_a?(WindowProxy)
|
88
|
+
found_proxy = found_proxy.parent_proxy
|
89
|
+
end
|
90
|
+
found_proxy
|
91
|
+
end
|
71
92
|
|
72
93
|
def can_handle_listener?(listener_name)
|
73
|
-
::LibUI.respond_to?("
|
94
|
+
::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}") ||
|
95
|
+
::LibUI.respond_to?("control_#{listener_name}")
|
74
96
|
end
|
75
97
|
|
76
98
|
def handle_listener(listener_name, &listener)
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
99
|
+
safe_listener = Proc.new { listener.call(self) }
|
100
|
+
if ::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}")
|
101
|
+
::LibUI.send("#{libui_api_keyword}_#{listener_name}", @libui, &safe_listener)
|
102
|
+
elsif ::LibUI.respond_to?("control_#{listener_name}")
|
103
|
+
::LibUI.send("control_#{listener_name}", @libui, &safe_listener)
|
81
104
|
end
|
82
105
|
end
|
83
106
|
|
84
107
|
def respond_to?(method_name, *args, &block)
|
85
108
|
respond_to_libui?(method_name, *args, &block) ||
|
86
109
|
(append_properties.include?(method_name.to_s) || append_properties.include?(method_name.to_s.sub(/=$/, ''))) ||
|
87
|
-
super
|
110
|
+
super(method_name, true)
|
88
111
|
end
|
89
112
|
|
90
113
|
def respond_to_libui?(method_name, *args, &block)
|
91
114
|
::LibUI.respond_to?("control_#{method_name}") ||
|
92
|
-
::LibUI.respond_to?("#{
|
93
|
-
::LibUI.respond_to?("#{
|
94
|
-
::LibUI.respond_to?("#{
|
115
|
+
::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") ||
|
116
|
+
::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name}") ||
|
117
|
+
::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}")
|
95
118
|
end
|
96
119
|
|
97
120
|
def method_missing(method_name, *args, &block)
|
@@ -105,16 +128,18 @@ module Glimmer
|
|
105
128
|
end
|
106
129
|
|
107
130
|
def send_to_libui(method_name, *args, &block)
|
108
|
-
if ::LibUI.respond_to?("
|
131
|
+
if ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") && args.empty?
|
132
|
+
::LibUI.send("#{libui_api_keyword}_#{method_name}", @libui, *args)
|
133
|
+
elsif ::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name}") && !args.empty?
|
134
|
+
::LibUI.send("#{libui_api_keyword}_set_#{method_name}", @libui, *args)
|
135
|
+
elsif ::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}") && !args.empty?
|
136
|
+
::LibUI.send("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}", @libui, *args)
|
137
|
+
elsif ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") && method_name.start_with?('set_') && !args.empty?
|
138
|
+
::LibUI.send("#{libui_api_keyword}_#{method_name}", @libui, *args)
|
139
|
+
elsif ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") && !args.empty?
|
140
|
+
::LibUI.send("#{libui_api_keyword}_#{method_name}", @libui, *args)
|
141
|
+
elsif ::LibUI.respond_to?("control_#{method_name}")
|
109
142
|
::LibUI.send("control_#{method_name}", @libui, *args)
|
110
|
-
elsif ::LibUI.respond_to?("#{@keyword}_#{method_name}") && args.empty?
|
111
|
-
::LibUI.send("#{@keyword}_#{method_name}", @libui, *args)
|
112
|
-
elsif ::LibUI.respond_to?("#{@keyword}_set_#{method_name}") && !args.empty?
|
113
|
-
::LibUI.send("#{@keyword}_set_#{method_name}", @libui, *args)
|
114
|
-
elsif ::LibUI.respond_to?("#{@keyword}_set_#{method_name.to_s.sub(/=$/, '')}") && !args.empty?
|
115
|
-
::LibUI.send("#{@keyword}_set_#{method_name.to_s.sub(/=$/, '')}", @libui, *args)
|
116
|
-
elsif ::LibUI.respond_to?("#{@keyword}_#{method_name}") && method_name.start_with?('set_') && !args.empty?
|
117
|
-
::LibUI.send("#{@keyword}_#{method_name}", @libui, *args)
|
118
143
|
end
|
119
144
|
end
|
120
145
|
|
@@ -132,10 +157,50 @@ module Glimmer
|
|
132
157
|
end
|
133
158
|
end
|
134
159
|
|
160
|
+
def libui_api_keyword
|
161
|
+
@keyword
|
162
|
+
end
|
163
|
+
|
164
|
+
def enabled(value = nil)
|
165
|
+
if value.nil?
|
166
|
+
@enabled
|
167
|
+
elsif value != @enabled
|
168
|
+
if value == 1
|
169
|
+
send_to_libui('enable')
|
170
|
+
else
|
171
|
+
send_to_libui('disable')
|
172
|
+
end
|
173
|
+
end
|
174
|
+
end
|
175
|
+
alias enabled? enabled
|
176
|
+
alias set_enabled enabled
|
177
|
+
alias enabled= enabled
|
178
|
+
|
179
|
+
def visible(value = nil)
|
180
|
+
current_value = send_to_libui('visible')
|
181
|
+
if value.nil?
|
182
|
+
current_value
|
183
|
+
elsif value != current_value
|
184
|
+
if value == 1
|
185
|
+
send_to_libui('show')
|
186
|
+
else
|
187
|
+
send_to_libui('hide')
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
alias visible? visible
|
192
|
+
alias set_visible visible
|
193
|
+
alias visible= visible
|
194
|
+
|
195
|
+
def destroy
|
196
|
+
send_to_libui('destroy')
|
197
|
+
self.class.all_control_proxies.delete(self)
|
198
|
+
end
|
199
|
+
|
135
200
|
private
|
136
201
|
|
137
202
|
def build_control
|
138
|
-
@libui
|
203
|
+
@libui = if ::LibUI.respond_to?("new_#{keyword}")
|
139
204
|
::LibUI.send("new_#{@keyword}", *@args)
|
140
205
|
elsif ::LibUI.respond_to?(keyword)
|
141
206
|
@args[0] = @args.first.libui if @args.first.is_a?(ControlProxy)
|
@@ -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 = 1
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,41 @@
|
|
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 menu item objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class MenuItemProxy < ControlProxy
|
30
|
+
def libui_api_keyword
|
31
|
+
'menu_item'
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def build_control
|
37
|
+
@libui = @parent_proxy.append_item(*@args)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
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
|
@@ -0,0 +1,66 @@
|
|
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/horizontal_box_proxy'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module LibUI
|
27
|
+
# Proxy for LibUI tab item objects
|
28
|
+
#
|
29
|
+
# Follows the Proxy Design Pattern
|
30
|
+
class TabItemProxy < ControlProxy
|
31
|
+
attr_reader :index
|
32
|
+
|
33
|
+
def initialize(keyword, parent, args, &block)
|
34
|
+
@keyword = keyword
|
35
|
+
@parent_proxy = parent
|
36
|
+
@args = args
|
37
|
+
@block = block
|
38
|
+
@enabled = 1
|
39
|
+
@index = @parent_proxy.num_pages
|
40
|
+
@content = @block&.call
|
41
|
+
build_control
|
42
|
+
end
|
43
|
+
|
44
|
+
def name
|
45
|
+
@args.first
|
46
|
+
end
|
47
|
+
|
48
|
+
def margined(value = nil)
|
49
|
+
if value.nil?
|
50
|
+
@parent_proxy.margined(@index)
|
51
|
+
else
|
52
|
+
@parent_proxy.margined(@index, value)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
alias set_margined margined
|
56
|
+
alias margined= margined
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def build_control
|
61
|
+
@content = HorizontalBoxProxy.new('horizontal_box', @libui, []) if @content.nil?
|
62
|
+
@libui = @parent_proxy.append(name, @content.libui)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -23,7 +23,7 @@ require 'glimmer/libui/control_proxy'
|
|
23
23
|
|
24
24
|
module Glimmer
|
25
25
|
module LibUI
|
26
|
-
# Proxy for LibUI
|
26
|
+
# Proxy for LibUI window objects
|
27
27
|
#
|
28
28
|
# Follows the Proxy Design Pattern
|
29
29
|
class WindowProxy < ControlProxy
|
@@ -36,13 +36,14 @@ module Glimmer
|
|
36
36
|
unless @shown_at_least_once
|
37
37
|
@shown_at_least_once = true
|
38
38
|
::LibUI.main
|
39
|
+
::LibUI.quit
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
43
|
def handle_listener(listener_name, &listener)
|
43
44
|
if listener_name == 'on_closing'
|
44
45
|
default_behavior_listener = Proc.new do
|
45
|
-
return_value = listener.call
|
46
|
+
return_value = listener.call(self)
|
46
47
|
if return_value.is_a?(Numeric)
|
47
48
|
return_value
|
48
49
|
else
|
@@ -58,7 +59,6 @@ module Glimmer
|
|
58
59
|
private
|
59
60
|
|
60
61
|
def build_control
|
61
|
-
::LibUI.init
|
62
62
|
super.tap do
|
63
63
|
handle_listener('on_closing') do
|
64
64
|
destroy
|