core/panelwindow: move Margins to types.hpp
This commit is contained in:
parent
2773e5468f
commit
ef077ddd24
5 changed files with 51 additions and 44 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "types.hpp"
|
||||
|
||||
#include <qdebug.h>
|
||||
#include <qmargins.h>
|
||||
#include <qnamespace.h>
|
||||
#include <qrect.h>
|
||||
|
||||
|
@ -21,3 +22,5 @@ Qt::Edges Edges::toQt(Edges::Flags edges) { return Qt::Edges(edges.toInt()); }
|
|||
bool Edges::isOpposing(Edges::Flags edges) {
|
||||
return edges.testFlags(Edges::Top | Edges::Bottom) || edges.testFlags(Edges::Left | Edges::Right);
|
||||
}
|
||||
|
||||
QMargins Margins::qmargins() const { return {this->left, this->top, this->right, this->bottom}; }
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <qdebug.h>
|
||||
#include <qmargins.h>
|
||||
#include <qnamespace.h>
|
||||
#include <qpoint.h>
|
||||
#include <qqmlintegration.h>
|
||||
|
@ -49,6 +50,33 @@ public:
|
|||
|
||||
QDebug operator<<(QDebug debug, const Box& box);
|
||||
|
||||
class Margins {
|
||||
Q_GADGET;
|
||||
Q_PROPERTY(qint32 left MEMBER left);
|
||||
Q_PROPERTY(qint32 right MEMBER right);
|
||||
Q_PROPERTY(qint32 top MEMBER top);
|
||||
Q_PROPERTY(qint32 bottom MEMBER bottom);
|
||||
QML_CONSTRUCTIBLE_VALUE;
|
||||
QML_VALUE_TYPE(margins);
|
||||
|
||||
public:
|
||||
[[nodiscard]] bool operator==(const Margins& other) const noexcept {
|
||||
// clang-format off
|
||||
return this->left == other.left
|
||||
&& this->right == other.right
|
||||
&& this->top == other.top
|
||||
&& this->bottom == other.bottom;
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
qint32 left = 0;
|
||||
qint32 right = 0;
|
||||
qint32 top = 0;
|
||||
qint32 bottom = 0;
|
||||
|
||||
[[nodiscard]] QMargins qmargins() const;
|
||||
};
|
||||
|
||||
///! Top Left Right Bottom flags.
|
||||
/// Edge flags can be combined with the `|` operator.
|
||||
namespace Edges { // NOLINT
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue