mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:37:36 +00:00
PaintBrush: Add a "rectangle tool"
Fill, line, and gradient modes initially supported :^)
This commit is contained in:
parent
70a2355963
commit
b830639912
6 changed files with 145 additions and 1 deletions
36
Applications/PaintBrush/RectangleTool.h
Normal file
36
Applications/PaintBrush/RectangleTool.h
Normal file
|
@ -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 };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue