1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:27:44 +00:00

LibGfx: Add abstract StylePainter class

StylePainter's behavior is now handled by a static instance
of BaseStylePainter. The original static behavior of StylePainter
is left as-is for API compatibility.
This commit is contained in:
Sarah 2020-08-12 19:54:17 +10:00 committed by Andreas Kling
parent 868bd2e43d
commit d0900228d0
2 changed files with 33 additions and 266 deletions

View file

@ -49,8 +49,28 @@ enum class FrameShape {
HorizontalLine
};
// FIXME: should this be in its own header?
class BaseStylePainter {
public:
virtual ~BaseStylePainter() { }
virtual void paint_button(Painter&, const IntRect&, const Palette&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true) = 0;
virtual void paint_tab_button(Painter&, const IntRect&, const Palette&, bool active, bool hovered, bool enabled) = 0;
virtual void paint_surface(Painter&, const IntRect&, const Palette&, bool paint_vertical_lines = true, bool paint_top_line = true) = 0;
virtual void paint_frame(Painter&, const IntRect&, const Palette&, FrameShape, FrameShadow, int thickness, bool skip_vertical_lines = false) = 0;
virtual void paint_window_frame(Painter&, const IntRect&, const Palette&) = 0;
virtual void paint_progress_bar(Painter&, const IntRect&, const Palette&, int min, int max, int value, const StringView& text) = 0;
virtual void paint_radio_button(Painter&, const IntRect&, const Palette&, bool is_checked, bool is_being_pressed) = 0;
protected:
BaseStylePainter() { }
};
class StylePainter {
public:
static BaseStylePainter& current();
// FIXME: These are here for API compatibility, we should probably remove them and move BaseStylePainter into here
static void paint_button(Painter&, const IntRect&, const Palette&, ButtonStyle, bool pressed, bool hovered = false, bool checked = false, bool enabled = true);
static void paint_tab_button(Painter&, const IntRect&, const Palette&, bool active, bool hovered, bool enabled);
static void paint_surface(Painter&, const IntRect&, const Palette&, bool paint_vertical_lines = true, bool paint_top_line = true);