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.
79 lines
2.1 KiB
C++
79 lines
2.1 KiB
C++
#ifndef SLIDINGSTACKEDWIDGET_H
|
|
#define SLIDINGSTACKEDWIDGET_H
|
|
|
|
#include <QStackedWidget>
|
|
#include <QEasingCurve>
|
|
#include <QElapsedTimer>
|
|
#include <QList>
|
|
#include <QPoint>
|
|
#include <QPointer>
|
|
#include <QRect>
|
|
#include <QTimer>
|
|
|
|
class QLabel;
|
|
|
|
|
|
class SlidingStackedWidget : public QStackedWidget
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
enum SlideDirection {
|
|
LeftToRight,
|
|
RightToLeft,
|
|
TopToBottom,
|
|
BottomToTop,
|
|
Automatic
|
|
};
|
|
|
|
explicit SlidingStackedWidget(QWidget *parent = nullptr);
|
|
|
|
void setSpeed(int speed);
|
|
void setEasingCurve(QEasingCurve::Type curveType);
|
|
|
|
|
|
void slideInIdx(int idx, SlideDirection direction = Automatic);
|
|
void slideInWgt(QWidget *widget, SlideDirection direction = Automatic);
|
|
// Instant switch (no slide), safely finishing any in-flight animation.
|
|
// For targets with their own entrance animation (e.g. the player view).
|
|
void jumpToIdx(int idx);
|
|
void jumpToWgt(QWidget *widget);
|
|
void disposeWidgetWhenSafe(QWidget *widget);
|
|
|
|
Q_SIGNALS:
|
|
|
|
|
|
void animationFinished();
|
|
|
|
private Q_SLOTS:
|
|
void animationDoneSlot();
|
|
|
|
private:
|
|
QLabel *createSnapshotLabel(QWidget *source, const QRect &geometry);
|
|
void clearSnapshotLabels();
|
|
void startSlideAnimation(QWidget *widgetNow, const QPoint &nowStart,
|
|
const QPoint &nowEnd, QWidget *widgetNext,
|
|
const QPoint &nextStart,
|
|
const QPoint &nextEnd);
|
|
void updateSlideAnimation();
|
|
int animationFrameIntervalMs() const;
|
|
void flushPendingWidgetDisposals();
|
|
|
|
int m_speed;
|
|
QEasingCurve::Type m_animationType;
|
|
QTimer m_slideTimer;
|
|
QElapsedTimer m_slideClock;
|
|
QPointer<QWidget> m_animWidgetNow;
|
|
QPointer<QWidget> m_animWidgetNext;
|
|
QPoint m_animNowStart;
|
|
QPoint m_animNowEnd;
|
|
QPoint m_animNextStart;
|
|
QPoint m_animNextEnd;
|
|
bool m_isAnimating;
|
|
int m_nextIndex;
|
|
QList<QPointer<QWidget>> m_pendingWidgetDisposals;
|
|
QLabel* m_currentSnapshotLabel = nullptr;
|
|
QLabel* m_nextSnapshotLabel = nullptr;
|
|
};
|
|
|
|
#endif
|