From 02fcd22d8cde355aa898a8c6bb4773d9434b8e9a Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 10 Oct 2008 16:41:38 +0000 Subject: adds KeyPress, DevInfo and Stats widgets --- src/ui/ui.cc | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'src/ui/ui.cc') diff --git a/src/ui/ui.cc b/src/ui/ui.cc index 2b09938..bba9ea6 100644 --- a/src/ui/ui.cc +++ b/src/ui/ui.cc @@ -132,8 +132,15 @@ UI *root() void init() { con_print << "^BInitializing user interface..." << std::endl; - if (!global_ui) + + if (!global_ui) { global_ui = new UI(); + } else { + con_warn << "User interface already initialized!" << std::endl; + return; + } + + global_ui->load(); core::Func *func = core::Func::add("list_ui", func_list_ui); func->set_info("list user interface widgets"); @@ -178,11 +185,8 @@ UI::UI() : Window(0) // default fonts ui_font_small = new Font("gui", 12, 18); - ui_font_medium = new Font("gui", 14, 24); - ui_font_large = new Font("gui", 16, 30); + ui_font_large = new Font("gui", 14, 24); set_font(ui_font_small); - - load(); } UI::~UI() @@ -190,7 +194,6 @@ UI::~UI() delete ui_palette; delete ui_font_small; - delete ui_font_medium; delete ui_font_large; } @@ -315,7 +318,6 @@ void UI::add_window(Window *window) { Window::add_window(window); window->hide(); - window->set_font(ui_font_medium); } void UI::remove_window(Window *window) @@ -347,6 +349,7 @@ void UI::show_window(const char *label) ui_active_window->hide(); ui_active_window = window; ui_active_window->event_resize(); + ui_active_window->raise(); ui_active_window->show(); ui_focus = window; } else { @@ -364,23 +367,29 @@ void UI::hide_window() void UI::frame() { - ui_focus = find_focus(mouse_cursor); + ui_focus = event_focus(mouse_cursor); event_draw(); } -void UI::event_mousemove(float x, float y) +void UI::input_mouse(float x, float y) { mouse_cursor.assign(x, y); } -void UI::event_keypress(unsigned int key, unsigned int modifier) +void UI::input_key(bool pressed, unsigned int key, unsigned int modifier) { - ui_focus->keypress(key, modifier); + ui_focus->event_key(pressed, key, modifier); } -void UI::event_keyrelease(unsigned int key, unsigned int modifier) +bool UI::keypress(unsigned int key, unsigned int modifier) { - ui_focus->keyrelease(key, modifier); + return true; } +bool UI::keyrelease(unsigned int key, unsigned int modifier) +{ + return true; } + +} + -- cgit v1.2.3