mirror of
https://github.com/RGBCube/serenity
synced 2025-05-18 09:35:07 +00:00

This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
54 lines
1.1 KiB
C++
54 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <AK/DeprecatedString.h>
|
|
#include <AK/StdLibExtras.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibGfx/Line.h>
|
|
#include <LibGfx/Rect.h>
|
|
#include <LibIPC/Decoder.h>
|
|
#include <LibIPC/Encoder.h>
|
|
|
|
namespace Gfx {
|
|
|
|
template<>
|
|
DeprecatedString IntRect::to_deprecated_string() const
|
|
{
|
|
return DeprecatedString::formatted("[{},{} {}x{}]", x(), y(), width(), height());
|
|
}
|
|
|
|
template<>
|
|
DeprecatedString FloatRect::to_deprecated_string() const
|
|
{
|
|
return DeprecatedString::formatted("[{},{} {}x{}]", x(), y(), width(), height());
|
|
}
|
|
|
|
}
|
|
|
|
namespace IPC {
|
|
|
|
template<>
|
|
bool encode(Encoder& encoder, Gfx::IntRect const& rect)
|
|
{
|
|
encoder << rect.location() << rect.size();
|
|
return true;
|
|
}
|
|
|
|
template<>
|
|
ErrorOr<void> decode(Decoder& decoder, Gfx::IntRect& rect)
|
|
{
|
|
Gfx::IntPoint point;
|
|
Gfx::IntSize size;
|
|
TRY(decoder.decode(point));
|
|
TRY(decoder.decode(size));
|
|
rect = { point, size };
|
|
return {};
|
|
}
|
|
|
|
}
|
|
|
|
template class Gfx::Rect<int>;
|
|
template class Gfx::Rect<float>;
|