mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 08:17:35 +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
|
@ -48,6 +48,10 @@ const char* to_string(Variant::Type type)
|
|||
return "TextAlignment";
|
||||
case Variant::Type::ColorRole:
|
||||
return "ColorRole";
|
||||
case Variant::Type::MetricRole:
|
||||
return "MetricRole";
|
||||
case Variant::Type::PathRole:
|
||||
return "PathRole";
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
@ -93,6 +97,18 @@ Variant::Variant(Gfx::ColorRole value)
|
|||
m_value.as_color_role = value;
|
||||
}
|
||||
|
||||
Variant::Variant(Gfx::MetricRole value)
|
||||
: m_type(Type::MetricRole)
|
||||
{
|
||||
m_value.as_metric_role = value;
|
||||
}
|
||||
|
||||
Variant::Variant(Gfx::PathRole value)
|
||||
: m_type(Type::PathRole)
|
||||
{
|
||||
m_value.as_path_role = value;
|
||||
}
|
||||
|
||||
Variant::Variant(i32 value)
|
||||
: m_type(Type::Int32)
|
||||
{
|
||||
|
@ -331,6 +347,12 @@ void Variant::copy_from(const Variant& other)
|
|||
case Type::ColorRole:
|
||||
m_value.as_color_role = other.m_value.as_color_role;
|
||||
break;
|
||||
case Type::MetricRole:
|
||||
m_value.as_metric_role = other.m_value.as_metric_role;
|
||||
break;
|
||||
case Type::PathRole:
|
||||
m_value.as_path_role = other.m_value.as_path_role;
|
||||
break;
|
||||
case Type::Invalid:
|
||||
break;
|
||||
}
|
||||
|
@ -373,6 +395,10 @@ bool Variant::operator==(const Variant& other) const
|
|||
return m_value.as_text_alignment == other.m_value.as_text_alignment;
|
||||
case Type::ColorRole:
|
||||
return m_value.as_color_role == other.m_value.as_color_role;
|
||||
case Type::MetricRole:
|
||||
return m_value.as_metric_role == other.m_value.as_metric_role;
|
||||
case Type::PathRole:
|
||||
return m_value.as_path_role == other.m_value.as_path_role;
|
||||
case Type::Invalid:
|
||||
return true;
|
||||
}
|
||||
|
@ -412,6 +438,8 @@ bool Variant::operator<(const Variant& other) const
|
|||
case Type::Font:
|
||||
case Type::TextAlignment:
|
||||
case Type::ColorRole:
|
||||
case Type::MetricRole:
|
||||
case Type::PathRole:
|
||||
// FIXME: Figure out how to compare these.
|
||||
VERIFY_NOT_REACHED();
|
||||
case Type::Invalid:
|
||||
|
@ -468,9 +496,12 @@ String Variant::to_string() const
|
|||
}
|
||||
return "";
|
||||
}
|
||||
case Type::ColorRole: {
|
||||
case Type::ColorRole:
|
||||
return String::formatted("Gfx::ColorRole::{}", Gfx::to_string(m_value.as_color_role));
|
||||
}
|
||||
case Type::MetricRole:
|
||||
return String::formatted("Gfx::MetricRole::{}", Gfx::to_string(m_value.as_metric_role));
|
||||
case Type::PathRole:
|
||||
return String::formatted("Gfx::PathRole::{}", Gfx::to_string(m_value.as_path_role));
|
||||
case Type::Invalid:
|
||||
return "[null]";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue