all repos — fluxbox @ 4f921f77f459a983a75edb8bd3fb7b0bb2015298

custom fork of the fluxbox windowmanager

don't use hardcoded references to positions in the menu
Mathias Gumz akira at fluxbox dot org
commit

4f921f77f459a983a75edb8bd3fb7b0bb2015298

parent

d11aa42ace928efc3dd1eebc8988b6bbbc005b2b

2 files changed, 16 insertions(+), 11 deletions(-)

jump to
M src/AlphaMenu.ccsrc/AlphaMenu.cc

@@ -51,18 +51,18 @@ _FB_XTEXT(Configmenu, FocusedAlpha,

"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();
M src/AlphaMenu.hhsrc/AlphaMenu.hh

@@ -28,6 +28,10 @@ #include "WindowCmd.hh"

#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 @@

// 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 {