mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-28 16:11:35 +00:00
Don't expand MenuBar items on mouseover (fix #501)
This is how menu-bars work on Windows and OS X.
This commit is contained in:
parent
bac579b774
commit
3e18efcd8b
@ -687,7 +687,8 @@ bool MenuItem::onProcessMessage(Message* msg)
|
|||||||
// When a menu item receives the mouse, start a timer to open the submenu...
|
// When a menu item receives the mouse, start a timer to open the submenu...
|
||||||
if (isEnabled() && hasSubmenu()) {
|
if (isEnabled() && hasSubmenu()) {
|
||||||
// Start the timer to open the submenu...
|
// Start the timer to open the submenu...
|
||||||
startTimer();
|
if (!inBar())
|
||||||
|
startTimer();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -721,7 +722,7 @@ bool MenuItem::onProcessMessage(Message* msg)
|
|||||||
// Menubox position
|
// Menubox position
|
||||||
Rect pos = window->getBounds();
|
Rect pos = window->getBounds();
|
||||||
|
|
||||||
if (this->getParent()->getParent()->type == kMenuBarWidget) {
|
if (inBar()) {
|
||||||
pos.x = MID(0, getBounds().x, ui::display_w()-pos.w);
|
pos.x = MID(0, getBounds().x, ui::display_w()-pos.w);
|
||||||
pos.y = MID(0, getBounds().y2(), ui::display_h()-pos.h);
|
pos.y = MID(0, getBounds().y2(), ui::display_h()-pos.h);
|
||||||
}
|
}
|
||||||
@ -870,15 +871,12 @@ void MenuItem::onClick()
|
|||||||
void MenuItem::onPreferredSize(PreferredSizeEvent& ev)
|
void MenuItem::onPreferredSize(PreferredSizeEvent& ev)
|
||||||
{
|
{
|
||||||
Size size(0, 0);
|
Size size(0, 0);
|
||||||
bool bar = (getParent() &&
|
|
||||||
getParent()->getParent() &&
|
|
||||||
getParent()->getParent()->type == kMenuBarWidget);
|
|
||||||
|
|
||||||
if (hasText()) {
|
if (hasText()) {
|
||||||
size.w =
|
size.w =
|
||||||
+ this->border_width.l
|
+ this->border_width.l
|
||||||
+ getTextWidth()
|
+ getTextWidth()
|
||||||
+ (bar ? this->child_spacing/4: this->child_spacing)
|
+ (inBar() ? this->child_spacing/4: this->child_spacing)
|
||||||
+ this->border_width.r;
|
+ this->border_width.r;
|
||||||
|
|
||||||
size.h =
|
size.h =
|
||||||
@ -1001,6 +999,14 @@ void Menu::unhighlightItem()
|
|||||||
highlightItem(NULL, false, false, false);
|
highlightItem(NULL, false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MenuItem::inBar()
|
||||||
|
{
|
||||||
|
return
|
||||||
|
(getParent() &&
|
||||||
|
getParent()->getParent() &&
|
||||||
|
getParent()->getParent()->type == kMenuBarWidget);
|
||||||
|
}
|
||||||
|
|
||||||
void MenuItem::openSubmenu(bool select_first)
|
void MenuItem::openSubmenu(bool select_first)
|
||||||
{
|
{
|
||||||
Widget* menu;
|
Widget* menu;
|
||||||
|
@ -55,8 +55,7 @@ namespace ui {
|
|||||||
friend class MenuItem;
|
friend class MenuItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MenuBox : public Widget
|
class MenuBox : public Widget {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
MenuBox(WidgetType type = kMenuBoxWidget);
|
MenuBox(WidgetType type = kMenuBoxWidget);
|
||||||
~MenuBox();
|
~MenuBox();
|
||||||
@ -86,14 +85,12 @@ namespace ui {
|
|||||||
friend class Menu;
|
friend class Menu;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MenuBar : public MenuBox
|
class MenuBar : public MenuBox {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
MenuBar();
|
MenuBar();
|
||||||
};
|
};
|
||||||
|
|
||||||
class MenuItem : public Widget
|
class MenuItem : public Widget {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
MenuItem(const std::string& text);
|
MenuItem(const std::string& text);
|
||||||
~MenuItem();
|
~MenuItem();
|
||||||
@ -131,6 +128,7 @@ namespace ui {
|
|||||||
virtual void onClick();
|
virtual void onClick();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool inBar();
|
||||||
void openSubmenu(bool select_first);
|
void openSubmenu(bool select_first);
|
||||||
void closeSubmenu(bool last_of_close_chain);
|
void closeSubmenu(bool last_of_close_chain);
|
||||||
void startTimer();
|
void startTimer();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user