LibGfx: Make Color formattable

This commit is contained in:
Nico Weber 2020-10-26 11:47:38 -04:00 committed by Andreas Kling
parent 709b3ccb0a
commit 63dcd59fa5
Notes: sideshowbarker 2024-07-19 01:42:13 +09:00
2 changed files with 13 additions and 0 deletions

View file

@ -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());
}

View file

@ -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&);