mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05: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:
parent
27b63feae5
commit
07bceb861a
4 changed files with 19 additions and 6 deletions
|
@ -1026,10 +1026,10 @@ using FloatRect = Rect<float>;
|
|||
namespace AK {
|
||||
|
||||
template<typename T>
|
||||
struct Formatter<Gfx::Rect<T>> : Formatter<StringView> {
|
||||
struct Formatter<Gfx::Rect<T>> : Formatter<FormatString> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Gfx::Rect<T> const& value)
|
||||
{
|
||||
return Formatter<StringView>::format(builder, value.to_string());
|
||||
return Formatter<FormatString>::format(builder, "[{},{} {}x{}]"sv, value.x(), value.y(), value.width(), value.height());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue