clean up a bit

This commit is contained in:
Peter Hartmann 2022-01-14 15:46:43 +01:00
parent 73e703be91
commit f7bb1ec69f
6 changed files with 47 additions and 56 deletions

View File

@ -451,7 +451,7 @@ static void addColoredBorderRectangles5( QskLinearBox* parent, bool rounded, Box
box->setBackground( fillType, QskRgbPalette::Indigo ); box->setBackground( fillType, QskRgbPalette::Indigo );
if( rounded ) if( rounded )
box->setShape( 30, Qt::AbsoluteSize ); box->setShape( { 10, 20, 20, 40 } );
} }
class TabView : public QskTabView class TabView : public QskTabView
@ -496,7 +496,6 @@ class TabView : public QskTabView
#endif #endif
auto* tab5 = new QskLinearBox( Qt::Horizontal, 5 ); auto* tab5 = new QskLinearBox( Qt::Horizontal, 5 );
// ### also add some filling:
addColoredBorderRectangles1( tab5, false, Box::Unfilled ); addColoredBorderRectangles1( tab5, false, Box::Unfilled );
addColoredBorderRectangles2( tab5, false, Box::Unfilled ); addColoredBorderRectangles2( tab5, false, Box::Unfilled );
addColoredBorderRectangles3( tab5, false, Box::Unfilled ); addColoredBorderRectangles3( tab5, false, Box::Unfilled );

View File

@ -79,7 +79,7 @@ void QskBoxBorderColors::setAlpha( int alpha )
} }
} }
void QskBoxBorderColors::setGradients( const QskGradient &gradient ) void QskBoxBorderColors::setGradients( const QskGradient& gradient )
{ {
qskSetGradients( gradient, m_gradients ); qskSetGradients( gradient, m_gradients );
} }
@ -90,12 +90,12 @@ void QskBoxBorderColors::setGradients( const QskGradient& left, const QskGradien
qskSetGradients( left, top, right, bottom, m_gradients ); qskSetGradients( left, top, right, bottom, m_gradients );
} }
void QskBoxBorderColors::setGradient( Qsk::Position position, const QskGradient &gradient ) void QskBoxBorderColors::setGradient( Qsk::Position position, const QskGradient& gradient )
{ {
m_gradients[ position ] = gradient; m_gradients[ position ] = gradient;
} }
void QskBoxBorderColors::setGradientAt( Qt::Edges edges, const QskGradient &gradient ) void QskBoxBorderColors::setGradientAt( Qt::Edges edges, const QskGradient& gradient )
{ {
if ( edges & Qt::TopEdge ) if ( edges & Qt::TopEdge )
m_gradients[ Qsk::Top ] = gradient; m_gradients[ Qsk::Top ] = gradient;

View File

@ -171,7 +171,7 @@ void QskBoxNode::setBoxData( const QRectF& rect,
} }
else else
{ {
flatMaterial->setColor( borderColors.gradient( Qsk::Left ).startColor().rgba() ); // ### flatMaterial->setColor( borderColors.gradient( Qsk::Left ).startColor().rgba() );
renderer.renderBorder( m_rect, shape, borderMetrics, *geometry() ); renderer.renderBorder( m_rect, shape, borderMetrics, *geometry() );
} }
} }

View File

@ -104,7 +104,6 @@ class QSK_EXPORT QskBoxRenderer
bool isBorderRegular; bool isBorderRegular;
bool isRadiusRegular; bool isRadiusRegular;
bool isTotallyCropped; bool isTotallyCropped;
// ### here add gradients;
}; };
private: private:

View File

