summaryrefslogtreecommitdiffstats
path: root/demos/composition/composition.h
diff options
context:
space:
mode:
authorBenjamin Poulain <benjamin.poulain@nokia.com>2010-02-15 13:35:50 (GMT)
committerBenjamin Poulain <benjamin.poulain@nokia.com>2010-02-15 14:03:15 (GMT)
commit1a5c3af0f3e75a518c27c6bdd3f58896a49b167e (patch)
treef23ec6c187335bcd77c5469184463cfdb6d52c63 /demos/composition/composition.h
parentc1fe9ae25aebc8d1b9c4a7f3e67fa25ecdcbadc8 (diff)
downloadQt-1a5c3af0f3e75a518c27c6bdd3f58896a49b167e.zip
Qt-1a5c3af0f3e75a518c27c6bdd3f58896a49b167e.tar.gz
Qt-1a5c3af0f3e75a518c27c6bdd3f58896a49b167e.tar.bz2
Update the composition demo at 60 FPS instead of at painting rate
The Composition demo was updating as fast as the possible (update was called in the paint event). This is very CPU intensive, making the demo look slow on slower computer. The update is now made with a 16ms interval. Reviewed-by: Gabriel de Dietrich
Diffstat (limited to 'demos/composition/composition.h')
-rw-r--r--demos/composition/composition.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/demos/composition/composition.h b/demos/composition/composition.h
index 1123531..f5a9fc3 100644
--- a/demos/composition/composition.h
+++ b/demos/composition/composition.h
@@ -109,10 +109,6 @@ public:
void paint(QPainter *);
- void mousePressEvent(QMouseEvent *);
- void mouseMoveEvent(QMouseEvent *);
- void mouseReleaseEvent(QMouseEvent *);
-
void setCirclePos(const QPointF &pos);
QSize sizeHint() const { return QSize(500, 400); }
@@ -121,6 +117,12 @@ public:
int circleColor() const { return m_circle_hue; }
int circleAlpha() const { return m_circle_alpha; }
+protected:
+ void mousePressEvent(QMouseEvent *);
+ void mouseMoveEvent(QMouseEvent *);
+ void mouseReleaseEvent(QMouseEvent *);
+ void timerEvent(QTimerEvent *);
+
public slots:
void setClearMode() { m_composition_mode = QPainter::CompositionMode_Clear; update(); }
void setSourceMode() { m_composition_mode = QPainter::CompositionMode_Source; update(); }
@@ -150,7 +152,7 @@ public slots:
void setCircleAlpha(int alpha) { m_circle_alpha = alpha; update(); }
void setCircleColor(int hue) { m_circle_hue = hue; update(); }
- void setAnimationEnabled(bool enabled) { m_animation_enabled = enabled; update(); }
+ void setAnimationEnabled(bool enabled);
private:
void updateCirclePos();
@@ -177,6 +179,7 @@ private:
ObjectType m_current_object;
bool m_animation_enabled;
+ int m_animationTimer;
#ifdef QT_OPENGL_SUPPORT
QGLPixelBuffer *m_pbuffer;