rubyx-debugger/app/main/lib/main_view.rb

47 lines
1.2 KiB
Ruby
Raw Normal View History

2015-07-08 01:10:34 +02:00
require 'opal/pixi'
require 'native'
2015-07-09 21:43:07 +02:00
require "salama"
2015-07-06 20:55:34 +02:00
require_relative "registers_view"
require_relative "object_view"
require_relative "space_view"
class MainView
2015-07-09 11:32:29 +02:00
2015-07-06 20:55:34 +02:00
def initialize
@container = PIXI::Container.new
2015-07-09 11:32:29 +02:00
height = `window.innerHeight`
width = `window.innerWidth`
renderer = PIXI::WebGLRenderer.new( width - 100 , height - 100, {"backgroundColor" => 0xFFFFFF})
2015-07-08 01:10:34 +02:00
body = Native(`window.document.body`)
# bit of a hack as it assumes index's structure
2015-07-09 11:32:29 +02:00
html_con = body.firstElementChild
html_con.insertBefore renderer.view , html_con.lastElementChild
2015-07-06 20:55:34 +02:00
2015-07-09 15:34:02 +02:00
registers = RegisterView.new(height - 150)
@container.add_child registers
2015-07-13 14:14:34 +02:00
ParseTask.parse(1).then do |result|
is = Ast::Expression.from_basic(result)
Virtual::Compiler.compile( is , Virtual.machine.space.get_main )
2015-07-14 12:07:28 +02:00
Virtual.machine.run_before Virtual::Machine::FIRST_PASS
2015-07-13 14:14:34 +02:00
end.fail do |error|
raise "Error: #{error}"
2015-07-13 14:14:34 +02:00
end
space = SpaceView.new
2015-07-09 15:34:02 +02:00
@container.add_child space
2015-07-06 20:55:34 +02:00
2015-07-08 01:10:34 +02:00
animate = Proc.new do
2015-07-09 11:32:29 +02:00
`requestAnimationFrame(animate)`
registers.draw_me
space.draw_me
2015-07-09 15:34:02 +02:00
renderer.render @container
2015-07-06 20:55:34 +02:00
end
2015-07-09 11:32:29 +02:00
animate.call
2015-07-06 20:55:34 +02:00
end
attr_reader :container
2015-07-06 20:55:34 +02:00
end