6#ifndef QSK_BOX_SHAPE_METRICS_H
7#define QSK_BOX_SHAPE_METRICS_H
12#include <qnamespace.h>
21 Q_PROPERTY( QSizeF topLeft READ topLeft WRITE setTopLeft )
22 Q_PROPERTY( QSizeF topRight READ topRight WRITE setTopRight )
23 Q_PROPERTY( QSizeF bottomLeft READ bottomLeft WRITE setBottomLeft )
24 Q_PROPERTY( QSizeF bottomRight READ bottomRight WRITE setBottomRight )
26 Q_PROPERTY( qreal radius READ radiusX WRITE setRadius )
28 Q_PROPERTY( Qt::SizeMode sizeMode READ sizeMode WRITE setSizeMode )
29 Q_PROPERTY( ScalingMode scalingMode READ scalingMode WRITE setScalingMode )
67 qreal bottomLeft, qreal bottomRight, Qt::SizeMode = Qt::AbsoluteSize )
noexcept;
70 qreal radius, Qt::SizeMode = Qt::AbsoluteSize )
noexcept;
73 Qt::SizeMode = Qt::AbsoluteSize )
noexcept;
78 void setRadius( qreal radius )
noexcept;
79 void setRadius( qreal radius, Qt::SizeMode )
noexcept;
80 void setRadius( Qt::Corner, qreal radius )
noexcept;
82 void setRadius( qreal radiusX, qreal radiusY )
noexcept;
83 void setRadius(
const QSizeF& )
noexcept;
84 void setRadius( Qt::Corner, qreal radiusX, qreal radiusY )
noexcept;
85 void setRadius( Qt::Corner,
const QSizeF& radius )
noexcept;
87 void setRadius( qreal topLeft, qreal topRight,
88 qreal bottomLeft, qreal bottomRight )
noexcept;
90 void setRadius(
const QSizeF& topLeft,
const QSizeF& topRight,
91 const QSizeF& bottomLeft,
const QSizeF& bottomRight )
noexcept;
94 qreal topLeftX, qreal topLeftY,
95 qreal topRightX, qreal topRightY,
96 qreal bottomLeftX, qreal bottomLeftY,
97 qreal bottomRightX, qreal bottomRightY )
noexcept;
99 constexpr QSizeF radius( Qt::Corner )
const noexcept;
101 constexpr QSizeF topLeft()
const noexcept;
102 constexpr QSizeF topRight()
const noexcept;
103 constexpr QSizeF bottomLeft()
const noexcept;
104 constexpr QSizeF bottomRight()
const noexcept;
106 void setTopLeft(
const QSizeF& )
noexcept;
107 void setTopRight(
const QSizeF& )
noexcept;
108 void setBottomLeft(
const QSizeF& )
noexcept;
109 void setBottomRight(
const QSizeF& )
noexcept;
111 constexpr bool isRectangle()
const noexcept;
112 constexpr bool isRectellipse()
const noexcept;
114 void setSizeMode( Qt::SizeMode )
noexcept;
115 constexpr Qt::SizeMode sizeMode()
const noexcept;
117 void setScalingMode( ScalingMode )
noexcept;
118 constexpr ScalingMode scalingMode()
const noexcept;
127 QskHashValue hash( QskHashValue seed = 0 )
const noexcept;
134 inline qreal radiusX()
const {
return radius( Qt::TopLeftCorner ).width(); }
137 const QSizeF& topLeft,
const QSizeF& topRight,
138 const QSizeF& bottomLeft,
const QSizeF& bottomRight,
139 Qt::SizeMode sizeMode, ScalingMode scalingMode ) noexcept
140 : m_radii{ topLeft, topRight, bottomLeft, bottomRight }
141 , m_sizeMode( sizeMode )
142 , m_scalingMode( scalingMode )
147 Qt::SizeMode m_sizeMode : 2;
148 ScalingMode m_scalingMode : 2;
151inline constexpr QskBoxShapeMetrics::QskBoxShapeMetrics() noexcept
152 : m_radii{ { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 }, { 0.0, 0.0 } }
153 , m_sizeMode( Qt::AbsoluteSize )
154 , m_scalingMode( Symmetric )
158inline constexpr QskBoxShapeMetrics::QskBoxShapeMetrics(
159 qreal radius, Qt::SizeMode sizeMode ) noexcept
164inline constexpr QskBoxShapeMetrics::QskBoxShapeMetrics(
165 qreal radiusX, qreal radiusY, Qt::SizeMode sizeMode ) noexcept
166 : m_radii{ { radiusX, radiusY }, { radiusX, radiusY },
167 { radiusX, radiusY }, { radiusX, radiusY } }
168 , m_sizeMode( sizeMode )
169 , m_scalingMode( Symmetric )
173inline constexpr QskBoxShapeMetrics::QskBoxShapeMetrics( qreal topLeft, qreal topRight,
174 qreal bottomLeft, qreal bottomRight, Qt::SizeMode sizeMode ) noexcept
175 : m_radii{ { topLeft, topLeft }, { topRight, topRight },
176 { bottomLeft, bottomLeft }, { bottomRight, bottomRight } }
177 , m_sizeMode( sizeMode )
178 , m_scalingMode( Symmetric )
182inline constexpr bool QskBoxShapeMetrics::operator==(
185 return ( m_sizeMode == other.m_sizeMode )
186 && ( m_scalingMode == other.m_scalingMode )
187 && ( m_radii[ 0 ] == other.m_radii[ 0 ] )
188 && ( m_radii[ 1 ] == other.m_radii[ 1 ] )
189 && ( m_radii[ 2 ] == other.m_radii[ 2 ] )
190 && ( m_radii[ 3 ] == other.m_radii[ 3 ] );
193inline constexpr bool QskBoxShapeMetrics::operator!=(
196 return !( *
this == other );
199inline void QskBoxShapeMetrics::setRadius( qreal radius )
noexcept
201 setRadius( radius, radius );
204inline void QskBoxShapeMetrics::setRadius( qreal radius, Qt::SizeMode sizeMode )
noexcept
207 setSizeMode( sizeMode );
210inline void QskBoxShapeMetrics::setRadius( qreal radiusX, qreal radiusY )
noexcept
212 setRadius( radiusX, radiusY, radiusX, radiusY,
213 radiusX, radiusY, radiusX, radiusY );
216inline void QskBoxShapeMetrics::setRadius(
const QSizeF& radius )
noexcept
218 setRadius( radius.width(), radius.height() );
221inline void QskBoxShapeMetrics::setRadius( Qt::Corner corner, qreal radius )
noexcept
223 setRadius( corner, radius, radius );
226inline void QskBoxShapeMetrics::setRadius( Qt::Corner corner,
const QSizeF& radius )
noexcept
228 setRadius( corner, radius.width(), radius.height() );
231inline void QskBoxShapeMetrics::setRadius(
232 qreal topLeft, qreal topRight, qreal bottomLeft, qreal bottomRight )
noexcept
234 setRadius( topLeft, topLeft, topRight, topRight,
235 bottomLeft, bottomLeft, bottomRight, bottomRight );
238inline void QskBoxShapeMetrics::setRadius(
239 const QSizeF& topLeft,
const QSizeF& topRight,
240 const QSizeF& bottomLeft,
const QSizeF& bottomRight )
noexcept
242 setRadius( topLeft.width(), topLeft.height(),
243 topRight.width(), topRight.height(),
244 bottomLeft.width(), bottomLeft.height(),
245 bottomRight.width(), bottomRight.height() );
248inline constexpr QSizeF QskBoxShapeMetrics::radius( Qt::Corner corner )
const noexcept
250 return ( (
static_cast< int >( corner ) >= 0 ) && (
static_cast< int >( corner ) < 4 ) )
251 ? m_radii[ corner ] : QSizeF();
254inline constexpr QSizeF QskBoxShapeMetrics::topLeft() const noexcept
256 return radius( Qt::TopLeftCorner );
259inline constexpr QSizeF QskBoxShapeMetrics::topRight() const noexcept
261 return radius( Qt::TopRightCorner );
264inline constexpr QSizeF QskBoxShapeMetrics::bottomLeft() const noexcept
266 return radius( Qt::BottomLeftCorner );
269inline constexpr QSizeF QskBoxShapeMetrics::bottomRight() const noexcept
271 return radius( Qt::BottomRightCorner );
274inline void QskBoxShapeMetrics::setSizeMode( Qt::SizeMode sizeMode )
noexcept
276 m_sizeMode = sizeMode;
279inline constexpr Qt::SizeMode QskBoxShapeMetrics::sizeMode() const noexcept
284inline void QskBoxShapeMetrics::setScalingMode( ScalingMode scalingMode )
noexcept
286 m_scalingMode = scalingMode;
289inline constexpr QskBoxShapeMetrics::ScalingMode
290 QskBoxShapeMetrics::scalingMode() const noexcept
292 return m_scalingMode;
295inline constexpr bool QskBoxShapeMetrics::isRectellipse() const noexcept
297 return ( m_radii[ 1 ] == m_radii[ 0 ] )
298 && ( m_radii[ 2 ] == m_radii[ 1 ] )
299 && ( m_radii[ 3 ] == m_radii[ 2 ] );
302inline constexpr bool QskBoxShapeMetrics::isRectangle() const noexcept
304 return ( ( ( m_radii[ 0 ].width() <= 0.0 ) && ( m_radii[ 0 ].height() <= 0.0 ) )
305 && ( ( m_radii[ 1 ].width() <= 0.0 ) && ( m_radii[ 1 ].height() <= 0.0 ) )
306 && ( ( m_radii[ 2 ].width() <= 0.0 ) && ( m_radii[ 2 ].height() <= 0.0 ) )
307 && ( ( m_radii[ 3 ].width() <= 0.0 ) && ( m_radii[ 3 ].height() <= 0.0 ) ) );
313 m_radii[ 0 ].transposed(), m_radii[ 1 ].transposed(),
314 m_radii[ 2 ].transposed(), m_radii[ 3 ].transposed(),
315 m_sizeMode, m_scalingMode );
318#ifndef QT_NO_DEBUG_STREAM