mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:17:35 +00:00
PaintBrush: Factor out the pen tool into an actual PenTool class.
Also add a Tool base class, and an empty BucketTool subclass which is the next thing to implement.
This commit is contained in:
parent
a12751695e
commit
56cbe15033
10 changed files with 185 additions and 33 deletions
|
@ -2,8 +2,12 @@
|
|||
|
||||
#include <LibGUI/GWidget.h>
|
||||
|
||||
class Tool;
|
||||
|
||||
class PaintableWidget final : public GWidget {
|
||||
public:
|
||||
static PaintableWidget& the();
|
||||
|
||||
explicit PaintableWidget(GWidget* parent);
|
||||
virtual ~PaintableWidget() override;
|
||||
|
||||
|
@ -15,17 +19,24 @@ public:
|
|||
void set_primary_color(Color color) { m_primary_color = color; }
|
||||
void set_secondary_color(Color color) { m_secondary_color = color; }
|
||||
|
||||
void set_tool(Tool* tool) { m_tool = tool; }
|
||||
Tool* tool() { return m_tool; }
|
||||
|
||||
Color color_for(const GMouseEvent&);
|
||||
|
||||
GraphicsBitmap& bitmap() { return *m_bitmap; }
|
||||
const GraphicsBitmap& bitmap() const { return *m_bitmap; }
|
||||
|
||||
private:
|
||||
virtual void paint_event(GPaintEvent&) override;
|
||||
virtual void mousedown_event(GMouseEvent&) override;
|
||||
virtual void mouseup_event(GMouseEvent&) override;
|
||||
virtual void mousemove_event(GMouseEvent&) override;
|
||||
|
||||
Color color_for(const GMouseEvent&);
|
||||
|
||||
Point m_last_drawing_event_position { -1, -1 };
|
||||
RetainPtr<GraphicsBitmap> m_bitmap;
|
||||
|
||||
Color m_primary_color { Color::Black };
|
||||
Color m_secondary_color { Color::White };
|
||||
|
||||
Tool* m_tool { nullptr };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue