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", "Focused Window Alpha",
"Transparency level of the focused window"); "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); 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 = const FbTk::FbString unfocused_alpha_label =
_FB_XTEXT(Configmenu, UnfocusedAlpha, _FB_XTEXT(Configmenu, UnfocusedAlpha,
"Unfocused Window Alpha", "Unfocused Window Alpha",
"Transparency level of unfocused windows"); "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); 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, const FbTk::FbString usedefault_label = _FB_XTEXT(Windowmenu, DefaultAlpha,
"Use Defaults", "Use Defaults",
@ -79,18 +79,16 @@ void AlphaMenu::move(int x, int y) {
FbTk::Menu::move(x, y); FbTk::Menu::move(x, y);
if (isVisible()) { if (isVisible()) {
// TODO: hardcoding the indices is a bad idea m_focused_alpha_item->updateLabel();
((FbTk::IntMenuItem *)find(0))->updateLabel(); m_unfocused_alpha_item->updateLabel();
((FbTk::IntMenuItem *)find(1))->updateLabel();
frameWindow().updateBackground(false); frameWindow().updateBackground(false);
FbTk::Menu::clearWindow(); FbTk::Menu::clearWindow();
} }
} }
void AlphaMenu::show() { void AlphaMenu::show() {
// TODO: hardcoding the indices is a bad idea m_focused_alpha_item->updateLabel();
((FbTk::IntMenuItem *)find(0))->updateLabel(); m_unfocused_alpha_item->updateLabel();
((FbTk::IntMenuItem *)find(1))->updateLabel();
frameWindow().updateBackground(false); frameWindow().updateBackground(false);
FbTk::Menu::clearWindow(); FbTk::Menu::clearWindow();

View file

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