glimmer-dsl-libui 0.0.1 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/README.md +948 -21
- data/VERSION +1 -1
- data/examples/basic_entry.rb +31 -0
- data/examples/control_gallery.rb +184 -0
- data/examples/midi_player.rb +90 -0
- data/examples/simple_notepad.rb +15 -0
- data/glimmer-dsl-libui.gemspec +0 -0
- data/lib/glimmer/dsl/libui/control_expression.rb +2 -1
- 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 +37 -0
- data/lib/glimmer/libui/check_menu_item_proxy.rb +37 -0
- data/lib/glimmer/libui/combobox_proxy.rb +42 -0
- data/lib/glimmer/libui/control_proxy.rb +90 -24
- data/lib/glimmer/libui/editable_combobox_proxy.rb +42 -0
- data/lib/glimmer/libui/group_proxy.rb +35 -0
- data/lib/glimmer/libui/horizontal_box_proxy.rb +34 -0
- data/lib/glimmer/libui/menu_item_proxy.rb +41 -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 +42 -0
- data/lib/glimmer/libui/separator_menu_item_proxy.rb +37 -0
- data/lib/glimmer/libui/tab_item_proxy.rb +64 -0
- data/lib/glimmer/libui/vertical_box_proxy.rb +34 -0
- data/lib/glimmer/libui/window_proxy.rb +6 -2
- data/lib/glimmer-dsl-libui.rb +2 -0
- metadata +27 -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
|
-
def create(keyword, parent, args)
|
34
|
-
widget_proxy_class(keyword).new(keyword, parent, args)
|
35
|
+
def create(keyword, parent, args, &block)
|
36
|
+
widget_proxy_class(keyword).new(keyword, parent, args, &block)
|
35
37
|
end
|
36
38
|
|
37
39
|
def widget_proxy_class(keyword)
|
@@ -51,65 +53,129 @@ module Glimmer
|
|
51
53
|
@keyword = keyword
|
52
54
|
@parent_proxy = parent
|
53
55
|
@args = args
|
56
|
+
@block = block
|
57
|
+
@enabled = 1
|
54
58
|
build_control
|
55
|
-
if @parent_proxy.
|
56
|
-
|
59
|
+
if @parent_proxy.class.constants.include?(:APPEND_PROPERTIES)
|
60
|
+
@parent_proxy.class::APPEND_PROPERTIES
|
57
61
|
end
|
62
|
+
post_add_content if @block.nil?
|
58
63
|
end
|
59
64
|
|
65
|
+
# Subclasses may override to perform post add_content work (normally must call super)
|
60
66
|
def post_add_content
|
61
|
-
|
67
|
+
@parent_proxy&.post_initialize_child(self)
|
62
68
|
end
|
63
69
|
|
70
|
+
# Subclasses may override to perform post initialization work on an added child
|
71
|
+
def post_initialize_child(child)
|
72
|
+
# No Op by default
|
73
|
+
end
|
74
|
+
|
64
75
|
def can_handle_listener?(listener_name)
|
65
|
-
::LibUI.respond_to?("control_#{listener_name}") || ::LibUI.respond_to?("#{
|
76
|
+
::LibUI.respond_to?("control_#{listener_name}") || ::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}")
|
66
77
|
end
|
67
78
|
|
68
79
|
def handle_listener(listener_name, &listener)
|
69
80
|
if ::LibUI.respond_to?("control_#{listener_name}")
|
70
81
|
::LibUI.send("control_#{listener_name}", @libui, &listener)
|
71
|
-
elsif ::LibUI.respond_to?("#{
|
72
|
-
::LibUI.send("#{
|
82
|
+
elsif ::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}")
|
83
|
+
::LibUI.send("#{libui_api_keyword}_#{listener_name}", @libui, &listener)
|
73
84
|
end
|
74
85
|
end
|
75
86
|
|
76
87
|
def respond_to?(method_name, *args, &block)
|
77
|
-
respond_to_libui?(method_name, *args, &block) ||
|
88
|
+
respond_to_libui?(method_name, *args, &block) ||
|
89
|
+
(append_properties.include?(method_name.to_s) || append_properties.include?(method_name.to_s.sub(/=$/, ''))) ||
|
90
|
+
super
|
78
91
|
end
|
79
92
|
|
80
93
|
def respond_to_libui?(method_name, *args, &block)
|
81
94
|
::LibUI.respond_to?("control_#{method_name}") ||
|
82
|
-
::LibUI.respond_to?("#{
|
83
|
-
::LibUI.respond_to?("#{
|
84
|
-
::LibUI.respond_to?("#{
|
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(/=$/, '')}")
|
85
98
|
end
|
86
99
|
|
87
100
|
def method_missing(method_name, *args, &block)
|
88
101
|
if respond_to_libui?(method_name, *args, &block)
|
89
102
|
send_to_libui(method_name, *args, &block)
|
103
|
+
elsif (append_properties.include?(method_name.to_s) || append_properties.include?(method_name.to_s.sub(/=$/, '')))
|
104
|
+
append_property(method_name, *args)
|
90
105
|
else
|
91
106
|
super
|
92
107
|
end
|
93
108
|
end
|
94
109
|
|
95
110
|
def send_to_libui(method_name, *args, &block)
|
96
|
-
if ::LibUI.respond_to?("
|
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}")
|
97
122
|
::LibUI.send("control_#{method_name}", @libui, *args)
|
98
|
-
elsif ::LibUI.respond_to?("#{@keyword}_#{method_name}") && args.empty?
|
99
|
-
::LibUI.send("#{@keyword}_#{method_name}", @libui, *args)
|
100
|
-
elsif ::LibUI.respond_to?("#{@keyword}_set_#{method_name}") && !args.empty?
|
101
|
-
::LibUI.send("#{@keyword}_set_#{method_name}", @libui, *args)
|
102
|
-
elsif ::LibUI.respond_to?("#{@keyword}_set_#{method_name.to_s.sub(/=$/, '')}") && !args.empty?
|
103
|
-
::LibUI.send("#{@keyword}_set_#{method_name.to_s.sub(/=$/, '')}", @libui, *args)
|
104
|
-
elsif ::LibUI.respond_to?("#{@keyword}_#{method_name}") && method_name.start_with?('set_') && !args.empty?
|
105
|
-
::LibUI.send("#{@keyword}_#{method_name}", @libui, *args)
|
106
123
|
end
|
107
124
|
end
|
108
125
|
|
126
|
+
def append_properties
|
127
|
+
@parent_proxy&.class&.constants&.include?(:APPEND_PROPERTIES) ? @parent_proxy.class::APPEND_PROPERTIES : []
|
128
|
+
end
|
129
|
+
|
130
|
+
def append_property(property, value = nil)
|
131
|
+
property = property.to_s.sub(/=$/, '')
|
132
|
+
@append_property_hash ||= {}
|
133
|
+
if value.nil?
|
134
|
+
@append_property_hash[property]
|
135
|
+
else
|
136
|
+
@append_property_hash[property] = value
|
137
|
+
end
|
138
|
+
end
|
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
|
+
|
109
175
|
private
|
110
176
|
|
111
177
|
def build_control
|
112
|
-
@libui
|
178
|
+
@libui = if ::LibUI.respond_to?("new_#{keyword}")
|
113
179
|
::LibUI.send("new_#{@keyword}", *@args)
|
114
180
|
elsif ::LibUI.respond_to?(keyword)
|
115
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
|
@@ -0,0 +1,34 @@
|
|
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/box'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module LibUI
|
27
|
+
# Proxy for LibUI horizontal box objects
|
28
|
+
#
|
29
|
+
# Follows the Proxy Design Pattern
|
30
|
+
class HorizontalBoxProxy < ControlProxy
|
31
|
+
include Box
|
32
|
+
end
|
33
|
+
end
|
34
|
+
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,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
|
38
|
+
if return_value.is_a?(Numeric)
|
39
|
+
return_value
|
40
|
+
else
|
41
|
+
destroy
|
42
|
+
::LibUI.quit
|
43
|
+
0
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
::LibUI.on_should_quit(&default_behavior_listener)
|
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
|
+
destroy
|
56
|
+
::LibUI.quit
|
57
|
+
0
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -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 radio buttons objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class RadioButtonsProxy < 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,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,64 @@
|
|
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 tab item objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class TabItemProxy < ControlProxy
|
30
|
+
attr_reader :index
|
31
|
+
|
32
|
+
def initialize(keyword, parent, args, &block)
|
33
|
+
@keyword = keyword
|
34
|
+
@parent_proxy = parent
|
35
|
+
@args = args
|
36
|
+
@block = block
|
37
|
+
@enabled = 1
|
38
|
+
@index = @parent_proxy.num_pages
|
39
|
+
@content = @block.call
|
40
|
+
build_control
|
41
|
+
end
|
42
|
+
|
43
|
+
def name
|
44
|
+
@args.first
|
45
|
+
end
|
46
|
+
|
47
|
+
def margined(value = nil)
|
48
|
+
if value.nil?
|
49
|
+
@parent_proxy.margined(@index)
|
50
|
+
else
|
51
|
+
@parent_proxy.margined(@index, value)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
alias set_margined margined
|
55
|
+
alias margined= margined
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def build_control
|
60
|
+
@libui = @parent_proxy.append(name, @content.libui)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,34 @@
|
|
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/box'
|
24
|
+
|
25
|
+
module Glimmer
|
26
|
+
module LibUI
|
27
|
+
# Proxy for LibUI vertical box objects
|
28
|
+
#
|
29
|
+
# Follows the Proxy Design Pattern
|
30
|
+
class VerticalBoxProxy < ControlProxy
|
31
|
+
include Box
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -23,15 +23,20 @@ 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
|
30
|
+
def post_initialize_child(child)
|
31
|
+
::LibUI.window_set_child(@libui, child.libui)
|
32
|
+
end
|
33
|
+
|
30
34
|
def show
|
31
35
|
send_to_libui('show')
|
32
36
|
unless @shown_at_least_once
|
33
37
|
@shown_at_least_once = true
|
34
38
|
::LibUI.main
|
39
|
+
::LibUI.quit
|
35
40
|
end
|
36
41
|
end
|
37
42
|
|
@@ -54,7 +59,6 @@ module Glimmer
|
|
54
59
|
private
|
55
60
|
|
56
61
|
def build_control
|
57
|
-
::LibUI.init
|
58
62
|
super.tap do
|
59
63
|
handle_listener('on_closing') do
|
60
64
|
destroy
|