2022-12-06 15:52:55 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "QskBoxRenderer.h"
|
|
|
|
#include "QskBoxShapeMetrics.h"
|
|
|
|
|
|
|
|
#include "QskGradient.h"
|
|
|
|
#include "QskGradientDirection.h"
|
|
|
|
|
|
|
|
void QskBoxRenderer::renderBorder(
|
|
|
|
const QRectF& rect, const QskBoxShapeMetrics& shape,
|
|
|
|
const QskBoxBorderMetrics& border, QSGGeometry& geometry )
|
|
|
|
{
|
|
|
|
if ( shape.isRectangle() )
|
|
|
|
renderRectBorder( rect, border, geometry );
|
|
|
|
else
|
|
|
|
renderRectellipseBorder( rect, shape, border, geometry );
|
|
|
|
}
|
|
|
|
|
|
|
|
void QskBoxRenderer::renderFill(
|
|
|
|
const QRectF& rect, const QskBoxShapeMetrics& shape,
|
|
|
|
const QskBoxBorderMetrics& border, QSGGeometry& geometry )
|
|
|
|
{
|
|
|
|
if ( shape.isRectangle() )
|
|
|
|
renderRectFill( rect, border, geometry );
|
|
|
|
else
|
|
|
|
renderRectellipseFill( rect, shape, border, geometry );
|
|
|
|
}
|
|
|
|
|
|
|
|
void QskBoxRenderer::renderBox( const QRectF& rect,
|
|
|
|
const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& border,
|
|
|
|
const QskBoxBorderColors& borderColors, const QskGradient& gradient,
|
|
|
|
QSGGeometry& geometry )
|
|
|
|
{
|
|
|
|
if ( shape.isRectangle() )
|
|
|
|
renderRect( rect, border, borderColors, gradient, geometry );
|
|
|
|
else
|
|
|
|
renderRectellipse( rect, shape, border, borderColors, gradient, geometry );
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QskBoxRenderer::isGradientSupported(
|
|
|
|
const QskBoxShapeMetrics&, const QskGradient& gradient )
|
|
|
|
{
|
2022-12-10 15:08:32 +00:00
|
|
|
if ( !gradient.isVisible() || gradient.isMonochrome()
|
|
|
|
|| ( gradient.type() == QskGradient::Stops ) )
|
|
|
|
{
|
2022-12-06 15:52:55 +00:00
|
|
|
return true;
|
2022-12-10 15:08:32 +00:00
|
|
|
}
|
2022-12-06 15:52:55 +00:00
|
|
|
|
2022-12-10 15:08:32 +00:00
|
|
|
if ( gradient.type() == QskGradient::Linear )
|
2022-12-06 15:52:55 +00:00
|
|
|
{
|
2022-12-10 15:08:32 +00:00
|
|
|
const auto dir = gradient.linearDirection();
|
2022-12-06 15:52:55 +00:00
|
|
|
|
2022-12-10 15:08:32 +00:00
|
|
|
if ( dir.isTilted() )
|
|
|
|
{
|
|
|
|
if ( dir.x1() == 0.0 && dir.y1() == 0.0
|
|
|
|
&& dir.x2() == 1.0 && dir.y2() == 1.0 )
|
2022-12-06 15:52:55 +00:00
|
|
|
{
|
2022-12-10 15:08:32 +00:00
|
|
|
return true;
|
2022-12-06 15:52:55 +00:00
|
|
|
}
|
|
|
|
}
|
2022-12-10 15:08:32 +00:00
|
|
|
else
|
2022-12-06 15:52:55 +00:00
|
|
|
{
|
2022-12-10 15:08:32 +00:00
|
|
|
if ( dir.x1() == 0.0 && dir.x2() == 1.0 )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if ( dir.y1() == 0.0 && dir.y2() == 1.0 )
|
|
|
|
return true;
|
2022-12-06 15:52:55 +00:00
|
|
|
}
|
|
|
|
}
|
2022-12-10 15:08:32 +00:00
|
|
|
|
|
|
|
return false;
|
2022-12-06 15:52:55 +00:00
|
|
|
}
|