QskSkinlet cleanup by using QskBoxHints
This commit is contained in:
parent
da1691eaa0
commit
fbcce286d4
|
@ -9,6 +9,7 @@
|
||||||
#include <QskSGNode.h>
|
#include <QskSGNode.h>
|
||||||
#include <QskTextOptions.h>
|
#include <QskTextOptions.h>
|
||||||
#include <QskTextColors.h>
|
#include <QskTextColors.h>
|
||||||
|
#include <QskBoxHints.h>
|
||||||
|
|
||||||
#include <QskPlotCurve.h>
|
#include <QskPlotCurve.h>
|
||||||
#include <QskPlotCorridor.h>
|
#include <QskPlotCorridor.h>
|
||||||
|
@ -143,8 +144,10 @@ QSGNode* PlotCursorSkinlet::updateSampleNode( const QskSkinnable* skinnable,
|
||||||
|
|
||||||
if ( subControl == Q::LabelPanel )
|
if ( subControl == Q::LabelPanel )
|
||||||
{
|
{
|
||||||
const auto gradient = skinnable->gradientHint( aspect );
|
auto hints = skinnable->boxHints( subControl );
|
||||||
return updateBoxNode( skinnable, node, rect, gradient, subControl );
|
hints.gradient = skinnable->gradientHint( aspect );
|
||||||
|
|
||||||
|
return updateBoxNode( skinnable, node, rect, hints );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( subControl == Q::LabelText )
|
if ( subControl == Q::LabelText )
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "QskProgressBarSkinlet.h"
|
#include "QskProgressBarSkinlet.h"
|
||||||
#include "QskProgressBar.h"
|
#include "QskProgressBar.h"
|
||||||
#include "QskIntervalF.h"
|
#include "QskIntervalF.h"
|
||||||
#include "QskBoxBorderMetrics.h"
|
#include "QskBoxHints.h"
|
||||||
|
|
||||||
#include <qeasingcurve.h>
|
#include <qeasingcurve.h>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
@ -50,41 +50,6 @@ static QskIntervalF qskFillInterval( const QskProgressIndicator* indicator )
|
||||||
return QskIntervalF( pos1, pos2 );
|
return QskIntervalF( pos1, pos2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
static QskGradient qskFillGradient( const QskProgressBar* progressBar )
|
|
||||||
{
|
|
||||||
auto gradient = progressBar->gradientHint( Q::Fill );
|
|
||||||
|
|
||||||
if ( gradient.isVisible() && !gradient.isMonochrome()
|
|
||||||
&& ( gradient.type() == QskGradient::Stops ) )
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
When having stops only we use a linear gradient,
|
|
||||||
where the colors are increasing in direction of the
|
|
||||||
progress value. We interprete the gradient as a
|
|
||||||
definition for the 100% situation and have to adjust
|
|
||||||
the stops for smaller bars.
|
|
||||||
|
|
||||||
For this situation it would be more convenient to
|
|
||||||
adjust the start/stop positions, but the box renderer is
|
|
||||||
not supporting this yet. TODO ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
const auto intv = qskFillInterval( progressBar );
|
|
||||||
|
|
||||||
const auto stops = qskExtractedGradientStops(
|
|
||||||
gradient.stops(), intv.lowerBound(), intv.upperBound() );
|
|
||||||
|
|
||||||
gradient.setStops( stops );
|
|
||||||
|
|
||||||
gradient.setLinearDirection( progressBar->orientation() );
|
|
||||||
|
|
||||||
if ( progressBar->orientation() == Qt::Vertical || progressBar->layoutMirroring() )
|
|
||||||
gradient.reverse();
|
|
||||||
}
|
|
||||||
|
|
||||||
return gradient;
|
|
||||||
}
|
|
||||||
|
|
||||||
QskProgressBarSkinlet::QskProgressBarSkinlet( QskSkin* skin )
|
QskProgressBarSkinlet::QskProgressBarSkinlet( QskSkin* skin )
|
||||||
: Inherited( skin )
|
: Inherited( skin )
|
||||||
{
|
{
|
||||||
|
@ -122,9 +87,40 @@ QSGNode* QskProgressBarSkinlet::updateFillNode(
|
||||||
if ( rect.isEmpty() )
|
if ( rect.isEmpty() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const auto progressBar = static_cast< const Q* >( indicator );
|
auto hints = indicator->boxHints( Q::Fill );
|
||||||
return updateBoxNode( indicator, node, rect,
|
|
||||||
qskFillGradient( progressBar ), Q::Fill );
|
auto& gradient = hints.gradient;
|
||||||
|
|
||||||
|
if ( gradient.isVisible() && !gradient.isMonochrome()
|
||||||
|
&& ( gradient.type() == QskGradient::Stops ) )
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
When having stops only we use a linear gradient,
|
||||||
|
where the colors are increasing in direction of the
|
||||||
|
progress value. We interprete the gradient as a
|
||||||
|
definition for the 100% situation and have to adjust
|
||||||
|
the stops for smaller bars.
|
||||||
|
|
||||||
|
For this situation it would be more convenient to
|
||||||
|
adjust the start/stop positions, but the box renderer is
|
||||||
|
not supporting this yet. TODO ...
|
||||||
|
*/
|
||||||
|
|
||||||
|
const auto intv = qskFillInterval( indicator );
|
||||||
|
|
||||||
|
const auto stops = qskExtractedGradientStops(
|
||||||
|
gradient.stops(), intv.lowerBound(), intv.upperBound() );
|
||||||
|
|
||||||
|
gradient.setStops( stops );
|
||||||
|
|
||||||
|
const auto orientation = static_cast< const Q* >( indicator )->orientation();
|
||||||
|
gradient.setLinearDirection( orientation );
|
||||||
|
|
||||||
|
if ( orientation == Qt::Vertical || indicator->layoutMirroring() )
|
||||||
|
gradient.reverse();
|
||||||
|
}
|
||||||
|
|
||||||
|
return updateBoxNode( indicator, node, rect, hints );
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF QskProgressBarSkinlet::grooveRect(
|
QRectF QskProgressBarSkinlet::grooveRect(
|
||||||
|
|
|
@ -202,22 +202,18 @@ static inline QQuickWindow* qskWindowOfSkinnable( const QskSkinnable* skinnable
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline QSGNode* qskUpdateBoxNode(
|
static inline QSGNode* qskUpdateBoxNode( const QskSkinnable* skinnable,
|
||||||
const QskSkinnable* skinnable, QSGNode* node, const QRectF& rect,
|
QSGNode* node, const QRectF& rect, const QskBoxHints& hints )
|
||||||
const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& borderMetrics,
|
|
||||||
const QskBoxBorderColors& borderColors, const QskGradient& gradient,
|
|
||||||
const QskShadowMetrics& shadowMetrics, const QColor& shadowColor )
|
|
||||||
{
|
{
|
||||||
if ( !rect.isEmpty() )
|
if ( !rect.isEmpty() )
|
||||||
{
|
{
|
||||||
if ( qskIsBoxVisible( borderMetrics, borderColors, gradient )
|
if ( qskIsBoxVisible( hints.borderMetrics, hints.borderColors, hints.gradient )
|
||||||
|| qskIsShadowVisible( shadowMetrics, shadowColor ) )
|
|| qskIsShadowVisible( hints.shadowMetrics, hints.shadowColor ) )
|
||||||
{
|
{
|
||||||
if ( auto window = qskWindowOfSkinnable( skinnable ) )
|
if ( auto window = qskWindowOfSkinnable( skinnable ) )
|
||||||
{
|
{
|
||||||
auto boxNode = QskSGNode::ensureNode< QskBoxNode >( node );
|
auto boxNode = QskSGNode::ensureNode< QskBoxNode >( node );
|
||||||
boxNode->updateNode( window, rect, shape, borderMetrics,
|
boxNode->updateNode( window, rect, hints );
|
||||||
borderColors, gradient, shadowMetrics, shadowColor );
|
|
||||||
|
|
||||||
return boxNode;
|
return boxNode;
|
||||||
}
|
}
|
||||||
|
@ -435,53 +431,27 @@ QSGNode* QskSkinlet::updateBoxNode( const QskSkinnable* skinnable,
|
||||||
QSGNode* node, QskAspect::Subcontrol subControl ) const
|
QSGNode* node, QskAspect::Subcontrol subControl ) const
|
||||||
{
|
{
|
||||||
const auto rect = qskSubControlRect( this, skinnable, subControl );
|
const auto rect = qskSubControlRect( this, skinnable, subControl );
|
||||||
return updateBoxNode( skinnable, node, rect, subControl );
|
if ( rect.isEmpty() )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return qskUpdateBoxNode( skinnable, node,
|
||||||
|
rect, skinnable->boxHints( subControl ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* QskSkinlet::updateBoxNode( const QskSkinnable* skinnable,
|
QSGNode* QskSkinlet::updateBoxNode( const QskSkinnable* skinnable,
|
||||||
QSGNode* node, const QRectF& rect, QskAspect::Subcontrol subControl )
|
QSGNode* node, const QRectF& rect, QskAspect::Subcontrol subControl )
|
||||||
{
|
{
|
||||||
const auto fillGradient = skinnable->gradientHint( subControl );
|
if ( rect.isEmpty() )
|
||||||
return updateBoxNode( skinnable, node, rect, fillGradient, subControl );
|
|
||||||
}
|
|
||||||
|
|
||||||
QSGNode* QskSkinlet::updateBoxNode( const QskSkinnable* skinnable,
|
|
||||||
QSGNode* node, const QRectF& rect, const QskGradient& fillGradient,
|
|
||||||
QskAspect::Subcontrol subControl )
|
|
||||||
{
|
|
||||||
const auto margins = skinnable->marginHint( subControl );
|
|
||||||
|
|
||||||
const auto boxRect = rect.marginsRemoved( margins );
|
|
||||||
if ( boxRect.isEmpty() )
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const auto borderMetrics = skinnable->boxBorderMetricsHint( subControl );
|
const auto hints = skinnable->boxHints( subControl );
|
||||||
const auto borderColors = skinnable->boxBorderColorsHint( subControl );
|
return qskUpdateBoxNode( skinnable, node, rect, hints );
|
||||||
const auto shape = skinnable->boxShapeHint( subControl );
|
|
||||||
const auto shadowMetrics = skinnable->shadowMetricsHint( subControl );
|
|
||||||
const auto shadowColor = skinnable->shadowColorHint( subControl );
|
|
||||||
|
|
||||||
return qskUpdateBoxNode( skinnable, node,
|
|
||||||
boxRect, shape, borderMetrics, borderColors, fillGradient,
|
|
||||||
shadowMetrics, shadowColor );
|
|
||||||
}
|
|
||||||
|
|
||||||
QSGNode* QskSkinlet::updateBoxNode(
|
|
||||||
const QskSkinnable* skinnable, QSGNode* node, const QRectF& rect,
|
|
||||||
const QskBoxShapeMetrics& shape, const QskBoxBorderMetrics& borderMetrics,
|
|
||||||
const QskBoxBorderColors& borderColors, const QskGradient& fillGradient )
|
|
||||||
{
|
|
||||||
return qskUpdateBoxNode( skinnable, node,
|
|
||||||
rect, shape, borderMetrics, borderColors, fillGradient,
|
|
||||||
QskShadowMetrics(), QColor() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* QskSkinlet::updateBoxNode( const QskSkinnable* skinnable,
|
QSGNode* QskSkinlet::updateBoxNode( const QskSkinnable* skinnable,
|
||||||
QSGNode* node, const QRectF& rect, const QskBoxHints& hints )
|
QSGNode* node, const QRectF& rect, const QskBoxHints& hints )
|
||||||
{
|
{
|
||||||
return qskUpdateBoxNode( skinnable, node, rect,
|
return qskUpdateBoxNode( skinnable, node, rect, hints );
|
||||||
hints.shape, hints.borderMetrics, hints.borderColors, hints.gradient,
|
|
||||||
hints.shadowMetrics, hints.shadowColor );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* QskSkinlet::updateInterpolatedBoxNode(
|
QSGNode* QskSkinlet::updateInterpolatedBoxNode(
|
||||||
|
|
|
@ -76,13 +76,6 @@ class QSK_EXPORT QskSkinlet
|
||||||
static QSGNode* updateBoxNode( const QskSkinnable*, QSGNode*,
|
static QSGNode* updateBoxNode( const QskSkinnable*, QSGNode*,
|
||||||
const QRectF&, QskAspect::Subcontrol );
|
const QRectF&, QskAspect::Subcontrol );
|
||||||
|
|
||||||
static QSGNode* updateBoxNode( const QskSkinnable*, QSGNode*,
|
|
||||||
const QRectF&, const QskGradient&, QskAspect::Subcontrol );
|
|
||||||
|
|
||||||
static QSGNode* updateBoxNode( const QskSkinnable*, QSGNode*,
|
|
||||||
const QRectF&, const QskBoxShapeMetrics&, const QskBoxBorderMetrics&,
|
|
||||||
const QskBoxBorderColors&, const QskGradient& );
|
|
||||||
|
|
||||||
static QSGNode* updateBoxNode( const QskSkinnable*, QSGNode*,
|
static QSGNode* updateBoxNode( const QskSkinnable*, QSGNode*,
|
||||||
const QRectF&, const QskBoxHints& );
|
const QRectF&, const QskBoxHints& );
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,8 @@
|
||||||
#include "QskBoxRectangleNode.h"
|
#include "QskBoxRectangleNode.h"
|
||||||
#include "QskSGNode.h"
|
#include "QskSGNode.h"
|
||||||
|
|
||||||
#include "QskGradient.h"
|
#include "QskBoxHints.h"
|
||||||
#include "QskGradientDirection.h"
|
#include "QskGradientDirection.h"
|
||||||
#include "QskShadowMetrics.h"
|
|
||||||
#include "QskBoxBorderMetrics.h"
|
|
||||||
#include "QskBoxBorderColors.h"
|
|
||||||
#include "QskBoxShapeMetrics.h"
|
|
||||||
#include "QskRgbValue.h"
|
#include "QskRgbValue.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
@ -60,10 +56,8 @@ QskBoxNode::~QskBoxNode()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskBoxNode::updateNode( const QQuickWindow* window, const QRectF& rect,
|
void QskBoxNode::updateNode( const QQuickWindow* window,
|
||||||
const QskBoxShapeMetrics& shapeMetrics, const QskBoxBorderMetrics& borderMetrics,
|
const QRectF& rect, const QskBoxHints& hints )
|
||||||
const QskBoxBorderColors& borderColors, const QskGradient& gradient,
|
|
||||||
const QskShadowMetrics& shadowMetrics, const QColor& shadowColor )
|
|
||||||
{
|
{
|
||||||
using namespace QskSGNode;
|
using namespace QskSGNode;
|
||||||
|
|
||||||
|
@ -74,6 +68,13 @@ void QskBoxNode::updateNode( const QQuickWindow* window, const QRectF& rect,
|
||||||
|
|
||||||
if ( !rect.isEmpty() )
|
if ( !rect.isEmpty() )
|
||||||
{
|
{
|
||||||
|
const auto& shapeMetrics = hints.shape;
|
||||||
|
const auto& borderMetrics = hints.borderMetrics;
|
||||||
|
const auto& borderColors = hints.borderColors;
|
||||||
|
const auto& gradient = hints.gradient;
|
||||||
|
const auto& shadowMetrics = hints.shadowMetrics;
|
||||||
|
const auto& shadowColor = hints.shadowColor;
|
||||||
|
|
||||||
const auto hasFilling = gradient.isVisible();
|
const auto hasFilling = gradient.isVisible();
|
||||||
const auto hasBorder = !borderMetrics.isNull() && borderColors.isVisible();
|
const auto hasBorder = !borderMetrics.isNull() && borderColors.isVisible();
|
||||||
const auto hasShadow = !shadowMetrics.isNull() && QskRgb::isVisible( shadowColor );
|
const auto hasShadow = !shadowMetrics.isNull() && QskRgb::isVisible( shadowColor );
|
||||||
|
|
|
@ -9,14 +9,8 @@
|
||||||
#include "QskGlobal.h"
|
#include "QskGlobal.h"
|
||||||
#include <qsgnode.h>
|
#include <qsgnode.h>
|
||||||
|
|
||||||
class QskShadowMetrics;
|
class QskBoxHints;
|
||||||
class QskBoxShapeMetrics;
|
|
||||||
class QskBoxBorderMetrics;
|
|
||||||
class QskBoxBorderColors;
|
|
||||||
class QskGradient;
|
|
||||||
class QskShadowMetrics;
|
|
||||||
class QQuickWindow;
|
class QQuickWindow;
|
||||||
class QColor;
|
|
||||||
|
|
||||||
class QSK_EXPORT QskBoxNode : public QSGNode
|
class QSK_EXPORT QskBoxNode : public QSGNode
|
||||||
{
|
{
|
||||||
|
@ -24,10 +18,7 @@ class QSK_EXPORT QskBoxNode : public QSGNode
|
||||||
QskBoxNode();
|
QskBoxNode();
|
||||||
~QskBoxNode() override;
|
~QskBoxNode() override;
|
||||||
|
|
||||||
void updateNode( const QQuickWindow*, const QRectF&,
|
void updateNode( const QQuickWindow*, const QRectF&, const QskBoxHints& );
|
||||||
const QskBoxShapeMetrics&, const QskBoxBorderMetrics&,
|
|
||||||
const QskBoxBorderColors&, const QskGradient&,
|
|
||||||
const QskShadowMetrics&, const QColor& shadowColor );
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue