Class: Glimmer::LibUI::ControlProxy::AreaProxy

Inherits:
Glimmer::LibUI::ControlProxy show all
Includes:
FiddleConsumer, Parent, Transformable
Defined in:
lib/glimmer/libui/control_proxy/area_proxy.rb,
lib/glimmer/libui/control_proxy/area_proxy/scrolling_area_proxy.rb

Overview

Proxy for LibUI area objects

Follows the Proxy Design Pattern

Direct Known Subclasses

ScrollingAreaProxy

Defined Under Namespace

Classes: ScrollingAreaProxy

Constant Summary collapse

CUSTOM_LISTENER_NAMES =
['on_draw', 'on_mouse_event', 'on_mouse_move', 'on_mouse_down', 'on_mouse_up', 'on_mouse_drag_start', 'on_mouse_drag', 'on_mouse_drop', 'on_mouse_crossed', 'on_mouse_enter', 'on_mouse_exit', 'on_drag_broken', 'on_key_event', 'on_key_down', 'on_key_up']
CUSTOM_LISTENER_NAME_ALIASES =
{
  on_drawn: 'on_draw',
  on_mouse_moved: 'on_mouse_move',
  on_mouse_drag_started: 'on_mouse_drag_start',
  on_mouse_dragged: 'on_mouse_drag',
  on_mouse_dropped: 'on_mouse_drop',
  on_mouse_cross: 'on_mouse_crossed',
  on_mouse_entered: 'on_mouse_enter',
  on_mouse_exited: 'on_mouse_exit',
  on_drag_break: 'on_drag_broken',
}
SHIFTED_KEY_CODE_CHARS =
{
  '`' => '~',
  '1' => '!',
  '2' => '@',
  '3' => '#',
  '4' => '$',
  '5' => '%',
  '6' => '^',
  '7' => '&',
  '8' => '*',
  '9' => '(',
  '10' => ')',
  '-' => '_',
  '=' => '+',
  ',' => '<',
  '.' => '>',
  '/' => '?',
  ';' => ':',
  "'" => '"',
  '[' => '{',
  ']' => '}',
  "\\" => '|',
}

Constants inherited from Glimmer::LibUI::ControlProxy

BOOLEAN_PROPERTIES, KEYWORD_ALIASES, STRING_PROPERTIES, TransformProxy

Class Attribute Summary collapse

Instance Attribute Summary collapse

Attributes inherited from Glimmer::LibUI::ControlProxy

#args, #block, #content_added, #keyword, #libui, #parent_proxy

Instance Method Summary collapse

Methods included from Parent

#children, #post_initialize_child

Methods included from FiddleConsumer

#fiddle_closure_block_caller

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_name_aliases, #custom_listener_names, #default_destroy, #deregister_all_custom_listeners, #deregister_custom_listeners, descendant_keyword_constant_map, #destroy, #destroy_child, #enabled, exists?, #handle_custom_listener, #handle_listener, #has_custom_listener?, image_proxies, #initialize, keyword, #listeners, #listeners_for, main_window_proxy, map_descendant_keyword_constants_for, menu_proxies, #method_missing, new_control, #notify_custom_listeners, #post_initialize_child, reset_descendant_keyword_constant_map, #respond_to?, #respond_to_libui?, #send_to_libui, #visible, widget_proxy_class, #window_proxy

Methods included from DataBindable

#data_bind, #data_bind_read, #data_bind_write, #data_binding_model_attribute_observer_registrations

Constructor Details

This class inherits a constructor from Glimmer::LibUI::ControlProxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Glimmer::LibUI::ControlProxy

Class Attribute Details

.current_area_draw_paramsObject

this attribute is only populated during on_draw call



36
37
38
# File 'lib/glimmer/libui/control_proxy/area_proxy.rb', line 36

def current_area_draw_params
  @current_area_draw_params
end

Instance Attribute Details

#area_handlerObject (readonly)

Returns the value of attribute area_handler.



81
82
83
# File 'lib/glimmer/libui/control_proxy/area_proxy.rb', line 81

def area_handler
  @area_handler
end

Instance Method Details

#auto_redraw_enabled(value = nil) ⇒ Object Also known as: auto_redraw_enabled?, auto_redraw_enabled=, set_auto_redraw_enabled



120
121
122
123
124
125
126
127
# File 'lib/glimmer/libui/control_proxy/area_proxy.rb', line 120

def auto_redraw_enabled(value = nil)
  if value.nil?
    @auto_redraw_enabled = true if @auto_redraw_enabled.nil?
    @auto_redraw_enabled
  else
    @auto_redraw_enabled = !!value
  end
end

#draw(area_draw_params) ⇒ Object



106
107
108
109
# File 'lib/glimmer/libui/control_proxy/area_proxy.rb', line 106

def draw(area_draw_params)
  children.dup.each {|child| child.draw(area_draw_params)}
  notify_custom_listeners('on_draw', area_draw_params)
end

#libui_api_keywordObject



83
84
85
# File 'lib/glimmer/libui/control_proxy/area_proxy.rb', line 83

def libui_api_keyword
  'area'
end

#pause_auto_redrawObject



132
133
134
# File 'lib/glimmer/libui/control_proxy/area_proxy.rb', line 132

def pause_auto_redraw
  self.auto_redraw_enabled = false
end

#post_add_contentObject



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/glimmer/libui/control_proxy/area_proxy.rb', line 87

def post_add_content
  unless parent_proxy.is_a?(Box)
    unless @content_added
      original_parent_proxy = @parent_proxy
      @vertical_box_parent_proxy = ControlProxy.create('vertical_box', parent_proxy, []) {} # block prevents calling post add content
      append_properties.each do |property|
        @vertical_box_parent_proxy.append_property(property, append_property(property))
      end
      @vertical_box_parent_proxy.post_add_content
      @parent_proxy = @vertical_box_parent_proxy
      @vertical_box_parent_proxy.post_initialize_child(self)
      @content_added = true
    end
  else
    super
  end
  install_listeners
end

#redrawObject



111
112
113
# File 'lib/glimmer/libui/control_proxy/area_proxy.rb', line 111

def redraw
  queue_redraw_all
end

#request_auto_redrawObject



115
116
117
118
# File 'lib/glimmer/libui/control_proxy/area_proxy.rb', line 115

def request_auto_redraw
  # TODO implement functionality to delay queuing area redraws until post_add_content has been called (area definition is done). Maybe offer an option to enable redrawing before area is closed too.
  queue_redraw_all if auto_redraw_enabled?
end

#resume_auto_redrawObject



136
137
138
# File 'lib/glimmer/libui/control_proxy/area_proxy.rb', line 136

def resume_auto_redraw
  self.auto_redraw_enabled = true
end