summaryrefslogtreecommitdiff
path: root/Libraries/LibGfx
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2020-10-26 11:47:38 -0400
committerAndreas Kling <kling@serenityos.org>2020-10-26 18:55:36 +0100
commit63dcd59fa5d22d6c07fdeeaee6e5492692b2a425 (patch)
tree186976d95b90e948775f282331815c41227d6eeb /Libraries/LibGfx
parent709b3ccb0ab1f933d7ae48ea3891f69819e0c03d (diff)
downloadserenity-63dcd59fa5d22d6c07fdeeaee6e5492692b2a425.zip
LibGfx: Make Color formattable
Diffstat (limited to 'Libraries/LibGfx')
-rw-r--r--Libraries/LibGfx/Color.cpp5
-rw-r--r--Libraries/LibGfx/Color.h8
2 files changed, 13 insertions, 0 deletions
diff --git a/Libraries/LibGfx/Color.cpp b/Libraries/LibGfx/Color.cpp
index 5cf0299e54..1dfcda7666 100644
--- a/Libraries/LibGfx/Color.cpp
+++ b/Libraries/LibGfx/Color.cpp
@@ -433,3 +433,8 @@ bool IPC::decode(IPC::Decoder& decoder, Color& color)
color = Color::from_rgba(rgba);
return true;
}
+
+void AK::Formatter<Gfx::Color>::format(TypeErasedFormatParams& params, FormatBuilder& builder, const Gfx::Color& value)
+{
+ Formatter<StringView>::format(params, builder, value.to_string());
+}
diff --git a/Libraries/LibGfx/Color.h b/Libraries/LibGfx/Color.h
index a935f7af7e..721b5ad02a 100644
--- a/Libraries/LibGfx/Color.h
+++ b/Libraries/LibGfx/Color.h
@@ -27,6 +27,7 @@
#pragma once
#include <AK/Assertions.h>
+#include <AK/Format.h>
#include <AK/Forward.h>
#include <AK/StdLibExtras.h>
#include <LibIPC/Forward.h>
@@ -295,6 +296,13 @@ const LogStream& operator<<(const LogStream&, Color);
using Gfx::Color;
+namespace AK {
+template<>
+struct Formatter<Gfx::Color> : public Formatter<StringView> {
+ void format(TypeErasedFormatParams& params, FormatBuilder& builder, const Gfx::Color& value);
+};
+}
+
namespace IPC {
bool encode(Encoder&, const Gfx::Color&);
bool decode(Decoder&, Gfx::Color&);