[aseprite] 06/134: Add option to enable/disable automatic menu bar items popup (related to issue #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 bb24d8b995600f47a8fd42ea9847f17ca5ea8347
Author: David Capello <davidcapello at gmail.com>
Date:   Sat Oct 25 11:24:29 2014 -0300

    Add option to enable/disable automatic menu bar items popup (related to issue #501)
---
 data/widgets/options.xml         |  1 +
 src/app/commands/cmd_options.cpp | 11 +++++++++++
 src/ui/menu.cpp                  | 28 +++++++++++++++++++++++++++-
 src/ui/menu.h                    |  6 ++++++
 4 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/data/widgets/options.xml b/data/widgets/options.xml
index f140d50..3659d0f 100644
--- a/data/widgets/options.xml
+++ b/data/widgets/options.xml
@@ -22,6 +22,7 @@
             <combobox id="screen_scale" />
           </hbox>
           <check text="Show timeline automatically" id="autotimeline" tooltip="Show the timeline automatically
when a new frame or layer is added." />
+          <check text="Expand menu bar items on mouseover" id="expand_menubar_on_mouseover" tooltip="Check this option to get
this old menus behavior." />
           <separator horizontal="true" />
           <link id="locate_file" text="Locate Configuration File" />
           <link id="locate_crash_folder" text="Locate Crash Folder" />
diff --git a/src/app/commands/cmd_options.cpp b/src/app/commands/cmd_options.cpp
index eb700c8..3af8ee7 100644
--- a/src/app/commands/cmd_options.cpp
+++ b/src/app/commands/cmd_options.cpp
@@ -74,6 +74,10 @@ public:
     if (get_config_bool("Options", "AutoShowTimeline", true))
       autotimeline()->setSelected(true);
 
+    if (get_config_bool("Options", "ExpandMenuBarOnMouseover",
+        ui::MenuBar::expandOnMouseover()))
+      expandMenubarOnMouseover()->setSelected(true);
+
     if (m_settings->experimental()->useNativeCursor())
       nativeCursor()->setSelected(true);
 
@@ -143,6 +147,10 @@ public:
 
     set_config_bool("Options", "AutoShowTimeline", autotimeline()->isSelected());
 
+    bool expandOnMouseover = expandMenubarOnMouseover()->isSelected();
+    set_config_bool("Options", "ExpandMenuBarOnMouseover", expandOnMouseover);
+    ui::MenuBar::setExpandOnMouseover(expandOnMouseover);
+
     m_settings->setShowSpriteEditorScrollbars(showScrollbars()->isSelected());
     m_settings->setZoomWithScrollWheel(wheelZoom()->isSelected());
     m_settings->setRightClickMode(static_cast<RightClickMode>(rightClickBehavior()->getSelectedItemIndex()));
@@ -223,6 +231,9 @@ OptionsCommand::OptionsCommand()
             "Options",
             CmdUIOnlyFlag)
 {
+  ui::MenuBar::setExpandOnMouseover(
+    get_config_bool("Options", "ExpandMenuBarOnMouseover",
+      ui::MenuBar::expandOnMouseover()));
 }
 
 void OptionsCommand::onExecute(Context* context)
diff --git a/src/ui/menu.cpp b/src/ui/menu.cpp
index facd40d..51a7e93 100644
--- a/src/ui/menu.cpp
+++ b/src/ui/menu.cpp
@@ -123,6 +123,9 @@ static MenuItem* check_for_letter(Menu* menu, int ascii);
 static MenuItem* find_nextitem(Menu* menu, MenuItem* menuitem);
 static MenuItem* find_previtem(Menu* menu, MenuItem* menuitem);
 
+//////////////////////////////////////////////////////////////////////
+// Menu
+
 Menu::Menu()
   : Widget(kMenuWidget)
   , m_menuitem(NULL)
@@ -142,6 +145,9 @@ Menu::~Menu()
   }
 }
 
+//////////////////////////////////////////////////////////////////////
+// MenuBox
+
 MenuBox::MenuBox(WidgetType type)
  : Widget(type)
  , m_base(NULL)
@@ -160,12 +166,32 @@ MenuBox::~MenuBox()
   delete m_base;
 }
 
+//////////////////////////////////////////////////////////////////////
+// MenuBar
+
+bool MenuBar::m_expandOnMouseover = false;
+
 MenuBar::MenuBar()
   : MenuBox(kMenuBarWidget)
 {
   createBase();
 }
 
+// static
+bool MenuBar::expandOnMouseover()
+{
+  return m_expandOnMouseover;
+}
+
+// static
+void MenuBar::setExpandOnMouseover(bool state)
+{
+  m_expandOnMouseover = state;
+}
+
+//////////////////////////////////////////////////////////////////////
+// MenuItem
+
 MenuItem::MenuItem(const std::string& text)
   : Widget(kMenuItemWidget)
 {
@@ -687,7 +713,7 @@ 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...
-        if (!inBar())
+        if (!inBar() || MenuBar::expandOnMouseover())
           startTimer();
       }
       break;
diff --git a/src/ui/menu.h b/src/ui/menu.h
index e0befb8..6547892 100644
--- a/src/ui/menu.h
+++ b/src/ui/menu.h
@@ -88,6 +88,12 @@ namespace ui {
   class MenuBar : public MenuBox {
   public:
     MenuBar();
+
+    static bool expandOnMouseover();
+    static void setExpandOnMouseover(bool state);
+
+  private:
+    static bool m_expandOnMouseover;
   };
 
   class MenuItem : public Widget {

-- 
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