Class: Glimmer::LibUI::ControlProxy
- Inherits:
-
Object
- Object
- Glimmer::LibUI::ControlProxy
show all
- Includes:
- 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
-
#bind_content(*binding_args, &content_block) ⇒ Object
Data-binds the generation of nested content to a model/property (in binding args) consider providing an option to avoid initial rendering without any changes happening.
-
#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
#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.
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/glimmer/libui/control_proxy.rb', line 134
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
270
271
272
273
274
275
276
277
278
279
280
281
|
# File 'lib/glimmer/libui/control_proxy.rb', line 270
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
131
132
133
|
# File 'lib/glimmer/libui/control_proxy.rb', line 131
def args
@args
end
|
#block ⇒ Object
libui returns the contained LibUI object
131
132
133
|
# File 'lib/glimmer/libui/control_proxy.rb', line 131
def block
@block
end
|
#content_added ⇒ Object
Also known as:
content_added?
libui returns the contained LibUI object
131
132
133
|
# File 'lib/glimmer/libui/control_proxy.rb', line 131
def content_added
@content_added
end
|
#custom_control ⇒ Object
libui returns the contained LibUI object
131
132
133
|
# File 'lib/glimmer/libui/control_proxy.rb', line 131
def custom_control
@custom_control
end
|
#keyword ⇒ Object
libui returns the contained LibUI object
131
132
133
|
# File 'lib/glimmer/libui/control_proxy.rb', line 131
def keyword
@keyword
end
|
#libui ⇒ Object
libui returns the contained LibUI object
131
132
133
|
# File 'lib/glimmer/libui/control_proxy.rb', line 131
def libui
@libui
end
|
#options ⇒ Object
libui returns the contained LibUI object
131
132
133
|
# File 'lib/glimmer/libui/control_proxy.rb', line 131
def options
@options
end
|
#parent_custom_control ⇒ Object
libui returns the contained LibUI object
131
132
133
|
# File 'lib/glimmer/libui/control_proxy.rb', line 131
def parent_custom_control
@parent_custom_control
end
|
#parent_proxy ⇒ Object
libui returns the contained LibUI object
131
132
133
|
# File 'lib/glimmer/libui/control_proxy.rb', line 131
def parent_proxy
@parent_proxy
end
|
#slot ⇒ Object
libui returns the contained LibUI object
131
132
133
|
# File 'lib/glimmer/libui/control_proxy.rb', line 131
def slot
@slot
end
|
Class Method Details
.constant_symbol(keyword) ⇒ Object
68
69
70
|
# File 'lib/glimmer/libui/control_proxy.rb', line 68
def constant_symbol(keyword)
"#{keyword.camelcase(:upper)}Proxy".to_sym
end
|
.control_proxies ⇒ Object
autosave all controls in this array to avoid garbage collection
47
48
49
50
|
# File 'lib/glimmer/libui/control_proxy.rb', line 47
def control_proxies
@@control_proxies = [] unless defined?(@@control_proxies)
@@control_proxies
end
|
.control_proxy_class(keyword) ⇒ Object
42
43
44
|
# File 'lib/glimmer/libui/control_proxy.rb', line 42
def control_proxy_class(keyword)
descendant_keyword_constant_map[keyword] || ControlProxy
end
|
.create(keyword, parent, args, &block) ⇒ Object
38
39
40
|
# File 'lib/glimmer/libui/control_proxy.rb', line 38
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
76
77
78
|
# File 'lib/glimmer/libui/control_proxy.rb', line 76
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
32
33
34
35
36
|
# File 'lib/glimmer/libui/control_proxy.rb', line 32
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
60
61
62
|
# File 'lib/glimmer/libui/control_proxy.rb', line 60
def image_proxies
control_proxies.select {|c| c.keyword == 'image' }
end
|
.keyword(constant_symbol) ⇒ Object
72
73
74
|
# File 'lib/glimmer/libui/control_proxy.rb', line 72
def keyword(constant_symbol)
constant_symbol.to_s.underscore.sub(/_proxy$/, '')
end
|
.main_window_proxy ⇒ Object
52
53
54
|
# File 'lib/glimmer/libui/control_proxy.rb', line 52
def main_window_proxy
control_proxies.find {|c| c.is_a?(WindowProxy)}
end
|
.map_descendant_keyword_constants_for(klass, accumulator: {}) ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/glimmer/libui/control_proxy.rb', line 85
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
|
56
57
58
|
# File 'lib/glimmer/libui/control_proxy.rb', line 56
def
control_proxies.select {|c| c.keyword == 'menu' }
end
|
.new_control(keyword, args) ⇒ Object
64
65
66
|
# File 'lib/glimmer/libui/control_proxy.rb', line 64
def new_control(keyword, args)
::LibUI.send("new_#{keyword}", *args)
end
|
.reset_descendant_keyword_constant_map ⇒ Object
80
81
82
83
|
# File 'lib/glimmer/libui/control_proxy.rb', line 80
def reset_descendant_keyword_constant_map
@descendant_keyword_constant_map = nil
descendant_keyword_constant_map
end
|
Instance Method Details
#append_properties ⇒ Object
319
320
321
|
# File 'lib/glimmer/libui/control_proxy.rb', line 319
def append_properties
@parent_proxy&.class&.constants&.include?(:APPEND_PROPERTIES) ? @parent_proxy.class::APPEND_PROPERTIES : []
end
|
#append_property(property, value = nil) ⇒ Object
323
324
325
326
327
328
329
330
331
332
333
|
# File 'lib/glimmer/libui/control_proxy.rb', line 323
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
|
#bind_content(*binding_args, &content_block) ⇒ Object
Data-binds the generation of nested content to a model/property (in binding args) consider providing an option to avoid initial rendering without any changes happening
400
401
402
403
404
405
406
407
408
409
410
|
# File 'lib/glimmer/libui/control_proxy.rb', line 400
def bind_content(*binding_args, &content_block)
content_binding_work = proc do |*values|
children.dup.each { |child| child.destroy }
content(&content_block)
end
model_binding_observer = Glimmer::DataBinding::ModelBinding.new(*binding_args)
content_binding_observer = Glimmer::DataBinding::Observer.proc(&content_binding_work)
content_binding_observer.observe(model_binding_observer)
content_binding_work.call end
|
#can_handle_listener?(listener_name) ⇒ Boolean
173
174
175
176
177
|
# File 'lib/glimmer/libui/control_proxy.rb', line 173
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
394
395
396
|
# File 'lib/glimmer/libui/control_proxy.rb', line 394
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
218
219
220
|
# File 'lib/glimmer/libui/control_proxy.rb', line 218
def custom_listener_name_aliases
self.class.constants.include?(:CUSTOM_LISTENER_NAME_ALIASES) ? self.class::CUSTOM_LISTENER_NAME_ALIASES : {}
end
|
#custom_listener_names ⇒ Object
214
215
216
|
# File 'lib/glimmer/libui/control_proxy.rb', line 214
def custom_listener_names
self.class.constants.include?(:CUSTOM_LISTENER_NAMES) ? self.class::CUSTOM_LISTENER_NAMES : []
end
|
#default_destroy ⇒ Object
355
356
357
358
359
360
|
# File 'lib/glimmer/libui/control_proxy.rb', line 355
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
246
247
248
|
# File 'lib/glimmer/libui/control_proxy.rb', line 246
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
241
242
243
|
# File 'lib/glimmer/libui/control_proxy.rb', line 241
def deregister_custom_listeners(listener_name)
handle_custom_listener(listener_name).clear
end
|
#destroy ⇒ Object
339
340
341
342
343
344
345
346
347
348
|
# File 'lib/glimmer/libui/control_proxy.rb', line 339
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
350
351
352
353
|
# File 'lib/glimmer/libui/control_proxy.rb', line 350
def destroy_child(child)
child.default_destroy
children.delete(child)
end
|
#enabled(value = nil) ⇒ Object
Also known as:
enabled?, set_enabled, enabled=
362
363
364
365
366
367
368
369
370
371
372
373
|
# File 'lib/glimmer/libui/control_proxy.rb', line 362
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
222
223
224
225
226
227
228
229
230
231
232
233
|
# File 'lib/glimmer/libui/control_proxy.rb', line 222
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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
# File 'lib/glimmer/libui/control_proxy.rb', line 179
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
209
210
211
212
|
# File 'lib/glimmer/libui/control_proxy.rb', line 209
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
335
336
337
|
# File 'lib/glimmer/libui/control_proxy.rb', line 335
def libui_api_keyword
@keyword
end
|
#listeners ⇒ Object
201
202
203
|
# File 'lib/glimmer/libui/control_proxy.rb', line 201
def listeners
@listeners ||= {}
end
|
#listeners_for(listener_name) ⇒ Object
205
206
207
|
# File 'lib/glimmer/libui/control_proxy.rb', line 205
def listeners_for(listener_name)
listeners[listener_name] ||= []
end
|
#notify_custom_listeners(listener_name, *args) ⇒ Object
235
236
237
238
239
|
# File 'lib/glimmer/libui/control_proxy.rb', line 235
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
161
162
163
|
# File 'lib/glimmer/libui/control_proxy.rb', line 161
def post_initialize_child(child)
end
|
#respond_to?(method_name, *args, &block) ⇒ Boolean
250
251
252
253
254
255
256
257
258
259
|
# File 'lib/glimmer/libui/control_proxy.rb', line 250
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
261
262
263
264
265
266
267
268
|
# File 'lib/glimmer/libui/control_proxy.rb', line 261
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
283
284
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
|
# File 'lib/glimmer/libui/control_proxy.rb', line 283
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=
378
379
380
381
382
383
384
385
386
387
388
389
|
# File 'lib/glimmer/libui/control_proxy.rb', line 378
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
165
166
167
168
169
170
171
|
# File 'lib/glimmer/libui/control_proxy.rb', line 165
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
|