diff options
author | Stijn Buys <ingar@osirion.org> | 2008-10-07 17:14:27 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-10-07 17:14:27 +0000 |
commit | f54bd48a884e4e3c95818f042a4b2418a6e070a4 (patch) | |
tree | 73e82729a2f97b58e94ffd6944ac1ad47bf8314e /src/ui/menu.cc | |
parent | f8d1ee921c83b7b148883b3ee16e4ec9c776d6db (diff) |
working button click
Diffstat (limited to 'src/ui/menu.cc')
-rw-r--r-- | src/ui/menu.cc | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/ui/menu.cc b/src/ui/menu.cc index 9485e82..34aa96c 100644 --- a/src/ui/menu.cc +++ b/src/ui/menu.cc @@ -12,23 +12,25 @@ namespace ui { -const float element_width = 256.0f; -const float element_height = 64.0f; -const float element_margin = 24.0f; - Menu::Menu(Window *parent, const char *label) : Window(parent) { set_label(label); set_border(false); + menu_element_width = 256.0f; + menu_element_height = 48.0f; + menu_element_margin = 24.0f; + menu_background = new Bitmap(this); menu_container = new Window(this); + menu_container->set_border(false); menu_container->set_label("container"); } Menu::~Menu() { + // menu_container and menu_background are deleted by Widget::~Widget() } void Menu::load() @@ -73,6 +75,12 @@ void Menu::load() if (ini.in_section("menu")) { if (ini.got_key_string("background", strval)) { set_background(strval.c_str()); + } else if (ini.got_key_float("elementwidth", menu_element_width)) { + continue; + } else if (ini.got_key_float("elementheight", menu_element_height)) { + continue; + } else if (ini.got_key_float("elementmargin", menu_element_margin)) { + continue; } else { ini.unkown_key(); } @@ -122,15 +130,15 @@ void Menu::resize() menu_background->size().assign(size()); float n = (float) menu_container->children().size(); - menu_container->set_size(2.0f * element_width, n * (element_height + element_margin) + element_height); - menu_container->set_location(element_margin, (height() - menu_container->height()) / 2.0f); + 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); // 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(element_width, element_height); - w->set_location(element_width * 0.5f, element_height * 0.5f + i * (element_height + element_margin)); + 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)); i++; } } |