LibGfx: Allow constructing Float{Rect,Point,Size} from integer buddies
This commit is contained in:
parent
dd7796515f
commit
5c780c9ef7
Notes:
sideshowbarker
2024-07-19 07:40:20 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/5c780c9ef75
3 changed files with 19 additions and 0 deletions
|
@ -29,6 +29,7 @@
|
|||
#include <AK/LogStream.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/Orientation.h>
|
||||
#include <LibGfx/Point.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
@ -42,6 +43,13 @@ public:
|
|||
, m_y(y)
|
||||
{
|
||||
}
|
||||
|
||||
explicit FloatPoint(const Point& other)
|
||||
: m_x(other.x())
|
||||
, m_y(other.y())
|
||||
{
|
||||
}
|
||||
|
||||
float x() const { return m_x; }
|
||||
float y() const { return m_y; }
|
||||
|
||||
|
|
|
@ -56,6 +56,11 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
explicit FloatRect(const Rect& other)
|
||||
: FloatRect((FloatPoint)other.location(), (FloatSize)other.size())
|
||||
{
|
||||
}
|
||||
|
||||
bool is_null() const
|
||||
{
|
||||
return width() == 0 && height() == 0;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <AK/LogStream.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibGfx/Orientation.h>
|
||||
#include <LibGfx/Size.h>
|
||||
|
||||
namespace Gfx {
|
||||
|
||||
|
@ -40,6 +41,11 @@ public:
|
|||
, m_height(h)
|
||||
{
|
||||
}
|
||||
explicit FloatSize(const Size& other)
|
||||
: m_width(other.width())
|
||||
, m_height(other.height())
|
||||
{
|
||||
}
|
||||
|
||||
bool is_null() const { return !m_width && !m_height; }
|
||||
bool is_empty() const { return m_width <= 0 || m_height <= 0; }
|
||||
|
|
Loading…
Add table
Reference in a new issue