mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:57:34 +00:00
PaintBrush: Add an "ellipse tool"
The tool currently supports drawing an elliptical line of a specified thickness. Further improvements can include adding a fill mode, and holding down shift to draw a perfect circle. Closes #375.
This commit is contained in:
parent
123b5c9d34
commit
c85bdff57a
5 changed files with 145 additions and 0 deletions
36
Applications/PaintBrush/EllipseTool.h
Normal file
36
Applications/PaintBrush/EllipseTool.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include "Tool.h"
|
||||
#include <LibDraw/Point.h>
|
||||
|
||||
class GMenu;
|
||||
class Painter;
|
||||
|
||||
class EllipseTool final : public Tool {
|
||||
public:
|
||||
EllipseTool();
|
||||
virtual ~EllipseTool() 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,
|
||||
// FIXME: Add Mode::Fill
|
||||
};
|
||||
|
||||
virtual const char* class_name() const override { return "EllipseTool"; }
|
||||
void draw_using(Painter& painter);
|
||||
|
||||
GMouseButton m_drawing_button { GMouseButton::None };
|
||||
Point m_ellipse_start_position;
|
||||
Point m_ellipse_end_position;
|
||||
RefPtr<GMenu> m_context_menu;
|
||||
int m_thickness { 1 };
|
||||
Mode m_mode { Mode::Outline };
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue