aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/Menu.cc
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-09-22 05:32:02 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-09-22 05:32:02 (GMT)
commit3f33657fb721645292f798480e9e0b46d64aedf8 (patch)
tree71f3e5d97e984bbdf69ae6c3a3cf9fc72d060a69 /src/FbTk/Menu.cc
parented53f3c623e7c3ae35672b33ae3b52759dc1a6ed (diff)
downloadfluxbox-3f33657fb721645292f798480e9e0b46d64aedf8.zip
fluxbox-3f33657fb721645292f798480e9e0b46d64aedf8.tar.bz2
fix active menu item when inserting or removing other items
Diffstat (limited to 'src/FbTk/Menu.cc')
-rw-r--r--src/FbTk/Menu.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index 7d50302..7cb5599 100644
--- a/src/FbTk/Menu.cc
+++ b/src/FbTk/Menu.cc
@@ -219,6 +219,8 @@ int Menu::insert(MenuItem *item, int pos) {
219 } else { 219 } else {
220 menuitems.insert(menuitems.begin() + pos, item); 220 menuitems.insert(menuitems.begin() + pos, item);
221 fixMenuItemIndices(); 221 fixMenuItemIndices();
222 if (m_active_index >= pos)
223 m_active_index++;
222 } 224 }
223 m_need_update = true; // we need to redraw the menu 225 m_need_update = true; // we need to redraw the menu
224 return menuitems.size(); 226 return menuitems.size();
@@ -233,7 +235,7 @@ int Menu::remove(unsigned int index) {
233 if (index >= menuitems.size()) { 235 if (index >= menuitems.size()) {
234#ifdef DEBUG 236#ifdef DEBUG
235 cout << "Bad index (" << index << ") given to Menu::remove()" 237 cout << "Bad index (" << index << ") given to Menu::remove()"
236 << " -- should be between 0 and " << menuitems.size() 238 << " -- should be between 0 and " << menuitems.size()-1
237 << " inclusive." << endl; 239 << " inclusive." << endl;
238#endif // DEBUG 240#endif // DEBUG
239 return -1; 241 return -1;
@@ -271,6 +273,9 @@ int Menu::remove(unsigned int index) {
271 else if (static_cast<unsigned int>(m_which_sub) > index) 273 else if (static_cast<unsigned int>(m_which_sub) > index)
272 m_which_sub--; 274 m_which_sub--;
273 275
276 if (static_cast<unsigned int>(m_active_index) > index)
277 m_active_index--;
278
274 m_need_update = true; // we need to redraw the menu 279 m_need_update = true; // we need to redraw the menu
275 280
276 return menuitems.size(); 281 return menuitems.size();
@@ -366,7 +371,7 @@ void Menu::enableTitle() {
366 setTitleVisibility(true); 371 setTitleVisibility(true);
367} 372}
368 373
369void Menu::updateMenu(int active_index) { 374void Menu::updateMenu() {
370 if (m_title_vis) { 375 if (m_title_vis) {
371 menu.item_w = theme()->titleFont().textWidth(menu.label, 376 menu.item_w = theme()->titleFont().textWidth(menu.label,
372 menu.label.size()); 377 menu.label.size());