Class: GlimR::Widget

Inherits:
Model show all
Includes:
Layoutable
Defined in:
lib/glimr/widget.rb

Constant Summary

Constants included from Layoutable

Layoutable::DIMENSIONS

Instance Attribute Summary collapse

Attributes included from Layoutable

#align, #valign

Attributes inherited from Model

#geometry, #material, #shader, #texture, #transform

Attributes inherited from SceneObject

#children, #drawables, #mtime, #parent, #viewport

Attributes included from EventListener

#event_listeners, #listener_count

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Layoutable

#attach, #children_change, #constant_size?, #default_config, #detach, #expand!, #expand?, #expand_height, #expand_to_max_height!, #expand_to_max_width!, #expand_width, #fit_height!, #fit_to_children!, #fit_width!, #free_height, #free_width, #full_depth, #full_height, #full_width, #inner_depth, #inner_height, #inner_width, #inspect, #layout, #layoutable_children, #margin, #margin=, #max_height=, #max_width=, #min_height=, #min_width=, #padding, #padding=, #parent=, #size_changing, size_changing_accessor, #tell_children_of_size_change, #x=, #y=

Methods inherited from Model

#absolute_transform, #apply, #inspect, #pop_state, #push_state

Methods inherited from SceneObject

#<<, #absolute_geometry, #absolute_material, #absolute_shader, #absolute_texture, #absolute_transform, #absolute_transform_for_drawing, #add_drawables, #apply, #attach, #clone, #default_config, #detach, #detach_self, #inspect, #pop_state, #push_state, #remove_drawables, #render, #replace_node, #root, #touch!, #visible

Methods included from Configurable

#default_config

Methods included from EventListener

#add_event_listener, #decrement_listener_count, #dispatch_event, #event_root, #increment_listener_count, #method_missing, #multicast_event, #process_event, #remove_event_listener

Constructor Details

#initialize(*args, &block) ⇒ Widget

Returns a new instance of Widget.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/glimr/widget.rb', line 19

def initialize(*args, &block)
  @buttons_down = {}
  super
  on_mouse_over(:mouse_over)
  on_mouse_out(:mouse_out)
  on_mouse_down(:mouse_down)
  on_mouse_up(:mouse_up)
  on_mouse_move(:mouse_move)
  on_key_down(:key_down)
  on_key_up(:key_up)
  on_click(:click)
  on_activate(:activate)
  on_focus(:focus)
  on_blur(:blur)
  on_lock(:lock)
  on_unlock(:unlock)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class GlimR::EventListener

Instance Attribute Details

#focusedObject

Returns the value of attribute focused.



11
12
13
# File 'lib/glimr/widget.rb', line 11

def focused
  @focused
end

#hoverObject (readonly)

Returns the value of attribute hover.



13
14
15
# File 'lib/glimr/widget.rb', line 13

def hover
  @hover
end

Class Method Details

.for(*args, &block) ⇒ Object



15
16
17
# File 'lib/glimr/widget.rb', line 15

def self.for(*args,&block)
  GlimR.for(*args,&block)
end

Instance Method Details

#activate(o, event) ⇒ Object



66
67
# File 'lib/glimr/widget.rb', line 66

def activate(o, event)
end

#blur(o, event) ⇒ Object



73
74
75
# File 'lib/glimr/widget.rb', line 73

def blur(o, event)
  self.focused = false
end

#click(o, event) ⇒ Object



63
64
# File 'lib/glimr/widget.rb', line 63

def click(o, event)
end

#focus(o, event) ⇒ Object



69
70
71
# File 'lib/glimr/widget.rb', line 69

def focus(o, event)
  self.focused = true
end

#key_down(o, event) ⇒ Object



57
58
# File 'lib/glimr/widget.rb', line 57

def key_down(o, event)
end

#key_up(o, event) ⇒ Object



60
61
# File 'lib/glimr/widget.rb', line 60

def key_up(o, event)
end

#lock(o, event) ⇒ Object



77
78
79
# File 'lib/glimr/widget.rb', line 77

def lock(o, event)
  self.locked = true
end

#mouse_down(o, event) ⇒ Object



45
46
47
48
# File 'lib/glimr/widget.rb', line 45

def mouse_down(o, event)
  @hover = true
  focus(o,event) unless focused and event.button == :left
end

#mouse_move(o, event) ⇒ Object



54
55
# File 'lib/glimr/widget.rb', line 54

def mouse_move(o, event)
end

#mouse_out(o, event) ⇒ Object



41
42
43
# File 'lib/glimr/widget.rb', line 41

def mouse_out(o, event)
  @hover = false
end

#mouse_over(o, event) ⇒ Object



37
38
39
# File 'lib/glimr/widget.rb', line 37

def mouse_over(o, event)
  @hover = true
end

#mouse_up(o, event) ⇒ Object



50
51
52
# File 'lib/glimr/widget.rb', line 50

def mouse_up(o, event)
  blur(o,event) if focused and !@hover and event.button == :left
end

#unlock(o, event) ⇒ Object



81
82
83
# File 'lib/glimr/widget.rb', line 81

def unlock(o, event)
  self.locked = false
end