6#ifndef QSK_SIZE_POLICY_H
7#define QSK_SIZE_POLICY_H
10#include <qnamespace.h>
17 Q_PROPERTY( Policy horizontal READ horizontalPolicy WRITE setHorizontalPolicy )
18 Q_PROPERTY( Policy vertical READ verticalPolicy WRITE setVerticalPolicy )
27 ConstrainedFlag = 1 << 4
36 Preferred = GrowFlag | ShrinkFlag,
37 MinimumExpanding = GrowFlag | ExpandFlag,
38 Expanding = GrowFlag | ShrinkFlag | ExpandFlag,
40 Ignored = ShrinkFlag | GrowFlag | IgnoreFlag,
42 Constrained = ConstrainedFlag,
44 ConstrainedMinimum = ConstrainedFlag | Minimum,
45 ConstrainedMaximum = ConstrainedFlag | Maximum,
46 ConstrainedPreferred = ConstrainedFlag | Preferred,
47 ConstrainedMinimumExpanding = ConstrainedFlag | MinimumExpanding,
48 ConstrainedExpanding = ConstrainedFlag | Expanding
51 enum ConstraintType : quint8
55 WidthForHeight = 1 << 0,
56 HeightForWidth = 1 << 1
61 Q_ENUM( ConstraintType )
64 constexpr QskSizePolicy( Policy horizontalPolicy, Policy verticalPolicy )
noexcept;
66 constexpr bool operator==(
const QskSizePolicy& )
const noexcept;
67 constexpr bool operator!=(
const QskSizePolicy& )
const noexcept;
69 void setHorizontalPolicy( Policy )
noexcept;
70 constexpr Policy horizontalPolicy()
const noexcept;
72 void setVerticalPolicy( Policy )
noexcept;
73 constexpr Policy verticalPolicy()
const noexcept;
75 void setPolicy( Qt::Orientation, Policy )
noexcept;
76 constexpr Policy policy( Qt::Orientation )
const noexcept;
78 ConstraintType constraintType()
const noexcept;
79 constexpr bool isConstrained( Qt::Orientation )
const noexcept;
81 Qt::SizeHint effectiveSizeHintType(
82 Qt::SizeHint, Qt::Orientation )
const noexcept;
85 void transpose()
noexcept;
88 Policy m_horizontalPolicy = Ignored;
89 Policy m_verticalPolicy = Ignored;
92inline constexpr QskSizePolicy::QskSizePolicy(
93 Policy horizontalPolicy, Policy verticalPolicy ) noexcept
94 : m_horizontalPolicy( horizontalPolicy )
95 , m_verticalPolicy( verticalPolicy )
99inline constexpr bool QskSizePolicy::operator==(
102 return ( other.m_horizontalPolicy == m_horizontalPolicy ) &&
103 ( other.m_verticalPolicy == m_verticalPolicy );
106inline constexpr bool QskSizePolicy::operator!=(
109 return !( *
this == other );
112inline void QskSizePolicy::setHorizontalPolicy( Policy policy )
noexcept
114 m_horizontalPolicy = policy;
117inline constexpr QskSizePolicy::Policy QskSizePolicy::horizontalPolicy() const noexcept
119 return m_horizontalPolicy;
122inline void QskSizePolicy::setVerticalPolicy( Policy policy )
noexcept
124 m_verticalPolicy = policy;
127inline constexpr QskSizePolicy::Policy QskSizePolicy::verticalPolicy() const noexcept
129 return m_verticalPolicy;
132inline constexpr QskSizePolicy::Policy QskSizePolicy::policy(
133 Qt::Orientation orientation )
const noexcept
135 return ( orientation == Qt::Horizontal ) ? m_horizontalPolicy : m_verticalPolicy;
138inline void QskSizePolicy::setPolicy(
139 Qt::Orientation orientation, Policy policy )
noexcept
141 if ( orientation == Qt::Horizontal )
142 m_horizontalPolicy = policy;
144 m_verticalPolicy = policy;
147inline constexpr bool QskSizePolicy::isConstrained(
148 Qt::Orientation orientation )
const noexcept
150 return ( policy( orientation ) & ConstrainedFlag );
153inline constexpr QskSizePolicy QskSizePolicy::transposed() const noexcept
155 return QskSizePolicy( m_verticalPolicy, m_horizontalPolicy );
158#ifndef QT_NO_DEBUG_STREAM