[aseprite] 22/51: Add support to right-click with Ctrl+left click on OS X (fix #438)

Tobias Hansen thansen at moszumanska.debian.org
Mon Jul 11 21:35:16 UTC 2016


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

thansen pushed a commit to branch master
in repository aseprite.

commit f5c43267fca6770611b842d97410e5baadcda8be
Author: David Capello <davidcapello at gmail.com>
Date:   Wed Jun 29 18:52:09 2016 -0300

    Add support to right-click with Ctrl+left click on OS X (fix #438)
    
    This is only for Tabs and Entry widgets at the moment.
---
 src/app/ui/tabs.cpp |  8 +++++++-
 src/ui/base.h       |  3 ++-
 src/ui/entry.cpp    |  5 +++--
 src/ui/manager.cpp  | 15 ++++++++++++++-
 4 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/src/app/ui/tabs.cpp b/src/app/ui/tabs.cpp
index 8848ed0..e383e25 100644
--- a/src/app/ui/tabs.cpp
+++ b/src/app/ui/tabs.cpp
@@ -62,6 +62,8 @@ Tabs::Tabs(TabsDelegate* delegate)
   , m_dropNewTab(nullptr)
   , m_dropNewIndex(-1)
 {
+  enableFlags(CTRL_RIGHT_CLICK);
+
   setDoubleBuffered(true);
   initTheme();
 
@@ -1003,7 +1005,11 @@ void Tabs::updateDragCopyCursor(ui::Message* msg)
   TabPtr tab = (m_isDragging ? m_dragTab: m_hot);
 
   bool oldDragCopy = m_dragCopy;
-  m_dragCopy = ((msg->ctrlPressed() || msg->altPressed()) &&
+  m_dragCopy = ((
+#if !defined __APPLE__
+                 msg->ctrlPressed() ||
+#endif
+                 msg->altPressed()) &&
                 (tab && m_delegate && m_delegate->canCloneTab(this, tab->view)));
 
   if (oldDragCopy != m_dragCopy) {
diff --git a/src/ui/base.h b/src/ui/base.h
index 5d18d40..1df93d5 100644
--- a/src/ui/base.h
+++ b/src/ui/base.h
@@ -1,5 +1,5 @@
 // Aseprite UI Library
-// Copyright (C) 2001-2013, 2015  David Capello
+// Copyright (C) 2001-2016  David Capello
 //
 // This file is released under the terms of the MIT license.
 // Read LICENSE.txt for more information.
@@ -47,6 +47,7 @@ namespace ui {
     INITIALIZED      = 0x00000400, // The widget was already initialized by a theme.
     DIRTY            = 0x00000800, // The widget (or one child) is dirty (update_region != empty).
     HAS_TEXT         = 0x00001000, // The widget has text (at least setText() was called one time).
+    CTRL_RIGHT_CLICK = 0x00002000, // The widget should transform Ctrl+click to right-click on OS X.
     PROPERTIES_MASK  = 0x0000ffff,
 
     HORIZONTAL       = 0x00010000,
diff --git a/src/ui/entry.cpp b/src/ui/entry.cpp
index c382b09..4c71b3c 100644
--- a/src/ui/entry.cpp
+++ b/src/ui/entry.cpp
@@ -28,7 +28,7 @@
 
 namespace ui {
 
-Entry::Entry(std::size_t maxsize, const char *format, ...)
+Entry::Entry(std::size_t maxsize, const char* format, ...)
   : Widget(kEntryWidget)
   , m_timer(500, this)
   , m_maxsize(maxsize)
@@ -42,9 +42,10 @@ Entry::Entry(std::size_t maxsize, const char *format, ...)
   , m_recent_focused(false)
   , m_lock_selection(false)
 {
-  char buf[4096];
+  enableFlags(CTRL_RIGHT_CLICK);
 
   // formatted string
+  char buf[4096];
   if (format) {
     va_list ap;
     va_start(ap, format);
diff --git a/src/ui/manager.cpp b/src/ui/manager.cpp
index 1317f68..697eed7 100644
--- a/src/ui/manager.cpp
+++ b/src/ui/manager.cpp
@@ -1458,11 +1458,24 @@ Message* Manager::newMouseMessage(
   const gfx::Point& wheelDelta,
   bool preciseWheel)
 {
+#ifdef __APPLE__
+  // Convert Ctrl+left click -> right-click
+  if (widget &&
+      widget->isVisible() &&
+      widget->isEnabled() &&
+      widget->hasFlags(CTRL_RIGHT_CLICK) &&
+      (modifiers & kKeyCtrlModifier) &&
+      (buttons == kButtonLeft)) {
+    modifiers = KeyModifiers(int(modifiers) & ~int(kKeyCtrlModifier));
+    buttons = kButtonRight;
+  }
+#endif
+
   Message* msg = new MouseMessage(
     type, pointerType, buttons, modifiers, mousePos,
     wheelDelta, preciseWheel);
 
-  if (widget != NULL)
+  if (widget)
     msg->addRecipient(widget);
 
   return msg;

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