perf: smooth UI animations and reduce repaint overhead
Batch of performance and animation work: shared FadeHelper/MotionPrefs primitives, hover animators, shadow pixmap caching, smooth scrolling, seek time bubble, and widespread component repaint reductions.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "slidingstackedwidget.h"
|
||||
#include "../tokens/AnimationTokens.h"
|
||||
#include <QWidget>
|
||||
#include <QLabel>
|
||||
#include <QScreen>
|
||||
@@ -17,8 +18,8 @@ QPoint interpolatePoint(const QPoint &start, const QPoint &end, qreal progress)
|
||||
|
||||
SlidingStackedWidget::SlidingStackedWidget(QWidget *parent)
|
||||
: QStackedWidget(parent),
|
||||
m_speed(350),
|
||||
m_animationType(QEasingCurve::OutCubic),
|
||||
m_speed(AnimationTokens::DurationMs::kSlow),
|
||||
m_animationType(AnimationTokens::Curve::enter().type()),
|
||||
m_isAnimating(false),
|
||||
m_nextIndex(0)
|
||||
{
|
||||
@@ -45,6 +46,35 @@ void SlidingStackedWidget::slideInWgt(QWidget *widget, SlideDirection direction)
|
||||
}
|
||||
}
|
||||
|
||||
void SlidingStackedWidget::jumpToWgt(QWidget *widget)
|
||||
{
|
||||
int idx = indexOf(widget);
|
||||
if (idx != -1) {
|
||||
jumpToIdx(idx);
|
||||
}
|
||||
}
|
||||
|
||||
void SlidingStackedWidget::jumpToIdx(int idx)
|
||||
{
|
||||
if (idx < 0 || idx >= count())
|
||||
return;
|
||||
|
||||
if (currentIndex() == idx && !m_isAnimating)
|
||||
return;
|
||||
|
||||
if (m_isAnimating) {
|
||||
m_slideTimer.stop();
|
||||
animationDoneSlot();
|
||||
}
|
||||
|
||||
m_nextIndex = idx;
|
||||
setCurrentIndex(idx);
|
||||
QWidget *w = widget(idx);
|
||||
if (w) w->raise();
|
||||
flushPendingWidgetDisposals();
|
||||
Q_EMIT animationFinished();
|
||||
}
|
||||
|
||||
void SlidingStackedWidget::slideInIdx(int idx, SlideDirection direction)
|
||||
{
|
||||
if (idx < 0 || idx >= count())
|
||||
@@ -55,21 +85,16 @@ void SlidingStackedWidget::slideInIdx(int idx, SlideDirection direction)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
|
||||
if (m_isAnimating) {
|
||||
m_slideTimer.stop();
|
||||
animationDoneSlot();
|
||||
animationDoneSlot();
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool reduceAnimations = ConfigStore::instance()->get<bool>(ConfigKeys::UiAnimations, false);
|
||||
if (reduceAnimations) {
|
||||
m_nextIndex = idx;
|
||||
setCurrentIndex(idx);
|
||||
QWidget *w = widget(idx);
|
||||
if (w) w->raise();
|
||||
flushPendingWidgetDisposals();
|
||||
Q_EMIT animationFinished();
|
||||
jumpToIdx(idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user