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...
|
||||
if (isEnabled() && hasSubmenu()) {
|
||||
// Start the timer to open the submenu...
|
||||
startTimer();
|
||||
if (!inBar())
|
||||
startTimer();
|
||||
}
|
||||
break;
|
||||
|
||||
@ -721,7 +722,7 @@ bool MenuItem::onProcessMessage(Message* msg)
|
||||
// Menubox position
|
||||
Rect pos = window->getBounds();
|
||||
|
||||
if (this->getParent()->getParent()->type == kMenuBarWidget) {
|
||||
if (inBar()) {
|
||||
pos.x = MID(0, getBounds().x, ui::display_w()-pos.w);
|
||||
pos.y = MID(0, getBounds().y2(), ui::display_h()-pos.h);
|
||||
}
|
||||
@ -870,15 +871,12 @@ void MenuItem::onClick()
|
||||
void MenuItem::onPreferredSize(PreferredSizeEvent& ev)
|
||||
{
|
||||
Size size(0, 0);
|
||||
bool bar = (getParent() &&
|
||||
getParent()->getParent() &&
|
||||
getParent()->getParent()->type == kMenuBarWidget);
|
||||
|
||||
if (hasText()) {
|
||||
size.w =
|
||||
+ this->border_width.l
|
||||
+ getTextWidth()
|
||||
+ (bar ? this->child_spacing/4: this->child_spacing)
|
||||
+ (inBar() ? this->child_spacing/4: this->child_spacing)
|
||||
+ this->border_width.r;
|
||||
|
||||
size.h =
|
||||
@ -1001,6 +999,14 @@ void Menu::unhighlightItem()
|
||||
highlightItem(NULL, false, false, false);
|
||||
}
|
||||
|
||||
bool MenuItem::inBar()
|
||||
{
|
||||
return
|
||||
(getParent() &&
|
||||
getParent()->getParent() &&
|
||||
getParent()->getParent()->type == kMenuBarWidget);
|
||||
}
|
||||
|
||||
void MenuItem::openSubmenu(bool select_first)
|
||||
{
|
||||
Widget* menu;
|
||||
|
@ -55,8 +55,7 @@ namespace ui {
|
||||
friend class MenuItem;
|
||||
};
|
||||
|
||||
class MenuBox : public Widget
|
||||
{
|
||||
class MenuBox : public Widget {
|
||||
public:
|
||||
MenuBox(WidgetType type = kMenuBoxWidget);
|
||||
~MenuBox();
|
||||
@ -86,14 +85,12 @@ namespace ui {
|
||||
friend class Menu;
|
||||
};
|
||||
|
||||
class MenuBar : public MenuBox
|
||||
{
|
||||
class MenuBar : public MenuBox {
|
||||
public:
|
||||
MenuBar();
|
||||
};
|
||||
|
||||
class MenuItem : public Widget
|
||||
{
|
||||
class MenuItem : public Widget {
|
||||
public:
|
||||
MenuItem(const std::string& text);
|
||||
~MenuItem();
|
||||
@ -131,6 +128,7 @@ namespace ui {
|
||||
virtual void onClick();
|
||||
|
||||
private:
|
||||
bool inBar();
|
||||
void openSubmenu(bool select_first);
|
||||
void closeSubmenu(bool last_of_close_chain);
|
||||
void startTimer();
|
||||
|
Loading…
x
Reference in New Issue
Block a user