Module: Savio::IORenderable
- Included in:
- Button, ColorSlider, InputBox, Slider
- Defined in:
- lib/savio/IORenderable.rb
Instance Attribute Summary collapse
-
#allowDrag ⇒ Object
Returns the value of attribute allowDrag.
-
#displayName ⇒ Object
Returns the value of attribute displayName.
-
#draggingEnabled ⇒ Object
Returns the value of attribute draggingEnabled.
-
#duplicate ⇒ Object
Returns the value of attribute duplicate.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#shown ⇒ Object
Returns the value of attribute shown.
-
#size ⇒ Object
Returns the value of attribute size.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
-
#z ⇒ Object
Returns the value of attribute z.
Instance Method Summary collapse
- #add ⇒ Object
- #context ⇒ Object
- #drag(x, y) ⇒ Object
- #dragType=(type) ⇒ Object
- #endDrag ⇒ Object
- #initialize(args = {}) ⇒ Object
- #kill ⇒ Object
- #rebuild ⇒ Object
- #remove ⇒ Object
Instance Attribute Details
#allowDrag ⇒ Object
Returns the value of attribute allowDrag.
3 4 5 |
# File 'lib/savio/IORenderable.rb', line 3 def allowDrag @allowDrag end |
#displayName ⇒ Object
Returns the value of attribute displayName.
4 5 6 |
# File 'lib/savio/IORenderable.rb', line 4 def displayName @displayName end |
#draggingEnabled ⇒ Object
Returns the value of attribute draggingEnabled.
3 4 5 |
# File 'lib/savio/IORenderable.rb', line 3 def draggingEnabled @draggingEnabled end |
#duplicate ⇒ Object
Returns the value of attribute duplicate.
3 4 5 |
# File 'lib/savio/IORenderable.rb', line 3 def duplicate @duplicate end |
#enabled ⇒ Object
Returns the value of attribute enabled.
3 4 5 |
# File 'lib/savio/IORenderable.rb', line 3 def enabled @enabled end |
#shown ⇒ Object
Returns the value of attribute shown.
3 4 5 |
# File 'lib/savio/IORenderable.rb', line 3 def shown @shown end |
#size ⇒ Object
Returns the value of attribute size.
4 5 6 |
# File 'lib/savio/IORenderable.rb', line 4 def size @size end |
#x ⇒ Object
Returns the value of attribute x.
4 5 6 |
# File 'lib/savio/IORenderable.rb', line 4 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
4 5 6 |
# File 'lib/savio/IORenderable.rb', line 4 def y @y end |
#z ⇒ Object
Returns the value of attribute z.
4 5 6 |
# File 'lib/savio/IORenderable.rb', line 4 def z @z end |
Instance Method Details
#add ⇒ Object
31 32 33 |
# File 'lib/savio/IORenderable.rb', line 31 def add() @shown = true end |
#context ⇒ Object
106 107 108 109 110 111 |
# File 'lib/savio/IORenderable.rb', line 106 def context() self.instance_variables.map do |attribute| key = attribute.to_s.gsub('@','').intern [key, self.instance_variable_get(attribute)] end.to_h end |
#drag(x, y) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/savio/IORenderable.rb', line 71 def drag(x, y) case @dragType when "move" if @isDragging == false @grabFixX = (x - @x).abs @grabFixY = (y - @y).abs @isDragging = true end if @isDragging == true @x = x - @grabFixX @y = y - @grabFixY rebuild() end when "duplicate" if @isDragging == false @grabFixX = (x - @x).abs @grabFixY = (y - @y).abs classType = Object.const_get(self.class.name) @duplicate = classType.new(self.context) @duplicate.enabled = false @duplicate.draggingEnabled = false @duplicate.dragType = "move" @isDragging = true end if @isDragging == true @duplicate.enabled = false @duplicate.draggingEnabled = false @duplicate.x = x - @grabFixX @duplicate.y = y - @grabFixY end end end |
#dragType=(type) ⇒ Object
65 66 67 68 69 |
# File 'lib/savio/IORenderable.rb', line 65 def dragType=(type) if type == "move" || type == "duplicate" @dragType = type end end |
#endDrag ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/savio/IORenderable.rb', line 113 def endDrag() if @isDragging if @dragType == "duplicate" @duplicate.draggingEnabled = true @duplicate.enabled = true @duplicate.allowDrag = false @duplicate = nil end @isDragging = false @allowDrag = false end end |
#initialize(args = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/savio/IORenderable.rb', line 6 def initialize(args = {}) Savio.addElement(self) @x = args[:x] || 0 @y = args[:y] || 0 @z = args[:z] || 1 @size = args[:size] || 10 @enabled = args[:enabled] || true @shown = args[:shown] || true @displayName = args[:displayName] || "" @draggingEnabled = args[:draggingEnabled] || false @dragType = args[:dragType] || "move" @isDragging = false @allowDrag = false end |
#kill ⇒ Object
35 36 37 |
# File 'lib/savio/IORenderable.rb', line 35 def kill() remove() end |
#rebuild ⇒ Object
39 40 41 42 |
# File 'lib/savio/IORenderable.rb', line 39 def rebuild() remove() build() end |
#remove ⇒ Object
27 28 29 |
# File 'lib/savio/IORenderable.rb', line 27 def remove() @shown = false end |