mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-27 03:16:58 +00:00
Add "LockAxis" key (Shift) to move the selection in X or Y axis only.
Now "Alt" modifier is the key used to snap to grid the selection.
This commit is contained in:
parent
11d20a6e33
commit
9b9daca59f
@ -196,7 +196,11 @@
|
||||
|
||||
<!-- When you move the selection, pressing this
|
||||
keyboard shortcut you can snap to grid -->
|
||||
<key action="SnapToGrid" shortcut="Shift" />
|
||||
<key action="SnapToGrid" shortcut="Alt" />
|
||||
|
||||
<!-- When you move the selection, pressing this keyboard
|
||||
shortcut so you lock the movement to one axis -->
|
||||
<key action="LockAxis" shortcut="Shift" />
|
||||
|
||||
<!-- When you rotate the selection, pressing this
|
||||
keyboard shortcut you activate angle snap -->
|
||||
|
@ -152,6 +152,14 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isLockAxisKeyPressed() OVERRIDE {
|
||||
JAccel accel = get_accel_to_lock_axis();
|
||||
if (accel)
|
||||
return jaccel_check_from_key(accel);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class MiniEditor : public Editor
|
||||
|
@ -65,6 +65,7 @@
|
||||
#define SPRITEDITOR_ACTION_SNAPTOGRID "SnapToGrid"
|
||||
#define SPRITEDITOR_ACTION_ANGLESNAP "AngleSnap"
|
||||
#define SPRITEDITOR_ACTION_MAINTAINASPECTRATIO "MaintainAspectRatio"
|
||||
#define SPRITEDITOR_ACTION_LOCKAXIS "LockAxis"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -789,6 +790,15 @@ JAccel get_accel_to_maintain_aspect_ratio()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JAccel get_accel_to_lock_axis()
|
||||
{
|
||||
Shortcut* shortcut = get_keyboard_shortcut_for_spriteeditor(SPRITEDITOR_ACTION_LOCKAXIS);
|
||||
if (shortcut)
|
||||
return shortcut->accel;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
tools::Tool* get_selected_quicktool(tools::Tool* currentTool)
|
||||
{
|
||||
if (currentTool && currentTool->getInk(0)->isSelection()) {
|
||||
|
@ -82,6 +82,7 @@ ui::JAccel get_accel_to_copy_selection();
|
||||
ui::JAccel get_accel_to_snap_to_grid();
|
||||
ui::JAccel get_accel_to_angle_snap();
|
||||
ui::JAccel get_accel_to_maintain_aspect_ratio();
|
||||
ui::JAccel get_accel_to_lock_axis();
|
||||
|
||||
tools::Tool* get_selected_quicktool(tools::Tool* currentTool);
|
||||
|
||||
|
@ -51,6 +51,10 @@ public:
|
||||
// Returns true if the user wants to maintain the aspect ratio when
|
||||
// he is scaling the selection.
|
||||
virtual bool isMaintainAspectRatioKeyPressed() = 0;
|
||||
|
||||
// Returns true if the user wants to lock the X or Y axis when he is
|
||||
// dragging the selection.
|
||||
virtual bool isLockAxisKeyPressed() = 0;
|
||||
};
|
||||
|
||||
#endif // WIDGETS_EDITOR_CUSTOMIZATION_DELEGATE_H_INCLUDED
|
||||
|
@ -249,6 +249,9 @@ bool MovingPixelsState::onMouseMove(Editor* editor, Message* msg)
|
||||
if (editor->getCustomizationDelegate()->isMaintainAspectRatioKeyPressed())
|
||||
moveModifier |= PixelsMovement::MaintainAspectRatioMovement;
|
||||
|
||||
if (editor->getCustomizationDelegate()->isLockAxisKeyPressed())
|
||||
moveModifier |= PixelsMovement::LockAxisMovement;
|
||||
|
||||
// Invalidate handles area.
|
||||
Decorator* decorator = static_cast<Decorator*>(editor->getDecorator());
|
||||
TransformHandles* transfHandles = decorator->getTransformHandles(editor);
|
||||
|
@ -216,6 +216,16 @@ gfx::Rect PixelsMovement::moveImage(int x, int y, MoveModifier moveModifier)
|
||||
x2 += gridOffset.x;
|
||||
y2 += gridOffset.y;
|
||||
}
|
||||
else if ((moveModifier & LockAxisMovement) == LockAxisMovement) {
|
||||
if (ABS(dx) < ABS(dy)) {
|
||||
x1 -= dx;
|
||||
x2 -= dx;
|
||||
}
|
||||
else {
|
||||
y1 -= dy;
|
||||
y2 -= dy;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ScaleNWHandle:
|
||||
|
@ -41,7 +41,8 @@ public:
|
||||
NormalMovement = 1,
|
||||
SnapToGridMovement = 2,
|
||||
AngleSnapMovement = 4,
|
||||
MaintainAspectRatioMovement = 8
|
||||
MaintainAspectRatioMovement = 8,
|
||||
LockAxisMovement = 16
|
||||
};
|
||||
|
||||
// The "moveThis" image specifies the chunk of pixels to be moved.
|
||||
|
Loading…
Reference in New Issue
Block a user