diff options
author | Stijn Buys <ingar@osirion.org> | 2008-10-10 16:41:38 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-10-10 16:41:38 +0000 |
commit | 02fcd22d8cde355aa898a8c6bb4773d9434b8e9a (patch) | |
tree | 9397f1f5b61a0978acadc4c15fd330ee7138c59b /src/ui/menu.cc | |
parent | 4331f5c17901f46693dcb5c2df96276f6851be25 (diff) |
adds KeyPress, DevInfo and Stats widgets
Diffstat (limited to 'src/ui/menu.cc')
-rw-r--r-- | src/ui/menu.cc | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/src/ui/menu.cc b/src/ui/menu.cc index 34aa96c..af9929c 100644 --- a/src/ui/menu.cc +++ b/src/ui/menu.cc @@ -23,7 +23,8 @@ Menu::Menu(Window *parent, const char *label) : Window(parent) menu_background = new Bitmap(this); menu_container = new Window(this); - menu_container->set_border(false); + menu_container->set_border(true); + menu_container->set_background(true); menu_container->set_label("container"); } @@ -91,12 +92,34 @@ void Menu::load() } else if (ini.got_key_string("command", strval)) { button->set_command(strval); + } else if (ini.got_key_string("align", strval)) { + aux::to_label(strval); + if (strval.compare("left") == 0) { + button->set_alignment(AlignLeft | AlignVCenter); + } else if (strval.compare("center") == 0) { + button->set_alignment(AlignCenter); + } else if (strval.compare("right") == 0) { + button->set_alignment(AlignRight | AlignVCenter); + } else { + ini.unknown_value(); + } } else { ini.unkown_key(); } } else if (ini.in_section("label")) { if (ini.got_key_string("text", strval)) { label->set_text(strval); + } else if (ini.got_key_string("align", strval)) { + aux::to_label(strval); + if (strval.compare("left") == 0) { + label->set_alignment(AlignLeft | AlignHCenter); + } else if (strval.compare("center") == 0) { + label->set_alignment(AlignCenter); + } else if (strval.compare("right") == 0) { + label->set_alignment(AlignRight | AlignHCenter); + } else { + ini.unknown_value(); + } } else { ini.unkown_key(); } @@ -116,7 +139,11 @@ void Menu::set_background(const char *texture) Label *Menu::add_label(char const * text) { - return new Label(menu_container, text); + Label *label = new Label(menu_container, text); + label->set_alignment(AlignCenter); + label->set_border(false); + label->set_font(ui::root()->font_large()); + return label; } Button *Menu::add_button(char const *text, char const *command) @@ -130,15 +157,15 @@ void Menu::resize() menu_background->size().assign(size()); float n = (float) menu_container->children().size(); - menu_container->set_size(2.0f * menu_element_width, n * (menu_element_height + menu_element_margin) + menu_element_height); - menu_container->set_location(menu_element_margin, (height() - menu_container->height()) / 2.0f); + menu_container->set_size(1.5f * menu_element_width, n * (menu_element_height + menu_element_margin) + menu_element_height); + menu_container->set_location(menu_element_width * 0.25, (height() - menu_container->height()) / 2.0f); // reposition all children within the container size_t i = 0; for (Children::iterator it = menu_container->children().begin(); it != menu_container->children().end(); it++) { Widget *w = (*it); w->set_size(menu_element_width, menu_element_height); - w->set_location(menu_element_width * 0.5f, menu_element_height * 0.5f + i * (menu_element_height + menu_element_margin)); + w->set_location(menu_element_width * 0.25f, menu_element_height * 0.5f + i * (menu_element_height + menu_element_margin)); i++; } } |