2023-02-08 17:58:09 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
2023-04-06 09:23:37 +02:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2023-02-08 17:58:09 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_BOX_METRICS_H
|
|
|
|
#define QSK_BOX_METRICS_H
|
|
|
|
|
|
|
|
#include <qrect.h>
|
2023-02-14 09:29:51 +01:00
|
|
|
#include <qglobal.h>
|
2023-02-08 17:58:09 +01:00
|
|
|
#include <qnamespace.h>
|
|
|
|
|
|
|
|
class QskBoxShapeMetrics;
|
|
|
|
class QskBoxBorderMetrics;
|
|
|
|
|
|
|
|
class QskBoxMetrics
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
QskBoxMetrics( const QRectF&,
|
|
|
|
const QskBoxShapeMetrics&, const QskBoxBorderMetrics& );
|
|
|
|
|
|
|
|
const QRectF outerRect;
|
|
|
|
QRectF innerRect;
|
|
|
|
|
|
|
|
int outerStepCount() const;
|
|
|
|
int innerStepCount() const;
|
|
|
|
|
2023-02-14 09:29:51 +01:00
|
|
|
int innerStepCount( int corner1, int corner2 ) const
|
|
|
|
{
|
|
|
|
return qMax( corners[ corner1 ].innerStepCount(),
|
|
|
|
corners[ corner2 ].innerStepCount() );
|
|
|
|
}
|
|
|
|
|
2023-02-08 17:58:09 +01:00
|
|
|
struct Corner
|
|
|
|
{
|
|
|
|
inline qreal xInner( qreal cos ) const
|
|
|
|
{ return centerInnerX + sx * cos * radiusInnerX; }
|
|
|
|
|
|
|
|
inline qreal yInner( qreal sin ) const
|
|
|
|
{ return centerInnerY + sy * sin * radiusInnerY; }
|
|
|
|
|
|
|
|
inline qreal xOuter( qreal cos ) const
|
|
|
|
{ return centerX + sx * ( cos * radiusX ); }
|
|
|
|
|
|
|
|
inline qreal yOuter( qreal sin ) const
|
|
|
|
{ return centerY + sy * ( sin * radiusY ); }
|
|
|
|
|
|
|
|
inline int innerStepCount() const
|
|
|
|
{ return ( centerInnerX == 0.0 ) ? 1 : stepCount; }
|
|
|
|
|
|
|
|
qreal centerX, centerY;
|
|
|
|
qreal radiusX, radiusY;
|
|
|
|
|
|
|
|
qreal centerInnerX, centerInnerY;
|
|
|
|
qreal radiusInnerX, radiusInnerY;
|
|
|
|
|
|
|
|
qreal sx, sy;
|
|
|
|
|
|
|
|
int stepCount = 0;
|
|
|
|
|
|
|
|
} corners[ 4 ];
|
|
|
|
|
|
|
|
bool hasBorder = false;
|
|
|
|
|
|
|
|
// the same border width on all sides
|
|
|
|
bool isBorderRegular = false;
|
|
|
|
|
|
|
|
// true for plain rectangles
|
|
|
|
bool isOutsideRounded = false;
|
|
|
|
/*
|
|
|
|
outer radii are symmetric in both directions ( rectellipse )
|
|
|
|
However the inner radii might differ when isBorderRegular is false
|
|
|
|
*/
|
|
|
|
bool isOutsideSymmetric = false;
|
|
|
|
|
|
|
|
/*
|
|
|
|
When the border width exceed the inner radius the corner
|
|
|
|
becomes rectangular at the inside. When this happens to
|
|
|
|
all corners the inner part dgenerates to a rectangle and
|
|
|
|
can be filled with a simpler algo.
|
|
|
|
*/
|
|
|
|
bool isInsideRounded = false;
|
|
|
|
|
|
|
|
/*
|
|
|
|
stepSymmetries indicates the directions, where we can
|
|
|
|
iterate with the the same steps along opposing corners.
|
|
|
|
This is possible, when both corners have the same radius
|
|
|
|
or one of them has a radius of 0.
|
|
|
|
*/
|
|
|
|
Qt::Orientations stepSymmetries;
|
|
|
|
|
2023-02-14 11:19:13 +01:00
|
|
|
// the direction that needs less contour lines is preferred.
|
2023-02-08 17:58:09 +01:00
|
|
|
Qt::Orientation preferredOrientation;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|