Class: Glimmer::LibUI::ControlProxy
- Inherits:
-
Object
- Object
- Glimmer::LibUI::ControlProxy
show all
- Includes:
- ContentBindable, DataBindable, Parent
- Defined in:
- lib/glimmer/libui/control_proxy.rb,
lib/glimmer/libui/control_proxy/box.rb,
lib/glimmer/libui/control_proxy/column.rb,
lib/glimmer/libui/control_proxy/area_proxy.rb,
lib/glimmer/libui/control_proxy/form_proxy.rb,
lib/glimmer/libui/control_proxy/grid_proxy.rb,
lib/glimmer/libui/control_proxy/menu_proxy.rb,
lib/glimmer/libui/control_proxy/path_proxy.rb,
lib/glimmer/libui/control_proxy/text_proxy.rb,
lib/glimmer/libui/control_proxy/dual_column.rb,
lib/glimmer/libui/control_proxy/entry_proxy.rb,
lib/glimmer/libui/control_proxy/group_proxy.rb,
lib/glimmer/libui/control_proxy/image_proxy.rb,
lib/glimmer/libui/control_proxy/label_proxy.rb,
lib/glimmer/libui/control_proxy/message_box.rb,
lib/glimmer/libui/control_proxy/table_proxy.rb,
lib/glimmer/libui/control_proxy/button_proxy.rb,
lib/glimmer/libui/control_proxy/matrix_proxy.rb,
lib/glimmer/libui/control_proxy/slider_proxy.rb,
lib/glimmer/libui/control_proxy/window_proxy.rb,
lib/glimmer/libui/control_proxy/spinbox_proxy.rb,
lib/glimmer/libui/control_proxy/triple_column.rb,
lib/glimmer/libui/control_proxy/checkbox_proxy.rb,
lib/glimmer/libui/control_proxy/combobox_proxy.rb,
lib/glimmer/libui/control_proxy/tab_item_proxy.rb,
lib/glimmer/libui/control_proxy/editable_column.rb,
lib/glimmer/libui/control_proxy/menu_item_proxy.rb,
lib/glimmer/libui/control_proxy/image_part_proxy.rb,
lib/glimmer/libui/control_proxy/enableable_column.rb,
lib/glimmer/libui/control_proxy/font_button_proxy.rb,
lib/glimmer/libui/control_proxy/color_button_proxy.rb,
lib/glimmer/libui/control_proxy/open_type_tag_proxy.rb,
lib/glimmer/libui/control_proxy/radio_buttons_proxy.rb,
lib/glimmer/libui/control_proxy/multiline_entry_proxy.rb,
lib/glimmer/libui/control_proxy/box/vertical_box_proxy.rb,
lib/glimmer/libui/control_proxy/date_time_picker_proxy.rb,
lib/glimmer/libui/control_proxy/editable_combobox_proxy.rb,
lib/glimmer/libui/control_proxy/box/horizontal_box_proxy.rb,
lib/glimmer/libui/control_proxy/column/text_column_proxy.rb,
lib/glimmer/libui/control_proxy/open_type_features_proxy.rb,
lib/glimmer/libui/control_proxy/column/image_column_proxy.rb,
lib/glimmer/libui/control_proxy/message_box/msg_box_proxy.rb,
lib/glimmer/libui/control_proxy/column/button_column_proxy.rb,
lib/glimmer/libui/control_proxy/column/checkbox_column_proxy.rb,
lib/glimmer/libui/control_proxy/column/image_text_column_proxy.rb,
lib/glimmer/libui/control_proxy/column/text_color_column_proxy.rb,
lib/glimmer/libui/control_proxy/entry_proxy/search_entry_proxy.rb,
lib/glimmer/libui/control_proxy/area_proxy/scrolling_area_proxy.rb,
lib/glimmer/libui/control_proxy/message_box/msg_box_error_proxy.rb,
lib/glimmer/libui/control_proxy/column/progress_bar_column_proxy.rb,
lib/glimmer/libui/control_proxy/entry_proxy/password_entry_proxy.rb,
lib/glimmer/libui/control_proxy/column/checkbox_text_column_proxy.rb,
lib/glimmer/libui/control_proxy/column/background_color_column_proxy.rb,
lib/glimmer/libui/control_proxy/column/image_text_color_column_proxy.rb,
lib/glimmer/libui/control_proxy/menu_item_proxy/quit_menu_item_proxy.rb,
lib/glimmer/libui/control_proxy/menu_item_proxy/about_menu_item_proxy.rb,
lib/glimmer/libui/control_proxy/menu_item_proxy/check_menu_item_proxy.rb,
lib/glimmer/libui/control_proxy/menu_item_proxy/radio_menu_item_proxy.rb,
lib/glimmer/libui/control_proxy/column/checkbox_text_color_column_proxy.rb,
lib/glimmer/libui/control_proxy/date_time_picker_proxy/date_picker_proxy.rb,
lib/glimmer/libui/control_proxy/date_time_picker_proxy/time_picker_proxy.rb,
lib/glimmer/libui/control_proxy/menu_item_proxy/separator_menu_item_proxy.rb,
lib/glimmer/libui/control_proxy/menu_item_proxy/preferences_menu_item_proxy.rb,
lib/glimmer/libui/control_proxy/multiline_entry_proxy/non_wrapping_multiline_entry_proxy.rb
Overview
Proxy for LibUI control objects
Follows the Proxy Design Pattern
Direct Known Subclasses
AreaProxy, Box::HorizontalBoxProxy, Box::VerticalBoxProxy, ButtonProxy, CheckboxProxy, ColorButtonProxy, Column::BackgroundColorColumnProxy, Column::ButtonColumnProxy, Column::CheckboxColumnProxy, Column::CheckboxTextColorColumnProxy, Column::CheckboxTextColumnProxy, Column::ImageColumnProxy, Column::ImageTextColorColumnProxy, Column::ImageTextColumnProxy, Column::ProgressBarColumnProxy, Column::TextColorColumnProxy, Column::TextColumnProxy, ComboboxProxy, DateTimePickerProxy, EditableComboboxProxy, EntryProxy, FontButtonProxy, FormProxy, GridProxy, GroupProxy, ImagePartProxy, ImageProxy, LabelProxy, MatrixProxy, MenuItemProxy, MenuProxy, MessageBox::MsgBoxErrorProxy, MessageBox::MsgBoxProxy, MultilineEntryProxy, OpenTypeFeaturesProxy, OpenTypeTagProxy, PathProxy, RadioButtonsProxy, SliderProxy, SpinboxProxy, TabItemProxy, TableProxy, TextProxy, WindowProxy
Defined Under Namespace
Modules: Box, Column, DualColumn, EditableColumn, EnableableColumn, MessageBox, TripleColumn
Classes: AreaProxy, ButtonProxy, CheckboxProxy, ColorButtonProxy, ComboboxProxy, DateTimePickerProxy, EditableComboboxProxy, EntryProxy, FontButtonProxy, FormProxy, GridProxy, GroupProxy, ImagePartProxy, ImageProxy, LabelProxy, MatrixProxy, MenuItemProxy, MenuProxy, MultilineEntryProxy, NonWrappingMultilineEntryProxy, OpenTypeFeaturesProxy, OpenTypeTagProxy, PathProxy, PreferencesMenuItemProxy, RadioButtonsProxy, SliderProxy, SpinboxProxy, TabItemProxy, TableProxy, TextProxy, WindowProxy
Constant Summary
collapse
- KEYWORD_ALIASES =
{
'message_box' => 'msg_box',
'message_box_error' => 'msg_box_error',
}
- BOOLEAN_PROPERTIES =
%w[
padded
checked
enabled toplevel visible
read_only
margined
borderless fullscreen
stretchy
]
- STRING_PROPERTIES =
%w[
text
title
]
- TransformProxy =
MatrixProxy
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
-
#append_properties ⇒ Object
-
#append_property(property, value = nil) ⇒ Object
-
#can_handle_listener?(listener_name) ⇒ Boolean
-
#content(&block) ⇒ Object
-
#custom_listener_name_aliases ⇒ Object
-
#custom_listener_names ⇒ Object
-
#default_destroy ⇒ Object
-
#deregister_all_custom_listeners ⇒ Object
deregisters all custom listeners except on_destroy, which can only be deregistered after destruction of a control, using deregister_custom_listeners.
-
#deregister_custom_listeners(listener_name) ⇒ Object
-
#destroy ⇒ Object
-
#destroy_child(child) ⇒ Object
-
#enabled(value = nil) ⇒ Object
(also: #enabled?, #set_enabled, #enabled=)
-
#handle_custom_listener(listener_name, &listener) ⇒ Object
-
#handle_listener(listener_name, &listener) ⇒ Object
-
#has_custom_listener?(listener_name) ⇒ Boolean
-
#initialize(keyword, parent, args, &block) ⇒ ControlProxy
constructor
A new instance of ControlProxy.
-
#libui_api_keyword ⇒ Object
-
#listeners ⇒ Object
-
#listeners_for(listener_name) ⇒ Object
-
#method_missing(method_name, *args, &block) ⇒ Object
-
#notify_custom_listeners(listener_name, *args) ⇒ Object
-
#post_add_content ⇒ Object
Subclasses may override to perform post add_content work (normally must call super).
-
#post_initialize_child(child) ⇒ Object
Subclasses may override to perform post initialization work on an added child.
-
#respond_to?(method_name, *args, &block) ⇒ Boolean
-
#respond_to_libui?(method_name, *args, &block) ⇒ Boolean
-
#send_to_libui(method_name, *args, &block) ⇒ Object
-
#visible(value = nil) ⇒ Object
(also: #visible?, #set_visible, #visible=)
-
#window_proxy ⇒ Object
#bind_content
#data_bind, #data_bind_read, #data_bind_write, #data_binding_model_attribute_observer_registrations
Methods included from Parent
#children
Constructor Details
#initialize(keyword, parent, args, &block) ⇒ ControlProxy
Returns a new instance of ControlProxy.
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
# File 'lib/glimmer/libui/control_proxy.rb', line 136
def initialize(keyword, parent, args, &block)
@keyword = keyword
@custom_control = CustomControl.custom_controls_being_interpreted.last
@parent_custom_control = parent if parent.is_a?(CustomControl)
@parent_proxy = parent.is_a?(CustomControl) ? parent.body_root : parent
@args = args
@options = args.last.is_a?(Hash) ? args.pop : {}
@slot = options[:slot]
custom_control.slot_controls[@slot] = self if @slot && custom_control
@block = block
@enabled = true
build_control
post_add_content if @block.nil?
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
272
273
274
275
276
277
278
279
280
281
282
283
|
# File 'lib/glimmer/libui/control_proxy.rb', line 272
def method_missing(method_name, *args, &block)
if respond_to_libui?(method_name, *args, &block)
send_to_libui(method_name, *args, &block)
elsif append_properties.include?(method_name.to_s) ||
append_properties.include?(method_name.to_s.sub(/(=|\?)$/, ''))
append_property(method_name, *args)
elsif can_handle_listener?(method_name.to_s)
handle_listener(method_name.to_s, &block)
else
super
end
end
|
Instance Attribute Details
#args ⇒ Object
libui returns the contained LibUI object
133
134
135
|
# File 'lib/glimmer/libui/control_proxy.rb', line 133
def args
@args
end
|
#block ⇒ Object
libui returns the contained LibUI object
133
134
135
|
# File 'lib/glimmer/libui/control_proxy.rb', line 133
def block
@block
end
|
#content_added ⇒ Object
Also known as:
content_added?
libui returns the contained LibUI object
133
134
135
|
# File 'lib/glimmer/libui/control_proxy.rb', line 133
def content_added
@content_added
end
|
#custom_control ⇒ Object
libui returns the contained LibUI object
133
134
135
|
# File 'lib/glimmer/libui/control_proxy.rb', line 133
def custom_control
@custom_control
end
|
#keyword ⇒ Object
libui returns the contained LibUI object
133
134
135
|
# File 'lib/glimmer/libui/control_proxy.rb', line 133
def keyword
@keyword
end
|
#libui ⇒ Object
libui returns the contained LibUI object
133
134
135
|
# File 'lib/glimmer/libui/control_proxy.rb', line 133
def libui
@libui
end
|
#options ⇒ Object
libui returns the contained LibUI object
133
134
135
|
# File 'lib/glimmer/libui/control_proxy.rb', line 133
def options
@options
end
|
#parent_custom_control ⇒ Object
libui returns the contained LibUI object
133
134
135
|
# File 'lib/glimmer/libui/control_proxy.rb', line 133
def parent_custom_control
@parent_custom_control
end
|
#parent_proxy ⇒ Object
libui returns the contained LibUI object
133
134
135
|
# File 'lib/glimmer/libui/control_proxy.rb', line 133
def parent_proxy
@parent_proxy
end
|
#slot ⇒ Object
libui returns the contained LibUI object
133
134
135
|
# File 'lib/glimmer/libui/control_proxy.rb', line 133
def slot
@slot
end
|
Class Method Details
.constant_symbol(keyword) ⇒ Object
69
70
71
|
# File 'lib/glimmer/libui/control_proxy.rb', line 69
def constant_symbol(keyword)
"#{keyword.camelcase(:upper)}Proxy".to_sym
end
|
.control_proxies ⇒ Object
autosave all controls in this array to avoid garbage collection
48
49
50
51
|
# File 'lib/glimmer/libui/control_proxy.rb', line 48
def control_proxies
@@control_proxies = [] unless defined?(@@control_proxies)
@@control_proxies
end
|
.control_proxy_class(keyword) ⇒ Object
43
44
45
|
# File 'lib/glimmer/libui/control_proxy.rb', line 43
def control_proxy_class(keyword)
descendant_keyword_constant_map[keyword] || ControlProxy
end
|
.create(keyword, parent, args, &block) ⇒ Object
39
40
41
|
# File 'lib/glimmer/libui/control_proxy.rb', line 39
def create(keyword, parent, args, &block)
control_proxy_class(keyword).new(keyword, parent, args, &block).tap {|c| control_proxies << c}
end
|
.descendant_keyword_constant_map ⇒ Object
77
78
79
|
# File 'lib/glimmer/libui/control_proxy.rb', line 77
def descendant_keyword_constant_map
@descendant_keyword_constant_map ||= add_aliases_to_keyword_constant_map(map_descendant_keyword_constants_for(self))
end
|
.exists?(keyword) ⇒ Boolean
33
34
35
36
37
|
# File 'lib/glimmer/libui/control_proxy.rb', line 33
def exists?(keyword)
::LibUI.respond_to?("new_#{keyword}") or
::LibUI.respond_to?(keyword) or
descendant_keyword_constant_map.keys.include?(keyword)
end
|
.image_proxies ⇒ Object
61
62
63
|
# File 'lib/glimmer/libui/control_proxy.rb', line 61
def image_proxies
control_proxies.select {|c| c.keyword == 'image' }
end
|
.keyword(constant_symbol) ⇒ Object
73
74
75
|
# File 'lib/glimmer/libui/control_proxy.rb', line 73
def keyword(constant_symbol)
constant_symbol.to_s.underscore.sub(/_proxy$/, '')
end
|
.main_window_proxy ⇒ Object
53
54
55
|
# File 'lib/glimmer/libui/control_proxy.rb', line 53
def main_window_proxy
control_proxies.find {|c| c.is_a?(WindowProxy)}
end
|
.map_descendant_keyword_constants_for(klass, accumulator: {}) ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/glimmer/libui/control_proxy.rb', line 86
def map_descendant_keyword_constants_for(klass, accumulator: {})
klass.constants.map do |constant_symbol|
[constant_symbol, klass.const_get(constant_symbol)]
end.select do |constant_symbol, constant|
constant.is_a?(Module) && !accumulator.values.include?(constant)
end.each do |constant_symbol, constant|
accumulator[keyword(constant_symbol)] = constant
map_descendant_keyword_constants_for(constant, accumulator: accumulator)
end
accumulator
end
|
57
58
59
|
# File 'lib/glimmer/libui/control_proxy.rb', line 57
def
control_proxies.select {|c| c.keyword == 'menu' }
end
|
.new_control(keyword, args) ⇒ Object
65
66
67
|
# File 'lib/glimmer/libui/control_proxy.rb', line 65
def new_control(keyword, args)
::LibUI.send("new_#{keyword}", *args)
end
|
.reset_descendant_keyword_constant_map ⇒ Object
81
82
83
84
|
# File 'lib/glimmer/libui/control_proxy.rb', line 81
def reset_descendant_keyword_constant_map
@descendant_keyword_constant_map = nil
descendant_keyword_constant_map
end
|
Instance Method Details
#append_properties ⇒ Object
321
322
323
|
# File 'lib/glimmer/libui/control_proxy.rb', line 321
def append_properties
@parent_proxy&.class&.constants&.include?(:APPEND_PROPERTIES) ? @parent_proxy.class::APPEND_PROPERTIES : []
end
|
#append_property(property, value = nil) ⇒ Object
325
326
327
328
329
330
331
332
333
334
335
|
# File 'lib/glimmer/libui/control_proxy.rb', line 325
def append_property(property, value = nil)
property = property.to_s.sub(/(=|\?)$/, '')
@append_property_hash ||= {}
if value.nil?
value = @append_property_hash[property]
handle_string_property(property, handle_boolean_property(property, value))
else
value = Glimmer::LibUI.boolean_to_integer(value) if BOOLEAN_PROPERTIES.include?(property) && (value.is_a?(TrueClass) || value.is_a?(FalseClass))
@append_property_hash[property] = value
end
end
|
#can_handle_listener?(listener_name) ⇒ Boolean
175
176
177
178
179
|
# File 'lib/glimmer/libui/control_proxy.rb', line 175
def can_handle_listener?(listener_name)
::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}") ||
::LibUI.respond_to?("control_#{listener_name}") ||
has_custom_listener?(listener_name)
end
|
#content(&block) ⇒ Object
396
397
398
|
# File 'lib/glimmer/libui/control_proxy.rb', line 396
def content(&block)
Glimmer::DSL::Engine.add_content(self, Glimmer::DSL::Libui::ControlExpression.new, @keyword, {post_add_content: @content_added}, &block)
end
|
#custom_listener_name_aliases ⇒ Object
220
221
222
|
# File 'lib/glimmer/libui/control_proxy.rb', line 220
def custom_listener_name_aliases
self.class.constants.include?(:CUSTOM_LISTENER_NAME_ALIASES) ? self.class::CUSTOM_LISTENER_NAME_ALIASES : {}
end
|
#custom_listener_names ⇒ Object
216
217
218
|
# File 'lib/glimmer/libui/control_proxy.rb', line 216
def custom_listener_names
self.class.constants.include?(:CUSTOM_LISTENER_NAMES) ? self.class::CUSTOM_LISTENER_NAMES : []
end
|
#default_destroy ⇒ Object
357
358
359
360
361
362
|
# File 'lib/glimmer/libui/control_proxy.rb', line 357
def default_destroy
deregister_all_custom_listeners
send_to_libui('destroy')
ControlProxy.control_proxies.delete(self)
end
|
#deregister_all_custom_listeners ⇒ Object
deregisters all custom listeners except on_destroy, which can only be deregistered after destruction of a control, using deregister_custom_listeners
248
249
250
|
# File 'lib/glimmer/libui/control_proxy.rb', line 248
def deregister_all_custom_listeners
(custom_listener_names - ['on_destroy']).each { |listener_name| deregister_custom_listeners(listener_name) }
end
|
#deregister_custom_listeners(listener_name) ⇒ Object
243
244
245
|
# File 'lib/glimmer/libui/control_proxy.rb', line 243
def deregister_custom_listeners(listener_name)
handle_custom_listener(listener_name).clear
end
|
#destroy ⇒ Object
341
342
343
344
345
346
347
348
349
350
|
# File 'lib/glimmer/libui/control_proxy.rb', line 341
def destroy
return if !is_a?(ControlProxy::WindowProxy) && ControlProxy.main_window_proxy&.destroying?
data_binding_model_attribute_observer_registrations.each(&:deregister)
if parent_proxy.nil?
default_destroy
else
parent_proxy.destroy_child(self)
end
end
|
#destroy_child(child) ⇒ Object
352
353
354
355
|
# File 'lib/glimmer/libui/control_proxy.rb', line 352
def destroy_child(child)
child.default_destroy
children.delete(child)
end
|
#enabled(value = nil) ⇒ Object
Also known as:
enabled?, set_enabled, enabled=
364
365
366
367
368
369
370
371
372
373
374
375
|
# File 'lib/glimmer/libui/control_proxy.rb', line 364
def enabled(value = nil)
if value.nil?
@enabled
elsif value != @enabled
@enabled = value == 1 || value
if value == 1 || value
send_to_libui('enable')
else
send_to_libui('disable')
end
end
end
|
#handle_custom_listener(listener_name, &listener) ⇒ Object
224
225
226
227
228
229
230
231
232
233
234
235
|
# File 'lib/glimmer/libui/control_proxy.rb', line 224
def handle_custom_listener(listener_name, &listener)
listener_name = listener_name.to_s
listener_name = custom_listener_name_aliases.stringify_keys[listener_name] || listener_name
instance_variable_name = "@#{listener_name}_procs" instance_variable_set(instance_variable_name, []) if instance_variable_get(instance_variable_name).nil?
if listener.nil?
instance_variable_get(instance_variable_name)
else
instance_variable_get(instance_variable_name) << listener
listener
end
end
|
#handle_listener(listener_name, &listener) ⇒ Object
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
# File 'lib/glimmer/libui/control_proxy.rb', line 181
def handle_listener(listener_name, &listener)
safe_listener = Proc.new { |*args| listener.call(self, *args[1..-1]) }
if ::LibUI.respond_to?("#{libui_api_keyword}_#{listener_name}")
if listeners[listener_name].nil?
::LibUI.send("#{libui_api_keyword}_#{listener_name}", libui) do |*args|
listeners_for(listener_name).map { |listener| listener.call(*args) }.last
end
end
listeners_for(listener_name) << safe_listener
elsif ::LibUI.respond_to?("control_#{listener_name}")
if listeners[listener_name].nil?
::LibUI.send("control_#{listener_name}", libui) do |*args|
listeners_for(listener_name).map { |listener| listener.call(*args) }.last
end
end
listeners_for(listener_name) << safe_listener
elsif has_custom_listener?(listener_name)
handle_custom_listener(listener_name, &listener)
end
end
|
#has_custom_listener?(listener_name) ⇒ Boolean
211
212
213
214
|
# File 'lib/glimmer/libui/control_proxy.rb', line 211
def has_custom_listener?(listener_name)
listener_name = listener_name.to_s
custom_listener_names.include?(listener_name) || custom_listener_name_aliases.stringify_keys.keys.include?(listener_name)
end
|
#libui_api_keyword ⇒ Object
337
338
339
|
# File 'lib/glimmer/libui/control_proxy.rb', line 337
def libui_api_keyword
@keyword
end
|
#listeners ⇒ Object
203
204
205
|
# File 'lib/glimmer/libui/control_proxy.rb', line 203
def listeners
@listeners ||= {}
end
|
#listeners_for(listener_name) ⇒ Object
207
208
209
|
# File 'lib/glimmer/libui/control_proxy.rb', line 207
def listeners_for(listener_name)
listeners[listener_name] ||= []
end
|
#notify_custom_listeners(listener_name, *args) ⇒ Object
237
238
239
240
241
|
# File 'lib/glimmer/libui/control_proxy.rb', line 237
def notify_custom_listeners(listener_name, *args)
handle_custom_listener(listener_name).map do |listener|
listener.call(*args)
end
end
|
#post_add_content ⇒ Object
Subclasses may override to perform post add_content work (normally must call super)
#post_initialize_child(child) ⇒ Object
Subclasses may override to perform post initialization work on an added child
163
164
165
|
# File 'lib/glimmer/libui/control_proxy.rb', line 163
def post_initialize_child(child)
end
|
#respond_to?(method_name, *args, &block) ⇒ Boolean
252
253
254
255
256
257
258
259
260
261
|
# File 'lib/glimmer/libui/control_proxy.rb', line 252
def respond_to?(method_name, *args, &block)
respond_to_libui?(method_name, *args, &block) ||
(
append_properties.include?(method_name.to_s) ||
(append_properties.include?(method_name.to_s.sub(/\?$/, '')) && BOOLEAN_PROPERTIES.include?(method_name.to_s.sub(/\?$/, ''))) ||
append_properties.include?(method_name.to_s.sub(/=$/, ''))
) ||
can_handle_listener?(method_name.to_s) ||
super(method_name, true)
end
|
#respond_to_libui?(method_name, *args, &block) ⇒ Boolean
263
264
265
266
267
268
269
270
|
# File 'lib/glimmer/libui/control_proxy.rb', line 263
def respond_to_libui?(method_name, *args, &block)
::LibUI.respond_to?("control_#{method_name}") or
(::LibUI.respond_to?("control_#{method_name.to_s.sub(/\?$/, '')}") && BOOLEAN_PROPERTIES.include?(method_name.to_s.sub(/\?$/, '')) ) or
::LibUI.respond_to?("control_set_#{method_name.to_s.sub(/=$/, '')}") or
::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") or
(::LibUI.respond_to?("#{libui_api_keyword}_#{method_name.to_s.sub(/\?$/, '')}") && BOOLEAN_PROPERTIES.include?(method_name.to_s.sub(/\?$/, '')) ) or
::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}")
end
|
#send_to_libui(method_name, *args, &block) ⇒ Object
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
|
# File 'lib/glimmer/libui/control_proxy.rb', line 285
def send_to_libui(method_name, *args, &block)
if ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name.to_s.sub(/\?$/, '')}") && args.empty?
property = method_name.to_s.sub(/\?$/, '')
value = ::LibUI.send("#{libui_api_keyword}_#{property}", libui, *args)
handle_string_property(property, handle_boolean_property(property, value))
elsif ::LibUI.respond_to?("#{libui_api_keyword}_get_#{method_name.to_s.sub(/\?$/, '')}") && args.empty?
property = method_name.to_s.sub(/\?$/, '')
value = ::LibUI.send("#{libui_api_keyword}_get_#{property}", libui, *args)
handle_string_property(property, handle_boolean_property(property, value))
elsif ::LibUI.respond_to?("#{libui_api_keyword}_set_#{method_name.to_s.sub(/=$/, '')}") && !args.empty?
property = method_name.to_s.sub(/=$/, '')
args[0] = Glimmer::LibUI.boolean_to_integer(args.first) if BOOLEAN_PROPERTIES.include?(property) && (args.first.is_a?(TrueClass) || args.first.is_a?(FalseClass))
args[0] = '' if STRING_PROPERTIES.include?(property) && args.first == nil
if property.to_s == 'checked'
current_value = Glimmer::LibUI.integer_to_boolean(::LibUI.send("#{libui_api_keyword}_checked", libui), allow_nil: false)
new_value = Glimmer::LibUI.integer_to_boolean(args[0], allow_nil: false)
::LibUI.send("#{libui_api_keyword}_set_#{property}", libui, *args) if new_value != current_value
else
::LibUI.send("#{libui_api_keyword}_set_#{property}", libui, *args)
end
elsif ::LibUI.respond_to?("#{libui_api_keyword}_#{method_name}") && !args.empty?
::LibUI.send("#{libui_api_keyword}_#{method_name}", libui, *args)
elsif ::LibUI.respond_to?("control_#{method_name.to_s.sub(/\?$/, '')}") && args.empty?
property = method_name.to_s.sub(/\?$/, '')
value = ::LibUI.send("control_#{property}", libui, *args)
handle_string_property(property, handle_boolean_property(property, value))
elsif ::LibUI.respond_to?("control_set_#{method_name.to_s.sub(/=$/, '')}")
property = method_name.to_s.sub(/=$/, '')
args[0] = Glimmer::LibUI.boolean_to_integer(args.first) if BOOLEAN_PROPERTIES.include?(property) && (args.first.is_a?(TrueClass) || args.first.is_a?(FalseClass))
args[0] = '' if STRING_PROPERTIES.include?(property) && args.first == nil
::LibUI.send("control_set_#{method_name.to_s.sub(/=$/, '')}", libui, *args)
elsif ::LibUI.respond_to?("control_#{method_name}") && !args.empty?
::LibUI.send("control_#{method_name}", libui, *args)
end
end
|
#visible(value = nil) ⇒ Object
Also known as:
visible?, set_visible, visible=
380
381
382
383
384
385
386
387
388
389
390
391
|
# File 'lib/glimmer/libui/control_proxy.rb', line 380
def visible(value = nil)
current_value = send_to_libui('visible')
if value.nil?
current_value
elsif value != current_value
if value == 1 || value
send_to_libui('show')
else
send_to_libui('hide')
end
end
end
|
#window_proxy ⇒ Object
167
168
169
170
171
172
173
|
# File 'lib/glimmer/libui/control_proxy.rb', line 167
def window_proxy
found_proxy = self
until found_proxy.nil? || found_proxy.is_a?(WindowProxy)
found_proxy = found_proxy.parent_proxy
end
found_proxy
end
|