don't use hardcoded references to positions in the menu

This commit is contained in:
Mathias Gumz 2011-02-22 22:17:11 +01:00
parent d11aa42ace
commit 4f921f77f4
2 changed files with 16 additions and 11 deletions

View file

@ -51,18 +51,18 @@ AlphaMenu::AlphaMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm,
"Focused Window Alpha",
"Transparency level of the focused window");
FbTk::MenuItem *focused_alpha_item =
m_focused_alpha_item =
new FbTk::IntMenuItem(focused_alpha_label, m_focused_alpha, 0, 255, *this);
insert(focused_alpha_item);
insert(m_focused_alpha_item);
const FbTk::FbString unfocused_alpha_label =
_FB_XTEXT(Configmenu, UnfocusedAlpha,
"Unfocused Window Alpha",
"Transparency level of unfocused windows");
FbTk::MenuItem *unfocused_alpha_item =
m_unfocused_alpha_item =
new FbTk::IntMenuItem(unfocused_alpha_label, m_unfocused_alpha, 0, 255, *this);
insert(unfocused_alpha_item);
insert(m_unfocused_alpha_item);
const FbTk::FbString usedefault_label = _FB_XTEXT(Windowmenu, DefaultAlpha,
"Use Defaults",
@ -79,18 +79,16 @@ void AlphaMenu::move(int x, int y) {
FbTk::Menu::move(x, y);
if (isVisible()) {
// TODO: hardcoding the indices is a bad idea
((FbTk::IntMenuItem *)find(0))->updateLabel();
((FbTk::IntMenuItem *)find(1))->updateLabel();
m_focused_alpha_item->updateLabel();
m_unfocused_alpha_item->updateLabel();
frameWindow().updateBackground(false);
FbTk::Menu::clearWindow();
}
}
void AlphaMenu::show() {
// TODO: hardcoding the indices is a bad idea
((FbTk::IntMenuItem *)find(0))->updateLabel();
((FbTk::IntMenuItem *)find(1))->updateLabel();
m_focused_alpha_item->updateLabel();
m_unfocused_alpha_item->updateLabel();
frameWindow().updateBackground(false);
FbTk::Menu::clearWindow();

View file

@ -28,6 +28,10 @@
#include "WindowMenuAccessor.hh"
#include "FbTk/MenuItem.hh"
namespace FbTk {
class IntMenuItem;
}
class AlphaMenu : public ToggleMenu {
public:
AlphaMenu(FbTk::ThemeProxy<FbTk::MenuTheme> &tm,
@ -36,6 +40,9 @@ public:
// we override these to update the menu when the active window changes
void move(int x, int y);
void show();
private:
FbTk::IntMenuItem* m_focused_alpha_item;
FbTk::IntMenuItem* m_unfocused_alpha_item;
};
class AlphaMenuSelectItem : public FbTk::MenuItem {