diff --git a/ChangeLog b/ChangeLog index 605fb0fc..51a50cec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2015-10-18 Markus Gans + * Hidden windows are now non-clickable + 2015-10-17 Markus Gans * More faster header inline code * Improve getXTermFont() and getXTermTitle() diff --git a/src/fapp.cpp b/src/fapp.cpp index b5328471..1e19dba9 100644 --- a/src/fapp.cpp +++ b/src/fapp.cpp @@ -948,7 +948,7 @@ void FApplication::processMouseEvent() || b_state.wheel_up == Pressed || b_state.wheel_down == Pressed ) ) { - FWidget* window = FWindow::windowWidgetAt (*mouse); + FWidget* window = FWindow::getWindowWidgetAt (*mouse); if ( window ) { FWidget* child = childWidgetAt (window, *mouse); diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 0f246876..cfe14039 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -165,15 +165,48 @@ bool FMenu::isMenu (FWidget* w) const } //---------------------------------------------------------------------- -FWidget* FMenu::getSuperMenu() const +void FMenu::hideSubMenus() { - return super_menu; + // hide all sub-menus + if ( selectedListItem ) + { + if ( selectedListItem->hasMenu() ) + { + FMenu* m = selectedListItem->getMenu(); + m->hideSubMenus(); + m->hide(); + } + selectedListItem->unsetSelected(); + selectedListItem = 0; + } } //---------------------------------------------------------------------- -void FMenu::setSuperMenu (FWidget* smenu) +void FMenu::hideSuperMenus() { - super_menu = smenu; + // hide all menus to the top + FWidget* super = getSuperMenu(); + if ( super ) + { + if ( isMenuBar(super) ) + { + FMenuBar* mb = reinterpret_cast(super); + FMenuItem* selectedMenuItem = mb->selectedMenuItem; + + if ( selectedMenuItem ) + { + selectedMenuItem->unsetSelected(); + selectedMenuItem = 0; + mb->redraw(); + } + } + else if ( isMenu(super) ) + { + FMenu* m = reinterpret_cast(super); + m->hide(); + m->hideSuperMenus(); + } + } } //---------------------------------------------------------------------- @@ -467,7 +500,6 @@ void FMenu::onMouseUp (FMouseEvent* ev) if ( ! itemlist.empty() ) { std::vector::const_iterator iter, end; - bool focus_changed = false; FPoint mouse_pos; iter = itemlist.begin(); @@ -492,14 +524,14 @@ void FMenu::onMouseUp (FMouseEvent* ev) && mouse_x <= x2 && mouse_y == y ) { + unselectItemInList(); + hide(); + hideSuperMenus(); (*iter)->processClicked(); - focus_changed = true; } } ++iter; } - if ( focus_changed ) - redraw(); } } } @@ -607,7 +639,13 @@ void FMenu::show() //---------------------------------------------------------------------- void FMenu::hide() { - FWindow::hide(); + if ( isVisible() ) + { + FWindow::hide(); + restoreVTerm (getGeometryGlobalShadow()); + updateTerminal(); + flush_out(); + } } //---------------------------------------------------------------------- diff --git a/src/fmenu.h b/src/fmenu.h index 5b82ec3b..32d924c0 100644 --- a/src/fmenu.h +++ b/src/fmenu.h @@ -61,6 +61,8 @@ class FMenu : public FWindow, public FMenuList bool isMenu (FWidget*) const; FWidget* getSuperMenu() const; void setSuperMenu (FWidget*); + void hideSubMenus(); + void hideSuperMenus(); int getHotkeyPos (wchar_t*&, wchar_t*&, uInt); void draw(); void drawBorder(); @@ -112,6 +114,14 @@ class FMenu : public FWindow, public FMenuList // FMenu inline functions +//---------------------------------------------------------------------- +inline FWidget* FMenu::getSuperMenu() const +{ return super_menu; } + +//---------------------------------------------------------------------- +inline void FMenu::setSuperMenu (FWidget* smenu) +{ super_menu = smenu; } + //---------------------------------------------------------------------- inline const char* FMenu::getClassName() const { return "FMenu"; } diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index 6f5410af..7af642c0 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -536,10 +536,9 @@ void FMenuBar::cb_item_activated (FWidget* widget, void*) menu->show(); raiseWindow(menu); menu->redraw(); + updateTerminal(); + flush_out(); } - - updateTerminal(); - flush_out(); } } @@ -551,12 +550,6 @@ void FMenuBar::cb_item_deactivated (FWidget* widget, void*) if ( menuitem->hasMenu() ) { FMenu* menu = menuitem->getMenu(); - if ( menu->isVisible() ) - menu->hide(); - - restoreVTerm (menu->getGeometryGlobalShadow()); - - updateTerminal(); - flush_out(); + menu->hide(); } } diff --git a/src/fmenubar.h b/src/fmenubar.h index 72a002fc..61396079 100644 --- a/src/fmenubar.h +++ b/src/fmenubar.h @@ -76,6 +76,7 @@ class FMenuBar : public FWindow, public FMenuList void cb_item_deactivated (FWidget*, void*); private: + friend class FMenu; friend class FMenuItem; }; #pragma pack(pop) diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index 4f438c26..2affdf3c 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -181,18 +181,6 @@ bool FMenuItem::isMenu (FWidget* w) const , const_cast("FMenu") ) == 0 ); } -//---------------------------------------------------------------------- -FWidget* FMenuItem::getSuperMenu() const -{ - return super_menu; -} - -//---------------------------------------------------------------------- -void FMenuItem::setSuperMenu (FWidget* smenu) -{ - super_menu = smenu; -} - //---------------------------------------------------------------------- void FMenuItem::processActivate() { diff --git a/src/fmenuitem.h b/src/fmenuitem.h index aa6e7f5b..de1cb74e 100644 --- a/src/fmenuitem.h +++ b/src/fmenuitem.h @@ -109,6 +109,14 @@ class FMenuItem : public FWidget // FMenuItem inline functions +//---------------------------------------------------------------------- +inline FWidget* FMenuItem::getSuperMenu() const +{ return super_menu; } + +//---------------------------------------------------------------------- +inline void FMenuItem::setSuperMenu (FWidget* smenu) +{ super_menu = smenu; } + //---------------------------------------------------------------------- inline FString FMenuItem::getText() const { return text; } diff --git a/src/fwindow.cpp b/src/fwindow.cpp index 165434c0..33391487 100644 --- a/src/fwindow.cpp +++ b/src/fwindow.cpp @@ -87,7 +87,7 @@ void FWindow::hide() } //---------------------------------------------------------------------- -FWindow* FWindow::windowWidgetAt(int x, int y) +FWindow* FWindow::getWindowWidgetAt(int x, int y) { if ( statusBar() && statusBar()->getGeometryGlobal().contains(x,y) ) return statusBar(); @@ -104,8 +104,13 @@ FWindow* FWindow::windowWidgetAt(int x, int y) do { --iter; - if ( *iter && (*iter)->getGeometryGlobal().contains(x,y) ) - return static_cast(*iter); + if ( *iter ) + { + FWindow* w = static_cast(*iter); + if ( ! w->isHiddenWindow() + && w->getGeometryGlobal().contains(x,y) ) + return w; + } } while ( iter != begin ); } @@ -361,3 +366,13 @@ bool FWindow::activateWindow(bool on) return window_active = (on) ? true : false; } + +//---------------------------------------------------------------------- +bool FWindow::isHiddenWindow() const +{ + term_area* area = getVWin(); + if ( area ) + return ! area->visible; + else + return false; +} diff --git a/src/fwindow.h b/src/fwindow.h index b6f2ea0e..b06763ab 100644 --- a/src/fwindow.h +++ b/src/fwindow.h @@ -64,8 +64,8 @@ class FWindow : public FWidget const char* getClassName() const; virtual void show(); virtual void hide(); - static FWindow* windowWidgetAt (const FPoint&); - static FWindow* windowWidgetAt (int, int); + static FWindow* getWindowWidgetAt (const FPoint&); + static FWindow* getWindowWidgetAt (int, int); static void addWindow (FWidget*); static void delWindow (FWidget*); static FWindow* getWindowWidget (FWidget*); @@ -82,6 +82,7 @@ class FWindow : public FWidget bool activateWindow(); bool deactivateWindow(); bool isActiveWindow() const; + bool isHiddenWindow() const; }; #pragma pack(pop) @@ -92,8 +93,8 @@ inline const char* FWindow::getClassName() const { return "FWindow"; } //---------------------------------------------------------------------- -inline FWindow* FWindow::windowWidgetAt (const FPoint& pos) -{ return windowWidgetAt(pos.getX(), pos.getY()); } +inline FWindow* FWindow::getWindowWidgetAt (const FPoint& pos) +{ return getWindowWidgetAt (pos.getX(), pos.getY()); } //---------------------------------------------------------------------- inline bool FWindow::raiseWindow() @@ -117,4 +118,3 @@ inline bool FWindow::isActiveWindow() const #endif // _FWINDOW_H -