13#include <qnamespace.h>
26 Q_PROPERTY( qreal left READ left WRITE setLeft )
27 Q_PROPERTY( qreal top READ top WRITE setTop )
28 Q_PROPERTY( qreal right READ right WRITE setRight )
29 Q_PROPERTY( qreal bottom READ bottom WRITE setBottom )
33 constexpr QskMargins(
const QMarginsF& )
noexcept;
34 constexpr QskMargins(
const QMargins& )
noexcept;
36 constexpr QskMargins( qreal left, qreal top, qreal right, qreal bottom )
noexcept;
38 constexpr QskMargins( qreal horizontal, qreal vertical )
noexcept;
40 QskMargins mirrored( Qt::Orientations )
const noexcept;
43 constexpr QskMargins translated( qreal dx, qreal dy )
const noexcept;
45 constexpr QskMargins grownBy( qreal dx, qreal dy )
const noexcept;
46 constexpr QskMargins shrunkBy( qreal dx, qreal dy )
const noexcept;
51 void setMargins( qreal margin )
noexcept;
52 void setMargins( qreal horizontal, qreal vertical )
noexcept;
54 void setMarginsAt( Qt::Edges, qreal )
noexcept;
55 qreal marginAt( Qt::Edge )
const noexcept;
57 constexpr qreal width()
const noexcept;
58 constexpr qreal height()
const noexcept;
59 constexpr qreal extent( Qt::Orientation )
const noexcept;
63 constexpr bool isExpanding()
const noexcept;
64 constexpr bool isEquidistant()
const noexcept;
66 static QVariant interpolate(
const QskMargins&,
70constexpr inline QskMargins::QskMargins( qreal margin ) noexcept
75constexpr inline QskMargins::QskMargins(
76 qreal horizontal, qreal vertical ) noexcept
77 :
QskMargins( horizontal, vertical, horizontal, vertical )
81constexpr QskMargins::QskMargins(
82 qreal left, qreal top, qreal right, qreal bottom ) noexcept
83 : QMarginsF( left, top, right, bottom )
87constexpr inline QskMargins::QskMargins(
const QMarginsF& margins ) noexcept
88 : QMarginsF( margins )
92constexpr inline QskMargins::QskMargins(
const QMargins& margins ) noexcept
93 : QMarginsF( margins )
97inline void QskMargins::setMargins( qreal margin )
noexcept
102inline constexpr bool QskMargins::isExpanding() const noexcept
104 return ( left() > 0 ) || ( right() > 0 ) || ( top() > 0 ) || ( right() > 0 );
107inline void QskMargins::setMargins( qreal horizontal, qreal vertical )
noexcept
113 Qt::Orientations orientations )
const noexcept
115 switch (
int( orientations ) )
118 return QskMargins( left(), bottom(), right(), top() );
121 return QskMargins( right(), top(), left(), bottom() );
123 case Qt::Vertical | Qt::Horizontal:
124 return QskMargins( right(), bottom(), left(), top() );
131constexpr inline QskMargins QskMargins::rotated() const noexcept
133 return QskMargins( top(), left(), bottom(), right() );
136constexpr inline QskMargins QskMargins::translated( qreal dx, qreal dy )
const noexcept
138 return QskMargins( left() + dx, top() + dy, right() - dx, bottom() - dy );
141constexpr inline QskMargins QskMargins::grownBy( qreal dx, qreal dy )
const noexcept
143 return QskMargins( left() + dx, top() + dy, right() + dx, bottom() + dy );
146constexpr inline QskMargins QskMargins::shrunkBy( qreal dx, qreal dy )
const noexcept
148 return QskMargins( left() - dx, top() - dy, right() - dx, bottom() - dy );
154 qMax( left(), other.left() ),
155 qMax( top(), other.top() ),
156 qMax( right(), other.right() ),
157 qMax( bottom(), other.bottom() )
164 qMin( left(), other.left() ),
165 qMin( top(), other.top() ),
166 qMin( right(), other.right() ),
167 qMin( bottom(), other.bottom() )
170constexpr inline qreal QskMargins::extent( Qt::Orientation orientation )
const noexcept
172 return ( orientation == Qt::Horizontal ) ? width() : height();
175constexpr inline qreal QskMargins::width() const noexcept
177 return left() + right();
180constexpr inline qreal QskMargins::height() const noexcept
182 return top() + bottom();
185inline constexpr bool QskMargins::isEquidistant() const noexcept
187 return ( left() == top() ) && ( left() == right() ) && ( left() == bottom() );
190Q_DECLARE_TYPEINFO(
QskMargins, Q_MOVABLE_TYPE );