Hidden windows are now non-clickable

This commit is contained in:
Markus Gans 2015-10-19 00:07:07 +02:00
parent 5708ac5699
commit a478bf6a2a
10 changed files with 96 additions and 40 deletions

View File

@ -1,3 +1,6 @@
2015-10-18 Markus Gans <guru.mail@muenster.de>
* Hidden windows are now non-clickable
2015-10-17 Markus Gans <guru.mail@muenster.de>
* More faster header inline code
* Improve getXTermFont() and getXTermTitle()

View File

@ -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);

View File

@ -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<FMenuBar*>(super);
FMenuItem* selectedMenuItem = mb->selectedMenuItem;
if ( selectedMenuItem )
{
selectedMenuItem->unsetSelected();
selectedMenuItem = 0;
mb->redraw();
}
}
else if ( isMenu(super) )
{
FMenu* m = reinterpret_cast<FMenu*>(super);
m->hide();
m->hideSuperMenus();
}
}
}
//----------------------------------------------------------------------
@ -467,7 +500,6 @@ void FMenu::onMouseUp (FMouseEvent* ev)
if ( ! itemlist.empty() )
{
std::vector<FMenuItem*>::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();
}
}
}
@ -606,8 +638,14 @@ void FMenu::show()
//----------------------------------------------------------------------
void FMenu::hide()
{
if ( isVisible() )
{
FWindow::hide();
restoreVTerm (getGeometryGlobalShadow());
updateTerminal();
flush_out();
}
}
//----------------------------------------------------------------------

View File

@ -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"; }

View File

@ -536,12 +536,11 @@ void FMenuBar::cb_item_activated (FWidget* widget, void*)
menu->show();
raiseWindow(menu);
menu->redraw();
}
updateTerminal();
flush_out();
}
}
}
//----------------------------------------------------------------------
void FMenuBar::cb_item_deactivated (FWidget* widget, void*)
@ -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();
}
}

View File

@ -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)

View File

@ -181,18 +181,6 @@ bool FMenuItem::isMenu (FWidget* w) const
, const_cast<char*>("FMenu") ) == 0 );
}
//----------------------------------------------------------------------
FWidget* FMenuItem::getSuperMenu() const
{
return super_menu;
}
//----------------------------------------------------------------------
void FMenuItem::setSuperMenu (FWidget* smenu)
{
super_menu = smenu;
}
//----------------------------------------------------------------------
void FMenuItem::processActivate()
{

View File

@ -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; }

View File

@ -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<FWindow*>(*iter);
if ( *iter )
{
FWindow* w = static_cast<FWindow*>(*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;
}

View File

@ -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