class Glimmer::LibUI::ControlProxy::WindowProxy
Proxy for LibUI
window objects
Follows the Proxy Design Pattern
Constants
- CUSTOM_LISTENER_NAMES
- CUSTOM_LISTENER_NAME_ALIASES
- DEFAULT_HAS_MENUBAR
- DEFAULT_HEIGHT
- DEFAULT_TITLE
- DEFAULT_WIDTH
Public Instance Methods
content_size(*args)
click to toggle source
Calls superclass method
# File lib/glimmer/libui/control_proxy/window_proxy.rb, line 100 def content_size(*args) if args.empty? width = Fiddle::Pointer.malloc(8) height = Fiddle::Pointer.malloc(8) ::LibUI.window_content_size(@libui, width, height) width = width[0, 8].unpack1('i') height = height[0, 8].unpack1('i') [width, height] else args = args.first if args.size == 1 && args.first.is_a?(Array) super @width = args[0] @height = args[1] end end
Also aliased as: content_size=, set_content_size
destroy()
click to toggle source
Calls superclass method
Glimmer::LibUI::ControlProxy#destroy
# File lib/glimmer/libui/control_proxy/window_proxy.rb, line 50 def destroy return if @destroying @destroying = true @on_closing_listeners&.clear super ControlProxy.image_proxies.each { |image_proxy| ::LibUI.free_image(image_proxy.libui) unless image_proxy.area_image? } notify_custom_listeners('on_destroy', self) deregister_custom_listeners('on_destroy') @destroying = false end
destroy_child(child)
click to toggle source
Calls superclass method
Glimmer::LibUI::ControlProxy#destroy_child
# File lib/glimmer/libui/control_proxy/window_proxy.rb, line 45 def destroy_child(child) ::LibUI.send("window_set_child", @libui, nil) super end
destroying?()
click to toggle source
# File lib/glimmer/libui/control_proxy/window_proxy.rb, line 61 def destroying? @destroying end
handle_listener(listener_name, &listener)
click to toggle source
Calls superclass method
Glimmer::LibUI::ControlProxy#handle_listener
# File lib/glimmer/libui/control_proxy/window_proxy.rb, line 74 def handle_listener(listener_name, &listener) case listener_name when 'on_closing' @on_closing_listeners ||= [] @on_closing_listeners << listener @default_behavior_listener ||= Proc.new do return_value = nil @on_closing_listeners.each do |l| return_value = l.call(self) break if return_value.is_a?(Numeric) end if return_value.is_a?(Numeric) return_value else destroy ::LibUI.quit 0 end end.tap do |default_behavior_listener| super(listener_name, &default_behavior_listener) end else super end end
height(value = nil)
click to toggle source
# File lib/glimmer/libui/control_proxy/window_proxy.rb, line 128 def height(value = nil) if value.nil? content_size.last else set_content_size(width, value) end end
Also aliased as: height=, set_height
post_initialize_child(child)
click to toggle source
# File lib/glimmer/libui/control_proxy/window_proxy.rb, line 41 def post_initialize_child(child) ::LibUI.window_set_child(@libui, child.libui) end
resizable(value = nil)
click to toggle source
# File lib/glimmer/libui/control_proxy/window_proxy.rb, line 138 def resizable(value = nil) if value.nil? @resizable = true if @resizable.nil? @resizable else @resizable = value if !@resizable && !@resizable_listener_registered handle_listener('on_content_size_changed') do set_content_size(@width, @height) unless @resizable end @resizable_listener_registered = true end end end
show()
click to toggle source
Calls superclass method
# File lib/glimmer/libui/control_proxy/window_proxy.rb, line 65 def show super unless @shown_at_least_once @shown_at_least_once = true ::LibUI.main ::LibUI.quit end end
width(value = nil)
click to toggle source
# File lib/glimmer/libui/control_proxy/window_proxy.rb, line 118 def width(value = nil) if value.nil? content_size.first else set_content_size(value, height) end end
Private Instance Methods
build_control()
click to toggle source
# File lib/glimmer/libui/control_proxy/window_proxy.rb, line 158 def build_control if OS.mac? && ControlProxy.menu_proxies.empty? menu_proxy = ControlProxy.create('menu', nil, ['']) quit_menu_item_proxy = ControlProxy.create('quit_menu_item', menu_proxy, []) end construction_args = @args.dup construction_args[0] = DEFAULT_TITLE if construction_args.size == 0 construction_args[1] = DEFAULT_WIDTH if construction_args.size == 1 construction_args[2] = DEFAULT_HEIGHT if construction_args.size == 2 construction_args[3] = DEFAULT_HAS_MENUBAR if construction_args.size == 3 construction_args[3] = Glimmer::LibUI.boolean_to_integer(construction_args[3]) if construction_args.size == 4 && (construction_args[3].is_a?(TrueClass) || construction_args[3].is_a?(FalseClass)) @width = construction_args[1] @height = construction_args[2] @libui = ControlProxy.new_control(@keyword, construction_args) @libui.tap do # setup default on_closing listener if no on_closing listeners are setup handle_listener('on_closing') {} if @on_closing_listeners.nil? || @on_closing_listeners.empty? end end