Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2011-09-04 17:54:51 +0000
committerStijn Buys <ingar@osirion.org>2011-09-04 17:54:51 +0000
commit69eed715f80c24c2435c82bb9fa1954697bf3af0 (patch)
treea21aa14d2ecfa86b94d3b122c2c972d758425782 /src/client/buttonmenu.cc
parentedd5dfcd15198f5d5d277835fdf75108eb67472d (diff)
Moved main menu infrastructure into client namespace,
removed ui::Container and ui::Menu classes.
Diffstat (limited to 'src/client/buttonmenu.cc')
-rw-r--r--src/client/buttonmenu.cc36
1 files changed, 13 insertions, 23 deletions
diff --git a/src/client/buttonmenu.cc b/src/client/buttonmenu.cc
index ed15223..18139d0 100644
--- a/src/client/buttonmenu.cc
+++ b/src/client/buttonmenu.cc
@@ -19,6 +19,7 @@ ButtonMenu::ButtonMenu(ui::Widget *parent, const char *label) : ui::Window(paren
set_background(false);
buttonmenu_container = new ui::Window(this);
+ buttonmenu_compact = false;
hide();
}
@@ -44,11 +45,10 @@ ui::Button *ButtonMenu::add_button(char const *text, char const *command)
void ButtonMenu::resize()
{
- // resize container widget
- buttonmenu_container->set_geometry(0, 0, ui::UI::elementsize.width() * 1.5f, height());
-
+ const float padding = ui::UI::elementsize.height();
+
// reposition all children within the container
- const float x = ui::UI::elementsize.width() * 0.25f;
+ const float x = padding;
float y = ui::UI::elementsize.height() * 0.5f;
for (Children::iterator it = buttonmenu_container->children().begin(); it != buttonmenu_container->children().end(); it++) {
@@ -60,6 +60,15 @@ void ButtonMenu::resize()
y += ui::UI::elementsize.height() + ui::UI::elementmargin;
}
+ // resize container widget
+ if (!buttonmenu_compact) {
+ buttonmenu_container->set_geometry(0, 0, ui::UI::elementsize.width() + 2.0f * padding, height());
+ } else {
+ y += ui::UI::elementsize.height() * 0.5f;
+ buttonmenu_container->set_geometry(0, (height() - y) * 0.5f, ui::UI::elementsize.width() + 2.0f * padding, y);
+ }
+
+
}
void ButtonMenu::clear()
@@ -70,23 +79,4 @@ void ButtonMenu::clear()
}
-bool ButtonMenu::on_keypress(const int key, const unsigned int modifier)
-{
- switch (key) {
-
- case SDLK_ESCAPE:
- // close window on ESC
- if (visible()) {
- this->hide();
- return true;
- }
- break;
-
- default:
- break;
- }
-
- return Window::on_keypress(key, modifier);
-}
-
}