mirror of
https://github.com/aseprite/aseprite.git
synced 2024-10-03 21:46:20 +00:00
Fix straight line while drawing on pixel perfect
This commit is contained in:
parent
74b0a70107
commit
c7dfff9b41
@ -384,6 +384,11 @@ class IntertwineAsPixelPerfect : public Intertwine {
|
||||
}
|
||||
}
|
||||
|
||||
// It was introduced to know if joinStroke function
|
||||
// was executed inmediatelly after a "Last" trace policy (i.e. after the
|
||||
// user confirms a line draw while he is holding down the SHIFT key), so
|
||||
// we have to ignore printing the first pixel of the line.
|
||||
bool retainedTracePolicyLast = false;
|
||||
Stroke m_pts;
|
||||
|
||||
public:
|
||||
@ -393,6 +398,7 @@ public:
|
||||
|
||||
void prepareIntertwine() override {
|
||||
m_pts.reset();
|
||||
retainedTracePolicyLast = false;
|
||||
}
|
||||
|
||||
void joinStroke(ToolLoop* loop, const Stroke& stroke) override {
|
||||
@ -401,8 +407,10 @@ public:
|
||||
// new joinStroke() is like a fresh start. Without this fix, the
|
||||
// first stage on LineFreehand will draw a "star" like pattern
|
||||
// with lines from the first point to the last point.
|
||||
if (loop->getTracePolicy() == TracePolicy::Last)
|
||||
if (loop->getTracePolicy() == TracePolicy::Last) {
|
||||
retainedTracePolicyLast = true;
|
||||
m_pts.reset();
|
||||
}
|
||||
|
||||
if (stroke.size() == 0)
|
||||
return;
|
||||
@ -435,6 +443,12 @@ public:
|
||||
++c;
|
||||
}
|
||||
|
||||
// We must ignore to print the first point of the line after
|
||||
// a joinStroke pass with a retained "Last" trace policy
|
||||
// (i.e. the user confirms draw a line while he is holding
|
||||
// the SHIFT key))
|
||||
if (c == 0 && retainedTracePolicyLast)
|
||||
continue;
|
||||
doPointshapePoint(m_pts[c].x, m_pts[c].y, loop);
|
||||
}
|
||||
}
|
||||
|
@ -77,6 +77,16 @@ void ToolLoopManager::pressButton(const Pointer& pointer)
|
||||
{
|
||||
TOOL_TRACE("ToolLoopManager::pressButton", pointer.point());
|
||||
|
||||
// A little patch to memorize initial Trace Policy in the
|
||||
// current function execution.
|
||||
// When the initial trace policy is "Last" and then
|
||||
// changes to different trace policy at the end of
|
||||
// this function, the user confirms a line draw while he
|
||||
// is holding the SHIFT key.
|
||||
bool tracePolicyWasLast = false;
|
||||
if (m_toolLoop->getTracePolicy() == TracePolicy::Last)
|
||||
tracePolicyWasLast = true;
|
||||
|
||||
m_lastPointer = pointer;
|
||||
|
||||
if (isCanceled())
|
||||
@ -102,7 +112,18 @@ void ToolLoopManager::pressButton(const Pointer& pointer)
|
||||
m_toolLoop->getController()->getStatusBarText(m_toolLoop, m_stroke, statusText);
|
||||
m_toolLoop->updateStatusBar(statusText.c_str());
|
||||
|
||||
doLoopStep(false);
|
||||
// We evaluate if the trace policy has changed compared with
|
||||
// the initial trace policy.
|
||||
if (!(m_toolLoop->getTracePolicy() == TracePolicy::Last) &&
|
||||
tracePolicyWasLast) {
|
||||
// Do nothing. We do not need execute an additional doLoopStep
|
||||
// (which it want to accumulate more points in m_pts in function
|
||||
// joinStroke() from intertwiners.h)
|
||||
// This avoid double print of a line while the user holds down
|
||||
// the SHIFT key.
|
||||
}
|
||||
else
|
||||
doLoopStep(false);
|
||||
}
|
||||
|
||||
bool ToolLoopManager::releaseButton(const Pointer& pointer)
|
||||
|
Loading…
Reference in New Issue
Block a user