glimmer-dsl-libui 0.0.5 → 0.0.9

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.
@@ -4,10 +4,10 @@ require 'glimmer-dsl-libui'
4
4
 
5
5
  include Glimmer
6
6
 
7
- window('Basic Entry', 300, 50, 1) { |w|
7
+ window('Basic Entry', 300, 50) { |w|
8
8
  horizontal_box {
9
9
  e = entry {
10
- # stretchy 1 # Smart default option for appending to horizontal_box
10
+ # stretchy true # Smart default option for appending to horizontal_box
11
11
 
12
12
  on_changed do
13
13
  puts e.text
@@ -16,7 +16,7 @@ window('Basic Entry', 300, 50, 1) { |w|
16
16
  }
17
17
 
18
18
  button('Button') {
19
- stretchy 0
19
+ stretchy false
20
20
 
21
21
  on_clicked do
22
22
  text = e.text
@@ -4,7 +4,7 @@ require 'glimmer-dsl-libui'
4
4
 
5
5
  include Glimmer
6
6
 
7
- window('hello world', 300, 200, 1) {
7
+ window('hello world', 300, 200, true) {
8
8
  on_closing do
9
9
  puts 'Bye Bye'
10
10
  end
@@ -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
@@ -31,8 +31,8 @@ menu('File') {
31
31
  menu('Edit') {
32
32
  check_menu_item('Checkable Item_')
33
33
  separator_menu_item
34
- menu_item('Disabled Item_') { |mi|
35
- enabled 0
34
+ menu_item('Disabled Item_') {
35
+ enabled false
36
36
  }
37
37
  }
38
38
 
@@ -42,115 +42,99 @@ 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, 1) {
46
- margined 1
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
- vertical_box { |vb|
53
- padded 1
54
-
52
+ vertical_box {
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 0
57
+ stretchy false
66
58
 
67
59
  on_clicked do
68
60
  msg_box(MAIN_WINDOW, 'Information', 'You clicked the button')
69
61
  end
70
62
  }
71
63
 
72
- checkbox('Checkbox') { |c|
73
- stretchy 0
64
+ checkbox('Checkbox') {
65
+ stretchy false
74
66
 
75
- on_toggled do
76
- checked = c.checked == 1
67
+ on_toggled do |c|
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 0 }
74
+ label('Label') { stretchy false }
83
75
 
84
- horizontal_separator { stretchy 0 }
76
+ horizontal_separator { stretchy false }
85
77
 
86
- date_picker { stretchy 0 }
78
+ date_picker { stretchy false }
87
79
 
88
- time_picker { stretchy 0 }
80
+ time_picker { stretchy false }
89
81
 
90
- date_time_picker { stretchy 0 }
82
+ date_time_picker { stretchy false }
91
83
 
92
- font_button { stretchy 0 }
84
+ font_button { stretchy false }
93
85
 
94
- color_button { stretchy 0 }
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 0
103
- margined 1
92
+ stretchy false
104
93
 
105
94
  vertical_box {
106
- padded 1
107
-
108
- spinbox(0, 100) { |s|
109
- stretchy 0
95
+ spinbox(0, 100) {
96
+ stretchy false
110
97
  value 42
111
98
 
112
- on_changed do
99
+ on_changed do |s|
113
100
  puts "New Spinbox value: #{s.value}"
114
101
  end
115
102
  }
116
103
 
117
- slider(0, 100) { |s|
118
- stretchy 0
104
+ slider(0, 100) {
105
+ stretchy false
119
106
 
120
- on_changed do
107
+ on_changed do |s|
121
108
  v = s.value
122
109
  puts "New Slider value: #{v}"
123
110
  @progress_bar.value = v
124
111
  end
125
112
  }
126
113
 
127
- @progress_bar = progress_bar { stretchy 0 }
114
+ @progress_bar = progress_bar { stretchy false }
128
115
  }
129
116
  }
130
117
 
131
118
  group('Lists') {
132
- stretchy 0
133
- margined 1
119
+ stretchy false
134
120
 
135
121
  vertical_box {
136
- padded 1
137
-
138
- combobox { |c|
139
- stretchy 0
140
- items ['combobox Item 1', 'combobox Item 2', 'combobox Item 3']
122
+ combobox {
123
+ stretchy false
124
+ items 'combobox Item 1', 'combobox Item 2', 'combobox Item 3' # also accepts a single array argument
141
125
 
142
- on_selected do
126
+ on_selected do |c|
143
127
  puts "New combobox selection: #{c.selected}"
144
128
  end
145
129
  }
146
130
 
147
131
  editable_combobox {
148
- stretchy 0
149
- items ['Editable Item 1', 'Editable Item 2', 'Editable Item 3']
132
+ stretchy false
133
+ items 'Editable Item 1', 'Editable Item 2', 'Editable Item 3' # also accepts a single array argument
150
134
  }
151
135
 
152
136
  radio_buttons {
153
- items ['Radio Button 1', 'Radio Button 2', 'Radio Button 3']
137
+ items 'Radio Button 1', 'Radio Button 2', 'Radio Button 3' # also accepts a single array argument
154
138
  }
155
139
  }
156
140
  }
@@ -158,20 +142,20 @@ MAIN_WINDOW = window('Control Gallery', 600, 500, 1) {
158
142
  tab {
159
143
  tab_item('Page 1') {
160
144
  horizontal_box {
161
- entry { |e|
145
+ entry {
162
146
  text 'Please enter your feelings'
163
147
 
164
- on_changed do
148
+ on_changed do |e|
165
149
  puts "Current textbox data: '#{e.text}'"
166
150
  end
167
151
  }
168
152
  }
169
153
  }
170
-
154
+
171
155
  tab_item('Page 2') {
172
156
  horizontal_box
173
157
  }
174
-
158
+
175
159
  tab_item('Page 3') {
176
160
  horizontal_box
177
161
  }
@@ -0,0 +1,57 @@
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
+ window('Meta-Example', 700, 500) { |w|
25
+ margined true
26
+
27
+ horizontal_box {
28
+ vertical_box {
29
+ @rbs = radio_buttons {
30
+ stretchy false
31
+ items examples
32
+ selected 0
33
+
34
+ on_selected do
35
+ @nwme.text = File.read(file_path_for(@examples[@rbs.selected]))
36
+ end
37
+ }
38
+ button('Launch') {
39
+ stretchy false
40
+
41
+ on_clicked do
42
+ system "ruby -r puts_debuggerer -r #{File.expand_path('../lib/glimmer-dsl-libui', __dir__)} #{file_path_for(@examples[@rbs.selected])}"
43
+ end
44
+ }
45
+ }
46
+ vertical_box {
47
+ @nwme = non_wrapping_multiline_entry {
48
+ read_only true
49
+ text File.read(file_path_for(@examples[@rbs.selected]))
50
+ }
51
+ }
52
+ }
53
+ }.show
54
+ end
55
+ end
56
+
57
+ MetaExample.new.launch
@@ -56,10 +56,10 @@ class TinyMidiPlayer
56
56
  end
57
57
  }
58
58
  }
59
- @main_window = window('Tiny Midi Player', 200, 50, 1) {
59
+ @main_window = window('Tiny Midi Player', 200, 50) {
60
60
  horizontal_box {
61
61
  vertical_box {
62
- stretchy 0
62
+ stretchy false
63
63
 
64
64
  button('▶') {
65
65
  on_clicked do
@@ -4,7 +4,7 @@ require 'glimmer-dsl-libui'
4
4
 
5
5
  include Glimmer
6
6
 
7
- window('Notepad', 500, 300, 1) {
7
+ window('Notepad', 500, 300) {
8
8
  on_closing do
9
9
  puts 'Bye Bye'
10
10
  end
Binary file
@@ -27,7 +27,7 @@ module Glimmer
27
27
  module Libui
28
28
  class TabItemExpression < StaticExpression
29
29
  def interpret(parent, keyword, *args, &block)
30
- Glimmer::LibUI::TabItemProxy.new(keyword, parent, args, &block)
30
+ Glimmer::LibUI::TabItemProxy.create(keyword, parent, args, &block)
31
31
  end
32
32
  end
33
33
  end
@@ -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 = 1 if child.stretchy.nil?
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
@@ -27,8 +27,9 @@ module Glimmer
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
29
  class ComboboxProxy < ControlProxy
30
- def items(values = nil)
31
- if values.nil?
30
+ def items(*values)
31
+ values = values.first if values.first.is_a?(Array)
32
+ if values.empty?
32
33
  @values
33
34
  else
34
35
  @values = values
@@ -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,11 +87,8 @@ module Glimmer
54
87
  @parent_proxy = parent
55
88
  @args = args
56
89
  @block = block
57
- @enabled = 1
90
+ @enabled = true
58
91
  build_control
59
- if @parent_proxy.class.constants.include?(:APPEND_PROPERTIES)
60
- @parent_proxy.class::APPEND_PROPERTIES
61
- end
62
92
  post_add_content if @block.nil?
63
93
  end
64
94
 
@@ -71,36 +101,53 @@ module Glimmer
71
101
  def post_initialize_child(child)
72
102
  # No Op by default
73
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
74
112
 
75
113
  def can_handle_listener?(listener_name)
76
- ::LibUI.respond_to?("control_#{listener_name}") || ::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}")
114
+ ::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}") ||
115
+ ::LibUI.respond_to?("control_#{listener_name}")
77
116
  end
78
117
 
79
118
  def handle_listener(listener_name, &listener)
80
- if ::LibUI.respond_to?("control_#{listener_name}")
81
- ::LibUI.send("control_#{listener_name}", @libui, &listener)
82
- elsif ::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}")
83
- ::LibUI.send("#{libui_api_keyword}_#{listener_name}", @libui, &listener)
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)
84
124
  end
85
125
  end
86
126
 
87
127
  def respond_to?(method_name, *args, &block)
88
128
  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
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)
91
135
  end
92
136
 
93
137
  def respond_to_libui?(method_name, *args, &block)
94
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(/=$/, '')}") ||
95
141
  ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") ||
96
- ::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name}") ||
142
+ (::LibUI.respond_to?("#{libui_api_keyword}_#{method_name.to_s.sub(/\?$/, '')}") && BOOLEAN_PROPERTIES.include?(method_name.to_s.sub(/\?$/, '')) ) ||
97
143
  ::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}")
98
144
  end
99
145
 
100
146
  def method_missing(method_name, *args, &block)
101
147
  if respond_to_libui?(method_name, *args, &block)
102
148
  send_to_libui(method_name, *args, &block)
103
- elsif (append_properties.include?(method_name.to_s) || append_properties.include?(method_name.to_s.sub(/=$/, '')))
149
+ elsif append_properties.include?(method_name.to_s) ||
150
+ append_properties.include?(method_name.to_s.sub(/(=|\?)$/, ''))
104
151
  append_property(method_name, *args)
105
152
  else
106
153
  super
@@ -108,17 +155,25 @@ module Glimmer
108
155
  end
109
156
 
110
157
  def send_to_libui(method_name, *args, &block)
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)
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))
115
162
  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)
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)
119
166
  elsif ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") && !args.empty?
120
167
  ::LibUI.send("#{libui_api_keyword}_#{method_name}", @libui, *args)
121
- 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?
122
177
  ::LibUI.send("control_#{method_name}", @libui, *args)
123
178
  end
124
179
  end
@@ -128,11 +183,13 @@ module Glimmer
128
183
  end
129
184
 
130
185
  def append_property(property, value = nil)
131
- property = property.to_s.sub(/=$/, '')
186
+ property = property.to_s.sub(/(=|\?)$/, '')
132
187
  @append_property_hash ||= {}
133
188
  if value.nil?
134
- @append_property_hash[property]
189
+ value = @append_property_hash[property]
190
+ handle_string_property(property, handle_boolean_property(property, value))
135
191
  else
192
+ value = ControlProxy.boolean_to_integer(value) if BOOLEAN_PROPERTIES.include?(property) && (value.is_a?(TrueClass) || value.is_a?(FalseClass))
136
193
  @append_property_hash[property] = value
137
194
  end
138
195
  end
@@ -145,7 +202,7 @@ module Glimmer
145
202
  if value.nil?
146
203
  @enabled
147
204
  elsif value != @enabled
148
- if value == 1
205
+ if value == 1 || value
149
206
  send_to_libui('enable')
150
207
  else
151
208
  send_to_libui('disable')
@@ -161,7 +218,7 @@ module Glimmer
161
218
  if value.nil?
162
219
  current_value
163
220
  elsif value != current_value
164
- if value == 1
221
+ if value == 1 || value
165
222
  send_to_libui('show')
166
223
  else
167
224
  send_to_libui('hide')
@@ -172,6 +229,11 @@ module Glimmer
172
229
  alias set_visible visible
173
230
  alias visible= visible
174
231
 
232
+ def destroy
233
+ send_to_libui('destroy')
234
+ self.class.all_control_proxies.delete(self)
235
+ end
236
+
175
237
  private
176
238
 
177
239
  def build_control
@@ -182,6 +244,14 @@ module Glimmer
182
244
  ::LibUI.send(@keyword, *@args)
183
245
  end
184
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
185
255
  end
186
256
  end
187
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
@@ -27,8 +27,9 @@ module Glimmer
27
27
  #
28
28
  # Follows the Proxy Design Pattern
29
29
  class EditableComboboxProxy < ControlProxy
30
- def items(values = nil)
31
- if values.nil?
30
+ def items(*values)
31
+ values = values.first if values.first.is_a?(Array)
32
+ if values.empty?
32
33
  @values
33
34
  else
34
35
  @values = values