QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskBoxMetrics.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_BOX_METRICS_H
7#define QSK_BOX_METRICS_H
8
9#include <qrect.h>
10#include <qglobal.h>
11#include <qnamespace.h>
12
15
17{
18 public:
19 QskBoxMetrics( const QRectF&,
21
22 const QRectF outerRect;
23 QRectF innerRect;
24
25 int outerStepCount() const;
26 int innerStepCount() const;
27
28 int innerStepCount( int corner1, int corner2 ) const
29 {
30 return qMax( corners[ corner1 ].innerStepCount(),
31 corners[ corner2 ].innerStepCount() );
32 }
33
34 struct Corner
35 {
36 inline qreal xInner( qreal cos ) const
37 { return centerInnerX + sx * cos * radiusInnerX; }
38
39 inline qreal yInner( qreal sin ) const
40 { return centerInnerY + sy * sin * radiusInnerY; }
41
42 inline qreal xOuter( qreal cos ) const
43 { return centerX + sx * ( cos * radiusX ); }
44
45 inline qreal yOuter( qreal sin ) const
46 { return centerY + sy * ( sin * radiusY ); }
47
48 inline int innerStepCount() const
49 { return ( centerInnerX == 0.0 ) ? 1 : stepCount; }
50
51 qreal centerX, centerY;
52 qreal radiusX, radiusY;
53
54 qreal centerInnerX, centerInnerY;
55 qreal radiusInnerX, radiusInnerY;
56
57 qreal sx, sy;
58
59 int stepCount = 0;
60
61 } corners[ 4 ];
62
63 bool hasBorder = false;
64
65 // the same border width on all sides
66 bool isBorderRegular = false;
67
68 // true for plain rectangles
69 bool isOutsideRounded = false;
70 /*
71 outer radii are symmetric in both directions ( rectellipse )
72 However the inner radii might differ when isBorderRegular is false
73 */
74 bool isOutsideSymmetric = false;
75
76 /*
77 When the border width exceed the inner radius the corner
78 becomes rectangular at the inside. When this happens to
79 all corners the inner part dgenerates to a rectangle and
80 can be filled with a simpler algo.
81 */
82 bool isInsideRounded = false;
83
84 /*
85 stepSymmetries indicates the directions, where we can
86 iterate with the the same steps along opposing corners.
87 This is possible, when both corners have the same radius
88 or one of them has a radius of 0.
89 */
90 Qt::Orientations stepSymmetries;
91
92 // the direction that needs less contour lines is preferred.
93 Qt::Orientation preferredOrientation;
94};
95
96#endif