summaryrefslogtreecommitdiff
path: root/LibGUI/GVariant.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-24 04:28:36 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-24 04:28:36 +0100
commit86413a6f5a47593e78daaeca1d1af3def527b1d0 (patch)
tree9df2b5055b92d064e13852ac65405724658bfcfc /LibGUI/GVariant.h
parent7e54fdce996ef520624667ccc2c559b2cc5d6826 (diff)
downloadserenity-86413a6f5a47593e78daaeca1d1af3def527b1d0.zip
LibGUI+FileManager: Add a GIcon class to support multi-size icons.
A GIcon can contain any number of bitmaps internally, and will give you the best fitting icon when you call bitmap_for_size().
Diffstat (limited to 'LibGUI/GVariant.h')
-rw-r--r--LibGUI/GVariant.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/LibGUI/GVariant.h b/LibGUI/GVariant.h
index 1346188015..3631c6e581 100644
--- a/LibGUI/GVariant.h
+++ b/LibGUI/GVariant.h
@@ -1,6 +1,7 @@
#pragma once
#include <AK/AKString.h>
+#include <LibGUI/GIcon.h>
#include <SharedGraphics/GraphicsBitmap.h>
class GVariant {
@@ -11,6 +12,7 @@ public:
GVariant(int);
GVariant(const String&);
GVariant(const GraphicsBitmap&);
+ GVariant(const GIcon&);
GVariant(Color);
~GVariant();
@@ -22,6 +24,7 @@ public:
String,
Bitmap,
Color,
+ Icon,
};
bool is_valid() const { return m_type != Type::Invalid; }
@@ -31,6 +34,7 @@ public:
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; }
+ bool is_icon() const { return m_type == Type::Icon; }
Type type() const { return m_type; }
bool as_bool() const
@@ -63,6 +67,12 @@ public:
return *m_value.as_bitmap;
}
+ GIcon as_icon() const
+ {
+ ASSERT(type() == Type::Icon);
+ return GIcon(*m_value.as_icon);
+ }
+
Color as_color() const
{
ASSERT(type() == Type::Color);
@@ -85,6 +95,7 @@ private:
union {
StringImpl* as_string;
GraphicsBitmap* as_bitmap;
+ GIconImpl* as_icon;
bool as_bool;
int as_int;
float as_float;