fix #4217: Disable mouse stabilizer while previewing a straight 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.
This commit is contained in:
Guilherme Belchior 2024-04-01 20:12:04 +01:00 committed by David Capello
parent 1f529bd610
commit 531b2ded75
5 changed files with 23 additions and 0 deletions

View File

@ -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,

View File

@ -78,6 +78,10 @@ public:
// 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:

View File

@ -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);

View File

@ -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);

View File

@ -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()),