2015-08-22 21:17:32 +02:00
|
|
|
class RefView < ListView
|
2015-08-22 20:11:33 +02:00
|
|
|
|
|
|
|
def initialize name , value
|
|
|
|
@name = name
|
|
|
|
@value = value
|
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
|
|
|
|
@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}"
|
|
|
|
append ObjectView.new(@value)
|
|
|
|
@element.off("hover")
|
|
|
|
end
|
|
|
|
|
2015-08-22 20:11:33 +02:00
|
|
|
def marker id
|
|
|
|
var = Virtual.machine.objects[id]
|
|
|
|
if var.is_a? String
|
|
|
|
str "Wo"
|
|
|
|
else
|
|
|
|
str = var.class.name.split("::").last[0,2]
|
|
|
|
end
|
|
|
|
str + " : #{id.to_s}"
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|