From 4f921f77f459a983a75edb8bd3fb7b0bb2015298 Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Tue, 22 Feb 2011 22:17:11 +0100 Subject: don't use hardcoded references to positions in the menu --- src/AlphaMenu.cc | 20 +++++++++----------- src/AlphaMenu.hh | 7 +++++++ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/AlphaMenu.cc b/src/AlphaMenu.cc index 03aca47..f15c9d1 100644 --- a/src/AlphaMenu.cc +++ b/src/AlphaMenu.cc @@ -51,18 +51,18 @@ AlphaMenu::AlphaMenu(FbTk::ThemeProxy &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(); diff --git a/src/AlphaMenu.hh b/src/AlphaMenu.hh index 833b0d2..27f26dd 100644 --- a/src/AlphaMenu.hh +++ b/src/AlphaMenu.hh @@ -28,6 +28,10 @@ #include "WindowMenuAccessor.hh" #include "FbTk/MenuItem.hh" +namespace FbTk { + class IntMenuItem; +} + class AlphaMenu : public ToggleMenu { public: AlphaMenu(FbTk::ThemeProxy &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 { -- cgit v0.11.2