QskBoxBorderColors: rename API

This commit is contained in:
Peter Hartmann 2021-12-13 12:51:14 +01:00
parent 16df96700d
commit 9b10a4b523
7 changed files with 77 additions and 75 deletions

View File

@ -602,7 +602,7 @@ void Editor::setupTabButton()
QskBoxBorderColors borderColors( QskRgb::White ); QskBoxBorderColors borderColors( QskRgb::White );
setBoxBorderColors( aspect, borderColors ); setBoxBorderColors( aspect, borderColors );
borderColors.setColorsAt( edge, m_pal.accentColor ); borderColors.setGradientAt( edge, m_pal.accentColor );
for ( auto state : { Q::Checked, Q::Pressed, Q::Hovered } ) for ( auto state : { Q::Checked, Q::Pressed, Q::Hovered } )
setBoxBorderColors( aspect | state, borderColors ); setBoxBorderColors( aspect | state, borderColors );
} }
@ -750,8 +750,8 @@ void Editor::setupSubWindow()
setGradient( Q::Panel, m_pal.baseColor ); setGradient( Q::Panel, m_pal.baseColor );
QskBoxBorderColors colors; QskBoxBorderColors colors;
colors.setColorsAt( Qt::TopEdge | Qt::LeftEdge, m_pal.lighter125 ); colors.setGradientAt( Qt::TopEdge | Qt::LeftEdge, m_pal.lighter125 );
colors.setColorsAt( Qt::RightEdge | Qt::BottomEdge, m_pal.darker200 ); colors.setGradientAt( Qt::RightEdge | Qt::BottomEdge, m_pal.darker200 );
setBoxBorderColors( Q::Panel, colors ); setBoxBorderColors( Q::Panel, colors );

View File

