mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-30 06:32:42 +00:00
Add extra KeyContexts for each selection transformation
This commit is contained in:
parent
adce0b9569
commit
74e642d997
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -33,8 +33,10 @@ namespace app {
|
||||
enum class KeyContext {
|
||||
Any,
|
||||
Normal,
|
||||
Selection,
|
||||
MovingPixels,
|
||||
SelectionTool,
|
||||
TranslatingSelection,
|
||||
ScalingSelection,
|
||||
RotatingSelection,
|
||||
MoveTool,
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user