#!/usr/bin/env ruby
# vim: ts=2 sw=2

# make this demo run without installing the library...
$: << "../src"

require 'evas'

MYFONT = "Verdana_Bold"

dpy = Display.new
w, h = dpy.width/2, dpy.height/2

evas = Evas.new(
	:display => dpy,
	:width => w, :height => h,
	:title => 'Evas Demonstration',
	:fontpath => '/usr/share/fonts/truetype')

# without something in the background, the screen will be garbled.
# fill with a black rectangle at full opacity.
rect = evas.new_rectangle(
	:x => 0, :y => 0,
	:width => w, :height => h,
	:layer => -1
)
rect.set_color(0, 0, 0, 255)
rect.show()

# simple instructions.
text = evas.new_text(
	:x => 100, :y => 100,
	:fontname => MYFONT, :fontsize => 10,
	:text => "Click on the background.  Right-click to close."
)
text.set_color(255, 255, 255, 255)
text.show()

# text that interacts with the user.
statustext = evas.new_text(
	:x => 100, :y => 100 + text.height,
	:fontname => MYFONT, :fontsize => 10,
	:text => ""
)
statustext.set_color(255, 255, 255, 255)
statustext.show()

rect.onevent(EvasObject::EVENT_MOUSE_DOWN) do |b, x, y|
	statustext.text = "Button press #{b} at (#{x}, #{y})."
	$quit = true if b == 3
end

$quit = false
while not $quit 
	evas.handle_x_events
	evas.render
end

