summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/Variant.cpp
diff options
context:
space:
mode:
authorKarol Kosek <krkk@krkk.ct8.pl>2021-09-05 21:38:36 +0200
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2021-09-06 14:05:10 +0430
commit759d6df87dbae623ef246383ec1d14def5c13f97 (patch)
tree35078a76c06886756f35b489aca49c912d982ce2 /Userland/Libraries/LibGUI/Variant.cpp
parentc1ede97543a6374c07af8dbafb3191b9457ef3b1 (diff)
downloadserenity-759d6df87dbae623ef246383ec1d14def5c13f97.zip
LibGUI: Add Gfx::ColorRole to Variant
For Theme Editor. :^)
Diffstat (limited to 'Userland/Libraries/LibGUI/Variant.cpp')
-rw-r--r--Userland/Libraries/LibGUI/Variant.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/Variant.cpp b/Userland/Libraries/LibGUI/Variant.cpp
index d70e8bf114..e648339668 100644
--- a/Userland/Libraries/LibGUI/Variant.cpp
+++ b/Userland/Libraries/LibGUI/Variant.cpp
@@ -46,6 +46,8 @@ const char* to_string(Variant::Type type)
return "Font";
case Variant::Type::TextAlignment:
return "TextAlignment";
+ case Variant::Type::ColorRole:
+ return "ColorRole";
}
VERIFY_NOT_REACHED();
}
@@ -85,6 +87,12 @@ Variant::Variant(Gfx::TextAlignment value)
m_value.as_text_alignment = value;
}
+Variant::Variant(Gfx::ColorRole value)
+ : m_type(Type::ColorRole)
+{
+ m_value.as_color_role = value;
+}
+
Variant::Variant(i32 value)
: m_type(Type::Int32)
{
@@ -320,6 +328,9 @@ void Variant::copy_from(const Variant& other)
case Type::TextAlignment:
m_value.as_text_alignment = other.m_value.as_text_alignment;
break;
+ case Type::ColorRole:
+ m_value.as_color_role = other.m_value.as_color_role;
+ break;
case Type::Invalid:
break;
}
@@ -360,6 +371,8 @@ bool Variant::operator==(const Variant& other) const
return &as_font() == &other.as_font();
case Type::TextAlignment:
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::Invalid:
return true;
}
@@ -398,6 +411,7 @@ bool Variant::operator<(const Variant& other) const
case Type::Rect:
case Type::Font:
case Type::TextAlignment:
+ case Type::ColorRole:
// FIXME: Figure out how to compare these.
VERIFY_NOT_REACHED();
case Type::Invalid:
@@ -454,6 +468,9 @@ String Variant::to_string() const
}
return "";
}
+ case Type::ColorRole: {
+ return String::formatted("Gfx::ColorRole::{}", Gfx::to_string(m_value.as_color_role));
+ }
case Type::Invalid:
return "[null]";
}