Improved title bar menu integration
This commit is contained in:
parent
b576b8dcad
commit
28c4a61997
|
@ -1,3 +1,6 @@
|
||||||
|
2016-06-13 Markus Gans <guru.mail@muenster.de>
|
||||||
|
* Improved title bar menu integration
|
||||||
|
|
||||||
2016-06-12 Markus Gans <guru.mail@muenster.de>
|
2016-06-12 Markus Gans <guru.mail@muenster.de>
|
||||||
* Add a title bar menu to close dialogs
|
* Add a title bar menu to close dialogs
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ void FDialog::init()
|
||||||
|
|
||||||
dialog_menu = new FMenu ("-", this);
|
dialog_menu = new FMenu ("-", this);
|
||||||
dialog_menu->move (xpos, ypos+1);
|
dialog_menu->move (xpos, ypos+1);
|
||||||
|
|
||||||
dgl_menuitem = dialog_menu->getItem();
|
dgl_menuitem = dialog_menu->getItem();
|
||||||
if ( dgl_menuitem )
|
if ( dgl_menuitem )
|
||||||
{
|
{
|
||||||
|
@ -290,6 +290,21 @@ void FDialog::drawTitleBar()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
void FDialog::leaveMenu()
|
||||||
|
{
|
||||||
|
dialog_menu->unselectItem();
|
||||||
|
dialog_menu->hide();
|
||||||
|
activateWindow();
|
||||||
|
raiseWindow();
|
||||||
|
getFocusWidget()->setFocus();
|
||||||
|
redraw();
|
||||||
|
if ( statusBar() )
|
||||||
|
statusBar()->drawMessage();
|
||||||
|
updateTerminal();
|
||||||
|
flush_out();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
void FDialog::cb_close (FWidget*, void*)
|
void FDialog::cb_close (FWidget*, void*)
|
||||||
{
|
{
|
||||||
|
@ -530,16 +545,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
|
||||||
if ( mouse_x < 4 && mouse_y == 1 )
|
if ( mouse_x < 4 && mouse_y == 1 )
|
||||||
{
|
{
|
||||||
if ( dialog_menu->isVisible() )
|
if ( dialog_menu->isVisible() )
|
||||||
{
|
leaveMenu();
|
||||||
dialog_menu->unselectItem();
|
|
||||||
dialog_menu->hide();
|
|
||||||
activateWindow();
|
|
||||||
raiseWindow();
|
|
||||||
getFocusWidget()->setFocus();
|
|
||||||
redraw();
|
|
||||||
if ( statusBar() )
|
|
||||||
statusBar()->drawMessage();
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setOpenMenu(dialog_menu);
|
setOpenMenu(dialog_menu);
|
||||||
|
@ -555,17 +561,7 @@ void FDialog::onMouseDown (FMouseEvent* ev)
|
||||||
{
|
{
|
||||||
// click on titlebar menu button
|
// click on titlebar menu button
|
||||||
if ( mouse_x < 4 && mouse_y == 1 && dialog_menu->isVisible() )
|
if ( mouse_x < 4 && mouse_y == 1 && dialog_menu->isVisible() )
|
||||||
{
|
leaveMenu(); // close menu
|
||||||
// close menu
|
|
||||||
dialog_menu->unselectItem();
|
|
||||||
dialog_menu->hide();
|
|
||||||
activateWindow();
|
|
||||||
raiseWindow();
|
|
||||||
getFocusWidget()->setFocus();
|
|
||||||
redraw();
|
|
||||||
if ( statusBar() )
|
|
||||||
statusBar()->drawMessage();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ev->getButton() == fc::RightButton )
|
if ( ev->getButton() == fc::RightButton )
|
||||||
|
@ -648,7 +644,7 @@ void FDialog::onMouseUp (FMouseEvent* ev)
|
||||||
&& dialog_menu->isVisible()
|
&& dialog_menu->isVisible()
|
||||||
&& ! dialog_menu->hasSelectedItem() )
|
&& ! dialog_menu->hasSelectedItem() )
|
||||||
{
|
{
|
||||||
FMenuItem* first_item;
|
FMenuItem* first_item;
|
||||||
dialog_menu->selectFirstItem();
|
dialog_menu->selectFirstItem();
|
||||||
first_item = dialog_menu->getSelectedItem();
|
first_item = dialog_menu->getSelectedItem();
|
||||||
if ( first_item )
|
if ( first_item )
|
||||||
|
@ -679,7 +675,7 @@ void FDialog::onMouseMove (FMouseEvent* ev)
|
||||||
{
|
{
|
||||||
// Mouse event handover to the menu
|
// Mouse event handover to the menu
|
||||||
const FRect& menu_geometry = dialog_menu->getGeometryGlobal();
|
const FRect& menu_geometry = dialog_menu->getGeometryGlobal();
|
||||||
|
|
||||||
if ( dialog_menu->count() > 0
|
if ( dialog_menu->count() > 0
|
||||||
&& menu_geometry.contains(ev->getGlobalPos()) )
|
&& menu_geometry.contains(ev->getGlobalPos()) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -65,6 +65,7 @@ class FDialog : public FWindow
|
||||||
void init();
|
void init();
|
||||||
void drawBorder();
|
void drawBorder();
|
||||||
void drawTitleBar();
|
void drawTitleBar();
|
||||||
|
void leaveMenu();
|
||||||
void cb_close (FWidget*, void*);
|
void cb_close (FWidget*, void*);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -130,6 +131,9 @@ class FDialog : public FWindow
|
||||||
bool hasShadow();
|
bool hasShadow();
|
||||||
FString getText() const;
|
FString getText() const;
|
||||||
void setText (const FString&);
|
void setText (const FString&);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class FMenu;
|
||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
// Provides: class FMenu
|
// Provides: class FMenu
|
||||||
|
|
||||||
#include "fapp.h"
|
#include "fapp.h"
|
||||||
|
#include "fdialog.h"
|
||||||
#include "fmenu.h"
|
#include "fmenu.h"
|
||||||
#include "fstatusbar.h"
|
#include "fstatusbar.h"
|
||||||
|
|
||||||
|
@ -252,6 +253,12 @@ void FMenu::adjustSize()
|
||||||
//move (adjust_X, ypos);
|
//move (adjust_X, ypos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------
|
||||||
|
bool FMenu::isWindowsMenu (FWidget* w) const
|
||||||
|
{
|
||||||
|
return w->isDialog();
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
bool FMenu::isMenuBar (FWidget* w) const
|
bool FMenu::isMenuBar (FWidget* w) const
|
||||||
{
|
{
|
||||||
|
@ -337,6 +344,11 @@ void FMenu::hideSuperMenus()
|
||||||
m->hide();
|
m->hide();
|
||||||
m->hideSuperMenus();
|
m->hideSuperMenus();
|
||||||
}
|
}
|
||||||
|
else if ( isWindowsMenu(super) )
|
||||||
|
{
|
||||||
|
FDialog* dgl = reinterpret_cast<FDialog*>(super);
|
||||||
|
dgl->leaveMenu();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ class FMenu : public FWindow, public FMenuList
|
||||||
void adjustItems();
|
void adjustItems();
|
||||||
int adjustX(int);
|
int adjustX(int);
|
||||||
void adjustSize();
|
void adjustSize();
|
||||||
|
bool isWindowsMenu (FWidget*) const;
|
||||||
bool isMenuBar (FWidget*) const;
|
bool isMenuBar (FWidget*) const;
|
||||||
bool isMenu (FWidget*) const;
|
bool isMenu (FWidget*) const;
|
||||||
bool isRadioMenuItem (FWidget*) const;
|
bool isRadioMenuItem (FWidget*) const;
|
||||||
|
|
Loading…
Reference in New Issue