


#include <flare_gui/widget_screen.h>
#include <allegro_flare/allegro_flare.h>

#include <flare_gui/collision_box.h>






FGUIScreen::FGUIScreen(Display *display)
	: Screen(display)
	, FGUIParent(NULL, new FGUICollisionBox(0, 0, display->width(), display->height()))
	, bitmaps("data/bitmaps")
	, fonts("data/fonts")
	, samples("data/samples")
	, motion()
	, draw_focused_outline(false)
{
	collision_area->placement.align_x = 0;
	collision_area->placement.align_y = 0;
}



void FGUIScreen::primary_timer_func()
{
	motion.update(af::time_now);

	FGUIParent::primary_timer_func();
	FGUIParent::draw_func();

	//on_draw_after_children();
}



void FGUIScreen::mouse_axes_func()
{
	if (af::current_event->mouse.display != display->display) return;

	float mx = af::current_event->mouse.x;
	float my = af::current_event->mouse.y;
	float mdx = af::current_event->mouse.dx;
	float mdy = af::current_event->mouse.dy;

	FGUIParent::mouse_axes_func(mx, my, mdx, mdy);
}



void FGUIScreen::mouse_down_func()
{
	if (af::current_event->mouse.display != display->display) return;
	FGUIParent::mouse_down_func();
}



void FGUIScreen::mouse_up_func()
{
	if (af::current_event->mouse.display != display->display) return;
	FGUIParent::mouse_up_func();
}



void FGUIScreen::key_down_func()
{
	if (af::current_event->keyboard.display != display->display) return;
	FGUIParent::key_down_func();
}



void FGUIScreen::key_up_func()
{
	if (af::current_event->keyboard.display != display->display) return;
	FGUIParent::key_up_func();
}



void FGUIScreen::key_char_func()
{
	if (af::current_event->keyboard.display != display->display) return;
	FGUIParent::key_char_func();
}




void FGUIScreen::on_draw() {}



void FGUIScreen::on_draw_after_children() {}