mirror of https://github.com/aseprite/aseprite.git
Add Ctrl modifier to Shift+pencil to enable angle snap (#1387)
This commit is contained in:
parent
85b7996e9a
commit
8d693d1a08
|
@ -523,6 +523,7 @@
|
||||||
|
|
||||||
<!-- Modifiers for freehand tool controller -->
|
<!-- Modifiers for freehand tool controller -->
|
||||||
<key action="StraightLineFromLastPoint" shortcut="Shift" />
|
<key action="StraightLineFromLastPoint" shortcut="Shift" />
|
||||||
|
<key action="AngleSnapFromLastPoint" shortcut="Ctrl" />
|
||||||
|
|
||||||
<!-- Modifiers for two-points tool controller -->
|
<!-- Modifiers for two-points tool controller -->
|
||||||
<key action="SquareAspect" shortcut="Shift" />
|
<key action="SquareAspect" shortcut="Shift" />
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace app {
|
||||||
virtual bool canSnapToGrid() { return true; }
|
virtual bool canSnapToGrid() { return true; }
|
||||||
virtual bool isFreehand() { return false; }
|
virtual bool isFreehand() { return false; }
|
||||||
virtual bool isOnePoint() { return false; }
|
virtual bool isOnePoint() { return false; }
|
||||||
|
virtual bool isTwoPoints() { return false; }
|
||||||
|
|
||||||
virtual void prepareController(ToolLoop* loop) { }
|
virtual void prepareController(ToolLoop* loop) { }
|
||||||
|
|
||||||
|
|
|
@ -99,9 +99,7 @@ private:
|
||||||
// Controls clicks for tools like line
|
// Controls clicks for tools like line
|
||||||
class TwoPointsController : public MoveOriginCapability {
|
class TwoPointsController : public MoveOriginCapability {
|
||||||
public:
|
public:
|
||||||
TwoPointsController(const bool enableModifiers)
|
bool isTwoPoints() override { return true; }
|
||||||
: m_enableModifiers(enableModifiers) {
|
|
||||||
}
|
|
||||||
|
|
||||||
void pressButton(Stroke& stroke, const Point& point) override {
|
void pressButton(Stroke& stroke, const Point& point) override {
|
||||||
MoveOriginCapability::pressButton(stroke, point);
|
MoveOriginCapability::pressButton(stroke, point);
|
||||||
|
@ -126,8 +124,7 @@ public:
|
||||||
|
|
||||||
stroke[1] = point;
|
stroke[1] = point;
|
||||||
|
|
||||||
if (m_enableModifiers &&
|
if ((int(loop->getModifiers()) & int(ToolLoopModifiers::kSquareAspect))) {
|
||||||
(int(loop->getModifiers()) & int(ToolLoopModifiers::kSquareAspect))) {
|
|
||||||
int dx = stroke[1].x - m_first.x;
|
int dx = stroke[1].x - m_first.x;
|
||||||
int dy = stroke[1].y - m_first.y;
|
int dy = stroke[1].y - m_first.y;
|
||||||
int minsize = MIN(ABS(dx), ABS(dy));
|
int minsize = MIN(ABS(dx), ABS(dy));
|
||||||
|
@ -172,8 +169,7 @@ public:
|
||||||
|
|
||||||
stroke[0] = m_first;
|
stroke[0] = m_first;
|
||||||
|
|
||||||
if (m_enableModifiers &&
|
if ((int(loop->getModifiers()) & int(ToolLoopModifiers::kFromCenter))) {
|
||||||
(int(loop->getModifiers()) & int(ToolLoopModifiers::kFromCenter))) {
|
|
||||||
int rx = stroke[1].x - m_first.x;
|
int rx = stroke[1].x - m_first.x;
|
||||||
int ry = stroke[1].y - m_first.y;
|
int ry = stroke[1].y - m_first.y;
|
||||||
stroke[0].x = m_first.x - rx;
|
stroke[0].x = m_first.x - rx;
|
||||||
|
@ -232,7 +228,6 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
Point m_first;
|
Point m_first;
|
||||||
bool m_enableModifiers;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Controls clicks for tools like polygon
|
// Controls clicks for tools like polygon
|
||||||
|
@ -390,8 +385,6 @@ private:
|
||||||
// freehand until the mouse is released.
|
// freehand until the mouse is released.
|
||||||
class LineFreehandController : public Controller {
|
class LineFreehandController : public Controller {
|
||||||
public:
|
public:
|
||||||
LineFreehandController() : m_twoPoints(false) { }
|
|
||||||
|
|
||||||
bool isFreehand() override { return true; }
|
bool isFreehand() override { return true; }
|
||||||
|
|
||||||
gfx::Point getLastPoint() const override { return m_last; }
|
gfx::Point getLastPoint() const override { return m_last; }
|
||||||
|
@ -414,6 +407,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
bool releaseButton(Stroke& stroke, const Point& point) override {
|
bool releaseButton(Stroke& stroke, const Point& point) override {
|
||||||
|
if (!stroke.empty())
|
||||||
|
m_last = stroke.lastPoint();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -234,6 +234,10 @@ class IntertwineAsPixelPerfect : public Intertwine {
|
||||||
Stroke m_pts;
|
Stroke m_pts;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// Useful for Shift+Ctrl+pencil to draw straight lines and snap
|
||||||
|
// angle when "pixel perfect" is selected.
|
||||||
|
bool snapByAngle() override { return true; }
|
||||||
|
|
||||||
void prepareIntertwine() override {
|
void prepareIntertwine() override {
|
||||||
m_pts.reset();
|
m_pts.reset();
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ ToolBox::ToolBox()
|
||||||
m_controllers[WellKnownControllers::Freehand] = new FreehandController();
|
m_controllers[WellKnownControllers::Freehand] = new FreehandController();
|
||||||
m_controllers[WellKnownControllers::PointByPoint] = new PointByPointController();
|
m_controllers[WellKnownControllers::PointByPoint] = new PointByPointController();
|
||||||
m_controllers[WellKnownControllers::OnePoints] = new OnePointController();
|
m_controllers[WellKnownControllers::OnePoints] = new OnePointController();
|
||||||
m_controllers[WellKnownControllers::TwoPoints] = new TwoPointsController(true);
|
m_controllers[WellKnownControllers::TwoPoints] = new TwoPointsController();
|
||||||
m_controllers[WellKnownControllers::FourPoints] = new FourPointsController();
|
m_controllers[WellKnownControllers::FourPoints] = new FourPointsController();
|
||||||
m_controllers[WellKnownControllers::LineFreehand] = new LineFreehandController();
|
m_controllers[WellKnownControllers::LineFreehand] = new LineFreehandController();
|
||||||
|
|
||||||
|
|
|
@ -1442,14 +1442,27 @@ void Editor::updateToolLoopModifiersIndicators()
|
||||||
int(tools::ToolLoopModifiers::kAddSelection) |
|
int(tools::ToolLoopModifiers::kAddSelection) |
|
||||||
int(tools::ToolLoopModifiers::kSubtractSelection)));
|
int(tools::ToolLoopModifiers::kSubtractSelection)));
|
||||||
|
|
||||||
// Shape tools (line, curves, rectangles, etc.)
|
tools::Controller* controller =
|
||||||
action = m_customizationDelegate->getPressedKeyAction(KeyContext::ShapeTool);
|
(App::instance()->activeToolManager()->selectedTool() ?
|
||||||
if (int(action & KeyAction::MoveOrigin))
|
App::instance()->activeToolManager()->selectedTool()->getController(0): nullptr);
|
||||||
modifiers |= int(tools::ToolLoopModifiers::kMoveOrigin);
|
|
||||||
if (int(action & KeyAction::SquareAspect))
|
// Shape tools modifiers (line, curves, rectangles, etc.)
|
||||||
modifiers |= int(tools::ToolLoopModifiers::kSquareAspect);
|
if (controller && controller->isTwoPoints()) {
|
||||||
if (int(action & KeyAction::DrawFromCenter))
|
action = m_customizationDelegate->getPressedKeyAction(KeyContext::ShapeTool);
|
||||||
modifiers |= int(tools::ToolLoopModifiers::kFromCenter);
|
if (int(action & KeyAction::MoveOrigin))
|
||||||
|
modifiers |= int(tools::ToolLoopModifiers::kMoveOrigin);
|
||||||
|
if (int(action & KeyAction::SquareAspect))
|
||||||
|
modifiers |= int(tools::ToolLoopModifiers::kSquareAspect);
|
||||||
|
if (int(action & KeyAction::DrawFromCenter))
|
||||||
|
modifiers |= int(tools::ToolLoopModifiers::kFromCenter);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Freehand modifiers
|
||||||
|
if (controller && controller->isFreehand()) {
|
||||||
|
action = m_customizationDelegate->getPressedKeyAction(KeyContext::FreehandTool);
|
||||||
|
if (int(action & KeyAction::AngleSnapFromLastPoint))
|
||||||
|
modifiers |= int(tools::ToolLoopModifiers::kSquareAspect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// We update the selection mode only if we're not selecting.
|
// We update the selection mode only if we're not selecting.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
|
@ -44,6 +44,7 @@ namespace {
|
||||||
{ "SubtractSelection" , "Subtract Selection" , app::KeyAction::SubtractSelection },
|
{ "SubtractSelection" , "Subtract Selection" , app::KeyAction::SubtractSelection },
|
||||||
{ "AutoSelectLayer" , "Auto Select Layer" , app::KeyAction::AutoSelectLayer },
|
{ "AutoSelectLayer" , "Auto Select Layer" , app::KeyAction::AutoSelectLayer },
|
||||||
{ "StraightLineFromLastPoint", "Straight Line from Last Point", app::KeyAction::StraightLineFromLastPoint },
|
{ "StraightLineFromLastPoint", "Straight Line from Last Point", app::KeyAction::StraightLineFromLastPoint },
|
||||||
|
{ "AngleSnapFromLastPoint", "Angle Snap from Last Point", app::KeyAction::AngleSnapFromLastPoint },
|
||||||
{ "MoveOrigin" , "Move Origin" , app::KeyAction::MoveOrigin },
|
{ "MoveOrigin" , "Move Origin" , app::KeyAction::MoveOrigin },
|
||||||
{ "SquareAspect" , "Square Aspect" , app::KeyAction::SquareAspect },
|
{ "SquareAspect" , "Square Aspect" , app::KeyAction::SquareAspect },
|
||||||
{ "DrawFromCenter" , "Draw From Center" , app::KeyAction::DrawFromCenter },
|
{ "DrawFromCenter" , "Draw From Center" , app::KeyAction::DrawFromCenter },
|
||||||
|
@ -158,6 +159,7 @@ Key::Key(KeyAction action)
|
||||||
m_keycontext = KeyContext::MoveTool;
|
m_keycontext = KeyContext::MoveTool;
|
||||||
break;
|
break;
|
||||||
case KeyAction::StraightLineFromLastPoint:
|
case KeyAction::StraightLineFromLastPoint:
|
||||||
|
case KeyAction::AngleSnapFromLastPoint:
|
||||||
m_keycontext = KeyContext::FreehandTool;
|
m_keycontext = KeyContext::FreehandTool;
|
||||||
break;
|
break;
|
||||||
case KeyAction::MoveOrigin:
|
case KeyAction::MoveOrigin:
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2001-2016 David Capello
|
// Copyright (C) 2001-2017 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
// the End-User License Agreement for Aseprite.
|
// the End-User License Agreement for Aseprite.
|
||||||
|
@ -71,6 +71,7 @@ namespace app {
|
||||||
SquareAspect = 0x00001000,
|
SquareAspect = 0x00001000,
|
||||||
DrawFromCenter = 0x00002000,
|
DrawFromCenter = 0x00002000,
|
||||||
ScaleFromCenter = 0x00004000,
|
ScaleFromCenter = 0x00004000,
|
||||||
|
AngleSnapFromLastPoint = 0x00008000,
|
||||||
};
|
};
|
||||||
|
|
||||||
inline KeyAction operator&(KeyAction a, KeyAction b) {
|
inline KeyAction operator&(KeyAction a, KeyAction b) {
|
||||||
|
|
Loading…
Reference in New Issue