jes-ruby/runtime/lib/widget.rb

38 lines
535 B
Ruby

module Widget
def initialize
@x = 0
@y = 0
@width = 0
@height = 0
end
def children
[]
end
def resize(x, y, width, height)
@x = x
@y = y
@width = width
@height = height
end
def draw
if @width > 0 and @height > 0
render_begin
render
children.each do |child|
child.draw
end
render_end
end
end
def render_end
end
def draw_rect(x, y, width, height, r, g, b, a)
GL.draw_rect(@x + x, @y + y, width, height, r, g, b, a)
end
end