mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:27:43 +00:00
LibGUI: Add MetricRole and PathRole to GUI::Variant
This is needed for making them editable in the ThemeEditor, like ColorRole is.
This commit is contained in:
parent
31ce4d04b6
commit
859975f6bd
2 changed files with 55 additions and 2 deletions
|
@ -35,6 +35,8 @@ public:
|
|||
Variant(const Gfx::Font&);
|
||||
Variant(const Gfx::TextAlignment);
|
||||
Variant(const Gfx::ColorRole);
|
||||
Variant(const Gfx::MetricRole);
|
||||
Variant(const Gfx::PathRole);
|
||||
Variant(const JsonValue&);
|
||||
Variant(Color);
|
||||
|
||||
|
@ -65,6 +67,8 @@ public:
|
|||
Font,
|
||||
TextAlignment,
|
||||
ColorRole,
|
||||
MetricRole,
|
||||
PathRole,
|
||||
};
|
||||
|
||||
bool is_valid() const { return m_type != Type::Invalid; }
|
||||
|
@ -84,6 +88,8 @@ public:
|
|||
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; }
|
||||
bool is_metric_role() const { return m_type == Type::MetricRole; }
|
||||
bool is_path_role() const { return m_type == Type::PathRole; }
|
||||
Type type() const { return m_type; }
|
||||
|
||||
bool as_bool() const
|
||||
|
@ -245,6 +251,20 @@ public:
|
|||
return m_value.as_color_role;
|
||||
}
|
||||
|
||||
Gfx::MetricRole to_metric_role() const
|
||||
{
|
||||
if (type() != Type::MetricRole)
|
||||
return Gfx::MetricRole::NoRole;
|
||||
return m_value.as_metric_role;
|
||||
}
|
||||
|
||||
Gfx::PathRole to_path_role() const
|
||||
{
|
||||
if (type() != Type::PathRole)
|
||||
return Gfx::PathRole::NoRole;
|
||||
return m_value.as_path_role;
|
||||
}
|
||||
|
||||
Color to_color(Color default_value = {}) const
|
||||
{
|
||||
if (type() == Type::Color)
|
||||
|
@ -295,6 +315,8 @@ private:
|
|||
Gfx::RGBA32 as_color;
|
||||
Gfx::TextAlignment as_text_alignment;
|
||||
Gfx::ColorRole as_color_role;
|
||||
Gfx::MetricRole as_metric_role;
|
||||
Gfx::PathRole as_path_role;
|
||||
RawPoint as_point;
|
||||
RawSize as_size;
|
||||
RawRect as_rect;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue