From 9b10a4b523df8fb02d8371ba22b48139c36bba92 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Mon, 13 Dec 2021 12:51:14 +0100 Subject: [PATCH] QskBoxBorderColors: rename API --- skins/material/QskMaterialSkin.cpp | 6 +-- skins/squiek/QskSquiekSkin.cpp | 16 +++---- src/common/QskBoxBorderColors.cpp | 69 +++++++++++++++-------------- src/common/QskBoxBorderColors.h | 21 ++++----- src/nodes/QskBoxNode.cpp | 4 +- src/nodes/QskBoxRendererEllipse.cpp | 20 ++++----- src/nodes/QskBoxRendererRect.cpp | 16 +++---- 7 files changed, 77 insertions(+), 75 deletions(-) diff --git a/skins/material/QskMaterialSkin.cpp b/skins/material/QskMaterialSkin.cpp index c5948549..2bf3432d 100644 --- a/skins/material/QskMaterialSkin.cpp +++ b/skins/material/QskMaterialSkin.cpp @@ -602,7 +602,7 @@ void Editor::setupTabButton() QskBoxBorderColors borderColors( QskRgb::White ); setBoxBorderColors( aspect, borderColors ); - borderColors.setColorsAt( edge, m_pal.accentColor ); + borderColors.setGradientAt( edge, m_pal.accentColor ); for ( auto state : { Q::Checked, Q::Pressed, Q::Hovered } ) setBoxBorderColors( aspect | state, borderColors ); } @@ -750,8 +750,8 @@ void Editor::setupSubWindow() setGradient( Q::Panel, m_pal.baseColor ); QskBoxBorderColors colors; - colors.setColorsAt( Qt::TopEdge | Qt::LeftEdge, m_pal.lighter125 ); - colors.setColorsAt( Qt::RightEdge | Qt::BottomEdge, m_pal.darker200 ); + colors.setGradientAt( Qt::TopEdge | Qt::LeftEdge, m_pal.lighter125 ); + colors.setGradientAt( Qt::RightEdge | Qt::BottomEdge, m_pal.darker200 ); setBoxBorderColors( Q::Panel, colors ); diff --git a/skins/squiek/QskSquiekSkin.cpp b/skins/squiek/QskSquiekSkin.cpp index 5fb16fe9..377141c7 100644 --- a/skins/squiek/QskSquiekSkin.cpp +++ b/skins/squiek/QskSquiekSkin.cpp @@ -198,23 +198,23 @@ void Editor::setButton( QskAspect aspect, PanelStyle style, qreal border ) { case Raised: { - borderColors.setColorsAt( Qt::TopEdge | Qt::LeftEdge, m_pal.lighter135 ); - borderColors.setColorsAt( Qt::RightEdge | Qt::BottomEdge, m_pal.darker200 ); + borderColors.setGradientAt( Qt::TopEdge | Qt::LeftEdge, m_pal.lighter135 ); + borderColors.setGradientAt( Qt::RightEdge | Qt::BottomEdge, m_pal.darker200 ); gradient.setColors( m_pal.lighter125, m_pal.lighter110 ); break; } case Sunken: { - borderColors.setColorsAt( Qt::TopEdge | Qt::LeftEdge, m_pal.darker200 ); - borderColors.setColorsAt( Qt::RightEdge | Qt::BottomEdge, m_pal.lighter135 ); + borderColors.setGradientAt( Qt::TopEdge | Qt::LeftEdge, m_pal.darker200 ); + borderColors.setGradientAt( Qt::RightEdge | Qt::BottomEdge, m_pal.lighter135 ); gradient.setColors( m_pal.lighter110, m_pal.lighter125 ); break; } case Plain: { - borderColors.setColors( m_pal.darker125 ); + borderColors.setGradients( m_pal.darker125 ); gradient.setColor( m_pal.lighter125 ); break; @@ -225,7 +225,7 @@ void Editor::setButton( QskAspect aspect, PanelStyle style, qreal border ) QColor noColor( m_pal.theme ); noColor.setAlpha( 0 ); - borderColors.setColors( noColor ); + borderColors.setGradients( noColor ); gradient.setColor( noColor ); if ( style == NoPanel ) @@ -859,8 +859,8 @@ void Editor::setupSubWindow() setBoxShape( Q::Panel, radius, radius, 0, 0, Qt::AbsoluteSize ); QskBoxBorderColors borderColors; - borderColors.setColorsAt( Qt::TopEdge | Qt::LeftEdge, m_pal.lighter125 ); - borderColors.setColorsAt( Qt::RightEdge | Qt::BottomEdge, m_pal.darker200 ); + borderColors.setGradientAt( Qt::TopEdge | Qt::LeftEdge, m_pal.lighter125 ); + borderColors.setGradientAt( Qt::RightEdge | Qt::BottomEdge, m_pal.darker200 ); setBoxBorderColors( Q::Panel, borderColors ); setGradient( Q::Panel, m_pal.lighter135 ); diff --git a/src/common/QskBoxBorderColors.cpp b/src/common/QskBoxBorderColors.cpp index cfe96208..4bee8c17 100644 --- a/src/common/QskBoxBorderColors.cpp +++ b/src/common/QskBoxBorderColors.cpp @@ -19,19 +19,19 @@ static void 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( - const QColor& left, const QColor& top, - const QColor& right, const QColor& bottom, QskGradient* colors ) +static inline void qskSetGradients( + const QskGradient& left, const QskGradient& top, + const QskGradient& right, const QskGradient& bottom, QskGradient* colors ) { - colors[ Qsk::Left ] = left.toRgb(); - colors[ Qsk::Top ] = top.toRgb(); - colors[ Qsk::Right ] = right.toRgb(); - colors[ Qsk::Bottom ] = bottom.toRgb(); + colors[ Qsk::Left ] = left; + colors[ Qsk::Top ] = top; + colors[ Qsk::Right ] = right; + colors[ Qsk::Bottom ] = bottom; } QskBoxBorderColors::QskBoxBorderColors() @@ -39,15 +39,20 @@ QskBoxBorderColors::QskBoxBorderColors() } QskBoxBorderColors::QskBoxBorderColors( - const QColor& left, const QColor& top, - const QColor& right, const QColor& bottom ) + const QskGradient& left, const QskGradient& top, + 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 ) { - qskSetColors( color, m_gradients ); + qskSetGradients( color, m_gradients ); +} + +QskBoxBorderColors::QskBoxBorderColors( const QskGradient& gradient ) +{ + qskSetGradients( gradient, m_gradients ); } 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( - const QColor& left, const QColor& top, - const QColor& right, const QColor& bottom ) +void QskBoxBorderColors::setGradients( const QskGradient& left, const QskGradient& top, + const QskGradient& right, const QskGradient& bottom ) { - qskSetColors( left, top, right, bottom, m_gradients ); + qskSetGradients( left, top, right, bottom, m_gradients ); } -void QskBoxBorderColors::setColor( - Qsk::Position position, const QColor& color ) +void QskBoxBorderColors::setGradient( Qsk::Position position, const QskGradient &gradient ) { - 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 ) - m_gradients[ Qsk::Top ] = c; + m_gradients[ Qsk::Top ] = gradient; if ( edges & Qt::LeftEdge ) - m_gradients[ Qsk::Left ] = c; + m_gradients[ Qsk::Left ] = gradient; if ( edges & Qt::RightEdge ) - m_gradients[ Qsk::Right ] = c; + m_gradients[ Qsk::Right ] = gradient; 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 ) { @@ -201,13 +202,13 @@ QDebug operator<<( QDebug debug, const QskBoxBorderColors& colors ) 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 << " )"; diff --git a/src/common/QskBoxBorderColors.h b/src/common/QskBoxBorderColors.h index d71d0cf4..fae443ae 100644 --- a/src/common/QskBoxBorderColors.h +++ b/src/common/QskBoxBorderColors.h @@ -19,12 +19,13 @@ class QSK_EXPORT QskBoxBorderColors public: QskBoxBorderColors(); - QskBoxBorderColors( const QColor& left, const QColor& top, - const QColor& right, const QColor& bottom ); + QskBoxBorderColors( const QskGradient& left, const QskGradient& top, + const QskGradient& right, const QskGradient& bottom ); QskBoxBorderColors( Qt::GlobalColor ); QskBoxBorderColors( QRgb ); QskBoxBorderColors( const QColor& ); + QskBoxBorderColors( const QskGradient& ); ~QskBoxBorderColors(); @@ -33,15 +34,15 @@ class QSK_EXPORT QskBoxBorderColors void setAlpha( int alpha ); - void setColors( const QColor& ); - void setColors( const QColor& left, const QColor& top, - const QColor& right, const QColor& bottom ); + void setGradients( const QskGradient& ); + void setGradients( const QskGradient& left, const QskGradient& top, + const QskGradient& right, const QskGradient& bottom ); - void setColor( Qsk::Position, const QColor& ); - QskGradient color( Qsk::Position ) const; + void setGradient( Qsk::Position, const QskGradient& ); + QskGradient gradient( Qsk::Position ) const; - void setColorsAt( Qt::Edges, const QColor& ); - QskGradient colorAt( Qt::Edge ) const; + void setGradientAt( Qt::Edges, const QskGradient& ); + QskGradient gradientAt( Qt::Edge ) const; QskBoxBorderColors interpolated( const QskBoxBorderColors&, qreal value ) const; @@ -72,7 +73,7 @@ inline bool QskBoxBorderColors::operator!=( const QskBoxBorderColors& other ) co return !( *this == other ); } -inline QskGradient QskBoxBorderColors::color( Qsk::Position position ) const +inline QskGradient QskBoxBorderColors::gradient( Qsk::Position position ) const { return m_gradients[ position ]; } diff --git a/src/nodes/QskBoxNode.cpp b/src/nodes/QskBoxNode.cpp index 80516fa3..c572bd1d 100644 --- a/src/nodes/QskBoxNode.cpp +++ b/src/nodes/QskBoxNode.cpp @@ -117,7 +117,7 @@ void QskBoxNode::setBoxData( const QRectF& rect, { 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 hasBorder = false; @@ -171,7 +171,7 @@ void QskBoxNode::setBoxData( const QRectF& rect, } else { - flatMaterial->setColor( borderColors.color( Qsk::Left ).startColor().rgba() ); // ### + flatMaterial->setColor( borderColors.gradient( Qsk::Left ).startColor().rgba() ); // ### renderer.renderBorder( m_rect, shape, borderMetrics, *geometry() ); } } diff --git a/src/nodes/QskBoxRendererEllipse.cpp b/src/nodes/QskBoxRendererEllipse.cpp index 012a3e7b..113a2928 100644 --- a/src/nodes/QskBoxRendererEllipse.cpp +++ b/src/nodes/QskBoxRendererEllipse.cpp @@ -859,17 +859,17 @@ static inline void qskRenderBorder( const QskBoxRenderer::Metrics& metrics, 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 { const int stepCount = metrics.corner[ 0 ].stepCount; qskRenderBorderLines( metrics, orientation, line, - BorderMapGradient( stepCount, c.color( Qsk::Top ).startColor().rgb(), c.color( Qsk::Left ).startColor().rgb() ), // ### - BorderMapGradient( stepCount, c.color( Qsk::Right ).startColor().rgb(), c.color( Qsk::Top ).startColor().rgb() ), // ### - BorderMapGradient( stepCount, c.color( Qsk::Left ).startColor().rgb(), c.color( Qsk::Bottom ).startColor().rgb() ), // ### - BorderMapGradient( stepCount, c.color( Qsk::Bottom ).startColor().rgb(), c.color( Qsk::Right ).startColor().rgb() ) ); // ### + BorderMapGradient( stepCount, c.gradient( Qsk::Top ).startColor().rgb(), c.gradient( Qsk::Left ).startColor().rgb() ), // ### + BorderMapGradient( stepCount, c.gradient( Qsk::Right ).startColor().rgb(), c.gradient( Qsk::Top ).startColor().rgb() ), // ### + BorderMapGradient( stepCount, c.gradient( Qsk::Left ).startColor().rgb(), c.gradient( Qsk::Bottom ).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() ) { - const BorderMapSolid borderMap( bc.color( Qsk::Left ).startColor().rgb() ); // ### + const BorderMapSolid borderMap( bc.gradient( Qsk::Left ).startColor().rgb() ); // ### if ( gradient.isMonochrome() ) { @@ -918,10 +918,10 @@ static inline void qskRenderBoxRandom( { 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 tr( n, bc.color( Qsk::Right ).startColor().rgb(), bc.color( Qsk::Top ).startColor().rgb() ); - const BorderMapGradient bl( n, bc.color( Qsk::Left ).startColor().rgb(), bc.color( Qsk::Bottom ).startColor().rgb() ); - const BorderMapGradient br( n, bc.color( Qsk::Bottom ).startColor().rgb(), bc.color( Qsk::Right ).startColor().rgb() ); + const BorderMapGradient tl( n, bc.gradient( Qsk::Top ).startColor().rgb(), bc.gradient( Qsk::Left ).startColor().rgb() ); + const BorderMapGradient tr( n, bc.gradient( Qsk::Right ).startColor().rgb(), bc.gradient( Qsk::Top ).startColor().rgb() ); + const BorderMapGradient bl( n, bc.gradient( Qsk::Left ).startColor().rgb(), bc.gradient( Qsk::Bottom ).startColor().rgb() ); + const BorderMapGradient br( n, bc.gradient( Qsk::Bottom ).startColor().rgb(), bc.gradient( Qsk::Right ).startColor().rgb() ); if ( gradient.isMonochrome() ) { diff --git a/src/nodes/QskBoxRendererRect.cpp b/src/nodes/QskBoxRendererRect.cpp index 95899d37..55f64607 100644 --- a/src/nodes/QskBoxRendererRect.cpp +++ b/src/nodes/QskBoxRendererRect.cpp @@ -422,10 +422,10 @@ static inline void qskCreateBorder( const QskBoxRenderer::Quad& out, const QskBoxRenderer::Quad& in, const QskBoxBorderColors& colors, Line* line ) { - const Color colorLeft = colors.color( Qsk::Left ).startColor().rgb(); // ### - const Color colorRight = colors.color( Qsk::Right ).startColor().rgb(); // ### - const Color colorTop = colors.color( Qsk::Top ).startColor().rgb(); // ### - const Color colorBottom = colors.color( Qsk::Bottom ).startColor().rgb(); // ### + const Color colorLeft = colors.gradient( Qsk::Left ).startColor().rgb(); // ### + const Color colorRight = colors.gradient( Qsk::Right ).startColor().rgb(); // ### + const Color colorTop = colors.gradient( Qsk::Top ).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.left, in.bottom, out.left, out.bottom, colorBottom ); @@ -533,13 +533,13 @@ void QskBoxRenderer::renderRect( // we might need extra lines to separate colors // at the non closing corners - if ( bc.color( Qsk::Left ) != bc.color( Qsk::Bottom ) ) + if ( bc.gradient( Qsk::Left ) != bc.gradient( Qsk::Bottom ) ) borderLineCount++; - if ( bc.color( Qsk::Top ) != bc.color( Qsk::Left ) ) + if ( bc.gradient( Qsk::Top ) != bc.gradient( Qsk::Left ) ) borderLineCount++; - if ( bc.color( Qsk::Right ) != bc.color( Qsk::Top ) ) + if ( bc.gradient( Qsk::Right ) != bc.gradient( Qsk::Top ) ) borderLineCount++; } } @@ -587,7 +587,7 @@ void QskBoxRenderer::renderRect( auto fillLines = line + fillLineCount; if ( bc.isMonochrome() ) - qskCreateBorderMonochrome( rect, in, bc.color( Qsk::Left ).startColor().rgb(), fillLines ); + qskCreateBorderMonochrome( rect, in, bc.gradient( Qsk::Left ).startColor().rgb(), fillLines ); // ### else qskCreateBorder( rect, in, bc, fillLines ); }