From 104e5e647939c4476d2fdf2185bf186d923bc48d Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 20 May 2015 15:07:17 -0300 Subject: [PATCH] Shift key locks X/Y axis in Move tool (fix #602) --- src/app/ui/editor/moving_cel_state.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/app/ui/editor/moving_cel_state.cpp b/src/app/ui/editor/moving_cel_state.cpp index 9b0eaa38c..e4a027767 100644 --- a/src/app/ui/editor/moving_cel_state.cpp +++ b/src/app/ui/editor/moving_cel_state.cpp @@ -16,6 +16,7 @@ #include "app/document_api.h" #include "app/document_range.h" #include "app/ui/editor/editor.h" +#include "app/ui/editor/editor_customization_delegate.h" #include "app/ui/main_window.h" #include "app/ui/status_bar.h" #include "app/ui/timeline.h" @@ -119,8 +120,18 @@ bool MovingCelState::onMouseUp(Editor* editor, MouseMessage* msg) bool MovingCelState::onMouseMove(Editor* editor, MouseMessage* msg) { gfx::Point newCursorPos = editor->screenToEditor(msg->position()); + gfx::Point delta = newCursorPos - m_mouseStart; - m_celNew = m_celStart - m_mouseStart + newCursorPos; + if (editor->getCustomizationDelegate()->isLockAxisKeyPressed()) { + if (ABS(delta.x) < ABS(delta.y)) { + delta.x = 0; + } + else { + delta.y = 0; + } + } + + m_celNew = m_celStart + delta; if (m_cel) m_cel->setPosition(m_celNew);