diff --git a/data/gui.xml b/data/gui.xml
index b6b39f678..ef79b0626 100644
--- a/data/gui.xml
+++ b/data/gui.xml
@@ -523,6 +523,7 @@
+
diff --git a/src/app/tools/controller.h b/src/app/tools/controller.h
index dcd0f0ab1..3f667ae75 100644
--- a/src/app/tools/controller.h
+++ b/src/app/tools/controller.h
@@ -28,6 +28,7 @@ namespace app {
virtual bool canSnapToGrid() { return true; }
virtual bool isFreehand() { return false; }
virtual bool isOnePoint() { return false; }
+ virtual bool isTwoPoints() { return false; }
virtual void prepareController(ToolLoop* loop) { }
diff --git a/src/app/tools/controllers.h b/src/app/tools/controllers.h
index 5518da79f..06d6161a2 100644
--- a/src/app/tools/controllers.h
+++ b/src/app/tools/controllers.h
@@ -99,9 +99,7 @@ private:
// Controls clicks for tools like line
class TwoPointsController : public MoveOriginCapability {
public:
- TwoPointsController(const bool enableModifiers)
- : m_enableModifiers(enableModifiers) {
- }
+ bool isTwoPoints() override { return true; }
void pressButton(Stroke& stroke, const Point& point) override {
MoveOriginCapability::pressButton(stroke, point);
@@ -126,8 +124,7 @@ public:
stroke[1] = point;
- if (m_enableModifiers &&
- (int(loop->getModifiers()) & int(ToolLoopModifiers::kSquareAspect))) {
+ if ((int(loop->getModifiers()) & int(ToolLoopModifiers::kSquareAspect))) {
int dx = stroke[1].x - m_first.x;
int dy = stroke[1].y - m_first.y;
int minsize = MIN(ABS(dx), ABS(dy));
@@ -172,8 +169,7 @@ public:
stroke[0] = m_first;
- if (m_enableModifiers &&
- (int(loop->getModifiers()) & int(ToolLoopModifiers::kFromCenter))) {
+ if ((int(loop->getModifiers()) & int(ToolLoopModifiers::kFromCenter))) {
int rx = stroke[1].x - m_first.x;
int ry = stroke[1].y - m_first.y;
stroke[0].x = m_first.x - rx;
@@ -232,7 +228,6 @@ private:
}
Point m_first;
- bool m_enableModifiers;
};
// Controls clicks for tools like polygon
@@ -390,8 +385,6 @@ private:
// freehand until the mouse is released.
class LineFreehandController : public Controller {
public:
- LineFreehandController() : m_twoPoints(false) { }
-
bool isFreehand() override { return true; }
gfx::Point getLastPoint() const override { return m_last; }
@@ -414,6 +407,8 @@ public:
}
bool releaseButton(Stroke& stroke, const Point& point) override {
+ if (!stroke.empty())
+ m_last = stroke.lastPoint();
return false;
}
diff --git a/src/app/tools/intertwiners.h b/src/app/tools/intertwiners.h
index 143b77bbf..c6a7289e9 100644
--- a/src/app/tools/intertwiners.h
+++ b/src/app/tools/intertwiners.h
@@ -234,6 +234,10 @@ class IntertwineAsPixelPerfect : public Intertwine {
Stroke m_pts;
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 {
m_pts.reset();
}
diff --git a/src/app/tools/tool_box.cpp b/src/app/tools/tool_box.cpp
index c4b32e47a..c2be5672f 100644
--- a/src/app/tools/tool_box.cpp
+++ b/src/app/tools/tool_box.cpp
@@ -115,7 +115,7 @@ ToolBox::ToolBox()
m_controllers[WellKnownControllers::Freehand] = new FreehandController();
m_controllers[WellKnownControllers::PointByPoint] = new PointByPointController();
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::LineFreehand] = new LineFreehandController();
diff --git a/src/app/ui/editor/editor.cpp b/src/app/ui/editor/editor.cpp
index bf2729ab4..7b99bbe39 100644
--- a/src/app/ui/editor/editor.cpp
+++ b/src/app/ui/editor/editor.cpp
@@ -1442,14 +1442,27 @@ void Editor::updateToolLoopModifiersIndicators()
int(tools::ToolLoopModifiers::kAddSelection) |
int(tools::ToolLoopModifiers::kSubtractSelection)));
- // Shape tools (line, curves, rectangles, etc.)
- action = m_customizationDelegate->getPressedKeyAction(KeyContext::ShapeTool);
- 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);
+ tools::Controller* controller =
+ (App::instance()->activeToolManager()->selectedTool() ?
+ App::instance()->activeToolManager()->selectedTool()->getController(0): nullptr);
+
+ // Shape tools modifiers (line, curves, rectangles, etc.)
+ if (controller && controller->isTwoPoints()) {
+ action = m_customizationDelegate->getPressedKeyAction(KeyContext::ShapeTool);
+ 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 {
// We update the selection mode only if we're not selecting.
diff --git a/src/app/ui/keyboard_shortcuts.cpp b/src/app/ui/keyboard_shortcuts.cpp
index 08858194a..1a2fb588d 100644
--- a/src/app/ui/keyboard_shortcuts.cpp
+++ b/src/app/ui/keyboard_shortcuts.cpp
@@ -1,5 +1,5 @@
// Aseprite
-// Copyright (C) 2001-2016 David Capello
+// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@@ -44,6 +44,7 @@ namespace {
{ "SubtractSelection" , "Subtract Selection" , app::KeyAction::SubtractSelection },
{ "AutoSelectLayer" , "Auto Select Layer" , app::KeyAction::AutoSelectLayer },
{ "StraightLineFromLastPoint", "Straight Line from Last Point", app::KeyAction::StraightLineFromLastPoint },
+ { "AngleSnapFromLastPoint", "Angle Snap from Last Point", app::KeyAction::AngleSnapFromLastPoint },
{ "MoveOrigin" , "Move Origin" , app::KeyAction::MoveOrigin },
{ "SquareAspect" , "Square Aspect" , app::KeyAction::SquareAspect },
{ "DrawFromCenter" , "Draw From Center" , app::KeyAction::DrawFromCenter },
@@ -158,6 +159,7 @@ Key::Key(KeyAction action)
m_keycontext = KeyContext::MoveTool;
break;
case KeyAction::StraightLineFromLastPoint:
+ case KeyAction::AngleSnapFromLastPoint:
m_keycontext = KeyContext::FreehandTool;
break;
case KeyAction::MoveOrigin:
diff --git a/src/app/ui/keyboard_shortcuts.h b/src/app/ui/keyboard_shortcuts.h
index bcf91fce3..3a8fa9c08 100644
--- a/src/app/ui/keyboard_shortcuts.h
+++ b/src/app/ui/keyboard_shortcuts.h
@@ -1,5 +1,5 @@
// Aseprite
-// Copyright (C) 2001-2016 David Capello
+// Copyright (C) 2001-2017 David Capello
//
// This program is distributed under the terms of
// the End-User License Agreement for Aseprite.
@@ -71,6 +71,7 @@ namespace app {
SquareAspect = 0x00001000,
DrawFromCenter = 0x00002000,
ScaleFromCenter = 0x00004000,
+ AngleSnapFromLastPoint = 0x00008000,
};
inline KeyAction operator&(KeyAction a, KeyAction b) {