2015-08-22 21:17:32 +02:00
|
|
|
class RefView < ListView
|
2015-08-22 20:11:33 +02:00
|
|
|
|
2015-08-23 02:16:32 +02:00
|
|
|
def initialize name , value , z = nil
|
2015-08-22 20:11:33 +02:00
|
|
|
@name = name
|
|
|
|
@value = value
|
2015-08-23 02:16:32 +02:00
|
|
|
@z = z
|
2015-08-22 21:17:32 +02:00
|
|
|
super []
|
|
|
|
end
|
|
|
|
|
|
|
|
attr_reader :value
|
|
|
|
|
|
|
|
def value= val
|
|
|
|
@value = val
|
|
|
|
add_hover
|
2015-08-22 20:11:33 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def draw
|
|
|
|
@element = div("li") << div("a" , "#{@name} : #{marker(@value)}" )
|
2015-08-22 21:17:32 +02:00
|
|
|
add_hover
|
2015-08-23 02:16:32 +02:00
|
|
|
@element.style["z-index"] = @z if @z
|
2015-08-22 21:17:32 +02:00
|
|
|
@element
|
|
|
|
end
|
|
|
|
|
|
|
|
def add_hover
|
|
|
|
@element.on("hover"){ hover } if is_object?(@value)
|
|
|
|
end
|
|
|
|
|
|
|
|
def is_object?( id )
|
|
|
|
Virtual.machine.objects[id] != nil
|
2015-08-22 20:11:33 +02:00
|
|
|
end
|
|
|
|
|
2015-08-22 21:17:32 +02:00
|
|
|
def hover
|
|
|
|
puts "hovering #{@name}"
|
2015-08-24 02:04:07 +02:00
|
|
|
append_view ObjectView.new(@value)
|
2015-08-22 21:17:32 +02:00
|
|
|
@element.off("hover")
|
|
|
|
end
|
2015-08-23 02:16:32 +02:00
|
|
|
|
2015-08-22 20:11:33 +02:00
|
|
|
def marker id
|
|
|
|
var = Virtual.machine.objects[id]
|
|
|
|
if var.is_a? String
|
2015-08-25 09:57:22 +02:00
|
|
|
str = "Wo"
|
2015-08-22 20:11:33 +02:00
|
|
|
else
|
|
|
|
str = var.class.name.split("::").last[0,2]
|
|
|
|
end
|
|
|
|
str + " : #{id.to_s}"
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|