diff options
Diffstat (limited to 'src/AlphaMenu.hh')
-rw-r--r-- | src/AlphaMenu.hh | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/src/AlphaMenu.hh b/src/AlphaMenu.hh index 70f9c50..19df646 100644 --- a/src/AlphaMenu.hh +++ b/src/AlphaMenu.hh | |||
@@ -26,56 +26,40 @@ | |||
26 | #define ALPHAMENU_HH | 26 | #define ALPHAMENU_HH |
27 | 27 | ||
28 | #include "ToggleMenu.hh" | 28 | #include "ToggleMenu.hh" |
29 | #include "WindowCmd.hh" | ||
29 | #include "FbTk/MenuItem.hh" | 30 | #include "FbTk/MenuItem.hh" |
30 | #include "ObjectResource.hh" | ||
31 | |||
32 | class AlphaObject { | ||
33 | public: | ||
34 | |||
35 | virtual int getFocusedAlpha() const = 0; | ||
36 | virtual int getUnfocusedAlpha() const = 0; | ||
37 | virtual bool getUseDefaultAlpha() const = 0; | ||
38 | |||
39 | virtual void setFocusedAlpha(int alpha) = 0; | ||
40 | virtual void setUnfocusedAlpha(int alpha) = 0; | ||
41 | virtual void setDefaultAlpha() = 0; | ||
42 | |||
43 | virtual ~AlphaObject() {}; | ||
44 | }; | ||
45 | |||
46 | 31 | ||
47 | class AlphaMenu : public ToggleMenu { | 32 | class AlphaMenu : public ToggleMenu { |
48 | public: | 33 | public: |
49 | AlphaMenu(MenuTheme &tm, FbTk::ImageControl &imgctrl, | 34 | AlphaMenu(MenuTheme &tm, FbTk::ImageControl &imgctrl, |
50 | FbTk::XLayer &layer, AlphaObject &object); | 35 | FbTk::XLayer &layer); |
51 | 36 | ||
52 | // we override these to update the menu when the active window changes | 37 | // we override these to update the menu when the active window changes |
53 | void move(int x, int y); | 38 | void move(int x, int y); |
54 | void show(); | 39 | void show(); |
55 | |||
56 | ObjectResource<AlphaObject, int> m_focused_alpha_resource; | ||
57 | ObjectResource<AlphaObject, int> m_unfocused_alpha_resource; | ||
58 | |||
59 | }; | 40 | }; |
60 | 41 | ||
61 | class AlphaMenuSelectItem : public FbTk::MenuItem { | 42 | class AlphaMenuSelectItem : public FbTk::MenuItem { |
62 | 43 | ||
63 | public: | 44 | public: |
64 | AlphaMenuSelectItem(const FbTk::FbString &label, AlphaObject *object, AlphaMenu &parent): | 45 | AlphaMenuSelectItem(const FbTk::FbString &label, AlphaMenu &parent): |
65 | FbTk::MenuItem(label), m_object(object), m_parent(parent) { | 46 | FbTk::MenuItem(label), m_parent(parent) { |
66 | setToggleItem(true); | 47 | setToggleItem(true); |
67 | setCloseOnClick(false); | 48 | setCloseOnClick(false); |
68 | } | 49 | } |
69 | 50 | ||
70 | bool isSelected() const { return m_object->getUseDefaultAlpha(); } | 51 | bool isSelected() const { |
52 | static ConstWindowAccessor<bool> s_is_default(&FluxboxWindow::getUseDefaultAlpha, true); | ||
53 | return s_is_default; | ||
54 | } | ||
71 | void click(int button, int time, unsigned int mods) { | 55 | void click(int button, int time, unsigned int mods) { |
72 | m_object->setDefaultAlpha(); | 56 | static WindowCmd<void> s_set_default(&FluxboxWindow::setDefaultAlpha); |
57 | s_set_default.execute(); | ||
73 | m_parent.show(); // cheat to refreshing the window | 58 | m_parent.show(); // cheat to refreshing the window |
74 | FbTk::MenuItem::click(button, time, mods); | 59 | FbTk::MenuItem::click(button, time, mods); |
75 | } | 60 | } |
76 | 61 | ||
77 | private: | 62 | private: |
78 | AlphaObject *m_object; | ||
79 | AlphaMenu &m_parent; | 63 | AlphaMenu &m_parent; |
80 | }; | 64 | }; |
81 | 65 | ||