module Savio::IORenderable
Attributes
allowDrag[RW]
displayName[R]
draggingEnabled[RW]
duplicate[RW]
enabled[RW]
shown[R]
size[R]
x[R]
y[R]
z[R]
Public Class Methods
new(args = {})
click to toggle source
# 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 @displayName = args[:displayName] || "" @draggingEnabled = args[:draggingEnabled] || false @dragType = args[:dragType] || "move" @isDragging = false @allowDrag = false end
Public Instance Methods
add()
click to toggle source
# File lib/savio/IORenderable.rb, line 30 def add() if @shown == true return end @shown = true end
context()
click to toggle source
# File lib/savio/IORenderable.rb, line 107 def context() self.instance_variables.map do |attribute| key = attribute.to_s.gsub('@','').intern [key, self.instance_variable_get(attribute)] end.to_h end
displayName=(displayName)
click to toggle source
# File lib/savio/IORenderable.rb, line 62 def displayName=(displayName) @displayName = displayName rebuild() end
drag(x, y)
click to toggle source
# File lib/savio/IORenderable.rb, line 72 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)
click to toggle source
# File lib/savio/IORenderable.rb, line 66 def dragType=(type) if type == "move" || type == "duplicate" @dragType = type end end
endDrag()
click to toggle source
# File lib/savio/IORenderable.rb, line 114 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
kill()
click to toggle source
# File lib/savio/IORenderable.rb, line 37 def kill() remove() end
rebuild()
click to toggle source
# File lib/savio/IORenderable.rb, line 41 def rebuild() remove() build() end
remove()
click to toggle source
# File lib/savio/IORenderable.rb, line 23 def remove() if @shown == false return end @shown = false end
size=(size)
click to toggle source
# File lib/savio/IORenderable.rb, line 58 def size=(size) @size = size.abs rebuild() end
x=(x)
click to toggle source
# File lib/savio/IORenderable.rb, line 46 def x=(x) @x = x rebuild() end
y=(y)
click to toggle source
# File lib/savio/IORenderable.rb, line 50 def y=(y) @y = y rebuild() end
z=(z)
click to toggle source
# File lib/savio/IORenderable.rb, line 54 def z=(z) @z = z rebuild() end