summaryrefslogtreecommitdiff
path: root/LibGUI/GVariant.h
diff options
context:
space:
mode:
Diffstat (limited to 'LibGUI/GVariant.h')
-rw-r--r--LibGUI/GVariant.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/LibGUI/GVariant.h b/LibGUI/GVariant.h
index 87c7f27175..1346188015 100644
--- a/LibGUI/GVariant.h
+++ b/LibGUI/GVariant.h
@@ -11,6 +11,7 @@ public:
GVariant(int);
GVariant(const String&);
GVariant(const GraphicsBitmap&);
+ GVariant(Color);
~GVariant();
enum class Type {
@@ -20,6 +21,7 @@ public:
Float,
String,
Bitmap,
+ Color,
};
bool is_valid() const { return m_type != Type::Invalid; }
@@ -28,6 +30,7 @@ public:
bool is_float() const { return m_type == Type::Float; }
bool is_string() const { return m_type == Type::String; }
bool is_bitmap() const { return m_type == Type::Bitmap; }
+ bool is_color() const { return m_type == Type::Color; }
Type type() const { return m_type; }
bool as_bool() const
@@ -60,6 +63,19 @@ public:
return *m_value.as_bitmap;
}
+ Color as_color() const
+ {
+ ASSERT(type() == Type::Color);
+ return Color::from_rgba(m_value.as_color);
+ }
+
+ Color to_color(Color default_value) const
+ {
+ if (type() == Type::Color)
+ return as_color();
+ return default_value;
+ }
+
String to_string() const;
bool operator==(const GVariant&) const;
@@ -72,6 +88,7 @@ private:
bool as_bool;
int as_int;
float as_float;
+ RGBA32 as_color;
} m_value;
Type m_type { Type::Invalid };