@ -14,8 +14,6 @@
#include <qmath.h> #include <qmath.h>
#include <qsggeometry.h> #include <qsggeometry.h>
#include <QDebug> // ### remove
using namespace QskVertex; using namespace QskVertex;
namespace namespace
@ -515,7 +513,7 @@ namespace
class BorderMapGradient class BorderMapGradient
{ {
public: public:
inline BorderMapGradient( int stepCount, QRgb rgb1, QRgb rgb2, const QskGradient& gradient = {} ) inline BorderMapGradient( int stepCount, QRgb rgb1, QRgb rgb2, const QskGradient& gradient )
: m_stepCount( stepCount ) : m_stepCount( stepCount )
, m_color1( rgb1 ) , m_color1( rgb1 )
, m_color2( rgb2 ) , m_color2( rgb2 )
@ -556,21 +554,16 @@ namespace
auto s = gradient.stops(); auto s = gradient.stops();
qDebug() << "adding" << additionalStopCount << "stops"; for( int i = 1; i <= additionalStopCount; ++i )
for( int l = 1; l <= additionalStopCount; ++l )
{ {
auto p = ( 1 - s.at( l ).position() ); auto p = ( 1 - s.at( i ).position() );
float xStart = x11 + p * ( x21 - x11 ), float xStart = x11 + p * ( x21 - x11 ),
yStart = y11 + p * ( y21 - y11 ), yStart = y11 + p * ( y21 - y11 ),
xEnd = x12 + p * ( x22 - x12 ), xEnd = x12 + p * ( x22 - x12 ),
yEnd = y12 + p * ( y22 - y12 ); yEnd = y12 + p * ( y22 - y12 );
qDebug() << " start:" << x11 << y11 << x12 << y12; lines[ additionalStopCount - i + 1 ].setLine( xStart, yStart,
qDebug() << " end:" << x21 << y21 << x22 << y22; xEnd, yEnd, s.at( i ).color() );
qDebug() << " gradient stop:" << xStart << yStart << xEnd << yEnd;
lines[ additionalStopCount - l + 1 ].setLine( xStart, yStart, xEnd, yEnd, s.at( l ).color() );
} }
} }
@ -597,9 +590,12 @@ namespace
if ( borderLines ) if ( borderLines )
{ {
linesBR = borderLines; linesBR = borderLines;
linesTR = linesBR + numCornerLines + additionalGradientStops( borderMapBR.gradient() ); linesTR = linesBR + numCornerLines
linesTL = linesTR + numCornerLines + additionalGradientStops( borderMapTR.gradient() ); + additionalGradientStops( borderMapBR.gradient() );
linesBL = linesTL + numCornerLines + additionalGradientStops( borderMapTL.gradient() ); linesTL = linesTR + numCornerLines
+ additionalGradientStops( borderMapTR.gradient() );
linesBL = linesTL + numCornerLines
+ additionalGradientStops( borderMapTL.gradient() );
} }
if ( fillLines ) if ( fillLines )
@ -613,9 +609,12 @@ namespace
if ( borderLines ) if ( borderLines )
{ {
linesTR = borderLines + 1; linesTR = borderLines + 1;
linesTL = linesTR + numCornerLines + additionalGradientStops( borderMapTR.gradient() ); linesTL = linesTR + numCornerLines
linesBL = linesTL + numCornerLines + additionalGradientStops( borderMapTL.gradient() ); + additionalGradientStops( borderMapTR.gradient() );
linesBR = linesBL + numCornerLines + additionalGradientStops( borderMapBR.gradient() ); linesBL = linesTL + numCornerLines
+ additionalGradientStops( borderMapTL.gradient() );
linesBR = linesBL + numCornerLines
+ additionalGradientStops( borderMapBR.gradient() );
} }
if ( fillLines ) if ( fillLines )
@ -703,8 +702,8 @@ namespace
x2TL = c[ TopLeft ].centerX - v.dx2( TopLeft ), x2TL = c[ TopLeft ].centerX - v.dx2( TopLeft ),
y2TL = c[ TopLeft ].centerY - v.dy2( TopLeft ); y2TL = c[ TopLeft ].centerY - v.dy2( TopLeft );
qDebug() << "top:" << j << k; addAdditionalLines( x1TR, y1TR, x2TR, y2TR,
addAdditionalLines( x1TR, y1TR, x2TR, y2TR, x1TL, y1TL, x2TL, y2TL, x1TL, y1TL, x2TL, y2TL,
borderMapTR.gradient(), linesTR + k ); borderMapTR.gradient(), linesTR + k );
} }
@ -722,8 +721,8 @@ namespace
x2BR = c[ BottomRight ].centerX + v.dx2( BottomRight ), x2BR = c[ BottomRight ].centerX + v.dx2( BottomRight ),
y2BR = c[ BottomRight ].centerY + v.dy2( BottomRight ); y2BR = c[ BottomRight ].centerY + v.dy2( BottomRight );
qDebug() << "bottom:" << j << k; addAdditionalLines( x1BL, y1BL, x2BL, y2BL,
addAdditionalLines( x1BL, y1BL, x2BL, y2BL, x1BR, y1BR, x2BR, y2BR, x1BR, y1BR, x2BR, y2BR,
borderMapBL.gradient(), linesBL + k ); borderMapBL.gradient(), linesBL + k );
} }
} }
@ -734,7 +733,6 @@ namespace
{ {
auto stops = borderMapTL.gradient().stops(); auto stops = borderMapTL.gradient().stops();
// ### this can be simplified?
float x1TL = c[ TopLeft ].centerX - v.dx1( TopLeft ), float x1TL = c[ TopLeft ].centerX - v.dx1( TopLeft ),
y1TL = c[ TopLeft ].centerY - v.dy1( TopLeft ), y1TL = c[ TopLeft ].centerY - v.dy1( TopLeft ),
x2TL = c[ TopLeft ].centerX - v.dx2( TopLeft ), x2TL = c[ TopLeft ].centerX - v.dx2( TopLeft ),
@ -745,8 +743,8 @@ namespace
x2BL = c[ BottomLeft ].centerX - v.dx2( BottomLeft ), x2BL = c[ BottomLeft ].centerX - v.dx2( BottomLeft ),
y2BL = c[ BottomLeft ].centerY + v.dy2( BottomLeft ); y2BL = c[ BottomLeft ].centerY + v.dy2( BottomLeft );
qDebug() << "left:" << j << k; addAdditionalLines( x1TL, y1TL, x2TL, y2TL,
addAdditionalLines( x1TL, y1TL, x2TL, y2TL, x1BL, y1BL, x2BL, y2BL, x1BL, y1BL, x2BL, y2BL,
borderMapTL.gradient(), linesTL + j ); borderMapTL.gradient(), linesTL + j );
} }
@ -754,7 +752,6 @@ namespace
{ {
auto stops = borderMapBR.gradient().stops(); auto stops = borderMapBR.gradient().stops();
// ### this can be simplified?
float x1BR = c[ BottomRight ].centerX + v.dx1( BottomRight ), float x1BR = c[ BottomRight ].centerX + v.dx1( BottomRight ),
y1BR = c[ BottomRight ].centerY + v.dy1( BottomRight ), y1BR = c[ BottomRight ].centerY + v.dy1( BottomRight ),
x2BR = c[ BottomRight ].centerX + v.dx2( BottomRight ), x2BR = c[ BottomRight ].centerX + v.dx2( BottomRight ),
@ -765,8 +762,8 @@ namespace
x2TR = c[ TopRight ].centerX + v.dx2( TopRight ), x2TR = c[ TopRight ].centerX + v.dx2( TopRight ),
y2TR = c[ TopRight ].centerY - v.dy2( TopRight ); y2TR = c[ TopRight ].centerY - v.dy2( TopRight );
qDebug() << "right:" << j << k; addAdditionalLines( x1BR, y1BR, x2BR, y2BR,
addAdditionalLines( x1BR, y1BR, x2BR, y2BR, x1TR, y1TR, x2TR, y2TR, x1TR, y1TR, x2TR, y2TR,
borderMapBR.gradient(), linesBR + j ); borderMapBR.gradient(), linesBR + j );
} }
} }
@ -818,7 +815,8 @@ namespace
#if 1 #if 1
if ( borderLines ) if ( borderLines )
{ {
const int additionalStops = additionalGradientStops( borderMapBR.gradient() ) const int additionalStops =
additionalGradientStops( borderMapBR.gradient() )
+ additionalGradientStops( borderMapTR.gradient() ) + additionalGradientStops( borderMapTR.gradient() )
+ additionalGradientStops( borderMapTL.gradient() ) + additionalGradientStops( borderMapTL.gradient() )
+ additionalGradientStops( borderMapBL.gradient() ); + additionalGradientStops( borderMapBL.gradient() );
@ -1001,12 +999,15 @@ static inline void qskRenderBorder( const QskBoxRenderer::Metrics& metrics,
auto left = c.gradient( Qsk::Left ), top = c.gradient( Qsk::Top ), auto left = c.gradient( Qsk::Left ), top = c.gradient( Qsk::Top ),
right = c.gradient( Qsk::Right ), bottom = c.gradient( Qsk::Bottom ); right = c.gradient( Qsk::Right ), bottom = c.gradient( Qsk::Bottom );
// ### I guess we could get rid of the 2 colors completely here?
qskRenderBorderLines( metrics, orientation, line, qskRenderBorderLines( metrics, orientation, line,
BorderMapGradient( stepCount, top.startColor().rgb(), left.endColor().rgb(), left ), BorderMapGradient( stepCount, top.startColor().rgb(),
BorderMapGradient( stepCount, right.startColor().rgb(), top.endColor().rgb(), top ), left.endColor().rgb(), left ),
BorderMapGradient( stepCount, left.startColor().rgb(), bottom.endColor().rgb(), bottom ), BorderMapGradient( stepCount, right.startColor().rgb(),
BorderMapGradient( stepCount, bottom.startColor().rgb(), right.endColor().rgb(), right ) ); top.endColor().rgb(), top ),
BorderMapGradient( stepCount, left.startColor().rgb(),
bottom.endColor().rgb(), bottom ),
BorderMapGradient( stepCount, bottom.startColor().rgb(),
right.endColor().rgb(), right ) );
} }
} }
@ -1036,7 +1037,7 @@ static inline void qskRenderBoxRandom(
if ( bc.isMonochrome() ) if ( bc.isMonochrome() )
{ {
const BorderMapSolid borderMap( bc.gradient( Qsk::Left ).startColor().rgb() ); // ### const BorderMapSolid borderMap( bc.gradient( Qsk::Left ).startColor().rgb() );
if ( gradient.isMonochrome() ) if ( gradient.isMonochrome() )
{ {
@ -1357,16 +1358,13 @@ void QskBoxRenderer::renderRectellipse( const QRectF& rect,
{ {
borderLineCount = 4 * ( stepCount + 1 ) + 1; borderLineCount = 4 * ( stepCount + 1 ) + 1;
// ### when do we need an additional one? const int additionalLines =
const int additionalLines = qMax( 0, 0 additionalGradientStops( borderColors.gradient( Qsk::Left ) )
+ additionalGradientStops( borderColors.gradient( Qsk::Left ) )
+ additionalGradientStops( borderColors.gradient( Qsk::Top ) ) + additionalGradientStops( borderColors.gradient( Qsk::Top ) )
+ additionalGradientStops( borderColors.gradient( Qsk::Right ) ) + additionalGradientStops( borderColors.gradient( Qsk::Right ) )
+ additionalGradientStops( borderColors.gradient( Qsk::Bottom ) ) ); + additionalGradientStops( borderColors.gradient( Qsk::Bottom ) );
borderLineCount += additionalLines; borderLineCount += additionalLines;
qDebug() << "additional lines:" << additionalLines;
} }
int lineCount = borderLineCount + fillLineCount; int lineCount = borderLineCount + fillLineCount;
@ -1445,7 +1443,6 @@ void QskBoxRenderer::renderRectellipse( const QRectF& rect,
borderLines++; borderLines++;
const auto orientation = qskQtOrientation( gradient ); const auto orientation = qskQtOrientation( gradient );
qDebug() << "border line count:" << borderLineCount;
qskRenderBorder( metrics, orientation, borderColors, borderLines ); qskRenderBorder( metrics, orientation, borderColors, borderLines );
if ( extraLine ) if ( extraLine )

View File

@ -11,8 +11,6 @@
#include "QskGradient.h" #include "QskGradient.h"
#include "QskVertex.h" #include "QskVertex.h"
#include <QDebug>
using namespace QskVertex; using namespace QskVertex;
namespace namespace
@ -578,8 +576,6 @@ void QskBoxRenderer::renderRect(
} }
} }
qDebug() << "border lines:" << borderLineCount;
auto line = allocateLines< ColoredLine >( geometry, borderLineCount + fillLineCount ); auto line = allocateLines< ColoredLine >( geometry, borderLineCount + fillLineCount );
if ( fillLineCount > 0 ) if ( fillLineCount > 0 )