mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
LibGfx: Add a bunch of [[nodiscard]] to Size
This commit is contained in:
parent
bd9096c97d
commit
243dfb3bdc
2 changed files with 14 additions and 14 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -59,28 +59,28 @@ public:
|
||||||
ALWAYS_INLINE void scale_by(T dboth) { scale_by(dboth, dboth); }
|
ALWAYS_INLINE void scale_by(T dboth) { scale_by(dboth, dboth); }
|
||||||
ALWAYS_INLINE void scale_by(Point<T> const& s) { scale_by(s.x(), s.y()); }
|
ALWAYS_INLINE void scale_by(Point<T> const& s) { scale_by(s.x(), s.y()); }
|
||||||
|
|
||||||
Size scaled_by(T dx, T dy) const
|
[[nodiscard]] Size scaled_by(T dx, T dy) const
|
||||||
{
|
{
|
||||||
Size<T> size = *this;
|
Size<T> size = *this;
|
||||||
size.scale_by(dx, dy);
|
size.scale_by(dx, dy);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size scaled_by(T dboth) const
|
[[nodiscard]] Size scaled_by(T dboth) const
|
||||||
{
|
{
|
||||||
Size<T> size = *this;
|
Size<T> size = *this;
|
||||||
size.scale_by(dboth);
|
size.scale_by(dboth);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size scaled_by(Point<T> const& s) const
|
[[nodiscard]] Size scaled_by(Point<T> const& s) const
|
||||||
{
|
{
|
||||||
Size<T> size = *this;
|
Size<T> size = *this;
|
||||||
size.scale_by(s);
|
size.scale_by(s);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size transformed_by(AffineTransform const& transform) const
|
[[nodiscard]] Size transformed_by(AffineTransform const& transform) const
|
||||||
{
|
{
|
||||||
Size<T> size = *this;
|
Size<T> size = *this;
|
||||||
size.transform_by(transform);
|
size.transform_by(transform);
|
||||||
|
@ -88,19 +88,19 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U>
|
template<typename U>
|
||||||
bool contains(Size<U> const& other) const
|
[[nodiscard]] bool contains(Size<U> const& other) const
|
||||||
{
|
{
|
||||||
return other.m_width <= m_width && other.m_height <= m_height;
|
return other.m_width <= m_width && other.m_height <= m_height;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class U>
|
template<class U>
|
||||||
bool operator==(Size<U> const& other) const
|
[[nodiscard]] bool operator==(Size<U> const& other) const
|
||||||
{
|
{
|
||||||
return width() == other.width() && height() == other.height();
|
return width() == other.width() && height() == other.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class U>
|
template<class U>
|
||||||
bool operator!=(Size<U> const& other) const
|
[[nodiscard]] bool operator!=(Size<U> const& other) const
|
||||||
{
|
{
|
||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size<T> operator*(T factor) const { return { m_width * factor, m_height * factor }; }
|
[[nodiscard]] Size<T> operator*(T factor) const { return { m_width * factor, m_height * factor }; }
|
||||||
|
|
||||||
Size<T>& operator*=(T factor)
|
Size<T>& operator*=(T factor)
|
||||||
{
|
{
|
||||||
|
@ -128,7 +128,7 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
T primary_size_for_orientation(Orientation orientation) const
|
[[nodiscard]] T primary_size_for_orientation(Orientation orientation) const
|
||||||
{
|
{
|
||||||
return orientation == Orientation::Vertical ? height() : width();
|
return orientation == Orientation::Vertical ? height() : width();
|
||||||
}
|
}
|
||||||
|
@ -142,7 +142,7 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
T secondary_size_for_orientation(Orientation orientation) const
|
[[nodiscard]] T secondary_size_for_orientation(Orientation orientation) const
|
||||||
{
|
{
|
||||||
return orientation == Orientation::Vertical ? width() : height();
|
return orientation == Orientation::Vertical ? width() : height();
|
||||||
}
|
}
|
||||||
|
@ -157,12 +157,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename U>
|
template<typename U>
|
||||||
ALWAYS_INLINE Size<U> to_type() const
|
[[nodiscard]] ALWAYS_INLINE Size<U> to_type() const
|
||||||
{
|
{
|
||||||
return Size<U>(*this);
|
return Size<U>(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
String to_string() const;
|
[[nodiscard]] String to_string() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T m_width { 0 };
|
T m_width { 0 };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue