core/types: allow implicit conversion from point to box

This commit is contained in:
outfoxxed 2024-07-26 10:06:56 -07:00
parent 58c3718287
commit 4b2e569e94
Signed by: outfoxxed
GPG key ID: 4C88A185FB89301E

View file

@ -2,6 +2,7 @@
#include <qdebug.h>
#include <qnamespace.h>
#include <qpoint.h>
#include <qqmlintegration.h>
#include <qtmetamacros.h>
@ -21,6 +22,7 @@ public:
Box(qint32 x, qint32 y, qint32 w, qint32 h): x(x), y(y), w(w), h(h) {}
Q_INVOKABLE Box(const QRect& rect): x(rect.x()), y(rect.y()), w(rect.width()), h(rect.height()) {}
Q_INVOKABLE Box(const QPoint& rect): x(rect.x()), y(rect.y()) {}
Q_INVOKABLE Box(const QRectF& rect)
: x(static_cast<qint32>(rect.x()))
@ -28,6 +30,10 @@ public:
, w(static_cast<qint32>(rect.width()))
, h(static_cast<qint32>(rect.height())) {}
Q_INVOKABLE Box(const QPointF& rect)
: x(static_cast<qint32>(rect.x()))
, y(static_cast<qint32>(rect.y())) {}
bool operator==(const Box& other) const;
qint32 x = 0;