Class: Glimmer::LibUI::ControlProxy::ImageProxy
- Inherits:
-
Glimmer::LibUI::ControlProxy
- Object
- Glimmer::LibUI::ControlProxy
- Glimmer::LibUI::ControlProxy::ImageProxy
- Includes:
- Parent, Transformable
- Defined in:
- lib/glimmer/libui/control_proxy/image_proxy.rb
Overview
Proxy for LibUI image object and Glimmer custom control
Follows the Proxy Design Pattern
Constant Summary
Constants inherited from Glimmer::LibUI::ControlProxy
BOOLEAN_PROPERTIES, KEYWORD_ALIASES, STRING_PROPERTIES, TransformProxy
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#pixels ⇒ Object
readonly
Returns the value of attribute pixels.
-
#shapes ⇒ Object
readonly
Returns the value of attribute shapes.
Attributes inherited from Glimmer::LibUI::ControlProxy
#args, #block, #keyword, #libui, #parent_proxy
Instance Method Summary collapse
- #area_image? ⇒ Boolean
- #destroy ⇒ Object
- #draw(area_draw_params) ⇒ Object
- #file(value = nil) ⇒ Object (also: #file=, #set_file)
- #height(value = nil) ⇒ Object (also: #height=, #set_height)
-
#initialize(keyword, parent, args, &block) ⇒ ImageProxy
constructor
A new instance of ImageProxy.
- #post_add_content ⇒ Object
- #redraw ⇒ Object
- #request_auto_redraw ⇒ Object
- #width(value = nil) ⇒ Object (also: #width=, #set_width)
Methods included from Parent
#children, #post_initialize_child
Methods included from Transformable
#apply_transform, #post_initialize_child, #transform, #undo_transform
Methods inherited from Glimmer::LibUI::ControlProxy
#append_properties, #append_property, #can_handle_listener?, constant_symbol, #content, control_proxies, create, #custom_listener_aliases, #custom_listeners, #data_bind, #default_destroy, descendant_keyword_constant_map, #destroy_child, #enabled, exists?, #handle_custom_listener, #handle_listener, #has_custom_listener?, image_proxies, keyword, #libui_api_keyword, main_window_proxy, map_descendant_keyword_constants_for, menu_proxies, #method_missing, new_control, #post_initialize_child, reset_descendant_keyword_constant_map, #respond_to?, #respond_to_libui?, #send_to_libui, #visible, widget_proxy_class, #window_proxy
Constructor Details
#initialize(keyword, parent, args, &block) ⇒ ImageProxy
Returns a new instance of ImageProxy.
42 43 44 45 46 47 48 49 |
# File 'lib/glimmer/libui/control_proxy/image_proxy.rb', line 42 def initialize(keyword, parent, args, &block) @keyword = keyword @parent_proxy = parent @args = args @block = block @enabled = true post_add_content if @block.nil? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Glimmer::LibUI::ControlProxy
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
40 41 42 |
# File 'lib/glimmer/libui/control_proxy/image_proxy.rb', line 40 def data @data end |
#pixels ⇒ Object (readonly)
Returns the value of attribute pixels.
40 41 42 |
# File 'lib/glimmer/libui/control_proxy/image_proxy.rb', line 40 def pixels @pixels end |
#shapes ⇒ Object (readonly)
Returns the value of attribute shapes.
40 41 42 |
# File 'lib/glimmer/libui/control_proxy/image_proxy.rb', line 40 def shapes @shapes end |
Instance Method Details
#area_image? ⇒ Boolean
124 125 126 |
# File 'lib/glimmer/libui/control_proxy/image_proxy.rb', line 124 def area_image? @area_image ||= !!(@parent_proxy&.is_a?(AreaProxy) || AreaProxy.current_area_draw_params) end |
#destroy ⇒ Object
128 129 130 131 |
# File 'lib/glimmer/libui/control_proxy/image_proxy.rb', line 128 def destroy @parent_proxy&.children&.delete(self) ControlProxy.control_proxies.delete(self) end |
#draw(area_draw_params) ⇒ Object
115 116 117 118 119 120 121 122 |
# File 'lib/glimmer/libui/control_proxy/image_proxy.rb', line 115 def draw(area_draw_params) if @shapes.nil? load_image parse_pixels calculate_shapes end ImagePathRenderer.new(@parent_proxy, @shapes).render end |
#file(value = nil) ⇒ Object Also known as: file=, set_file
65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/glimmer/libui/control_proxy/image_proxy.rb', line 65 def file(value = nil) if value.nil? @args[0] else @args[0] = value if area_image? && @content_added post_add_content request_auto_redraw end end end |
#height(value = nil) ⇒ Object Also known as: height=, set_height
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/glimmer/libui/control_proxy/image_proxy.rb', line 93 def height(value = nil) if value.nil? @args[2] else @args[2] = value if area_image? && @content_added post_add_content request_auto_redraw end end end |
#post_add_content ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/glimmer/libui/control_proxy/image_proxy.rb', line 51 def post_add_content if area_image? @shapes = nil super if @parent_proxy.nil? && AreaProxy.current_area_draw_params draw(AreaProxy.current_area_draw_params) destroy end else # image object not control build_control unless @content_added super end end |
#redraw ⇒ Object
107 108 109 |
# File 'lib/glimmer/libui/control_proxy/image_proxy.rb', line 107 def redraw @parent_proxy&.redraw end |
#request_auto_redraw ⇒ Object
111 112 113 |
# File 'lib/glimmer/libui/control_proxy/image_proxy.rb', line 111 def request_auto_redraw @parent_proxy&.request_auto_redraw if area_image? end |
#width(value = nil) ⇒ Object Also known as: width=, set_width
79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/glimmer/libui/control_proxy/image_proxy.rb', line 79 def width(value = nil) if value.nil? @args[1] else @args[1] = value if area_image? && @content_added post_add_content request_auto_redraw end end end |