aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Menu.hh
diff options
context:
space:
mode:
authorMathias Gumz <akira@fluxbox.org>2015-01-16 07:36:49 (GMT)
committerMathias Gumz <akira@fluxbox.org>2015-01-16 07:36:49 (GMT)
commitb4958780650cfab97d4dc694a34c0c77bf99b26d (patch)
tree0982d91e368b1e9f020b606cb0f2b205cd619c4d /src/FbTk/Menu.hh
parentbd9afcafb93382b5b7f32c222594699214581596 (diff)
downloadfluxbox-b4958780650cfab97d4dc694a34c0c77bf99b26d.zip
fluxbox-b4958780650cfab97d4dc694a34c0c77bf99b26d.tar.bz2
Reduce number of allocations for menu creation
Every time either the Slit menu or the Toolbar menu were added to the root menu, the whole root menu was (re)created from scratch. Now we create and remove only the menus needed. Side effect: the position of these menus is now at the end of the root menu and not somewhere in between. If users complaint, I' ll think about it.
Diffstat (limited to 'src/FbTk/Menu.hh')
-rw-r--r--src/FbTk/Menu.hh14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh
index 49893c1..27d5b12 100644
--- a/src/FbTk/Menu.hh
+++ b/src/FbTk/Menu.hh
@@ -45,6 +45,12 @@ template <typename T> class RefCount;
45/// Base class for menus 45/// Base class for menus
46class Menu: public FbTk::EventHandler, FbTk::FbWindowRenderer { 46class Menu: public FbTk::EventHandler, FbTk::FbWindowRenderer {
47public: 47public:
48
49 static Menu* shownMenu();
50 static Menu* focused();
51 static void hideShownMenu();
52
53
48 enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; 54 enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM };
49 enum { RIGHT = 1, LEFT }; 55 enum { RIGHT = 1, LEFT };
50 56
@@ -134,11 +140,13 @@ public:
134 FbTk::ThemeProxy<MenuTheme> &theme() { return m_theme; } 140 FbTk::ThemeProxy<MenuTheme> &theme() { return m_theme; }
135 const FbTk::ThemeProxy<MenuTheme> &theme() const { return m_theme; } 141 const FbTk::ThemeProxy<MenuTheme> &theme() const { return m_theme; }
136 unsigned char alpha() const { return theme()->alpha(); } 142 unsigned char alpha() const { return theme()->alpha(); }
137 static Menu* shownMenu();
138 static Menu* focused();
139 static void hideShownMenu();
140 const MenuItem *find(size_t i) const { return m_items[i]; } 143 const MenuItem *find(size_t i) const { return m_items[i]; }
141 MenuItem *find(size_t i) { return m_items[i]; } 144 MenuItem *find(size_t i) { return m_items[i]; }
145
146 // returns index of 'submenu', it it is in the top most list of
147 // menu items. -1 if no match is found
148 int findSubmenuIndex(const Menu* submenu) const;
149
142 //@} 150 //@}
143 /// @return true if index is valid 151 /// @return true if index is valid
144 bool validIndex(int index) const { return (index < static_cast<int>(numberOfItems()) && index >= 0); } 152 bool validIndex(int index) const { return (index < static_cast<int>(numberOfItems()) && index >= 0); }