incorporate feedback from Uwe
This commit is contained in:
parent
0050fe5456
commit
fbd178a4ab
|
@ -22,9 +22,9 @@ static void qskRegisterBoxBorderColors()
|
|||
|
||||
Q_CONSTRUCTOR_FUNCTION( qskRegisterBoxBorderColors )
|
||||
|
||||
static inline void qskSetGradients( const QskGradient& c, QskGradient* gradients )
|
||||
static inline void qskSetGradients( const QskGradient& gradient, QskGradient* gradients )
|
||||
{
|
||||
gradients[ 0 ] = gradients[ 1 ] = gradients[ 2 ] = gradients[ 3 ] = c;
|
||||
gradients[ 0 ] = gradients[ 1 ] = gradients[ 2 ] = gradients[ 3 ] = gradient;
|
||||
}
|
||||
|
||||
static inline void qskSetGradients(
|
||||
|
@ -110,7 +110,7 @@ void QskBoxBorderColors::setGradientAt( Qt::Edges edges, const QskGradient& grad
|
|||
m_gradients[ Qsk::Bottom ] = gradient;
|
||||
}
|
||||
|
||||
QskGradient QskBoxBorderColors::gradientAt( Qt::Edge edge ) const
|
||||
const QskGradient& QskBoxBorderColors::gradientAt( Qt::Edge edge ) const
|
||||
{
|
||||
switch ( edge )
|
||||
{
|
||||
|
@ -127,7 +127,8 @@ QskGradient QskBoxBorderColors::gradientAt( Qt::Edge edge ) const
|
|||
return m_gradients[ Qsk::Bottom ];
|
||||
}
|
||||
|
||||
return QColor();
|
||||
static QskGradient noGradient;
|
||||
return noGradient;
|
||||
}
|
||||
|
||||
bool QskBoxBorderColors::isVisible() const
|
||||
|
|
|
@ -42,7 +42,7 @@ class QSK_EXPORT QskBoxBorderColors
|
|||
QskGradient gradient( Qsk::Position ) const;
|
||||
|
||||
void setGradientAt( Qt::Edges, const QskGradient& );
|
||||
QskGradient gradientAt( Qt::Edge ) const;
|
||||
const QskGradient& gradientAt( Qt::Edge ) const;
|
||||
|
||||
QskBoxBorderColors interpolated( const QskBoxBorderColors&, qreal value ) const;
|
||||
|
||||
|
|
|
@ -117,7 +117,8 @@ void QskBoxNode::setBoxData( const QRectF& rect,
|
|||
{
|
||||
if ( isFillMonochrome && isBorderMonochrome )
|
||||
{
|
||||
if ( borderColors.gradient( Qsk::Left ) == fillGradient.startColor() )
|
||||
if ( borderColors.gradient( Qsk::Left ).startColor()
|
||||
== fillGradient.startColor() )
|
||||
{
|
||||
// we can draw border and background in one
|
||||
hasBorder = false;
|
||||
|
|
|
@ -102,6 +102,21 @@ namespace
|
|||
{
|
||||
return qMax( 0, gradient.stops().count() - 2 );
|
||||
}
|
||||
|
||||
static inline QRgb qskRgbGradientStart( const QskGradient& gradient )
|
||||
{
|
||||
return gradient.startColor().rgba();
|
||||
}
|
||||
|
||||
static inline QRgb qskRgbGradientEnd( const QskGradient& gradient )
|
||||
{
|
||||
return gradient.endColor().rgba();
|
||||
}
|
||||
|
||||
static inline QRgb qskRgbBorder( const QskBoxBorderColors& borderColors )
|
||||
{
|
||||
return qskRgbGradientStart( borderColors.gradient( Qsk::Left ) );
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
|
@ -568,7 +583,7 @@ namespace
|
|||
}
|
||||
|
||||
template< class BorderMap, class FillMap >
|
||||
void createLines( Qt::Orientation orientation, Line* borderLines,
|
||||
inline void createLines( Qt::Orientation orientation, Line* borderLines,
|
||||
const BorderMap& borderMapTL, const BorderMap& borderMapTR,
|
||||
const BorderMap& borderMapBL, const BorderMap& borderMapBR,
|
||||
Line* fillLines, FillMap& fillMap )
|
||||
|
@ -690,8 +705,6 @@ namespace
|
|||
{
|
||||
if( additionalGradientStops( borderMapTR.gradient() ) > 0 )
|
||||
{
|
||||
auto stops = borderMapTR.gradient().stops();
|
||||
|
||||
float x1TR = c[ TopRight ].centerX + v.dx1( TopRight ),
|
||||
y1TR = c[ TopRight ].centerY - v.dy1( TopRight ),
|
||||
x2TR = c[ TopRight ].centerX + v.dx2( TopRight ),
|
||||
|
@ -709,8 +722,6 @@ namespace
|
|||
|
||||
if( additionalGradientStops( borderMapBL.gradient() ) > 0 )
|
||||
{
|
||||
auto stops = borderMapBL.gradient().stops();
|
||||
|
||||
float x1BL = c[ BottomLeft ].centerX - v.dx1( BottomLeft ),
|
||||
y1BL = c[ BottomLeft ].centerY + v.dy1( BottomLeft ),
|
||||
x2BL = c[ BottomLeft ].centerX - v.dx2( BottomLeft ),
|
||||
|
@ -731,8 +742,6 @@ namespace
|
|||
{
|
||||
if( additionalGradientStops( borderMapTL.gradient() ) > 0 )
|
||||
{
|
||||
auto stops = borderMapTL.gradient().stops();
|
||||
|
||||
float x1TL = c[ TopLeft ].centerX - v.dx1( TopLeft ),
|
||||
y1TL = c[ TopLeft ].centerY - v.dy1( TopLeft ),
|
||||
x2TL = c[ TopLeft ].centerX - v.dx2( TopLeft ),
|
||||
|
@ -750,8 +759,6 @@ namespace
|
|||
|
||||
if( additionalGradientStops( borderMapBR.gradient() ) > 0 )
|
||||
{
|
||||
auto stops = borderMapBR.gradient().stops();
|
||||
|
||||
float x1BR = c[ BottomRight ].centerX + v.dx1( BottomRight ),
|
||||
y1BR = c[ BottomRight ].centerY + v.dy1( BottomRight ),
|
||||
x2BR = c[ BottomRight ].centerX + v.dx2( BottomRight ),
|
||||
|
@ -990,7 +997,7 @@ static inline void qskRenderBorder( const QskBoxRenderer::Metrics& metrics,
|
|||
|
||||
if ( colors.isMonochrome() )
|
||||
{
|
||||
qskRenderBorderLines( metrics, orientation, line, BorderMapSolid( c.gradient( Qsk::Left ).startColor().rgb() ) );
|
||||
qskRenderBorderLines( metrics, orientation, line, BorderMapSolid( qskRgbBorder( c ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1000,14 +1007,14 @@ static inline void qskRenderBorder( const QskBoxRenderer::Metrics& metrics,
|
|||
right = c.gradient( Qsk::Right ), bottom = c.gradient( Qsk::Bottom );
|
||||
|
||||
qskRenderBorderLines( metrics, orientation, line,
|
||||
BorderMapGradient( stepCount, top.startColor().rgb(),
|
||||
left.endColor().rgb(), left ),
|
||||
BorderMapGradient( stepCount, right.startColor().rgb(),
|
||||
top.endColor().rgb(), top ),
|
||||
BorderMapGradient( stepCount, left.startColor().rgb(),
|
||||
bottom.endColor().rgb(), bottom ),
|
||||
BorderMapGradient( stepCount, bottom.startColor().rgb(),
|
||||
right.endColor().rgb(), right ) );
|
||||
BorderMapGradient( stepCount, qskRgbGradientStart( top ),
|
||||
qskRgbGradientEnd( left ), left ),
|
||||
BorderMapGradient( stepCount, qskRgbGradientStart( right ),
|
||||
qskRgbGradientEnd( top ), top ),
|
||||
BorderMapGradient( stepCount, qskRgbGradientStart( left ),
|
||||
qskRgbGradientEnd( bottom ), bottom ),
|
||||
BorderMapGradient( stepCount, qskRgbGradientStart( bottom ),
|
||||
qskRgbGradientEnd( right ), right ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1037,7 +1044,7 @@ static inline void qskRenderBoxRandom(
|
|||
|
||||
if ( bc.isMonochrome() )
|
||||
{
|
||||
const BorderMapSolid borderMap( bc.gradient( Qsk::Left ).startColor().rgb() );
|
||||
const BorderMapSolid borderMap( qskRgbBorder( bc.gradient( Qsk::Left ) ) );
|
||||
|
||||
if ( gradient.isMonochrome() )
|
||||
{
|
||||
|
@ -1056,18 +1063,17 @@ static inline void qskRenderBoxRandom(
|
|||
{
|
||||
const int n = metrics.corner[ 0 ].stepCount;
|
||||
|
||||
const BorderMapGradient tl( n, bc.gradient( Qsk::Top ).startColor().rgb(),
|
||||
bc.gradient( Qsk::Left ).endColor().rgb(),
|
||||
borderColors.gradient( Qsk::Left ) );
|
||||
const BorderMapGradient tr( n, bc.gradient( Qsk::Right ).startColor().rgb(),
|
||||
bc.gradient( Qsk::Top ).endColor().rgb(),
|
||||
borderColors.gradient( Qsk::Top ) );
|
||||
const BorderMapGradient bl( n, bc.gradient( Qsk::Left ).startColor().rgb(),
|
||||
bc.gradient( Qsk::Bottom ).endColor().rgb(),
|
||||
borderColors.gradient( Qsk::Bottom ) );
|
||||
const BorderMapGradient br( n, bc.gradient( Qsk::Bottom ).startColor().rgb(),
|
||||
bc.gradient( Qsk::Right ).endColor().rgb(),
|
||||
borderColors.gradient( Qsk::Right ) );
|
||||
auto left = bc.gradient( Qsk::Left ), top = bc.gradient( Qsk::Top ),
|
||||
right = bc.gradient( Qsk::Right ), bottom = bc.gradient( Qsk::Bottom );
|
||||
|
||||
const BorderMapGradient tl( n, qskRgbGradientStart( top.startColor() ),
|
||||
qskRgbGradientEnd( left.endColor() ), left );
|
||||
const BorderMapGradient tr( n, qskRgbGradientStart( right ),
|
||||
qskRgbGradientEnd( top ), top );
|
||||
const BorderMapGradient bl( n, qskRgbGradientStart( left ),
|
||||
qskRgbGradientEnd( bottom ), bottom );
|
||||
const BorderMapGradient br( n, qskRgbGradientStart( bottom ),
|
||||
qskRgbGradientEnd( right ), right );
|
||||
|
||||
if ( gradient.isMonochrome() )
|
||||
{
|
||||
|
@ -1270,7 +1276,7 @@ void QskBoxRenderer::renderRectellipseBorder(
|
|||
const int stepCount = metrics.corner[ 0 ].stepCount;
|
||||
const int lineCount = 4 * ( stepCount + 1 ) + 1;
|
||||
|
||||
const auto line = allocateLines< ColoredLine >( geometry, lineCount );
|
||||
const auto line = allocateLines< Line >( geometry, lineCount );
|
||||
qskRenderBorderLines( metrics, Qt::Vertical, line, BorderMapNone() );
|
||||
}
|
||||
|
||||
|
|
|
@ -429,48 +429,53 @@ static inline void qskCreateBorder(
|
|||
|
||||
// qdebug
|
||||
|
||||
for( const QskGradientStop& stop : gradientBottom.stops() )
|
||||
const qreal dx1 = in.right - in.left;
|
||||
const qreal dx2 = out.right - out.left;
|
||||
const qreal dy1 = in.top - in.bottom;
|
||||
const qreal dy2 = out.top - out.bottom;
|
||||
|
||||
for( const auto& stop : gradientBottom.stops() )
|
||||
{
|
||||
const Color c( stop.color() );
|
||||
const qreal x1 = in.right - stop.position() * ( in.right - in.left );
|
||||
const qreal x2 = out.right - stop.position() * ( out.right - out.left );
|
||||
const qreal x1 = in.right - stop.position() * dx1;
|
||||
const qreal x2 = out.right - stop.position() * dx2;
|
||||
const qreal y1 = in.bottom;
|
||||
const qreal y2 = out.bottom;
|
||||
|
||||
( line++ )->setLine( x1, y1, x2, y2, c );
|
||||
}
|
||||
|
||||
for( const QskGradientStop& stop : gradientLeft.stops() )
|
||||
for( const auto& stop : gradientLeft.stops() )
|
||||
{
|
||||
const Color c( stop.color() );
|
||||
const qreal x1 = in.left;
|
||||
const qreal x2 = out.left;
|
||||
const qreal y1 = in.bottom + stop.position() * ( in.top - in.bottom );
|
||||
const qreal y2 = out.bottom + stop.position() * ( out.top - out.bottom );
|
||||
const qreal y1 = in.bottom + stop.position() * dy1;
|
||||
const qreal y2 = out.bottom + stop.position() * dy2;
|
||||
|
||||
( line++ )->setLine( x1, y1, x2, y2, c );
|
||||
}
|
||||
|
||||
for( const QskGradientStop& stop : gradientTop.stops() )
|
||||
for( const auto& stop : gradientTop.stops() )
|
||||
{
|
||||
const Color c( stop.color() );
|
||||
const qreal x1 = in.left + stop.position() * ( in.right - in.left );
|
||||
const qreal x2 = out.left + stop.position() * ( out.right - out.left );
|
||||
const qreal x1 = in.left + stop.position() * dx1;
|
||||
const qreal x2 = out.left + stop.position() * dx2;
|
||||
const qreal y1 = in.top;
|
||||
const qreal y2 = out.top;
|
||||
|
||||
( line++ )->setLine( x1, y1, x2, y2, c );
|
||||
}
|
||||
|
||||
for( const QskGradientStop& stop : gradientRight.stops() )
|
||||
for( const auto& stop : gradientRight.stops() )
|
||||
{
|
||||
const Color c( stop.color() );
|
||||
const qreal x1 = in.right;
|
||||
const qreal x2 = out.right;
|
||||
// ( 1 - stop.position() ) because we want to make the gradients go
|
||||
// around the border clock-wise:
|
||||
const qreal y1 = in.bottom + ( 1 - stop.position() ) * ( in.top - in.bottom );
|
||||
const qreal y2 = out.bottom + ( 1 - stop.position() ) * ( out.top - out.bottom );
|
||||
const qreal y1 = in.bottom + ( 1 - stop.position() ) * dy1;
|
||||
const qreal y2 = out.bottom + ( 1 - stop.position() ) * dy2;
|
||||
|
||||
( line++ )->setLine( x1, y1, x2, y2, c );
|
||||
}
|
||||
|
@ -491,7 +496,7 @@ void QskBoxRenderer::renderRectBorder(
|
|||
return;
|
||||
}
|
||||
|
||||
const auto line = allocateLines< ColoredLine >( geometry, 4 + 1 );
|
||||
const auto line = allocateLines< Line >( geometry, 4 + 1 );
|
||||
qskCreateBorderMonochrome( out, in, Color(), line );
|
||||
}
|
||||
|
||||
|
@ -618,7 +623,7 @@ void QskBoxRenderer::renderRect(
|
|||
auto fillLines = line + fillLineCount;
|
||||
|
||||
if ( bc.isMonochrome() )
|
||||
qskCreateBorderMonochrome( rect, in, bc.gradient( Qsk::Left ).startColor().rgb(), fillLines );
|
||||
qskCreateBorderMonochrome( rect, in, bc.gradient( Qsk::Left ).startColor().rgba(), fillLines );
|
||||
else
|
||||
qskCreateBorder( rect, in, bc, fillLines );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue