Skip to content

Commit

Permalink
fix aseprite#4217: Disable mouse stabilizer while previewing a straig…
Browse files Browse the repository at this point in the history
…ht line

This commit addresses the issue where the Shift+brush tool was not disabling the mouse stabilizer, leading to unintended behavior when previewing a line. This commit adds the necessary implementation to properly disable the stabilizer when Shift+brush tool is used. Additionally, the function DrawingState::disableMouseStabilizer() now calls ToolLoopManager::disableMouseStabilizer() to ensure the stabilizer is disabled correctly.
  • Loading branch information
belchiorg authored and dacap committed May 23, 2024
1 parent 1f529bd commit 531b2de
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/app/tools/tool_loop_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,12 @@ void ToolLoopManager::movement(Pointer pointer)
doLoopStep(false);
}

void ToolLoopManager::disableMouseStabilizer()
{
// Disable mouse stabilizer for the current ToolLoopManager
m_dynamics.stabilizer = false;
}

void ToolLoopManager::doLoopStep(bool lastStep)
{
// Original set of points to interwine (original user stroke,
Expand Down
4 changes: 4 additions & 0 deletions src/app/tools/tool_loop_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ class ToolLoopManager {
// Should be called each time the user moves the mouse inside the editor.
void movement(Pointer pointer);

// Should be called when Shift+brush tool is used to disable stabilizer
// on the line preview
void disableMouseStabilizer();

const Pointer& lastPointer() const { return m_lastPointer; }

private:
Expand Down
6 changes: 6 additions & 0 deletions src/app/ui/editor/drawing_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ void DrawingState::initToolLoop(Editor* editor,
editor->captureMouse();
}

void DrawingState::disableMouseStabilizer()
{
ASSERT(m_toolLoopManager);
m_toolLoopManager->disableMouseStabilizer();
}

void DrawingState::sendMovementToToolLoop(const tools::Pointer& pointer)
{
ASSERT(m_toolLoopManager);
Expand Down
4 changes: 4 additions & 0 deletions src/app/ui/editor/drawing_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ namespace app {
const ui::MouseMessage* msg,
const tools::Pointer& pointer);

// Used to disable the current ToolLoopManager's stabilizer
// when Shift+brush tool is used to paint a line
void disableMouseStabilizer();

// Used to send a movement() to the ToolLoopManager when
// Shift+brush tool is used to paint a line.
void sendMovementToToolLoop(const tools::Pointer& pointer);
Expand Down
3 changes: 3 additions & 0 deletions src/app/ui/editor/standby_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,9 @@ bool StandbyState::checkStartDrawingStraightLine(Editor* editor,
pointer ? pointer->type(): PointerType::Unknown,
pointer ? pointer->pressure(): 0.0f));
if (drawingState) {
// Disable stabilizer so that it does not affect the line preview
drawingState->disableMouseStabilizer();

drawingState->sendMovementToToolLoop(
tools::Pointer(
pointer ? pointer->point(): editor->screenToEditor(editor->mousePosInDisplay()),
Expand Down

0 comments on commit 531b2de

Please sign in to comment.