mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 17:52:26 -05:00
a599317624
This macro goes at the top of every CObject-derived class like so: class SomeClass : public CObject { C_OBJECT(SomeClass) public: ... At the moment, all it does is create an override for the class_name() getter but in the future this will be used to automatically insert member functions into these classes.
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#pragma once
|
|
|
|
#include <LibGUI/GWidget.h>
|
|
class Tool;
|
|
|
|
class PaintableWidget final : public GWidget {
|
|
C_OBJECT(PaintableWidget)
|
|
public:
|
|
static PaintableWidget& the();
|
|
|
|
explicit PaintableWidget(GWidget* parent);
|
|
virtual ~PaintableWidget() override;
|
|
|
|
Color primary_color() const { return m_primary_color; }
|
|
Color secondary_color() const { return m_secondary_color; }
|
|
|
|
void set_primary_color(Color);
|
|
void set_secondary_color(Color);
|
|
|
|
void set_tool(Tool* tool);
|
|
Tool* tool();
|
|
|
|
Color color_for(const GMouseEvent&);
|
|
|
|
void set_bitmap(const GraphicsBitmap&);
|
|
|
|
GraphicsBitmap& bitmap() { return *m_bitmap; }
|
|
const GraphicsBitmap& bitmap() const { return *m_bitmap; }
|
|
|
|
Function<void(Color)> on_primary_color_change;
|
|
Function<void(Color)> on_secondary_color_change;
|
|
|
|
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;
|
|
|
|
RefPtr<GraphicsBitmap> m_bitmap;
|
|
|
|
Color m_primary_color { Color::Black };
|
|
Color m_secondary_color { Color::White };
|
|
|
|
Tool* m_tool { nullptr };
|
|
};
|