summaryrefslogtreecommitdiff
path: root/Applications/PaintBrush/RectangleTool.h
diff options
context:
space:
mode:
authorShannon Booth <shannon.ml.booth@gmail.com>2019-12-27 08:43:59 +1300
committerAndreas Kling <awesomekling@gmail.com>2019-12-26 21:22:29 +0100
commitb8306399126066d1dc2158f17fd37c249611ba04 (patch)
treed042cf511c20d6ff5bec9609abe6c38e2af6c469 /Applications/PaintBrush/RectangleTool.h
parent70a2355963867d14c3d3f529a1adeb60483ebc68 (diff)
downloadserenity-b8306399126066d1dc2158f17fd37c249611ba04.zip
PaintBrush: Add a "rectangle tool"
Fill, line, and gradient modes initially supported :^)
Diffstat (limited to 'Applications/PaintBrush/RectangleTool.h')
-rw-r--r--Applications/PaintBrush/RectangleTool.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/Applications/PaintBrush/RectangleTool.h b/Applications/PaintBrush/RectangleTool.h
new file mode 100644
index 0000000000..36f2616855
--- /dev/null
+++ b/Applications/PaintBrush/RectangleTool.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#include "Tool.h"
+#include <LibDraw/Point.h>
+
+class GMenu;
+class Painter;
+
+class RectangleTool final : public Tool {
+public:
+ RectangleTool();
+ virtual ~RectangleTool() override;
+
+ virtual void on_mousedown(GMouseEvent&) override;
+ virtual void on_mousemove(GMouseEvent&) override;
+ virtual void on_mouseup(GMouseEvent&) override;
+ virtual void on_contextmenu(GContextMenuEvent&) override;
+ virtual void on_second_paint(GPaintEvent&) override;
+ virtual void on_keydown(GKeyEvent&) override;
+
+private:
+ enum class Mode {
+ Outline,
+ Fill,
+ Gradient,
+ };
+
+ virtual const char* class_name() const override { return "RectangleTool"; }
+ void draw_using(Painter& painter);
+
+ GMouseButton m_drawing_button { GMouseButton::None };
+ Point m_rectangle_start_position;
+ Point m_rectangle_end_position;
+ RefPtr<GMenu> m_context_menu;
+ Mode m_mode { Mode::Outline };
+};