mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:17:35 +00:00
LibGUI: Add Gfx::ColorRole to Variant
For Theme Editor. :^)
This commit is contained in:
parent
c1ede97543
commit
759d6df87d
2 changed files with 29 additions and 0 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <LibGUI/Icon.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
#include <LibGfx/Font.h>
|
||||
#include <LibGfx/SystemTheme.h>
|
||||
|
||||
namespace GUI {
|
||||
|
||||
|
@ -33,6 +34,7 @@ public:
|
|||
Variant(const Gfx::IntRect&);
|
||||
Variant(const Gfx::Font&);
|
||||
Variant(const Gfx::TextAlignment);
|
||||
Variant(const Gfx::ColorRole);
|
||||
Variant(const JsonValue&);
|
||||
Variant(Color);
|
||||
|
||||
|
@ -62,6 +64,7 @@ public:
|
|||
Rect,
|
||||
Font,
|
||||
TextAlignment,
|
||||
ColorRole,
|
||||
};
|
||||
|
||||
bool is_valid() const { return m_type != Type::Invalid; }
|
||||
|
@ -80,6 +83,7 @@ public:
|
|||
bool is_rect() const { return m_type == Type::Rect; }
|
||||
bool is_font() const { return m_type == Type::Font; }
|
||||
bool is_text_alignment() const { return m_type == Type::TextAlignment; }
|
||||
bool is_color_role() const { return m_type == Type::ColorRole; }
|
||||
Type type() const { return m_type; }
|
||||
|
||||
bool as_bool() const
|
||||
|
@ -234,6 +238,13 @@ public:
|
|||
return m_value.as_text_alignment;
|
||||
}
|
||||
|
||||
Gfx::ColorRole to_color_role() const
|
||||
{
|
||||
if (type() != Type::ColorRole)
|
||||
return Gfx::ColorRole::NoRole;
|
||||
return m_value.as_color_role;
|
||||
}
|
||||
|
||||
Color to_color(Color default_value = {}) const
|
||||
{
|
||||
if (type() == Type::Color)
|
||||
|
@ -283,6 +294,7 @@ private:
|
|||
float as_float;
|
||||
Gfx::RGBA32 as_color;
|
||||
Gfx::TextAlignment as_text_alignment;
|
||||
Gfx::ColorRole as_color_role;
|
||||
RawPoint as_point;
|
||||
RawSize as_size;
|
||||
RawRect as_rect;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue