summaryrefslogtreecommitdiffstats
path: root/src/widgets/styles/qmacstyle_mac_p.h
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2012-10-30 13:47:20 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-02 19:49:22 +0100
commit3c2bfbff5f4c836de32628710ab7701b0db083f7 (patch)
tree4e6c262f6cbaa4978bcf47b239423fe305af50bb /src/widgets/styles/qmacstyle_mac_p.h
parent020196d16b6c25e16bf80483f08e0007a27eab13 (diff)
Mac: refactor scrollbar animations
Get rid of QWidget-centric QMacStyle::eventFilter() and implement the fade out animations for scrollbars using QNumberStyleAnimation-based QFadeOutAnimation. Change-Id: I2000fa50d46b153e981ceafc12a53932a196382e Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/widgets/styles/qmacstyle_mac_p.h')
-rw-r--r--src/widgets/styles/qmacstyle_mac_p.h54
1 files changed, 28 insertions, 26 deletions
diff --git a/src/widgets/styles/qmacstyle_mac_p.h b/src/widgets/styles/qmacstyle_mac_p.h
index af1c88d50d..f01d1e14c5 100644
--- a/src/widgets/styles/qmacstyle_mac_p.h
+++ b/src/widgets/styles/qmacstyle_mac_p.h
@@ -158,9 +158,6 @@ public:
static const qreal ScrollBarFadeOutDuration;
static const qreal ScrollBarFadeOutDelay;
- // Stuff from QAquaAnimate:
- bool addWidget(QWidget *);
-
enum Animates { AquaPushButton, AquaProgressBar, AquaListViewItemOpen, AquaScrollBar };
static ThemeDrawState getDrawState(QStyle::State flags);
QAquaWidgetSize aquaSizeConstrain(const QStyleOption *option, const QWidget *widg,
@@ -201,29 +198,6 @@ public:
mutable QPointer<QObject> defaultButton;
mutable QPointer<QObject> autoDefaultButton;
- struct OverlayScrollBarInfo {
- OverlayScrollBarInfo()
- : lastValue(-1),
- lastMinimum(-1),
- lastMaximum(-1),
- lastUpdate(QDateTime::currentMSecsSinceEpoch()),
- hovered(false),
- lastHovered(0),
- cleared(false),
- animating(false)
- {}
- int lastValue;
- int lastMinimum;
- int lastMaximum;
- QSize lastSize;
- qint64 lastUpdate;
- bool hovered;
- qint64 lastHovered;
- bool cleared;
- bool animating;
- };
- mutable QMap<const QWidget*, OverlayScrollBarInfo> scrollBarInfos;
-
struct ButtonState {
int frame;
enum { ButtonDark, ButtonLight } dir;
@@ -237,6 +211,34 @@ public:
#endif
};
+class QFadeOutAnimation : public QNumberStyleAnimation
+{
+ Q_OBJECT
+
+public:
+ QFadeOutAnimation(QObject *target) : QNumberStyleAnimation(target), _active(false)
+ {
+ setDuration(QMacStylePrivate::ScrollBarFadeOutDelay + QMacStylePrivate::ScrollBarFadeOutDuration);
+ setDelay(QMacStylePrivate::ScrollBarFadeOutDelay);
+ setStartValue(1.0);
+ setEndValue(0.0);
+ }
+
+ bool wasActive() const { return _active; }
+ void setActive(bool active) { _active = active; }
+
+private slots:
+ void updateCurrentTime(int time)
+ {
+ QNumberStyleAnimation::updateCurrentTime(time);
+ if (qFuzzyIsNull(currentValue()))
+ target()->setProperty("visible", false);
+ }
+
+private:
+ bool _active;
+};
+
QT_END_NAMESPACE
#endif // QMACSTYLE_MAC_P_H