Add sub-menu support
This commit is contained in:
parent
d8d77f9246
commit
53ada3664c
|
@ -989,7 +989,9 @@ void FMenu::onMouseMove (FMouseEvent* ev)
|
||||||
{
|
{
|
||||||
std::vector<FMenuItem*>::const_iterator iter, end;
|
std::vector<FMenuItem*>::const_iterator iter, end;
|
||||||
bool focus_changed = false;
|
bool focus_changed = false;
|
||||||
|
bool mouse_over_menu = false;
|
||||||
bool mouse_over_submenu = false;
|
bool mouse_over_submenu = false;
|
||||||
|
bool mouse_over_supermenu = false;
|
||||||
bool hide_sub_menu = false;
|
bool hide_sub_menu = false;
|
||||||
FMenu* show_sub_menu = 0;
|
FMenu* show_sub_menu = 0;
|
||||||
FPoint mouse_pos;
|
FPoint mouse_pos;
|
||||||
|
@ -999,6 +1001,9 @@ void FMenu::onMouseMove (FMouseEvent* ev)
|
||||||
mouse_pos = ev->getPos();
|
mouse_pos = ev->getPos();
|
||||||
mouse_pos -= FPoint(getRightPadding(),getTopPadding());
|
mouse_pos -= FPoint(getRightPadding(),getTopPadding());
|
||||||
|
|
||||||
|
if ( getGeometryGlobal().contains(ev->getGlobalPos()) )
|
||||||
|
mouse_over_menu = true;
|
||||||
|
|
||||||
if ( open_sub_menu )
|
if ( open_sub_menu )
|
||||||
{
|
{
|
||||||
const FRect& submenu_geometry = open_sub_menu->getGeometryGlobal();
|
const FRect& submenu_geometry = open_sub_menu->getGeometryGlobal();
|
||||||
|
@ -1006,6 +1011,13 @@ void FMenu::onMouseMove (FMouseEvent* ev)
|
||||||
mouse_over_submenu = true;
|
mouse_over_submenu = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( isSubMenu() )
|
||||||
|
{
|
||||||
|
const FRect& supermenu_geometry = getSuperMenu()->getGeometryGlobal();
|
||||||
|
if ( supermenu_geometry.contains(ev->getGlobalPos()) )
|
||||||
|
mouse_over_supermenu = true;
|
||||||
|
}
|
||||||
|
|
||||||
while ( iter != end )
|
while ( iter != end )
|
||||||
{
|
{
|
||||||
int x1, x2, y, mouse_x, mouse_y;
|
int x1, x2, y, mouse_x, mouse_y;
|
||||||
|
@ -1048,7 +1060,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( getGeometryGlobal().contains(ev->getGlobalPos())
|
if ( mouse_over_menu
|
||||||
&& (*iter)->isEnabled()
|
&& (*iter)->isEnabled()
|
||||||
&& (*iter)->isSelected()
|
&& (*iter)->isSelected()
|
||||||
&& ! mouse_over_submenu )
|
&& ! mouse_over_submenu )
|
||||||
|
@ -1074,8 +1086,19 @@ void FMenu::onMouseMove (FMouseEvent* ev)
|
||||||
setClickedWidget(open_sub_menu);
|
setClickedWidget(open_sub_menu);
|
||||||
open_sub_menu->onMouseMove(ev);
|
open_sub_menu->onMouseMove(ev);
|
||||||
}
|
}
|
||||||
else if ( ! hasSelectedItem() && statusBar()
|
else if ( ! mouse_over_menu && mouse_over_supermenu )
|
||||||
&& getGeometryGlobal().contains(ev->getGlobalPos()) )
|
{
|
||||||
|
// Mouse event handover to super-menu
|
||||||
|
FMenu* smenu = dynamic_cast<FMenu*>(getSuperMenu());
|
||||||
|
const FPoint& g = ev->getGlobalPos();
|
||||||
|
const FPoint& p = smenu->globalToLocalPos(g);
|
||||||
|
int b = ev->getButton();
|
||||||
|
ev = new FMouseEvent (MouseMove_Event, p, g, b);
|
||||||
|
smenu->mouse_down = true;
|
||||||
|
setClickedWidget(smenu);
|
||||||
|
smenu->onMouseMove(ev);
|
||||||
|
}
|
||||||
|
else if ( ! hasSelectedItem() && statusBar() && mouse_over_menu )
|
||||||
{
|
{
|
||||||
// Mouse is over border or separator
|
// Mouse is over border or separator
|
||||||
FString msg = getStatusbarMessage();
|
FString msg = getStatusbarMessage();
|
||||||
|
|
|
@ -698,6 +698,7 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
|
||||||
{
|
{
|
||||||
std::vector<FMenuItem*>::const_iterator iter, end;
|
std::vector<FMenuItem*>::const_iterator iter, end;
|
||||||
int mouse_x, mouse_y;
|
int mouse_x, mouse_y;
|
||||||
|
bool mouse_over_menubar = false;
|
||||||
bool focus_changed = false;
|
bool focus_changed = false;
|
||||||
|
|
||||||
iter = itemlist.begin();
|
iter = itemlist.begin();
|
||||||
|
@ -705,6 +706,9 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
|
||||||
mouse_x = ev->getX();
|
mouse_x = ev->getX();
|
||||||
mouse_y = ev->getY();
|
mouse_y = ev->getY();
|
||||||
|
|
||||||
|
if ( getGeometryGlobal().contains(ev->getGlobalPos()) )
|
||||||
|
mouse_over_menubar = true;
|
||||||
|
|
||||||
while ( iter != end )
|
while ( iter != end )
|
||||||
{
|
{
|
||||||
int x1, x2;
|
int x1, x2;
|
||||||
|
@ -746,7 +750,7 @@ void FMenuBar::onMouseMove (FMouseEvent* ev)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( getGeometryGlobal().contains(ev->getGlobalPos())
|
if ( mouse_over_menubar
|
||||||
&& (*iter)->isEnabled()
|
&& (*iter)->isEnabled()
|
||||||
&& (*iter)->isSelected() )
|
&& (*iter)->isSelected() )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue