From f54bd48a884e4e3c95818f042a4b2418a6e070a4 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 7 Oct 2008 17:14:27 +0000 Subject: working button click --- src/ui/ui.cc | 63 ++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 12 deletions(-) (limited to 'src/ui/ui.cc') diff --git a/src/ui/ui.cc b/src/ui/ui.cc index ac5c0b8..0700c37 100644 --- a/src/ui/ui.cc +++ b/src/ui/ui.cc @@ -29,6 +29,12 @@ void func_list_ui(std::string const &args) } } +void func_ui_restart(std::string const &args) +{ + if (global_ui) { + global_ui->load(); + } +} void func_list_menu(std::string const &args) { @@ -44,7 +50,7 @@ void help() con_print << " ui list list widgets" << std::endl; con_print << " ui show show user interface" << std::endl; con_print << " ui hide hide user interface" << std::endl; - con_print << " ui restart reload menu files" << std::endl; + con_print << " ui restart reload user interface files" << std::endl; } void func_ui(std::string const &args) @@ -78,6 +84,17 @@ void func_ui(std::string const &args) } } +void help_menu() +{ + con_print << "^Bmenu functions" << std::endl; + con_print << " menu help show this help" << std::endl; + con_print << " menu list list available menus" << std::endl; + con_print << " menu hide hide the current menu" << std::endl; + con_print << " menu close close the current menu" << std::endl; + con_print << " menu [name] show a menu" << std::endl; + root()->list_menus(); +} + void func_menu(std::string const &args) { if (!global_ui) { @@ -125,10 +142,13 @@ void init() func->set_info("list available menus"); func = core::Func::add("ui", func_ui); - func->set_info("[command] [options] user interface subcommands"); + func->set_info("[command] user interface functions"); + + func = core::Func::add("ui_restart", func_ui_restart); + func->set_info("[command] [options] reload user interface files"); func = core::Func::add("menu", func_menu); - func->set_info("[hide|close|menuname] show or hide a menu"); + func->set_info("[command] menu functions"); } void shutdown() @@ -146,12 +166,6 @@ void shutdown() } } -void frame() -{ - if (global_ui) - global_ui->draw_event(); -} - UI::UI() : Window(0) { set_palette(new Palette()); @@ -170,6 +184,7 @@ void UI::load() remove_child(window); } window_children.clear(); + ui_focus = this; ui_active_window = 0; std::string filename("ui"); @@ -224,6 +239,9 @@ void UI::load() if (ini.got_key_color("foreground", color)) { widget_palette->set_foreground(color); continue; + } else if (ini.got_key_color("highlight", color)) { + widget_palette->set_highlight(color); + continue; } else if (ini.got_key_color("background", color)) { widget_palette->set_background(color); continue; @@ -271,8 +289,10 @@ void UI::add_window(Window *window) void UI::remove_window(Window *window) { - if (ui_active_window == window) + if (ui_active_window == window) { ui_active_window = 0; + ui_focus = this; + } Window::remove_window(window); } @@ -285,8 +305,9 @@ void UI::show_window(char const *label) if (ui_active_window) ui_active_window->hide(); ui_active_window = (*it); - ui_active_window->resize_event(); + ui_active_window->event_resize(); ui_active_window->show(); + ui_focus = this; return; } } @@ -302,9 +323,27 @@ void UI::hide_window() } } -void UI::set_mouse_cursor(float x, float y) +void UI::frame() +{ + ui_focus = find_focus(mouse_cursor); + event_draw(); +} + +void UI::event_mousecursor(float x, float y) { mouse_cursor.assign(x, y); } +void UI::event_keypress(unsigned int key, unsigned int modifier) +{ + if (ui_focus != this) + ui_focus->event_keypress(key, modifier); +} + +void UI::event_keyrelease(unsigned int key, unsigned int modifier) +{ + if (ui_focus != this) + ui_focus->event_keyrelease(key, modifier); +} + } -- cgit v1.2.3