forked from quickshell/quickshell
core/types: add implicit coversion from rect to box
This commit is contained in:
parent
6b9b1fcb53
commit
58c3718287
1 changed files with 10 additions and 0 deletions
|
@ -13,11 +13,21 @@ class Box {
|
|||
Q_PROPERTY(qint32 h MEMBER h);
|
||||
Q_PROPERTY(qint32 width MEMBER w);
|
||||
Q_PROPERTY(qint32 height MEMBER h);
|
||||
QML_CONSTRUCTIBLE_VALUE;
|
||||
QML_VALUE_TYPE(box);
|
||||
|
||||
public:
|
||||
explicit Box() = default;
|
||||
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 QRectF& rect)
|
||||
: x(static_cast<qint32>(rect.x()))
|
||||
, y(static_cast<qint32>(rect.y()))
|
||||
, w(static_cast<qint32>(rect.width()))
|
||||
, h(static_cast<qint32>(rect.height())) {}
|
||||
|
||||
bool operator==(const Box& other) const;
|
||||
|
||||
qint32 x = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue