Changeset 769 for trunk/demos/composition
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/demos/composition/composition.cpp
r651 r769 48 48 #include <QMouseEvent> 49 49 #include <qmath.h> 50 51 const int animationInterval = 15; // update every 16 ms = ~60FPS 50 52 51 53 CompositionWidget::CompositionWidget(QWidget *parent) … … 237 239 { 238 240 m_animation_enabled = true; 241 m_animationTimer = startTimer(animationInterval); 239 242 #ifdef Q_WS_QWS 240 243 m_image = QPixmap(":res/composition/flower.jpg"); … … 263 266 rect.translate(-size.width()/2, -size.height()/2); 264 267 return rect; 268 } 269 270 void CompositionRenderer::setAnimationEnabled(bool enabled) 271 { 272 if (m_animation_enabled == enabled) 273 return; 274 m_animation_enabled = enabled; 275 if (enabled) { 276 Q_ASSERT(!m_animationTimer); 277 m_animationTimer = startTimer(animationInterval); 278 } else { 279 killTimer(m_animationTimer); 280 m_animationTimer = 0; 281 } 265 282 } 266 283 … … 472 489 #endif 473 490 } 474 475 if (m_animation_enabled && m_current_object == NoObject) {476 updateCirclePos();477 }478 491 } 479 492 … … 490 503 m_current_object = NoObject; 491 504 } 505 if (m_animation_enabled) { 506 killTimer(m_animationTimer); 507 m_animationTimer = 0; 508 } 492 509 } 493 510 … … 501 518 m_current_object = NoObject; 502 519 503 if (m_animation_enabled) 520 if (m_animation_enabled) { 521 Q_ASSERT(!m_animationTimer); 522 m_animationTimer = startTimer(animationInterval); 523 } 524 } 525 526 void CompositionRenderer::timerEvent(QTimerEvent *event) 527 { 528 if (event->timerId() == m_animationTimer) 504 529 updateCirclePos(); 505 530 } -
trunk/demos/composition/composition.h
r651 r769 110 110 void paint(QPainter *); 111 111 112 void mousePressEvent(QMouseEvent *);113 void mouseMoveEvent(QMouseEvent *);114 void mouseReleaseEvent(QMouseEvent *);115 116 112 void setCirclePos(const QPointF &pos); 117 113 … … 121 117 int circleColor() const { return m_circle_hue; } 122 118 int circleAlpha() const { return m_circle_alpha; } 119 120 protected: 121 void mousePressEvent(QMouseEvent *); 122 void mouseMoveEvent(QMouseEvent *); 123 void mouseReleaseEvent(QMouseEvent *); 124 void timerEvent(QTimerEvent *); 123 125 124 126 public slots: … … 151 153 void setCircleAlpha(int alpha) { m_circle_alpha = alpha; update(); } 152 154 void setCircleColor(int hue) { m_circle_hue = hue; update(); } 153 void setAnimationEnabled(bool enabled) { m_animation_enabled = enabled; update(); }155 void setAnimationEnabled(bool enabled); 154 156 155 157 private: … … 178 180 ObjectType m_current_object; 179 181 bool m_animation_enabled; 182 int m_animationTimer; 180 183 181 184 #ifdef QT_OPENGL_SUPPORT
Note:
See TracChangeset
for help on using the changeset viewer.