/* ui/ui.h This file is part of the Osirion project and is distributed under the terms of the GNU General Public License version 2 */ #ifndef __INCLUDED_UI_H__ #define __INCLUDED_UI_H__ #include "ui/font.h" #include "ui/palette.h" #include "ui/widget.h" #include "ui/window.h" namespace ui { class UI : public Window { public: /// constructor UI(); /// destructor ~UI(); /// list widgets void list() const; /// list meus void list_menus() const; /// reload menu files void load(); /// make a window the active window void show_menu(const char *label); /// hide the active window void hide_menu(); /// show previous window void previous_menu(); /// return the active menu Window *active() { return ui_active_menu; } /// return the widget with global mouse focus inline Widget *mouse_focus() const { return ui_mouse_focus; } /// return the widget with global input focus inline Widget *input_focus() const { return ui_input_focus; } /// receive global mouse movement void input_mouse(const float x, const float y); /// receive global key input bool input_key(const bool pressed, const int key, const unsigned int modifier); /// run a user interface frame void frame(); /* -- fonts ------------------------------------------------ */ /// default small font inline const Font *font_small() const { return ui_font_small; } /// default medium font inline const Font *font_large() const { return ui_font_large; } protected: typedef std::list Menus; Menus::iterator find_menu(Window *menu); Window *find_menu(const char *label); void add_menu(Window *window); /* -- event handlers --------------------------------------- */ /// handle keypress events virtual bool on_keypress(const int key, const unsigned int modifier); /// handle key release events virtual bool on_keyrelease(const int key, const unsigned int modifier); private: Palette *ui_palette; Font *ui_font_small; Font *ui_font_large; Window *ui_active_menu; Widget *ui_mouse_focus; Widget *ui_input_focus; Menus ui_menus; /// TODO move to separate object to handle mouse cursor drawing math::Vector2f mouse_cursor; }; /// initialize the user interface void init(); /// shutdown the user interface void shutdown(); /// the global root window UI *root(); } #endif // __INCLUDED_UI_H__