mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
PixelPaint: Check modifier on mousemove in LineTool
Previously m_constrain_angle could end up not being reset if the keyup-event was lost, for example when opening a dialog. Instead check the modifiers in on_mousemove().
This commit is contained in:
parent
5836710e8f
commit
e718de454e
Notes:
sideshowbarker
2024-07-18 09:24:19 +09:00
Author: https://github.com/metmo Commit: https://github.com/SerenityOS/serenity/commit/e718de454e7 Pull-request: https://github.com/SerenityOS/serenity/pull/8615
2 changed files with 3 additions and 20 deletions
|
@ -67,11 +67,11 @@ void LineTool::on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEven
|
||||||
if (m_drawing_button == GUI::MouseButton::None)
|
if (m_drawing_button == GUI::MouseButton::None)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!m_constrain_angle) {
|
if (layer_event.shift()) {
|
||||||
m_line_end_position = layer_event.position();
|
|
||||||
} else {
|
|
||||||
constexpr auto ANGLE_STEP = M_PI / 8;
|
constexpr auto ANGLE_STEP = M_PI / 8;
|
||||||
m_line_end_position = constrain_line_angle(m_line_start_position, layer_event.position(), ANGLE_STEP);
|
m_line_end_position = constrain_line_angle(m_line_start_position, layer_event.position(), ANGLE_STEP);
|
||||||
|
} else {
|
||||||
|
m_line_end_position = layer_event.position();
|
||||||
}
|
}
|
||||||
m_editor->update();
|
m_editor->update();
|
||||||
}
|
}
|
||||||
|
@ -95,21 +95,6 @@ void LineTool::on_keydown(GUI::KeyEvent& event)
|
||||||
m_editor->update();
|
m_editor->update();
|
||||||
event.accept();
|
event.accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key() == Key_Shift) {
|
|
||||||
m_constrain_angle = true;
|
|
||||||
m_editor->update();
|
|
||||||
event.accept();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void LineTool::on_keyup(GUI::KeyEvent& event)
|
|
||||||
{
|
|
||||||
if (event.key() == Key_Shift) {
|
|
||||||
m_constrain_angle = false;
|
|
||||||
m_editor->update();
|
|
||||||
event.accept();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LineTool::on_tool_button_contextmenu(GUI::ContextMenuEvent& event)
|
void LineTool::on_tool_button_contextmenu(GUI::ContextMenuEvent& event)
|
||||||
|
|
|
@ -23,7 +23,6 @@ public:
|
||||||
virtual void on_tool_button_contextmenu(GUI::ContextMenuEvent&) override;
|
virtual void on_tool_button_contextmenu(GUI::ContextMenuEvent&) override;
|
||||||
virtual void on_second_paint(Layer const&, GUI::PaintEvent&) override;
|
virtual void on_second_paint(Layer const&, GUI::PaintEvent&) override;
|
||||||
virtual void on_keydown(GUI::KeyEvent&) override;
|
virtual void on_keydown(GUI::KeyEvent&) override;
|
||||||
virtual void on_keyup(GUI::KeyEvent&) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
|
||||||
|
@ -33,7 +32,6 @@ private:
|
||||||
RefPtr<GUI::Menu> m_context_menu;
|
RefPtr<GUI::Menu> m_context_menu;
|
||||||
GUI::ActionGroup m_thickness_actions;
|
GUI::ActionGroup m_thickness_actions;
|
||||||
int m_thickness { 1 };
|
int m_thickness { 1 };
|
||||||
bool m_constrain_angle { false };
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue