summaryrefslogtreecommitdiff
path: root/src/FbTk/Menu.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/Menu.cc')
-rw-r--r--src/FbTk/Menu.cc25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index ded5dab..d44612e 100644
--- a/src/FbTk/Menu.cc
+++ b/src/FbTk/Menu.cc
@@ -220,7 +220,7 @@ int Menu::insert(MenuItem *item, int pos) {
220 menuitems.insert(menuitems.begin() + pos, item); 220 menuitems.insert(menuitems.begin() + pos, item);
221 fixMenuItemIndices(); 221 fixMenuItemIndices();
222 if (m_active_index >= pos) 222 if (m_active_index >= pos)
223 m_active_index++; 223 setActive(m_active_index + 1);
224 } 224 }
225 m_need_update = true; // we need to redraw the menu 225 m_need_update = true; // we need to redraw the menu
226 return menuitems.size(); 226 return menuitems.size();
@@ -274,7 +274,7 @@ int Menu::remove(unsigned int index) {
274 m_which_sub--; 274 m_which_sub--;
275 275
276 if (static_cast<unsigned int>(m_active_index) > index) 276 if (static_cast<unsigned int>(m_active_index) > index)
277 m_active_index--; 277 setActive(m_active_index-1);
278 278
279 m_need_update = true; // we need to redraw the menu 279 m_need_update = true; // we need to redraw the menu
280 280
@@ -335,7 +335,7 @@ void Menu::cycleItems(bool reverse) {
335void Menu::setActiveIndex(int new_index) { 335void Menu::setActiveIndex(int new_index) {
336 // clear the items and close any open submenus 336 // clear the items and close any open submenus
337 int old_active_index = m_active_index; 337 int old_active_index = m_active_index;
338 m_active_index = new_index; 338 setActive(new_index);
339 if (validIndex(old_active_index) && 339 if (validIndex(old_active_index) &&
340 menuitems[old_active_index] != 0) { 340 menuitems[old_active_index] != 0) {
341 if (menuitems[old_active_index]->submenu()) { 341 if (menuitems[old_active_index]->submenu()) {
@@ -361,7 +361,7 @@ void Menu::enterSubmenu() {
361 361
362 drawSubmenu(m_active_index); 362 drawSubmenu(m_active_index);
363 submenu->grabInputFocus(); 363 submenu->grabInputFocus();
364 submenu->m_active_index = -1; // so we land on 0 after nextItem() 364 submenu->setActive(-1); // so we land on 0 after nextItem()
365 submenu->cycleItems(false); 365 submenu->cycleItems(false);
366} 366}
367 367
@@ -386,11 +386,11 @@ void Menu::updateMenu() {
386 for (size_t i = 1; i < menuitems.size(); i++) { 386 for (size_t i = 1; i < menuitems.size(); i++) {
387 if (validIndex(m_active_index + i) && 387 if (validIndex(m_active_index + i) &&
388 menuitems[m_active_index + i]->isEnabled()) { 388 menuitems[m_active_index + i]->isEnabled()) {
389 m_active_index += i; 389 setActive(m_active_index + i);
390 break; 390 break;
391 } else if (validIndex(m_active_index - i) && 391 } else if (validIndex(m_active_index - i) &&
392 menuitems[m_active_index - i]->isEnabled()) { 392 menuitems[m_active_index - i]->isEnabled()) {
393 m_active_index -= i; 393 setActive(m_active_index - i);
394 break; 394 break;
395 } 395 }
396 } 396 }
@@ -622,7 +622,7 @@ void Menu::internal_hide(bool first) {
622 // if we have an active index we need to redraw it 622 // if we have an active index we need to redraw it
623 // as non active 623 // as non active
624 int old = m_active_index; 624 int old = m_active_index;
625 m_active_index = -1; 625 setActive(-1);
626 clearItem(old); // clear old area from highlight 626 clearItem(old); // clear old area from highlight
627 627
628 if (shown == this) { 628 if (shown == this) {
@@ -932,7 +932,7 @@ void Menu::buttonReleaseEvent(XButtonEvent &re) {
932 menuitems[w]->click(re.button, re.time, re.state); 932 menuitems[w]->click(re.button, re.time, re.state);
933 } else { 933 } else {
934 int old = m_active_index; 934 int old = m_active_index;
935 m_active_index = w; 935 setActive(w);
936 clearItem(old); 936 clearItem(old);
937 } 937 }
938 clearItem(w); 938 clearItem(w);
@@ -983,7 +983,7 @@ void Menu::motionNotifyEvent(XMotionEvent &me) {
983 983
984 if (itmp->isEnabled()) { 984 if (itmp->isEnabled()) {
985 int old = m_active_index; 985 int old = m_active_index;
986 m_active_index = w; 986 setActive(w);
987 clearItem(w); 987 clearItem(w);
988 clearItem(old); 988 clearItem(old);
989 989
@@ -1148,7 +1148,7 @@ void Menu::leaveNotifyEvent(XCrossingEvent &ce) {
1148 if (validIndex(m_which_sub) && m_active_index != m_which_sub && 1148 if (validIndex(m_which_sub) && m_active_index != m_which_sub &&
1149 menuitems[m_which_sub]->submenu()->isVisible()) { 1149 menuitems[m_which_sub]->submenu()->isVisible()) {
1150 int old = m_active_index; 1150 int old = m_active_index;
1151 m_active_index = m_which_sub; 1151 setActive(m_which_sub);
1152 clearItem(m_active_index); 1152 clearItem(m_active_index);
1153 clearItem(old); 1153 clearItem(old);
1154 menuitems[m_which_sub]->submenu()->stopHide(); 1154 menuitems[m_which_sub]->submenu()->stopHide();
@@ -1280,6 +1280,8 @@ void Menu::clearItem(int index, bool clear, int search_index) {
1280 true, false, item_x, item_y, 1280 true, false, item_x, item_y,
1281 item_w, item_h); 1281 item_w, item_h);
1282 1282
1283 item->setActive(highlight);
1284
1283 if (search_index < (int)m_matches.size()) 1285 if (search_index < (int)m_matches.size())
1284 drawLine(index, m_type_ahead.stringSize()); 1286 drawLine(index, m_type_ahead.stringSize());
1285} 1287}
@@ -1313,6 +1315,9 @@ void Menu::highlightItem(int index) {
1313 item_x, item_y, 1315 item_x, item_y,
1314 item_w, item_h); 1316 item_w, item_h);
1315 1317
1318 MenuItem *item = menuitems[index];
1319 if (item)
1320 item->setActive(true);
1316} 1321}
1317 1322
1318void Menu::resetTypeAhead() { 1323void Menu::resetTypeAhead() {