[aseprite] 55/64: Add new option to zoom sliding two fingers on OS X trackpad
Tobias Hansen
thansen at moszumanska.debian.org
Tue Jun 21 14:43:05 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 af2c2838e00c0a39dd17e95b00150d588f1882ab
Author: David Capello <davidcapello at gmail.com>
Date: Fri May 27 13:15:13 2016 -0300
Add new option to zoom sliding two fingers on OS X trackpad
It was requested here:
http://steamcommunity.com/app/431730/discussions/2/357286663677659387/
---
data/pref.xml | 1 +
data/widgets/options.xml | 1 +
src/app/commands/cmd_options.cpp | 10 +++++++
src/app/ui/editor/state_with_wheel_behavior.cpp | 36 ++++++++++++++++++-------
4 files changed, 38 insertions(+), 10 deletions(-)
diff --git a/data/pref.xml b/data/pref.xml
index b7cc6e4..88513ab 100644
--- a/data/pref.xml
+++ b/data/pref.xml
@@ -97,6 +97,7 @@
</section>
<section id="editor" text="Editor">
<option id="zoom_with_wheel" type="bool" default="true" migrate="Options.ZoomWithMouseWheel" />
+ <option id="zoom_with_slide" type="bool" default="false" />
<option id="zoom_from_center_with_wheel" type="bool" default="false" />
<option id="zoom_from_center_with_keys" type="bool" default="false" />
<option id="show_scrollbars" type="bool" default="true" migrate="Options.ShowScrollbars" />
diff --git a/data/widgets/options.xml b/data/widgets/options.xml
index 0773a10..7198fc9 100644
--- a/data/widgets/options.xml
+++ b/data/widgets/options.xml
@@ -59,6 +59,7 @@
<vbox id="section_editor">
<separator text="Editor" horizontal="true" />
<check text="Zoom with scroll wheel" id="wheel_zoom" />
+ <check text="Zoom sliding two fingers up or down" id="slide_zoom" />
<check text="Zoom from center with scroll wheel" id="zoom_from_center_with_wheel" />
<check text="Zoom from center with keys" id="zoom_from_center_with_keys" />
<check text="Show scroll-bars in sprite editor" id="show_scrollbars" tooltip="Show scroll-bars in all sprite editors." />
diff --git a/src/app/commands/cmd_options.cpp b/src/app/commands/cmd_options.cpp
index c0fd221..a1c3397 100644
--- a/src/app/commands/cmd_options.cpp
+++ b/src/app/commands/cmd_options.cpp
@@ -153,6 +153,13 @@ public:
// Zoom with Scroll Wheel
wheelZoom()->setSelected(m_pref.editor.zoomWithWheel());
+ // Zoom sliding two fingers
+#if __APPLE__
+ slideZoom()->setSelected(m_pref.editor.zoomWithSlide());
+#else
+ slideZoom()->setVisible(false);
+#endif
+
// Checked background size
checkedBgSize()->addItem("16x16");
checkedBgSize()->addItem("8x8");
@@ -214,6 +221,9 @@ public:
m_pref.editor.zoomFromCenterWithKeys(zoomFromCenterWithKeys()->isSelected());
m_pref.editor.showScrollbars(showScrollbars()->isSelected());
m_pref.editor.zoomWithWheel(wheelZoom()->isSelected());
+#if __APPLE__
+ m_pref.editor.zoomWithSlide(slideZoom()->isSelected());
+#endif
m_pref.editor.rightClickMode(static_cast<app::gen::RightClickMode>(rightClickBehavior()->getSelectedItemIndex()));
m_pref.editor.cursorColor(m_cursorColor->getColor());
m_pref.editor.brushPreview(static_cast<app::gen::BrushPreview>(brushPreview()->getSelectedItemIndex()));
diff --git a/src/app/ui/editor/state_with_wheel_behavior.cpp b/src/app/ui/editor/state_with_wheel_behavior.cpp
index f1f8ec4..a29759a 100644
--- a/src/app/ui/editor/state_with_wheel_behavior.cpp
+++ b/src/app/ui/editor/state_with_wheel_behavior.cpp
@@ -36,7 +36,8 @@ enum WHEEL_ACTION { WHEEL_NONE,
bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
{
- double dz = msg->wheelDelta().x + msg->wheelDelta().y;
+ gfx::Point delta = msg->wheelDelta();
+ double dz = delta.x + delta.y;
WHEEL_ACTION wheelAction = WHEEL_NONE;
bool scrollBigSteps = false;
@@ -50,21 +51,40 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
// Normal behavior: mouse wheel zooms If the message is from a
// precise wheel i.e. a trackpad/touch-like device, we scroll by
// default.
- else if (Preferences::instance().editor.zoomWithWheel() &&
- !msg->preciseWheel()) {
+ else if (Preferences::instance().editor.zoomWithWheel() && !msg->preciseWheel()) {
if (msg->ctrlPressed())
wheelAction = WHEEL_FRAME;
- else if (msg->wheelDelta().x != 0 || msg->shiftPressed())
+ else if (delta.x != 0 || msg->shiftPressed())
wheelAction = WHEEL_HSCROLL;
else
wheelAction = WHEEL_ZOOM;
}
+ // Zoom sliding two fingers
+ else if (Preferences::instance().editor.zoomWithSlide() && msg->preciseWheel()) {
+ if (msg->ctrlPressed())
+ wheelAction = WHEEL_FRAME;
+ else if (std::abs(delta.x) > std::abs(delta.y)) {
+ delta.y = 0;
+ dz = delta.x;
+ wheelAction = WHEEL_HSCROLL;
+ }
+ else if (msg->shiftPressed()) {
+ delta.x = 0;
+ dz = delta.y;
+ wheelAction = WHEEL_VSCROLL;
+ }
+ else {
+ delta.x = 0;
+ dz = delta.y;
+ wheelAction = WHEEL_ZOOM;
+ }
+ }
// For laptops, it's convenient to that Ctrl+wheel zoom (because
// it's the "pinch" gesture).
else {
if (msg->ctrlPressed())
wheelAction = WHEEL_ZOOM;
- else if (msg->wheelDelta().x != 0 || msg->shiftPressed())
+ else if (delta.x != 0 || msg->shiftPressed())
wheelAction = WHEEL_HSCROLL;
else
wheelAction = WHEEL_VSCROLL;
@@ -131,12 +151,8 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
case WHEEL_VSCROLL: {
View* view = View::getView(editor);
gfx::Point scroll = view->viewScroll();
- gfx::Point delta(0, 0);
- if (msg->preciseWheel()) {
- delta = msg->wheelDelta();
- }
- else {
+ if (!msg->preciseWheel()) {
gfx::Rect vp = view->viewportBounds();
if (wheelAction == WHEEL_HSCROLL) {
--
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