@ -198,23 +198,23 @@ void Editor::setButton( QskAspect aspect, PanelStyle style, qreal border )
{ {
case Raised: case Raised:
{ {
borderColors.setColorsAt( Qt::TopEdge | Qt::LeftEdge, m_pal.lighter135 ); borderColors.setGradientAt( Qt::TopEdge | Qt::LeftEdge, m_pal.lighter135 );
borderColors.setColorsAt( Qt::RightEdge | Qt::BottomEdge, m_pal.darker200 ); borderColors.setGradientAt( Qt::RightEdge | Qt::BottomEdge, m_pal.darker200 );
gradient.setColors( m_pal.lighter125, m_pal.lighter110 ); gradient.setColors( m_pal.lighter125, m_pal.lighter110 );
break; break;
} }
case Sunken: case Sunken:
{ {
borderColors.setColorsAt( Qt::TopEdge | Qt::LeftEdge, m_pal.darker200 ); borderColors.setGradientAt( Qt::TopEdge | Qt::LeftEdge, m_pal.darker200 );
borderColors.setColorsAt( Qt::RightEdge | Qt::BottomEdge, m_pal.lighter135 ); borderColors.setGradientAt( Qt::RightEdge | Qt::BottomEdge, m_pal.lighter135 );
gradient.setColors( m_pal.lighter110, m_pal.lighter125 ); gradient.setColors( m_pal.lighter110, m_pal.lighter125 );
break; break;
} }
case Plain: case Plain:
{ {
borderColors.setColors( m_pal.darker125 ); borderColors.setGradients( m_pal.darker125 );
gradient.setColor( m_pal.lighter125 ); gradient.setColor( m_pal.lighter125 );
break; break;
@ -225,7 +225,7 @@ void Editor::setButton( QskAspect aspect, PanelStyle style, qreal border )
QColor noColor( m_pal.theme ); QColor noColor( m_pal.theme );
noColor.setAlpha( 0 ); noColor.setAlpha( 0 );
borderColors.setColors( noColor ); borderColors.setGradients( noColor );
gradient.setColor( noColor ); gradient.setColor( noColor );
if ( style == NoPanel ) if ( style == NoPanel )
@ -859,8 +859,8 @@ void Editor::setupSubWindow()
setBoxShape( Q::Panel, radius, radius, 0, 0, Qt::AbsoluteSize ); setBoxShape( Q::Panel, radius, radius, 0, 0, Qt::AbsoluteSize );
QskBoxBorderColors borderColors; QskBoxBorderColors borderColors;
borderColors.setColorsAt( Qt::TopEdge | Qt::LeftEdge, m_pal.lighter125 ); borderColors.setGradientAt( Qt::TopEdge | Qt::LeftEdge, m_pal.lighter125 );
borderColors.setColorsAt( Qt::RightEdge | Qt::BottomEdge, m_pal.darker200 ); borderColors.setGradientAt( Qt::RightEdge | Qt::BottomEdge, m_pal.darker200 );
setBoxBorderColors( Q::Panel, borderColors ); setBoxBorderColors( Q::Panel, borderColors );
setGradient( Q::Panel, m_pal.lighter135 ); setGradient( Q::Panel, m_pal.lighter135 );

View File

@ -19,19 +19,19 @@ static void qskRegisterBoxBorderColors()
Q_CONSTRUCTOR_FUNCTION( qskRegisterBoxBorderColors ) Q_CONSTRUCTOR_FUNCTION( qskRegisterBoxBorderColors )
static inline void qskSetColors( const QColor& c, QskGradient* colors ) static inline void qskSetGradients( const QskGradient& c, QskGradient* colors )
{ {
colors[ 0 ] = colors[ 1 ] = colors[ 2 ] = colors[ 3 ] = c.toRgb(); colors[ 0 ] = colors[ 1 ] = colors[ 2 ] = colors[ 3 ] = c;
} }
static inline void qskSetColors( static inline void qskSetGradients(
const QColor& left, const QColor& top, const QskGradient& left, const QskGradient& top,
const QColor& right, const QColor& bottom, QskGradient* colors ) const QskGradient& right, const QskGradient& bottom, QskGradient* colors )
{ {
colors[ Qsk::Left ] = left.toRgb(); colors[ Qsk::Left ] = left;
colors[ Qsk::Top ] = top.toRgb(); colors[ Qsk::Top ] = top;
colors[ Qsk::Right ] = right.toRgb(); colors[ Qsk::Right ] = right;
colors[ Qsk::Bottom ] = bottom.toRgb(); colors[ Qsk::Bottom ] = bottom;
} }
QskBoxBorderColors::QskBoxBorderColors() QskBoxBorderColors::QskBoxBorderColors()
@ -39,15 +39,20 @@ QskBoxBorderColors::QskBoxBorderColors()
} }
QskBoxBorderColors::QskBoxBorderColors( QskBoxBorderColors::QskBoxBorderColors(
const QColor& left, const QColor& top, const QskGradient& left, const QskGradient& top,
const QColor& right, const QColor& bottom ) const QskGradient& right, const QskGradient& bottom )
{ {
qskSetColors( left, top, right, bottom, m_gradients ); qskSetGradients( left, top, right, bottom, m_gradients );
} }
QskBoxBorderColors::QskBoxBorderColors( const QColor& color ) QskBoxBorderColors::QskBoxBorderColors( const QColor& color )
{ {
qskSetColors( color, m_gradients ); qskSetGradients( color, m_gradients );
}
QskBoxBorderColors::QskBoxBorderColors( const QskGradient& gradient )
{
qskSetGradients( gradient, m_gradients );
} }
QskBoxBorderColors::~QskBoxBorderColors() QskBoxBorderColors::~QskBoxBorderColors()
@ -71,42 +76,38 @@ void QskBoxBorderColors::setAlpha( int alpha )
} }
} }
void QskBoxBorderColors::setColors( const QColor& color ) void QskBoxBorderColors::setGradients( const QskGradient &gradient )
{ {
qskSetColors( color, m_gradients ); qskSetGradients( gradient, m_gradients );
} }
void QskBoxBorderColors::setColors( void QskBoxBorderColors::setGradients( const QskGradient& left, const QskGradient& top,
const QColor& left, const QColor& top, const QskGradient& right, const QskGradient& bottom )
const QColor& right, const QColor& bottom )
{ {
qskSetColors( left, top, right, bottom, m_gradients ); qskSetGradients( left, top, right, bottom, m_gradients );
} }
void QskBoxBorderColors::setColor( void QskBoxBorderColors::setGradient( Qsk::Position position, const QskGradient &gradient )
Qsk::Position position, const QColor& color )
{ {
m_gradients[ position ] = color.toRgb(); m_gradients[ position ] = gradient;
} }
void QskBoxBorderColors::setColorsAt( Qt::Edges edges, const QColor& color ) void QskBoxBorderColors::setGradientAt( Qt::Edges edges, const QskGradient &gradient )
{ {
const QColor c = color.toRgb();
if ( edges & Qt::TopEdge ) if ( edges & Qt::TopEdge )
m_gradients[ Qsk::Top ] = c; m_gradients[ Qsk::Top ] = gradient;
if ( edges & Qt::LeftEdge ) if ( edges & Qt::LeftEdge )
m_gradients[ Qsk::Left ] = c; m_gradients[ Qsk::Left ] = gradient;
if ( edges & Qt::RightEdge ) if ( edges & Qt::RightEdge )
m_gradients[ Qsk::Right ] = c; m_gradients[ Qsk::Right ] = gradient;
if ( edges & Qt::BottomEdge ) if ( edges & Qt::BottomEdge )
m_gradients[ Qsk::Bottom ] = c; m_gradients[ Qsk::Bottom ] = gradient;
} }
QskGradient QskBoxBorderColors::colorAt( Qt::Edge edge ) const QskGradient QskBoxBorderColors::gradientAt( Qt::Edge edge ) const
{ {
switch ( edge ) switch ( edge )
{ {
@ -201,13 +202,13 @@ QDebug operator<<( QDebug debug, const QskBoxBorderColors& colors )
debug << "BoxBorderColors" << '('; debug << "BoxBorderColors" << '(';
debug << " L" << colors.color( Qsk::Left ); debug << " L" << colors.gradient( Qsk::Left );
debug << ", T" << colors.color( Qsk::Top ); debug << ", T" << colors.gradient( Qsk::Top );
debug << ", R" << colors.color( Qsk::Right ); debug << ", R" << colors.gradient( Qsk::Right );
debug << ", B" << colors.color( Qsk::Bottom ); debug << ", B" << colors.gradient( Qsk::Bottom );
debug << " )"; debug << " )";

View File

@ -19,12 +19,13 @@ class QSK_EXPORT QskBoxBorderColors
public: public:
QskBoxBorderColors(); QskBoxBorderColors();
QskBoxBorderColors( const QColor& left, const QColor& top, QskBoxBorderColors( const QskGradient& left, const QskGradient& top,
const QColor& right, const QColor& bottom ); const QskGradient& right, const QskGradient& bottom );
QskBoxBorderColors( Qt::GlobalColor ); QskBoxBorderColors( Qt::GlobalColor );
QskBoxBorderColors( QRgb ); QskBoxBorderColors( QRgb );
QskBoxBorderColors( const QColor& ); QskBoxBorderColors( const QColor& );
QskBoxBorderColors( const QskGradient& );
~QskBoxBorderColors(); ~QskBoxBorderColors();
@ -33,15 +34,15 @@ class QSK_EXPORT QskBoxBorderColors
void setAlpha( int alpha ); void setAlpha( int alpha );
void setColors( const QColor& ); void setGradients( const QskGradient& );
void setColors( const QColor& left, const QColor& top, void setGradients( const QskGradient& left, const QskGradient& top,
const QColor& right, const QColor& bottom ); const QskGradient& right, const QskGradient& bottom );
void setColor( Qsk::Position, const QColor& ); void setGradient( Qsk::Position, const QskGradient& );
QskGradient color( Qsk::Position ) const; QskGradient gradient( Qsk::Position ) const;
void setColorsAt( Qt::Edges, const QColor& ); void setGradientAt( Qt::Edges, const QskGradient& );
QskGradient colorAt( Qt::Edge ) const; QskGradient gradientAt( Qt::Edge ) const;
QskBoxBorderColors interpolated( const QskBoxBorderColors&, qreal value ) const; QskBoxBorderColors interpolated( const QskBoxBorderColors&, qreal value ) const;
@ -72,7 +73,7 @@ inline bool QskBoxBorderColors::operator!=( const QskBoxBorderColors& other ) co
return !( *this == other ); return !( *this == other );
} }
inline QskGradient QskBoxBorderColors::color( Qsk::Position position ) const inline QskGradient QskBoxBorderColors::gradient( Qsk::Position position ) const
{ {
return m_gradients[ position ]; return m_gradients[ position ];
} }

View File

@ -117,7 +117,7 @@ void QskBoxNode::setBoxData( const QRectF& rect,
{ {
if ( isFillMonochrome && isBorderMonochrome ) if ( isFillMonochrome && isBorderMonochrome )
{ {
if ( borderColors.color( Qsk::Left ) == fillGradient.startColor() ) if ( borderColors.gradient( Qsk::Left ) == fillGradient.startColor() )
{ {
// we can draw border and background in one // we can draw border and background in one
hasBorder = false; hasBorder = false;
@ -171,7 +171,7 @@ void QskBoxNode::setBoxData( const QRectF& rect,
} }
else else
{ {
flatMaterial->setColor( borderColors.color( 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

@ -859,17 +859,17 @@ static inline void qskRenderBorder( const QskBoxRenderer::Metrics& metrics,
if ( colors.isMonochrome() ) if ( colors.isMonochrome() )
{ {
qskRenderBorderLines( metrics, orientation, line, BorderMapSolid( c.color( Qsk::Left ).startColor().rgb() ) ); // ### qskRenderBorderLines( metrics, orientation, line, BorderMapSolid( c.gradient( Qsk::Left ).startColor().rgb() ) ); // ###
} }
else else
{ {
const int stepCount = metrics.corner[ 0 ].stepCount; const int stepCount = metrics.corner[ 0 ].stepCount;
qskRenderBorderLines( metrics, orientation, line, qskRenderBorderLines( metrics, orientation, line,
BorderMapGradient( stepCount, c.color( Qsk::Top ).startColor().rgb(), c.color( Qsk::Left ).startColor().rgb() ), // ### BorderMapGradient( stepCount, c.gradient( Qsk::Top ).startColor().rgb(), c.gradient( Qsk::Left ).startColor().rgb() ), // ###
BorderMapGradient( stepCount, c.color( Qsk::Right ).startColor().rgb(), c.color( Qsk::Top ).startColor().rgb() ), // ### BorderMapGradient( stepCount, c.gradient( Qsk::Right ).startColor().rgb(), c.gradient( Qsk::Top ).startColor().rgb() ), // ###
BorderMapGradient( stepCount, c.color( Qsk::Left ).startColor().rgb(), c.color( Qsk::Bottom ).startColor().rgb() ), // ### BorderMapGradient( stepCount, c.gradient( Qsk::Left ).startColor().rgb(), c.gradient( Qsk::Bottom ).startColor().rgb() ), // ###
BorderMapGradient( stepCount, c.color( Qsk::Bottom ).startColor().rgb(), c.color( Qsk::Right ).startColor().rgb() ) ); // ### BorderMapGradient( stepCount, c.gradient( Qsk::Bottom ).startColor().rgb(), c.gradient( Qsk::Right ).startColor().rgb() ) ); // ###
} }
} }
@ -899,7 +899,7 @@ static inline void qskRenderBoxRandom(
if ( bc.isMonochrome() ) if ( bc.isMonochrome() )
{ {
const BorderMapSolid borderMap( bc.color( Qsk::Left ).startColor().rgb() ); // ### const BorderMapSolid borderMap( bc.gradient( Qsk::Left ).startColor().rgb() ); // ###
if ( gradient.isMonochrome() ) if ( gradient.isMonochrome() )
{ {
@ -918,10 +918,10 @@ static inline void qskRenderBoxRandom(
{ {
const int n = metrics.corner[ 0 ].stepCount; const int n = metrics.corner[ 0 ].stepCount;
const BorderMapGradient tl( n, bc.color( Qsk::Top ).startColor().rgb(), bc.color( Qsk::Left ).startColor().rgb() ); const BorderMapGradient tl( n, bc.gradient( Qsk::Top ).startColor().rgb(), bc.gradient( Qsk::Left ).startColor().rgb() );
const BorderMapGradient tr( n, bc.color( Qsk::Right ).startColor().rgb(), bc.color( Qsk::Top ).startColor().rgb() ); const BorderMapGradient tr( n, bc.gradient( Qsk::Right ).startColor().rgb(), bc.gradient( Qsk::Top ).startColor().rgb() );
const BorderMapGradient bl( n, bc.color( Qsk::Left ).startColor().rgb(), bc.color( Qsk::Bottom ).startColor().rgb() ); const BorderMapGradient bl( n, bc.gradient( Qsk::Left ).startColor().rgb(), bc.gradient( Qsk::Bottom ).startColor().rgb() );
const BorderMapGradient br( n, bc.color( Qsk::Bottom ).startColor().rgb(), bc.color( Qsk::Right ).startColor().rgb() ); const BorderMapGradient br( n, bc.gradient( Qsk::Bottom ).startColor().rgb(), bc.gradient( Qsk::Right ).startColor().rgb() );
if ( gradient.isMonochrome() ) if ( gradient.isMonochrome() )
{ {

View File

@ -422,10 +422,10 @@ 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 Color colorLeft = colors.color( Qsk::Left ).startColor().rgb(); // ### const Color colorLeft = colors.gradient( Qsk::Left ).startColor().rgb(); // ###
const Color colorRight = colors.color( Qsk::Right ).startColor().rgb(); // ### const Color colorRight = colors.gradient( Qsk::Right ).startColor().rgb(); // ###
const Color colorTop = colors.color( Qsk::Top ).startColor().rgb(); // ### const Color colorTop = colors.gradient( Qsk::Top ).startColor().rgb(); // ###
const Color colorBottom = colors.color( Qsk::Bottom ).startColor().rgb(); // ### const Color colorBottom = colors.gradient( Qsk::Bottom ).startColor().rgb(); // ###
( line++ )->setLine( in.right, in.bottom, out.right, out.bottom, colorBottom ); ( line++ )->setLine( in.right, in.bottom, out.right, out.bottom, colorBottom );
( line++ )->setLine( in.left, in.bottom, out.left, out.bottom, colorBottom ); ( line++ )->setLine( in.left, in.bottom, out.left, out.bottom, colorBottom );
@ -533,13 +533,13 @@ void QskBoxRenderer::renderRect(
// we might need extra lines to separate colors // we might need extra lines to separate colors
// at the non closing corners // at the non closing corners
if ( bc.color( Qsk::Left ) != bc.color( Qsk::Bottom ) ) if ( bc.gradient( Qsk::Left ) != bc.gradient( Qsk::Bottom ) )
borderLineCount++; borderLineCount++;
if ( bc.color( Qsk::Top ) != bc.color( Qsk::Left ) ) if ( bc.gradient( Qsk::Top ) != bc.gradient( Qsk::Left ) )
borderLineCount++; borderLineCount++;
if ( bc.color( Qsk::Right ) != bc.color( Qsk::Top ) ) if ( bc.gradient( Qsk::Right ) != bc.gradient( Qsk::Top ) )
borderLineCount++; borderLineCount++;
} }
} }
@ -587,7 +587,7 @@ void QskBoxRenderer::renderRect(
auto fillLines = line + fillLineCount; auto fillLines = line + fillLineCount;
if ( bc.isMonochrome() ) if ( bc.isMonochrome() )
qskCreateBorderMonochrome( rect, in, bc.color( Qsk::Left ).startColor().rgb(), fillLines ); qskCreateBorderMonochrome( rect, in, bc.gradient( Qsk::Left ).startColor().rgb(), fillLines ); // ###
else else
qskCreateBorder( rect, in, bc, fillLines ); qskCreateBorder( rect, in, bc, fillLines );
} }