1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:37:36 +00:00

LibGfx: Make formatting of spatial types work with non-int/floats

Line, Point, Rect, and Size now all have Formatters that will work with
any type that itself has a Formatter.
This commit is contained in:
Sam Atkins 2022-10-26 20:26:14 +01:00 committed by Andreas Kling
parent 27b63feae5
commit 07bceb861a
4 changed files with 19 additions and 6 deletions

View file

@ -183,10 +183,10 @@ using FloatSize = Size<float>;
namespace AK {
template<typename T>
struct Formatter<Gfx::Size<T>> : Formatter<StringView> {
struct Formatter<Gfx::Size<T>> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, Gfx::Size<T> const& value)
{
return Formatter<StringView>::format(builder, value.to_string());
return Formatter<FormatString>::format(builder, "[{}x{}]"sv, value.width(), value.height());
}
};