[aseprite] 32/250: Add extra KeyContexts for each selection transformation
Tobias Hansen
thansen at moszumanska.debian.org
Sun Dec 20 15:27:08 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 74e642d997356a62b84ec39c0b60c3dfe954a27a
Author: David Capello <davidcapello at gmail.com>
Date: Fri Sep 11 20:04:02 2015 -0300
Add extra KeyContexts for each selection transformation
---
src/app/commands/cmd_keyboard_shortcuts.cpp | 16 ++++++++++-----
src/app/ui/editor/editor.cpp | 4 ++--
src/app/ui/editor/moving_cel_state.cpp | 3 ++-
src/app/ui/editor/moving_pixels_state.cpp | 32 +++++++++++++++++++++++++++--
src/app/ui/editor/pixels_movement.h | 2 ++
src/app/ui/editor/standby_state.cpp | 4 ++--
src/app/ui/keyboard_shortcuts.cpp | 30 ++++++++++++++++-----------
src/app/ui/keyboard_shortcuts.h | 6 ++++--
8 files changed, 71 insertions(+), 26 deletions(-)
diff --git a/src/app/commands/cmd_keyboard_shortcuts.cpp b/src/app/commands/cmd_keyboard_shortcuts.cpp
index b2f1d4f..53a9c65 100644
--- a/src/app/commands/cmd_keyboard_shortcuts.cpp
+++ b/src/app/commands/cmd_keyboard_shortcuts.cpp
@@ -327,14 +327,20 @@ private:
for (Key* key : *app::KeyboardShortcuts::instance()) {
std::string text = key->triggerString();
switch (key->keycontext()) {
- case KeyContext::Selection:
- text = "Selection context: " + text;
+ case KeyContext::SelectionTool:
+ text = "Selection Tool: " + text;
break;
- case KeyContext::MovingPixels:
- text = "Moving pixels context: " + text;
+ case KeyContext::TranslatingSelection:
+ text = "Translating Selection: " + text;
+ break;
+ case KeyContext::ScalingSelection:
+ text = "Scaling Selection: " + text;
+ break;
+ case KeyContext::RotatingSelection:
+ text = "Rotating Selection: " + text;
break;
case KeyContext::MoveTool:
- text = "Move tool: " + text;
+ text = "Move Tool: " + text;
break;
}
KeyItem* keyItem = new KeyItem(text, key, NULL, 0);
diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp
index b2b845e..c3e611b 100644
--- a/src/app/ui/editor/editor.cpp
+++ b/src/app/ui/editor/editor.cpp
@@ -1072,7 +1072,7 @@ void Editor::updateQuicktool()
// Don't change quicktools if we are in a selection tool and using
// the selection modifiers.
if (current_tool->getInk(0)->isSelection() &&
- int(m_customizationDelegate->getPressedKeyAction(KeyContext::Selection)) != 0)
+ int(m_customizationDelegate->getPressedKeyAction(KeyContext::SelectionTool)) != 0)
return;
tools::Tool* old_quicktool = m_quicktool;
@@ -1126,7 +1126,7 @@ void Editor::updateContextBarFromModifiers()
KeyAction action = KeyAction::None;
if (m_customizationDelegate)
- action = m_customizationDelegate->getPressedKeyAction(KeyContext::Selection);
+ action = m_customizationDelegate->getPressedKeyAction(KeyContext::SelectionTool);
if (int(action & KeyAction::AddSelection))
mode = tools::SelectionMode::ADD;
diff --git a/src/app/ui/editor/moving_cel_state.cpp b/src/app/ui/editor/moving_cel_state.cpp
index fb72ff1..57145fc 100644
--- a/src/app/ui/editor/moving_cel_state.cpp
+++ b/src/app/ui/editor/moving_cel_state.cpp
@@ -129,7 +129,8 @@ bool MovingCelState::onMouseMove(Editor* editor, MouseMessage* msg)
gfx::Point newCursorPos = editor->screenToEditor(msg->position());
gfx::Point delta = newCursorPos - m_mouseStart;
- if (int(editor->getCustomizationDelegate()->getPressedKeyAction(KeyContext::MovingPixels) & KeyAction::LockAxis)) {
+ if (int(editor->getCustomizationDelegate()
+ ->getPressedKeyAction(KeyContext::TranslatingSelection) & KeyAction::LockAxis)) {
if (ABS(delta.x) < ABS(delta.y)) {
delta.x = 0;
}
diff --git a/src/app/ui/editor/moving_pixels_state.cpp b/src/app/ui/editor/moving_pixels_state.cpp
index 5f54584..890d02c 100644
--- a/src/app/ui/editor/moving_pixels_state.cpp
+++ b/src/app/ui/editor/moving_pixels_state.cpp
@@ -264,7 +264,7 @@ bool MovingPixelsState::onMouseDown(Editor* editor, MouseMessage* msg)
// In case that the user is pressing the copy-selection keyboard shortcut.
EditorCustomizationDelegate* customization = editor->getCustomizationDelegate();
if ((customization) &&
- int(customization->getPressedKeyAction(KeyContext::MovingPixels) & KeyAction::CopySelection)) {
+ int(customization->getPressedKeyAction(KeyContext::TranslatingSelection) & KeyAction::CopySelection)) {
// Stamp the pixels to create the copy.
m_pixelsMovement->stampImage();
}
@@ -315,8 +315,36 @@ bool MovingPixelsState::onMouseMove(Editor* editor, MouseMessage* msg)
gfx::Point spritePos = editor->screenToEditor(mousePos);
// Get the customization for the pixels movement (snap to grid, angle snap, etc.).
+ KeyContext keyContext = KeyContext::Normal;
+ switch (m_pixelsMovement->handle()) {
+ case MoveHandle:
+ keyContext = KeyContext::TranslatingSelection;
+ break;
+ case ScaleNWHandle:
+ case ScaleNHandle:
+ case ScaleNEHandle:
+ case ScaleWHandle:
+ case ScaleEHandle:
+ case ScaleSWHandle:
+ case ScaleSHandle:
+ case ScaleSEHandle:
+ keyContext = KeyContext::ScalingSelection;
+ break;
+ case RotateNWHandle:
+ case RotateNHandle:
+ case RotateNEHandle:
+ case RotateWHandle:
+ case RotateEHandle:
+ case RotateSWHandle:
+ case RotateSHandle:
+ case RotateSEHandle:
+ keyContext = KeyContext::RotatingSelection;
+ break;
+ }
+
PixelsMovement::MoveModifier moveModifier = PixelsMovement::NormalMovement;
- KeyAction action = editor->getCustomizationDelegate()->getPressedKeyAction(KeyContext::MovingPixels);
+ KeyAction action = editor->getCustomizationDelegate()
+ ->getPressedKeyAction(keyContext);
if (int(action & KeyAction::SnapToGrid))
moveModifier |= PixelsMovement::SnapToGridMovement;
diff --git a/src/app/ui/editor/pixels_movement.h b/src/app/ui/editor/pixels_movement.h
index abf6df7..6fb4973 100644
--- a/src/app/ui/editor/pixels_movement.h
+++ b/src/app/ui/editor/pixels_movement.h
@@ -54,6 +54,8 @@ namespace app {
const char* operationName);
~PixelsMovement();
+ HandleType handle() const { return m_handle; }
+
void cutMask();
void copyMask();
void catchImage(const gfx::Point& pos, HandleType handle);
diff --git a/src/app/ui/editor/standby_state.cpp b/src/app/ui/editor/standby_state.cpp
index 21331b5..37c2a63 100644
--- a/src/app/ui/editor/standby_state.cpp
+++ b/src/app/ui/editor/standby_state.cpp
@@ -316,7 +316,7 @@ bool StandbyState::onSetCursor(Editor* editor, const gfx::Point& mouseScreenPos)
if (editor->isInsideSelection()) {
EditorCustomizationDelegate* customization = editor->getCustomizationDelegate();
if ((customization) &&
- int(customization->getPressedKeyAction(KeyContext::MovingPixels) & KeyAction::CopySelection))
+ int(customization->getPressedKeyAction(KeyContext::TranslatingSelection) & KeyAction::CopySelection))
editor->showMouseCursor(kArrowPlusCursor);
else
editor->showMouseCursor(kMoveCursor);
@@ -453,7 +453,7 @@ void StandbyState::transformSelection(Editor* editor, MouseMessage* msg, HandleT
// If the Ctrl key is pressed start dragging a copy of the selection
if ((customization) &&
- int(customization->getPressedKeyAction(KeyContext::MovingPixels) & KeyAction::CopySelection))
+ int(customization->getPressedKeyAction(KeyContext::TranslatingSelection) & KeyAction::CopySelection))
pixelsMovement->copyMask();
else
pixelsMovement->cutMask();
diff --git a/src/app/ui/keyboard_shortcuts.cpp b/src/app/ui/keyboard_shortcuts.cpp
index 0f24f82..23ace88 100644
--- a/src/app/ui/keyboard_shortcuts.cpp
+++ b/src/app/ui/keyboard_shortcuts.cpp
@@ -135,25 +135,25 @@ Key::Key(KeyAction action)
m_keycontext = KeyContext::Any;
break;
case KeyAction::CopySelection:
- m_keycontext = KeyContext::MovingPixels;
+ m_keycontext = KeyContext::TranslatingSelection;
break;
case KeyAction::SnapToGrid:
- m_keycontext = KeyContext::MovingPixels;
+ m_keycontext = KeyContext::TranslatingSelection;
break;
case KeyAction::AngleSnap:
- m_keycontext = KeyContext::MovingPixels;
+ m_keycontext = KeyContext::RotatingSelection;
break;
case KeyAction::MaintainAspectRatio:
- m_keycontext = KeyContext::MovingPixels;
+ m_keycontext = KeyContext::ScalingSelection;
break;
case KeyAction::LockAxis:
- m_keycontext = KeyContext::MovingPixels;
+ m_keycontext = KeyContext::TranslatingSelection;
break;
case KeyAction::AddSelection:
- m_keycontext = KeyContext::Selection;
+ m_keycontext = KeyContext::SelectionTool;
break;
case KeyAction::SubtractSelection:
- m_keycontext = KeyContext::Selection;
+ m_keycontext = KeyContext::SelectionTool;
break;
case KeyAction::AutoSelectLayer:
m_keycontext = KeyContext::MoveTool;
@@ -316,7 +316,7 @@ void KeyboardShortcuts::importFile(TiXmlElement* rootElement, KeySource source)
const char* keycontextstr = xmlKey->Attribute("context");
if (keycontextstr) {
if (strcmp(keycontextstr, "Selection") == 0)
- keycontext = KeyContext::Selection;
+ keycontext = KeyContext::SelectionTool;
else if (strcmp(keycontextstr, "Normal") == 0)
keycontext = KeyContext::Normal;
}
@@ -518,11 +518,17 @@ void KeyboardShortcuts::exportAccel(TiXmlElement& parent, Key* key, const ui::Ac
case KeyContext::Normal:
keycontextStr = "Normal";
break;
- case KeyContext::Selection:
+ case KeyContext::SelectionTool:
keycontextStr = "Selection";
break;
- case KeyContext::MovingPixels:
- keycontextStr = "MovingPixels";
+ case KeyContext::TranslatingSelection:
+ keycontextStr = "TranslatingSelection";
+ break;
+ case KeyContext::ScalingSelection:
+ keycontextStr = "ScalingSelection";
+ break;
+ case KeyContext::RotatingSelection:
+ keycontextStr = "RotatingSelection";
break;
case KeyContext::MoveTool:
keycontextStr = "MoveTool";
@@ -646,7 +652,7 @@ KeyContext KeyboardShortcuts::getCurrentKeyContext()
if (doc &&
doc->isMaskVisible() &&
App::instance()->activeTool()->getInk(0)->isSelection())
- return KeyContext::Selection;
+ return KeyContext::SelectionTool;
else
return KeyContext::Normal;
}
diff --git a/src/app/ui/keyboard_shortcuts.h b/src/app/ui/keyboard_shortcuts.h
index 36bd7f9..35a8f38 100644
--- a/src/app/ui/keyboard_shortcuts.h
+++ b/src/app/ui/keyboard_shortcuts.h
@@ -33,8 +33,10 @@ namespace app {
enum class KeyContext {
Any,
Normal,
- Selection,
- MovingPixels,
+ SelectionTool,
+ TranslatingSelection,
+ ScalingSelection,
+ RotatingSelection,
MoveTool,
};
--
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