preparations for gradient updates
This commit is contained in:
parent
a21d96543f
commit
b1f63999c6
|
@ -561,25 +561,38 @@ namespace
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void setAdditionalLine(
|
||||||
|
float x11, float y11, float x12, float y12,
|
||||||
|
float dx1, float dy1, float dx2, float dy2,
|
||||||
|
const QskGradientStop& stop, Line* line )
|
||||||
|
{
|
||||||
|
const auto pos = 1.0 - stop.position();
|
||||||
|
|
||||||
|
const float x1 = x11 + pos * dx1;
|
||||||
|
const float y1 = y11 + pos * dy1;
|
||||||
|
const float x2 = x12 + pos * dx2;
|
||||||
|
const float y2 = y12 + pos * dy2;
|
||||||
|
|
||||||
|
line->setLine( x1, y1, x2, y2, stop.color() );
|
||||||
|
}
|
||||||
|
|
||||||
void addAdditionalLines(
|
void addAdditionalLines(
|
||||||
float x11, float y11, float x12, float y12, // start line
|
float x11, float y11, float x12, float y12, // start line
|
||||||
float x21, float y21, float x22, float y22, // end line
|
float x21, float y21, float x22, float y22, // end line
|
||||||
const QskGradient& gradient, Line* lines )
|
const QskGradient& gradient, Line* lines )
|
||||||
{
|
{
|
||||||
int additionalStopCount = additionalGradientStops( gradient );
|
const float dx1 = x21 - x11;
|
||||||
|
const float dy1 = y21 - y11;
|
||||||
|
const float dx2 = x22 - x12;
|
||||||
|
const float dy2 = y22 - y12;
|
||||||
|
|
||||||
auto s = gradient.stops();
|
const auto stops = gradient.stops();
|
||||||
|
|
||||||
for( int i = 1; i <= additionalStopCount; ++i )
|
auto line = lines + additionalGradientStops( gradient );
|
||||||
|
|
||||||
|
for( int i = 1; i < stops.count() - 1; i++ )
|
||||||
{
|
{
|
||||||
auto p = ( 1 - s.at( i ).position() );
|
setAdditionalLine( x11, y11, x12, y12, dx1, dy1, dx2, dy2, stops[i], line-- );
|
||||||
float xStart = x11 + p * ( x21 - x11 ),
|
|
||||||
yStart = y11 + p * ( y21 - y11 ),
|
|
||||||
xEnd = x12 + p * ( x22 - x12 ),
|
|
||||||
yEnd = y12 + p * ( y22 - y12 );
|
|
||||||
|
|
||||||
lines[ additionalStopCount - i + 1 ].setLine( xStart, yStart,
|
|
||||||
xEnd, yEnd, s.at( i ).color() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -422,62 +422,57 @@ static inline void qskCreateBorder(
|
||||||
const QskBoxRenderer::Quad& out, const QskBoxRenderer::Quad& in,
|
const QskBoxRenderer::Quad& out, const QskBoxRenderer::Quad& in,
|
||||||
const QskBoxBorderColors& colors, Line* line )
|
const QskBoxBorderColors& colors, Line* line )
|
||||||
{
|
{
|
||||||
const auto& gradientLeft = colors.left();
|
|
||||||
const auto& gradientRight = colors.right();
|
|
||||||
const auto& gradientTop = colors.top();
|
|
||||||
const auto& gradientBottom = colors.bottom();
|
|
||||||
|
|
||||||
// qdebug
|
|
||||||
|
|
||||||
const qreal dx1 = in.right - in.left;
|
const qreal dx1 = in.right - in.left;
|
||||||
const qreal dx2 = out.right - out.left;
|
const qreal dx2 = out.right - out.left;
|
||||||
const qreal dy1 = in.top - in.bottom;
|
const qreal dy1 = in.top - in.bottom;
|
||||||
const qreal dy2 = out.top - out.bottom;
|
const qreal dy2 = out.top - out.bottom;
|
||||||
|
|
||||||
for( const auto& stop : qAsConst( gradientBottom.stops() ) )
|
|
||||||
{
|
{
|
||||||
const Color c( stop.color() );
|
const auto stops = colors.bottom().stops();
|
||||||
|
|
||||||
|
for( const auto& stop : stops )
|
||||||
|
{
|
||||||
const qreal x1 = in.right - stop.position() * dx1;
|
const qreal x1 = in.right - stop.position() * dx1;
|
||||||
const qreal x2 = out.right - stop.position() * dx2;
|
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 );
|
( line++ )->setLine( x1, in.bottom, x2, out.bottom, stop.color() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( const auto& stop : qAsConst( gradientLeft.stops() ) )
|
|
||||||
{
|
{
|
||||||
const Color c( stop.color() );
|
const auto stops = colors.left().stops();
|
||||||
const qreal x1 = in.left;
|
|
||||||
const qreal x2 = out.left;
|
for( const auto& stop : stops )
|
||||||
|
{
|
||||||
const qreal y1 = in.bottom + stop.position() * dy1;
|
const qreal y1 = in.bottom + stop.position() * dy1;
|
||||||
const qreal y2 = out.bottom + stop.position() * dy2;
|
const qreal y2 = out.bottom + stop.position() * dy2;
|
||||||
|
|
||||||
( line++ )->setLine( x1, y1, x2, y2, c );
|
( line++ )->setLine( in.left, y1, out.left, y2, stop.color() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( const auto& stop : qAsConst( gradientTop.stops() ) )
|
|
||||||
{
|
{
|
||||||
const Color c( stop.color() );
|
const auto stops = colors.top().stops();
|
||||||
|
|
||||||
|
for( const auto& stop : stops )
|
||||||
|
{
|
||||||
const qreal x1 = in.left + stop.position() * dx1;
|
const qreal x1 = in.left + stop.position() * dx1;
|
||||||
const qreal x2 = out.left + stop.position() * dx2;
|
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 );
|
( line++ )->setLine( x1, in.top, x2, out.top, stop.color() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for( const auto& stop : qAsConst( gradientRight.stops() ) )
|
|
||||||
{
|
{
|
||||||
const Color c( stop.color() );
|
const auto stops = colors.right().stops();
|
||||||
const qreal x1 = in.right;
|
|
||||||
const qreal x2 = out.right;
|
for( const auto& stop : stops )
|
||||||
// ( 1 - stop.position() ) because we want to make the gradients go
|
{
|
||||||
// around the border clock-wise:
|
|
||||||
const qreal y1 = in.bottom + ( 1 - stop.position() ) * dy1;
|
const qreal y1 = in.bottom + ( 1 - stop.position() ) * dy1;
|
||||||
const qreal y2 = out.bottom + ( 1 - stop.position() ) * dy2;
|
const qreal y2 = out.bottom + ( 1 - stop.position() ) * dy2;
|
||||||
|
|
||||||
( line++ )->setLine( x1, y1, x2, y2, c );
|
( line++ )->setLine( in.right, y1, out.right, y2, stop.color() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -531,7 +526,7 @@ void QskBoxRenderer::renderRect(
|
||||||
const Quad in = qskValidOrEmptyInnerRect( rect, border.widths() );
|
const Quad in = qskValidOrEmptyInnerRect( rect, border.widths() );
|
||||||
|
|
||||||
int fillLineCount = 0;
|
int fillLineCount = 0;
|
||||||
if ( !in.isEmpty() )
|
if ( gradient.isValid() && !in.isEmpty() )
|
||||||
{
|
{
|
||||||
fillLineCount = gradient.stops().count();
|
fillLineCount = gradient.stops().count();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue