minor changes

This commit is contained in:
Uwe Rathmann 2022-08-03 09:40:18 +02:00
parent be53343375
commit 3763bd5bad
2 changed files with 18 additions and 20 deletions

View File

@ -6,11 +6,6 @@
#include "CircularProgressBarSkinlet.h"
#include "CircularProgressBar.h"
#include <QskPaintedNode.h>
#include <QEasingCurve>
#include <QPainter>
CircularProgressBarSkinlet::CircularProgressBarSkinlet( QskSkin* skin )
: QskSkinlet( skin )
{
@ -38,9 +33,11 @@ QSGNode* CircularProgressBarSkinlet::updateSubNode(
}
case BarRole:
{
const qreal startAngle = 90.0;
const auto bar = static_cast< const CircularProgressBar* >( skinnable );
const qreal startAngle = 90.0;
const qreal spanAngle = 360.0 * bar->valueAsRatio();
return updateArcNode( skinnable, node, startAngle, -spanAngle,
CircularProgressBar::Bar );
}

View File

@ -20,13 +20,17 @@ Cube::Cube( QQuickItem* parent )
void Cube::startAnimation( Qsk::Direction direction )
{
auto animator = dynamic_cast< QskStackBoxAnimator4* >( this->animator() );
using Animator = QskStackBoxAnimator4;
auto animator = qobject_cast< Animator* >( this->animator() );
if ( animator == nullptr )
{
animator = new QskStackBoxAnimator4( this );
animator = new Animator( this );
animator->setEasingCurve( QEasingCurve::InOutQuad );
animator->setDuration( 1000 );
setAnimator( animator );
}
const auto orientation = ( direction == Qsk::LeftToRight || direction == Qsk::RightToLeft )
@ -36,20 +40,18 @@ void Cube::startAnimation( Qsk::Direction direction )
const bool inverted = ( direction == Qsk::LeftToRight || direction == Qsk::TopToBottom );
animator->setInverted( inverted );
setAnimator( animator );
int newIndex;
switch( direction )
{
case Qsk::LeftToRight:
case Qsk::TopToBottom:
newIndex = currentIndex() + 1;
break;
case Qsk::RightToLeft:
case Qsk::BottomToTop:
newIndex = currentIndex() - 1;
break;
case Qsk::LeftToRight:
case Qsk::TopToBottom:
newIndex = currentIndex() + 1;
break;
case Qsk::RightToLeft:
case Qsk::BottomToTop:
newIndex = currentIndex() - 1;
break;
}
newIndex %= itemCount();
@ -109,8 +111,7 @@ void MainItem::gestureEvent( QskGestureEvent* event )
direction = ( delta.y() < 0 ) ? Qsk::TopToBottom : Qsk::BottomToTop;
}
// ### uncomment once animations are working:
// m_cube->startAnimation( direction );
m_cube->startAnimation( direction );
}
}