remove circular bar graph node
We can now use updateArcNode() and don't need our own method.
This commit is contained in:
parent
ee1085f95d
commit
c28c6df231
|
@ -6,6 +6,7 @@
|
||||||
#include "CircularProgressBar.h"
|
#include "CircularProgressBar.h"
|
||||||
|
|
||||||
#include <QskAnimator.h>
|
#include <QskAnimator.h>
|
||||||
|
#include <QskArcMetrics.h>
|
||||||
#include <QskFunctions.h>
|
#include <QskFunctions.h>
|
||||||
|
|
||||||
QSK_SUBCONTROL( CircularProgressBar, Groove )
|
QSK_SUBCONTROL( CircularProgressBar, Groove )
|
||||||
|
@ -179,6 +180,14 @@ void CircularProgressBar::setValueInternal( qreal value )
|
||||||
if ( !qskFuzzyCompare( value, m_data->value ) )
|
if ( !qskFuzzyCompare( value, m_data->value ) )
|
||||||
{
|
{
|
||||||
m_data->value = value;
|
m_data->value = value;
|
||||||
|
|
||||||
|
// if we didn't change the metrics here we would have to
|
||||||
|
// add our own drawing code to the skinlet:
|
||||||
|
QskArcMetrics arcMetrics = arcMetricsHint( Bar );
|
||||||
|
const int spanAngle = qRound( valueAsRatio() * -5760 );
|
||||||
|
arcMetrics.setSpanAngle( spanAngle );
|
||||||
|
setArcMetricsHint( Bar, arcMetrics );
|
||||||
|
|
||||||
Q_EMIT valueChanged( value );
|
Q_EMIT valueChanged( value );
|
||||||
|
|
||||||
update();
|
update();
|
||||||
|
|
|
@ -35,47 +35,20 @@ QSGNode* CircularProgressBarSkinlet::updateSubNode(
|
||||||
|
|
||||||
switch( nodeRole )
|
switch( nodeRole )
|
||||||
{
|
{
|
||||||
case GrooveRole: // fall through
|
case GrooveRole:
|
||||||
|
{
|
||||||
|
return updateArcNode( skinnable, node, CircularProgressBar::Groove,
|
||||||
|
bar->window() );
|
||||||
|
}
|
||||||
case BarRole:
|
case BarRole:
|
||||||
{
|
{
|
||||||
return updateBarNode( bar, nodeRole, node );
|
const auto subControl = CircularProgressBar::Bar;
|
||||||
|
return updateArcNode( skinnable, node, CircularProgressBar::Bar,
|
||||||
|
bar->window() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Inherited::updateSubNode( skinnable, nodeRole, node );
|
return Inherited::updateSubNode( skinnable, nodeRole, node );
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* CircularProgressBarSkinlet::updateBarNode(
|
|
||||||
const CircularProgressBar* bar, quint8 nodeRole, QSGNode* node ) const
|
|
||||||
{
|
|
||||||
auto arcNode = static_cast< QskArcNode* >( node );
|
|
||||||
|
|
||||||
if( arcNode == nullptr )
|
|
||||||
{
|
|
||||||
arcNode = new QskArcNode();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ### for the groove case, we can just call updateArcNode directly,
|
|
||||||
// but not for the bar case, because we need to change the angles
|
|
||||||
// for the latter case, we can just set the metrics rather than having
|
|
||||||
// this method here
|
|
||||||
const auto subControl = ( nodeRole == GrooveRole ) ?
|
|
||||||
CircularProgressBar::Groove : CircularProgressBar::Bar;
|
|
||||||
|
|
||||||
const QRectF rect = bar->contentsRect(); // ### rather call subcontrolrect
|
|
||||||
|
|
||||||
QskArcMetrics arcMetrics = bar->arcMetricsHint( subControl );
|
|
||||||
const int spanAngle = ( nodeRole == GrooveRole ) ?
|
|
||||||
5760 : qRound( bar->valueAsRatio() * -5760 );
|
|
||||||
arcMetrics.setSpanAngle( spanAngle );
|
|
||||||
|
|
||||||
QQuickWindow* window = bar->window();
|
|
||||||
|
|
||||||
const QskGradient gradient = bar->gradientHint( subControl );
|
|
||||||
|
|
||||||
arcNode->setArcData( rect, arcMetrics, gradient, window );
|
|
||||||
|
|
||||||
return arcNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "moc_CircularProgressBarSkinlet.cpp"
|
#include "moc_CircularProgressBarSkinlet.cpp"
|
||||||
|
|
|
@ -33,7 +33,4 @@ class CircularProgressBarSkinlet : public QskSkinlet
|
||||||
protected:
|
protected:
|
||||||
QSGNode* updateSubNode( const QskSkinnable*,
|
QSGNode* updateSubNode( const QskSkinnable*,
|
||||||
quint8 nodeRole, QSGNode* ) const override;
|
quint8 nodeRole, QSGNode* ) const override;
|
||||||
|
|
||||||
private:
|
|
||||||
QSGNode* updateBarNode( const CircularProgressBar*, quint8 nodeRole, QSGNode* ) const;
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue