make class view use ref view

so one can drill into a class like any old object
some work refreshing them (as they change on reboot)
This commit is contained in:
Torsten Ruger 2015-10-29 23:36:04 +02:00
parent e8b0a38478
commit 88aa296356
2 changed files with 23 additions and 11 deletions

View File

@ -1,15 +1,28 @@
require_relative "ref_view"
class ClassesView < ListView
def initialize interpreter
@interpreter = interpreter
@interpreter.register_event(:state_changed, self)
super( class_views )
end
def class_views
classes = []
Register.machine.space.classes.each do |name , claz|
next if [:Kernel,:Module,:MetaClass,:BinaryCode].index name
classes << claz
end
classes.sort! {|a,b| a.name <=> b.name }
super( classes.collect{|c| ClassView.new(c)})
classes.collect{|c| ClassView.new(c)}
end
def state_changed old , new_s
return unless new_s == :running
class_views.each_with_index do |v, i|
replace_at i , v
end
end
def draw
@ -21,17 +34,12 @@ class ClassesView < ListView
end
class ClassView < ElementView
class ClassView < RefView
def initialize clazz
@clazz = clazz
super(clazz.name , clazz.object_id , 20 )
end
def draw
@element = div("li") << div( "a" , @clazz.name ) << (ul = div("ul"))
@clazz.object_layout.instance_names.each do |name|
ul << (div("li") << div("a", name ))
end
@element.style["z-index"] = 20
@element
def ref_text
@name
end
end

View File

@ -15,12 +15,16 @@ class RefView < ListView
end
def draw
@element = div("li") << div("a" , "#{@name} : #{marker(@value)}" )
@element = div("li") << div("a" , ref_text )
add_hover
@element.style["z-index"] = @z if @z
@element
end
def ref_text
"#{@name} : #{marker(@value)}"
end
def add_hover
return if is_string?
@element.on("hover"){ hover } if is_object?(@value)