QskBoxRenderer fixes

This commit is contained in:
Uwe Rathmann 2023-01-04 16:15:22 +01:00
parent 25558dd50d
commit 1b85d3053e
2 changed files with 34 additions and 59 deletions

View File

@ -74,25 +74,42 @@ bool QskBoxRenderer::isGradientSupported(
// rectangles are fully supported
return true;
}
const auto dir = gradient.linearDirection();
if ( dir.isTilted() )
{
return ( dir.x1() == 0.0 && dir.x2() == 0.0 )
&& ( dir.y1() == 1.0 && dir.y2() == 1.0 );
}
else
{
/*
For rounded rectangles we currently support
only the most common use cases. TODO ...
*/
// different radii at oppsoite corners are not implemented TODO ...
const auto dir = gradient.linearDirection();
if ( dir.isTilted() )
const auto r1 = shape.radius( Qt::TopLeftCorner );
const auto r2 = shape.radius( Qt::TopRightCorner );
const auto r3 = shape.radius( Qt::BottomLeftCorner );
const auto r4 = shape.radius( Qt::BottomRightCorner );
if ( dir.isHorizontal() )
{
return ( dir.x1() == 0.0 && dir.x2() == 0.0 )
&& ( dir.y1() == 1.0 && dir.y2() == 1.0 );
if ( dir.x1() == 0.0 && dir.x2() == 1.0 )
{
return ( r1.width() == r3.width() )
&& ( r2.width() == r4.width() );
}
}
else
{
return ( dir.x1() == 0.0 && dir.x2() == 1.0 )
|| ( dir.y1() == 0.0 && dir.y2() == 1.0 );
if ( dir.y1() == 0.0 && dir.y2() == 1.0 )
{
return ( r1.height() == r2.height() )
&& ( r3.height() == r4.height() );
}
}
}
return false;
}
default:

View File

@ -6,7 +6,7 @@
#ifndef QSK_BOX_RENDERER_H
#define QSK_BOX_RENDERER_H
#include "QskVertex.h"
#include "QskGlobal.h"
class QskBoxBorderMetrics;
class QskBoxBorderColors;
@ -16,61 +16,19 @@ class QskGradient;
class QSGGeometry;
class QRectF;
class QSK_EXPORT QskBoxRenderer
namespace QskBoxRenderer
{
public:
static void renderBorder( const QRectF&,
QSK_EXPORT void renderBorder( const QRectF&,
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, QSGGeometry& );
static void renderFill( const QRectF&,
QSK_EXPORT void renderFill( const QRectF&,
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, QSGGeometry& );
static void renderBox( const QRectF&,
QSK_EXPORT void renderBox( const QRectF&,
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&,
const QskBoxBorderColors&, const QskGradient&, QSGGeometry& );
static bool isGradientSupported( const QskBoxShapeMetrics&, const QskGradient& );
class Metrics
{
public:
Metrics( const QRectF&, const QskBoxShapeMetrics&, const QskBoxBorderMetrics& );
QskVertex::Quad outerQuad;
QskVertex::Quad innerQuad;
#if 1
QskVertex::Quad centerQuad; // to be removed
#endif
struct Corner
{
bool isCropped;
qreal centerX, centerY;
qreal radiusX, radiusY;
qreal radiusInnerX, radiusInnerY;
int stepCount;
} corner[ 4 ];
bool isBorderRegular;
bool isRadiusRegular;
bool isTotallyCropped;
};
private:
static void renderRectellipseFill( const QRectF&,
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, QSGGeometry& );
static void renderRectellipseBorder( const QRectF&,
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&, QSGGeometry& );
static void renderRectellipse( const QRectF&,
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&,
const QskBoxBorderColors&, const QskGradient&, QSGGeometry& );
static void renderDiagonalFill( const Metrics&, const QskGradient&,
int lineCount, QskVertex::ColoredLine* );
};
QSK_EXPORT bool isGradientSupported( const QskBoxShapeMetrics&, const QskGradient& );
}
#endif