##// END OF EJS Templates
Fix grid animation to do not go out of bound
Michal Klocek -
r504:142210a64aff
parent child
Show More
@@ -19,17 +19,26 AxisAnimationItem::~AxisAnimationItem()
19
19
20 void AxisAnimationItem::updateLayout(QVector<qreal>& newLayout)
20 void AxisAnimationItem::updateLayout(QVector<qreal>& newLayout)
21 {
21 {
22
22 QVector<qreal> oldLayout = layout();
23 QVector<qreal> oldLayout = layout();
23
24
24 if(newLayout.count()==0) return;
25 if(newLayout.count()==0) return;
26
27 QRectF rect = geometry();
28
25 oldLayout.resize(newLayout.size());
29 oldLayout.resize(newLayout.size());
26
30
31 for(int i=0;i<oldLayout.count();i++)
32 {
33 oldLayout[i]= axisType()==X_AXIS?rect.left():rect.top();
34 }
35
27 if(m_animation->state()!=QAbstractAnimation::Stopped){
36 if(m_animation->state()!=QAbstractAnimation::Stopped){
28 m_animation->stop();
37 m_animation->stop();
29 }
38 }
30
39
31 m_animation->setDuration(duration);
40 m_animation->setDuration(duration);
32 m_animation->setEasingCurve(QEasingCurve::InOutBack);
41 m_animation->setEasingCurve(QEasingCurve::OutQuart);
33 m_animation->setKeyValueAt(0.0, qVariantFromValue(oldLayout));
42 m_animation->setKeyValueAt(0.0, qVariantFromValue(oldLayout));
34 m_animation->setKeyValueAt(1.0, qVariantFromValue(newLayout));
43 m_animation->setKeyValueAt(1.0, qVariantFromValue(newLayout));
35 QTimer::singleShot(0,m_animation,SLOT(start()));
44 QTimer::singleShot(0,m_animation,SLOT(start()));
@@ -49,6 +49,8 public:
49 void setLabelsBrush(const QBrush& brush);
49 void setLabelsBrush(const QBrush& brush);
50 void setLabelsFont(const QFont& font);
50 void setLabelsFont(const QFont& font);
51
51
52 QRectF geometry() const { return m_rect; }
53
52 public slots:
54 public slots:
53 void handleAxisUpdated();
55 void handleAxisUpdated();
54 void handleAxisCategoriesUpdated();
56 void handleAxisCategoriesUpdated();
General Comments 0
You need to be logged in to leave comments. Login now