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.cc37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/FbTk/Menu.cc b/src/FbTk/Menu.cc
index 23efcfe..4c41161 100644
--- a/src/FbTk/Menu.cc
+++ b/src/FbTk/Menu.cc
@@ -207,7 +207,6 @@ int Menu::insert(const FbString &label, int pos) {
207} 207}
208 208
209int Menu::insert(const FbString &label, Menu *submenu, int pos) { 209int Menu::insert(const FbString &label, Menu *submenu, int pos) {
210 submenu->m_parent = this;
211 return insert(new MenuItem(label, submenu), pos); 210 return insert(new MenuItem(label, submenu), pos);
212} 211}
213 212
@@ -516,32 +515,24 @@ void Menu::show() {
516 menu.window.show(); 515 menu.window.show();
517 raise(); 516 raise();
518 517
519 if (! m_parent && shown != this) { 518 if (shown && shown != this && shown != m_parent)
520 if (shown && (! shown->m_torn)) 519 shown->hide(true);
521 shown->hide(); 520 shown = this;
522
523 shown = this;
524 }
525 521
526} 522}
527 523
528 524
529void Menu::hide() { 525void Menu::hide(bool force) {
530 526
531 if (!isVisible()) 527 if (!isVisible() || m_torn && !force)
532 return; 528 return;
533 529
534 // if not m_torn and parent is m_visible, go to first parent 530 // if parent is visible, go to first parent and hide it
535 // and hide it 531 Menu *p = this;
536 if (!m_torn && m_parent && m_parent->isVisible()) { 532 while (p->m_parent && p->m_parent->isVisible())
537 Menu *p = m_parent; 533 p = p->m_parent;
538 534
539 while ((! p->m_torn) && p->m_parent && p->m_parent->isVisible()) 535 p->internal_hide();
540 p = p->m_parent;
541
542 p->internal_hide();
543 } else if (!m_torn) // if we dont have a parent then do hide here
544 internal_hide();
545 536
546} 537}
547 538
@@ -590,7 +581,7 @@ void Menu::internal_hide(bool first) {
590 m_active_index = -1; 581 m_active_index = -1;
591 clearItem(old); // clear old area from highlight 582 clearItem(old); // clear old area from highlight
592 583
593 if (shown && shown->menu.window == menu.window) { 584 if (shown == this) {
594 if (m_parent && m_parent->isVisible()) 585 if (m_parent && m_parent->isVisible())
595 shown = m_parent; 586 shown = m_parent;
596 else 587 else
@@ -604,6 +595,7 @@ void Menu::internal_hide(bool first) {
604 s_focused && !s_focused->isVisible()) 595 s_focused && !s_focused->isVisible())
605 m_parent->grabInputFocus(); 596 m_parent->grabInputFocus();
606 597
598 m_parent = 0;
607 menu.window.hide(); 599 menu.window.hide();
608} 600}
609 601
@@ -1281,4 +1273,9 @@ void Menu::drawLine(int index, int size){
1281 item->drawLine(menu.frame, theme(), size, item_x, item_y, menu.item_w); 1273 item->drawLine(menu.frame, theme(), size, item_x, item_y, menu.item_w);
1282} 1274}
1283 1275
1276void Menu::hideShownMenu(bool force) {
1277 if (shown)
1278 shown->hide(force);
1279}
1280
1284}; // end namespace FbTk 1281}; // end namespace FbTk