[aseprite] 03/134: Don't expand MenuBar items on mouseover (fix #501)

Tobias Hansen thansen at moszumanska.debian.org
Sat Mar 14 17:09:53 UTC 2015


This is an automated email from the git hooks/post-receive script.

thansen pushed a commit to branch master
in repository aseprite.

commit 3e18efcd8b7cd08053858eb1692bcea5ca85972e
Author: David Capello <davidcapello at gmail.com>
Date:   Thu Oct 23 11:16:22 2014 -0300

    Don't expand MenuBar items on mouseover (fix #501)
    
    This is how menu-bars work on Windows and OS X.
---
 src/ui/menu.cpp | 18 ++++++++++++------
 src/ui/menu.h   | 10 ++++------
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/src/ui/menu.cpp b/src/ui/menu.cpp
index c7e1823..facd40d 100644
--- a/src/ui/menu.cpp
+++ b/src/ui/menu.cpp
@@ -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;
diff --git a/src/ui/menu.h b/src/ui/menu.h
index b670caf..e0befb8 100644
--- a/src/ui/menu.h
+++ b/src/ui/menu.h
@@ -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();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git



More information about the Pkg-games-commits mailing list