glimmer-dsl-libui 0.0.6 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +298 -84
- 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 +20 -36
- data/examples/font_button.rb +18 -0
- data/examples/meta_example.rb +61 -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/libui/box.rb +12 -2
- data/lib/glimmer/libui/control_proxy.rb +82 -25
- 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/font_button_proxy.rb +48 -0
- data/lib/glimmer/libui/group_proxy.rb +8 -0
- data/lib/glimmer/libui/quit_menu_item_proxy.rb +1 -1
- data/lib/glimmer/libui/tab_item_proxy.rb +1 -0
- data/lib/glimmer/libui/time_picker_proxy.rb +32 -0
- data/lib/glimmer/libui/window_proxy.rb +13 -1
- metadata +12 -5
data/examples/basic_window.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
|
5
|
+
include Glimmer
|
6
|
+
|
7
|
+
window { # first 3 args can be set via properties with 4th arg has_menubar=true by default
|
8
|
+
title 'hello world'
|
9
|
+
content_size 300, 200
|
10
|
+
|
11
|
+
on_closing do
|
12
|
+
puts 'Bye Bye'
|
13
|
+
end
|
14
|
+
}.show
|
data/examples/control_gallery.rb
CHANGED
@@ -32,7 +32,7 @@ menu('Edit') {
|
|
32
32
|
check_menu_item('Checkable Item_')
|
33
33
|
separator_menu_item
|
34
34
|
menu_item('Disabled Item_') {
|
35
|
-
enabled
|
35
|
+
enabled false
|
36
36
|
}
|
37
37
|
}
|
38
38
|
|
@@ -42,27 +42,19 @@ menu('Help') {
|
|
42
42
|
about_menu_item # Can optionally contain an on_clicked listener
|
43
43
|
}
|
44
44
|
|
45
|
-
MAIN_WINDOW = window('Control Gallery', 600, 500
|
46
|
-
margined
|
45
|
+
MAIN_WINDOW = window('Control Gallery', 600, 500) {
|
46
|
+
margined true
|
47
47
|
|
48
48
|
on_closing do
|
49
49
|
puts 'Bye Bye'
|
50
50
|
end
|
51
51
|
|
52
52
|
vertical_box {
|
53
|
-
padded 1
|
54
|
-
|
55
53
|
horizontal_box {
|
56
|
-
padded 1
|
57
|
-
|
58
54
|
group('Basic Controls') {
|
59
|
-
margined 1
|
60
|
-
|
61
55
|
vertical_box {
|
62
|
-
padded 1
|
63
|
-
|
64
56
|
button('Button') {
|
65
|
-
stretchy
|
57
|
+
stretchy false
|
66
58
|
|
67
59
|
on_clicked do
|
68
60
|
msg_box(MAIN_WINDOW, 'Information', 'You clicked the button')
|
@@ -70,43 +62,38 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
70
62
|
}
|
71
63
|
|
72
64
|
checkbox('Checkbox') {
|
73
|
-
stretchy
|
65
|
+
stretchy false
|
74
66
|
|
75
67
|
on_toggled do |c|
|
76
|
-
checked = c.checked
|
68
|
+
checked = c.checked?
|
77
69
|
MAIN_WINDOW.title = "Checkbox is #{checked}"
|
78
70
|
c.text = "I am the checkbox (#{checked})"
|
79
71
|
end
|
80
72
|
}
|
81
73
|
|
82
|
-
label('Label') { stretchy
|
74
|
+
label('Label') { stretchy false }
|
83
75
|
|
84
|
-
horizontal_separator { stretchy
|
76
|
+
horizontal_separator { stretchy false }
|
85
77
|
|
86
|
-
date_picker { stretchy
|
78
|
+
date_picker { stretchy false }
|
87
79
|
|
88
|
-
time_picker { stretchy
|
80
|
+
time_picker { stretchy false }
|
89
81
|
|
90
|
-
date_time_picker { stretchy
|
82
|
+
date_time_picker { stretchy false }
|
91
83
|
|
92
|
-
font_button { stretchy
|
84
|
+
font_button { stretchy false }
|
93
85
|
|
94
|
-
color_button { stretchy
|
86
|
+
color_button { stretchy false }
|
95
87
|
}
|
96
88
|
}
|
97
89
|
|
98
90
|
vertical_box {
|
99
|
-
padded 1
|
100
|
-
|
101
91
|
group('Numbers') {
|
102
|
-
stretchy
|
103
|
-
margined 1
|
92
|
+
stretchy false
|
104
93
|
|
105
94
|
vertical_box {
|
106
|
-
padded 1
|
107
|
-
|
108
95
|
spinbox(0, 100) {
|
109
|
-
stretchy
|
96
|
+
stretchy false
|
110
97
|
value 42
|
111
98
|
|
112
99
|
on_changed do |s|
|
@@ -115,7 +102,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
115
102
|
}
|
116
103
|
|
117
104
|
slider(0, 100) {
|
118
|
-
stretchy
|
105
|
+
stretchy false
|
119
106
|
|
120
107
|
on_changed do |s|
|
121
108
|
v = s.value
|
@@ -124,19 +111,16 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
124
111
|
end
|
125
112
|
}
|
126
113
|
|
127
|
-
@progress_bar = progress_bar { stretchy
|
114
|
+
@progress_bar = progress_bar { stretchy false }
|
128
115
|
}
|
129
116
|
}
|
130
117
|
|
131
118
|
group('Lists') {
|
132
|
-
stretchy
|
133
|
-
margined 1
|
119
|
+
stretchy false
|
134
120
|
|
135
121
|
vertical_box {
|
136
|
-
padded 1
|
137
|
-
|
138
122
|
combobox {
|
139
|
-
stretchy
|
123
|
+
stretchy false
|
140
124
|
items 'combobox Item 1', 'combobox Item 2', 'combobox Item 3' # also accepts a single array argument
|
141
125
|
|
142
126
|
on_selected do |c|
|
@@ -145,7 +129,7 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
|
|
145
129
|
}
|
146
130
|
|
147
131
|
editable_combobox {
|
148
|
-
stretchy
|
132
|
+
stretchy false
|
149
133
|
items 'Editable Item 1', 'Editable Item 2', 'Editable Item 3' # also accepts a single array argument
|
150
134
|
}
|
151
135
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
|
5
|
+
include Glimmer
|
6
|
+
|
7
|
+
window('hello world', 300, 200) {
|
8
|
+
font_button { |fb|
|
9
|
+
on_changed do
|
10
|
+
font_descriptor = fb.font
|
11
|
+
p font_descriptor
|
12
|
+
end
|
13
|
+
}
|
14
|
+
|
15
|
+
on_closing do
|
16
|
+
puts 'Bye Bye'
|
17
|
+
end
|
18
|
+
}.show
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'glimmer-dsl-libui'
|
4
|
+
require 'facets'
|
5
|
+
|
6
|
+
class MetaExample
|
7
|
+
include Glimmer
|
8
|
+
|
9
|
+
def examples
|
10
|
+
if @examples.nil?
|
11
|
+
example_files = Dir.glob(File.join(File.expand_path('.', __dir__), '**', '*.rb'))
|
12
|
+
example_file_names = example_files.map { |f| File.basename(f, '.rb') }
|
13
|
+
example_file_names = example_file_names.reject { |f| f == 'meta_example' }
|
14
|
+
@examples = example_file_names.map { |f| f.underscore.titlecase }
|
15
|
+
end
|
16
|
+
@examples
|
17
|
+
end
|
18
|
+
|
19
|
+
def file_path_for(example)
|
20
|
+
File.join(File.expand_path('.', __dir__), "#{example.underscore}.rb")
|
21
|
+
end
|
22
|
+
|
23
|
+
def launch
|
24
|
+
menu('File') {
|
25
|
+
quit_menu_item
|
26
|
+
}
|
27
|
+
|
28
|
+
window('Meta-Example', 700, 500) { |w|
|
29
|
+
margined true
|
30
|
+
|
31
|
+
horizontal_box {
|
32
|
+
vertical_box {
|
33
|
+
@rbs = radio_buttons {
|
34
|
+
stretchy false
|
35
|
+
items examples
|
36
|
+
selected 0
|
37
|
+
|
38
|
+
on_selected do
|
39
|
+
@nwme.text = File.read(file_path_for(@examples[@rbs.selected]))
|
40
|
+
end
|
41
|
+
}
|
42
|
+
button('Launch') {
|
43
|
+
stretchy false
|
44
|
+
|
45
|
+
on_clicked do
|
46
|
+
system "ruby -r puts_debuggerer -r #{File.expand_path('../lib/glimmer-dsl-libui', __dir__)} #{file_path_for(@examples[@rbs.selected])}"
|
47
|
+
end
|
48
|
+
}
|
49
|
+
}
|
50
|
+
vertical_box {
|
51
|
+
@nwme = non_wrapping_multiline_entry {
|
52
|
+
read_only true
|
53
|
+
text File.read(file_path_for(@examples[@rbs.selected]))
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}.show
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
MetaExample.new.launch
|
data/examples/midi_player.rb
CHANGED
@@ -56,10 +56,10 @@ class TinyMidiPlayer
|
|
56
56
|
end
|
57
57
|
}
|
58
58
|
}
|
59
|
-
@main_window = window('Tiny Midi Player', 200, 50
|
59
|
+
@main_window = window('Tiny Midi Player', 200, 50) {
|
60
60
|
horizontal_box {
|
61
61
|
vertical_box {
|
62
|
-
stretchy
|
62
|
+
stretchy false
|
63
63
|
|
64
64
|
button('▶') {
|
65
65
|
on_clicked do
|
data/examples/simple_notepad.rb
CHANGED
data/glimmer-dsl-libui.gemspec
CHANGED
Binary file
|
data/lib/glimmer/libui/box.rb
CHANGED
@@ -19,19 +19,29 @@
|
|
19
19
|
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
20
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
21
|
|
22
|
+
require 'glimmer/libui/control_proxy'
|
23
|
+
|
22
24
|
module Glimmer
|
23
25
|
module LibUI
|
24
26
|
module Box
|
25
27
|
APPEND_PROPERTIES = %w[stretchy]
|
26
28
|
|
27
29
|
def post_initialize_child(child)
|
28
|
-
child.stretchy =
|
29
|
-
::LibUI.box_append(@libui, child.libui, child.stretchy)
|
30
|
+
child.stretchy = true if child.stretchy.nil?
|
31
|
+
::LibUI.box_append(@libui, child.libui, ControlProxy.boolean_to_integer(child.stretchy))
|
30
32
|
end
|
31
33
|
|
32
34
|
def libui_api_keyword
|
33
35
|
'box'
|
34
36
|
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def build_control
|
41
|
+
super.tap do
|
42
|
+
self.padded = true
|
43
|
+
end
|
44
|
+
end
|
35
45
|
end
|
36
46
|
end
|
37
47
|
end
|
@@ -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).tap {|c|
|
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)
|
@@ -46,12 +46,39 @@ module Glimmer
|
|
46
46
|
end
|
47
47
|
|
48
48
|
# autosave all controls in this array to avoid garbage collection
|
49
|
-
def
|
50
|
-
@@
|
51
|
-
@@
|
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)
|
52
64
|
end
|
53
65
|
end
|
54
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
|
+
|
55
82
|
# libui returns the contained LibUI object
|
56
83
|
attr_reader :parent_proxy, :libui, :args, :keyword
|
57
84
|
|
@@ -60,11 +87,8 @@ module Glimmer
|
|
60
87
|
@parent_proxy = parent
|
61
88
|
@args = args
|
62
89
|
@block = block
|
63
|
-
@enabled =
|
90
|
+
@enabled = true
|
64
91
|
build_control
|
65
|
-
if @parent_proxy.class.constants.include?(:APPEND_PROPERTIES)
|
66
|
-
@parent_proxy.class::APPEND_PROPERTIES
|
67
|
-
end
|
68
92
|
post_add_content if @block.nil?
|
69
93
|
end
|
70
94
|
|
@@ -77,6 +101,14 @@ module Glimmer
|
|
77
101
|
def post_initialize_child(child)
|
78
102
|
# No Op by default
|
79
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
|
80
112
|
|
81
113
|
def can_handle_listener?(listener_name)
|
82
114
|
::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}") ||
|
@@ -94,21 +126,28 @@ module Glimmer
|
|
94
126
|
|
95
127
|
def respond_to?(method_name, *args, &block)
|
96
128
|
respond_to_libui?(method_name, *args, &block) ||
|
97
|
-
(
|
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
|
+
) ||
|
98
134
|
super(method_name, true)
|
99
135
|
end
|
100
136
|
|
101
137
|
def respond_to_libui?(method_name, *args, &block)
|
102
138
|
::LibUI.respond_to?("control_#{method_name}") ||
|
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(/=$/, '')}") ||
|
103
141
|
::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") ||
|
104
|
-
::LibUI.respond_to?("#{libui_api_keyword}
|
142
|
+
(::LibUI.respond_to?("#{libui_api_keyword}_#{method_name.to_s.sub(/\?$/, '')}") && BOOLEAN_PROPERTIES.include?(method_name.to_s.sub(/\?$/, '')) ) ||
|
105
143
|
::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}")
|
106
144
|
end
|
107
145
|
|
108
146
|
def method_missing(method_name, *args, &block)
|
109
147
|
if respond_to_libui?(method_name, *args, &block)
|
110
148
|
send_to_libui(method_name, *args, &block)
|
111
|
-
elsif
|
149
|
+
elsif append_properties.include?(method_name.to_s) ||
|
150
|
+
append_properties.include?(method_name.to_s.sub(/(=|\?)$/, ''))
|
112
151
|
append_property(method_name, *args)
|
113
152
|
else
|
114
153
|
super
|
@@ -116,17 +155,25 @@ module Glimmer
|
|
116
155
|
end
|
117
156
|
|
118
157
|
def send_to_libui(method_name, *args, &block)
|
119
|
-
if ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") && args.empty?
|
120
|
-
|
121
|
-
|
122
|
-
|
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))
|
123
162
|
elsif ::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}") && !args.empty?
|
124
|
-
|
125
|
-
|
126
|
-
::LibUI.send("#{libui_api_keyword}
|
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)
|
127
166
|
elsif ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") && !args.empty?
|
128
167
|
::LibUI.send("#{libui_api_keyword}_#{method_name}", @libui, *args)
|
129
|
-
elsif ::LibUI.respond_to?("control_#{method_name}")
|
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?
|
130
177
|
::LibUI.send("control_#{method_name}", @libui, *args)
|
131
178
|
end
|
132
179
|
end
|
@@ -136,11 +183,13 @@ module Glimmer
|
|
136
183
|
end
|
137
184
|
|
138
185
|
def append_property(property, value = nil)
|
139
|
-
property = property.to_s.sub(
|
186
|
+
property = property.to_s.sub(/(=|\?)$/, '')
|
140
187
|
@append_property_hash ||= {}
|
141
188
|
if value.nil?
|
142
|
-
@append_property_hash[property]
|
189
|
+
value = @append_property_hash[property]
|
190
|
+
handle_string_property(property, handle_boolean_property(property, value))
|
143
191
|
else
|
192
|
+
value = ControlProxy.boolean_to_integer(value) if BOOLEAN_PROPERTIES.include?(property) && (value.is_a?(TrueClass) || value.is_a?(FalseClass))
|
144
193
|
@append_property_hash[property] = value
|
145
194
|
end
|
146
195
|
end
|
@@ -153,7 +202,7 @@ module Glimmer
|
|
153
202
|
if value.nil?
|
154
203
|
@enabled
|
155
204
|
elsif value != @enabled
|
156
|
-
if value == 1
|
205
|
+
if value == 1 || value
|
157
206
|
send_to_libui('enable')
|
158
207
|
else
|
159
208
|
send_to_libui('disable')
|
@@ -169,7 +218,7 @@ module Glimmer
|
|
169
218
|
if value.nil?
|
170
219
|
current_value
|
171
220
|
elsif value != current_value
|
172
|
-
if value == 1
|
221
|
+
if value == 1 || value
|
173
222
|
send_to_libui('show')
|
174
223
|
else
|
175
224
|
send_to_libui('hide')
|
@@ -182,9 +231,9 @@ module Glimmer
|
|
182
231
|
|
183
232
|
def destroy
|
184
233
|
send_to_libui('destroy')
|
185
|
-
self.class.
|
234
|
+
self.class.all_control_proxies.delete(self)
|
186
235
|
end
|
187
|
-
|
236
|
+
|
188
237
|
private
|
189
238
|
|
190
239
|
def build_control
|
@@ -195,6 +244,14 @@ module Glimmer
|
|
195
244
|
::LibUI.send(@keyword, *@args)
|
196
245
|
end
|
197
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
|
198
255
|
end
|
199
256
|
end
|
200
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,48 @@
|
|
1
|
+
# Copyright (c) 2021 Andy Maleh
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
require 'glimmer/libui/control_proxy'
|
23
|
+
|
24
|
+
module Glimmer
|
25
|
+
module LibUI
|
26
|
+
# Proxy for LibUI font button objects
|
27
|
+
#
|
28
|
+
# Follows the Proxy Design Pattern
|
29
|
+
class FontButtonProxy < ControlProxy
|
30
|
+
def font
|
31
|
+
@font_descriptor ||= ::LibUI::FFI::FontDescriptor.malloc
|
32
|
+
::LibUI.font_button_font(@libui, @font_descriptor)
|
33
|
+
{
|
34
|
+
family: @font_descriptor.Family.to_s,
|
35
|
+
size: @font_descriptor.Size,
|
36
|
+
weight: @font_descriptor.Weight,
|
37
|
+
italic: @font_descriptor.Italic,
|
38
|
+
stretch: @font_descriptor.Stretch
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
def destroy
|
43
|
+
::LibUI.free_font_button_font(@font_descriptor) unless @font_descriptor.nil?
|
44
|
+
super
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|