diff options
Diffstat (limited to 'src/FbTk')
-rw-r--r-- | src/FbTk/Menu.cc | 37 | ||||
-rw-r--r-- | src/FbTk/Menu.hh | 3 |
2 files changed, 19 insertions, 21 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 | ||
209 | int Menu::insert(const FbString &label, Menu *submenu, int pos) { | 209 | int 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 | ||
529 | void Menu::hide() { | 525 | void 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 | ||
1276 | void Menu::hideShownMenu(bool force) { | ||
1277 | if (shown) | ||
1278 | shown->hide(force); | ||
1279 | } | ||
1280 | |||
1284 | }; // end namespace FbTk | 1281 | }; // end namespace FbTk |
diff --git a/src/FbTk/Menu.hh b/src/FbTk/Menu.hh index 06af08d..2a84c77 100644 --- a/src/FbTk/Menu.hh +++ b/src/FbTk/Menu.hh | |||
@@ -124,7 +124,7 @@ public: | |||
124 | /// show menu | 124 | /// show menu |
125 | virtual void show(); | 125 | virtual void show(); |
126 | /// hide menu | 126 | /// hide menu |
127 | virtual void hide(); | 127 | virtual void hide(bool force = false); |
128 | virtual void clearWindow(); | 128 | virtual void clearWindow(); |
129 | #ifdef NOT_USED | 129 | #ifdef NOT_USED |
130 | void setActiveIndex(int index) { m_active_index = index; } | 130 | void setActiveIndex(int index) { m_active_index = index; } |
@@ -160,6 +160,7 @@ public: | |||
160 | inline unsigned char alpha() const { return theme().alpha(); } | 160 | inline unsigned char alpha() const { return theme().alpha(); } |
161 | inline static Menu *shownMenu() { return shown; } | 161 | inline static Menu *shownMenu() { return shown; } |
162 | inline static Menu *focused() { return s_focused; } | 162 | inline static Menu *focused() { return s_focused; } |
163 | static void hideShownMenu(bool force = true); | ||
163 | /// @return menuitem at index | 164 | /// @return menuitem at index |
164 | inline const MenuItem *find(unsigned int index) const { return menuitems[index]; } | 165 | inline const MenuItem *find(unsigned int index) const { return menuitems[index]; } |
165 | inline MenuItem *find(unsigned int index) { return menuitems[index]; } | 166 | inline MenuItem *find(unsigned int index) { return menuitems[index]; } |