mirror of
https://github.com/aseprite/aseprite.git
synced 2024-09-15 15:14:16 +00:00
Add new option to zoom sliding two fingers on OS X trackpad
It was requested here: http://steamcommunity.com/app/431730/discussions/2/357286663677659387/
This commit is contained in:
parent
21661a2a5d
commit
af2c2838e0
@ -97,6 +97,7 @@
|
|||||||
</section>
|
</section>
|
||||||
<section id="editor" text="Editor">
|
<section id="editor" text="Editor">
|
||||||
<option id="zoom_with_wheel" type="bool" default="true" migrate="Options.ZoomWithMouseWheel" />
|
<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_wheel" type="bool" default="false" />
|
||||||
<option id="zoom_from_center_with_keys" 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" />
|
<option id="show_scrollbars" type="bool" default="true" migrate="Options.ShowScrollbars" />
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
<vbox id="section_editor">
|
<vbox id="section_editor">
|
||||||
<separator text="Editor" horizontal="true" />
|
<separator text="Editor" horizontal="true" />
|
||||||
<check text="Zoom with scroll wheel" id="wheel_zoom" />
|
<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 scroll wheel" id="zoom_from_center_with_wheel" />
|
||||||
<check text="Zoom from center with keys" id="zoom_from_center_with_keys" />
|
<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." />
|
<check text="Show scroll-bars in sprite editor" id="show_scrollbars" tooltip="Show scroll-bars in all sprite editors." />
|
||||||
|
@ -153,6 +153,13 @@ public:
|
|||||||
// Zoom with Scroll Wheel
|
// Zoom with Scroll Wheel
|
||||||
wheelZoom()->setSelected(m_pref.editor.zoomWithWheel());
|
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
|
// Checked background size
|
||||||
checkedBgSize()->addItem("16x16");
|
checkedBgSize()->addItem("16x16");
|
||||||
checkedBgSize()->addItem("8x8");
|
checkedBgSize()->addItem("8x8");
|
||||||
@ -214,6 +221,9 @@ public:
|
|||||||
m_pref.editor.zoomFromCenterWithKeys(zoomFromCenterWithKeys()->isSelected());
|
m_pref.editor.zoomFromCenterWithKeys(zoomFromCenterWithKeys()->isSelected());
|
||||||
m_pref.editor.showScrollbars(showScrollbars()->isSelected());
|
m_pref.editor.showScrollbars(showScrollbars()->isSelected());
|
||||||
m_pref.editor.zoomWithWheel(wheelZoom()->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.rightClickMode(static_cast<app::gen::RightClickMode>(rightClickBehavior()->getSelectedItemIndex()));
|
||||||
m_pref.editor.cursorColor(m_cursorColor->getColor());
|
m_pref.editor.cursorColor(m_cursorColor->getColor());
|
||||||
m_pref.editor.brushPreview(static_cast<app::gen::BrushPreview>(brushPreview()->getSelectedItemIndex()));
|
m_pref.editor.brushPreview(static_cast<app::gen::BrushPreview>(brushPreview()->getSelectedItemIndex()));
|
||||||
|
@ -36,7 +36,8 @@ enum WHEEL_ACTION { WHEEL_NONE,
|
|||||||
|
|
||||||
bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
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;
|
WHEEL_ACTION wheelAction = WHEEL_NONE;
|
||||||
bool scrollBigSteps = false;
|
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
|
// Normal behavior: mouse wheel zooms If the message is from a
|
||||||
// precise wheel i.e. a trackpad/touch-like device, we scroll by
|
// precise wheel i.e. a trackpad/touch-like device, we scroll by
|
||||||
// default.
|
// default.
|
||||||
else if (Preferences::instance().editor.zoomWithWheel() &&
|
else if (Preferences::instance().editor.zoomWithWheel() && !msg->preciseWheel()) {
|
||||||
!msg->preciseWheel()) {
|
|
||||||
if (msg->ctrlPressed())
|
if (msg->ctrlPressed())
|
||||||
wheelAction = WHEEL_FRAME;
|
wheelAction = WHEEL_FRAME;
|
||||||
else if (msg->wheelDelta().x != 0 || msg->shiftPressed())
|
else if (delta.x != 0 || msg->shiftPressed())
|
||||||
wheelAction = WHEEL_HSCROLL;
|
wheelAction = WHEEL_HSCROLL;
|
||||||
else
|
else
|
||||||
wheelAction = WHEEL_ZOOM;
|
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
|
// For laptops, it's convenient to that Ctrl+wheel zoom (because
|
||||||
// it's the "pinch" gesture).
|
// it's the "pinch" gesture).
|
||||||
else {
|
else {
|
||||||
if (msg->ctrlPressed())
|
if (msg->ctrlPressed())
|
||||||
wheelAction = WHEEL_ZOOM;
|
wheelAction = WHEEL_ZOOM;
|
||||||
else if (msg->wheelDelta().x != 0 || msg->shiftPressed())
|
else if (delta.x != 0 || msg->shiftPressed())
|
||||||
wheelAction = WHEEL_HSCROLL;
|
wheelAction = WHEEL_HSCROLL;
|
||||||
else
|
else
|
||||||
wheelAction = WHEEL_VSCROLL;
|
wheelAction = WHEEL_VSCROLL;
|
||||||
@ -131,12 +151,8 @@ bool StateWithWheelBehavior::onMouseWheel(Editor* editor, MouseMessage* msg)
|
|||||||
case WHEEL_VSCROLL: {
|
case WHEEL_VSCROLL: {
|
||||||
View* view = View::getView(editor);
|
View* view = View::getView(editor);
|
||||||
gfx::Point scroll = view->viewScroll();
|
gfx::Point scroll = view->viewScroll();
|
||||||
gfx::Point delta(0, 0);
|
|
||||||
|
|
||||||
if (msg->preciseWheel()) {
|
if (!msg->preciseWheel()) {
|
||||||
delta = msg->wheelDelta();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
gfx::Rect vp = view->viewportBounds();
|
gfx::Rect vp = view->viewportBounds();
|
||||||
|
|
||||||
if (wheelAction == WHEEL_HSCROLL) {
|
if (wheelAction == WHEEL_HSCROLL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user