1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:57:45 +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

@ -285,10 +285,10 @@ inline Point<T> cubic_interpolate(Point<T> const& p1, Point<T> const& p2, Point<
namespace AK {
template<typename T>
struct Formatter<Gfx::Point<T>> : Formatter<StringView> {
struct Formatter<Gfx::Point<T>> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, Gfx::Point<T> const& value)
{
return Formatter<StringView>::format(builder, value.to_string());
return Formatter<FormatString>::format(builder, "[{},{}]"sv, value.x(), value.y());
}
};