summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Nilsson <brainbomb@gmail.com>2021-07-10 19:14:50 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-10 21:23:36 +0200
commite718de454e71f15e0284ecb2a725cfe3a8960c3b (patch)
tree552b9c5d9bb67a09589664a266f4c847225c0aac
parent5836710e8fbc9a40fd744fd18e576f5c290c2589 (diff)
downloadserenity-e718de454e71f15e0284ecb2a725cfe3a8960c3b.zip
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().
-rw-r--r--Userland/Applications/PixelPaint/LineTool.cpp21
-rw-r--r--Userland/Applications/PixelPaint/LineTool.h2
2 files changed, 3 insertions, 20 deletions
diff --git a/Userland/Applications/PixelPaint/LineTool.cpp b/Userland/Applications/PixelPaint/LineTool.cpp
index af058e424f..876f5094a5 100644
--- a/Userland/Applications/PixelPaint/LineTool.cpp
+++ b/Userland/Applications/PixelPaint/LineTool.cpp
@@ -67,11 +67,11 @@ void LineTool::on_mousemove(Layer&, GUI::MouseEvent& layer_event, GUI::MouseEven
if (m_drawing_button == GUI::MouseButton::None)
return;
- if (!m_constrain_angle) {
- m_line_end_position = layer_event.position();
- } else {
+ if (layer_event.shift()) {
constexpr auto ANGLE_STEP = M_PI / 8;
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();
}
@@ -95,21 +95,6 @@ void LineTool::on_keydown(GUI::KeyEvent& event)
m_editor->update();
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)
diff --git a/Userland/Applications/PixelPaint/LineTool.h b/Userland/Applications/PixelPaint/LineTool.h
index 5cda0ed9d0..20c8f29eb7 100644
--- a/Userland/Applications/PixelPaint/LineTool.h
+++ b/Userland/Applications/PixelPaint/LineTool.h
@@ -23,7 +23,6 @@ public:
virtual void on_tool_button_contextmenu(GUI::ContextMenuEvent&) override;
virtual void on_second_paint(Layer const&, GUI::PaintEvent&) override;
virtual void on_keydown(GUI::KeyEvent&) override;
- virtual void on_keyup(GUI::KeyEvent&) override;
private:
GUI::MouseButton m_drawing_button { GUI::MouseButton::None };
@@ -33,7 +32,6 @@ private:
RefPtr<GUI::Menu> m_context_menu;
GUI::ActionGroup m_thickness_actions;
int m_thickness { 1 };
- bool m_constrain_angle { false };
};
}