Changed speed of animation a bit release-1-12-maintained
authorinsilmaril
Thu Aug 07 10:56:52 2008 +0000 (2008-08-07)
branchrelease-1-12-maintained
changeset 47326e3336e9b0
parent 46 4d441cb0a856
child 48 8c40d4419e70
Changed speed of animation a bit
animpoint.cpp
version.h
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/animpoint.cpp	Thu Aug 07 10:56:52 2008 +0000
     1.3 @@ -0,0 +1,131 @@
     1.4 +#include "animpoint.h"
     1.5 +
     1.6 +#include <math.h>
     1.7 +
     1.8 +AnimPoint::AnimPoint()
     1.9 +{
    1.10 +	init();
    1.11 +}
    1.12 +
    1.13 +void AnimPoint::operator= ( const AnimPoint & other )
    1.14 +{
    1.15 +	copy (other);
    1.16 +}
    1.17 +
    1.18 +void AnimPoint::operator= ( const QPointF & other )
    1.19 +{
    1.20 +	init();
    1.21 +	setX (other.x() );
    1.22 +	setY (other.x() );
    1.23 +}
    1.24 +
    1.25 +bool AnimPoint::operator== ( const QPointF& other )
    1.26 +{
    1.27 +	QPointF p( x(),y());
    1.28 +	return p == other;
    1.29 +}
    1.30 +
    1.31 +bool AnimPoint::operator== ( AnimPoint  other )
    1.32 +{
    1.33 +    if (rx() != other.rx() ) return false;
    1.34 +    if (ry() != other.ry() ) return false;
    1.35 +	if (startPos != other.startPos) return false;
    1.36 +	if (destPos  != other.destPos) return false;
    1.37 +    if (animated != other.animated ) return false;
    1.38 +
    1.39 +	return true;
    1.40 +}
    1.41 +
    1.42 +void AnimPoint::init ()
    1.43 +{
    1.44 +	animated=false;
    1.45 +	n=0;
    1.46 +	startPos=QPointF(0,0);
    1.47 +	destPos=QPointF(0,0);
    1.48 +	vector=QPointF(0,0);
    1.49 +	animTicks=10;
    1.50 +}
    1.51 +
    1.52 +void AnimPoint::copy (AnimPoint other)
    1.53 +{
    1.54 +	setX (other.x() );
    1.55 +	setY (other.x() );
    1.56 +	startPos=other.startPos;
    1.57 +	destPos=other.destPos;
    1.58 +	vector=other.vector;
    1.59 +	animated=other.animated;
    1.60 +	n=other.n;
    1.61 +	animTicks=other.animTicks;
    1.62 +}
    1.63 +
    1.64 +void AnimPoint::setStart(const QPointF &p)
    1.65 +{
    1.66 +	startPos=p;
    1.67 +	initVector();
    1.68 +}
    1.69 +
    1.70 +QPointF AnimPoint::getStart()
    1.71 +{
    1.72 +	return startPos;
    1.73 +}
    1.74 +
    1.75 +
    1.76 +void AnimPoint::setDest(const QPointF &p)
    1.77 +{
    1.78 +	destPos=p;
    1.79 +	initVector();
    1.80 +}
    1.81 +
    1.82 +QPointF AnimPoint::getDest()
    1.83 +{
    1.84 +	return destPos;
    1.85 +}
    1.86 +
    1.87 +void AnimPoint::setTicks (const uint &t)
    1.88 +{
    1.89 +	animTicks=t;
    1.90 +}
    1.91 +
    1.92 +uint AnimPoint::getTicks()
    1.93 +{
    1.94 +	return animTicks;
    1.95 +}
    1.96 +
    1.97 +void AnimPoint::setAnimated(bool b)
    1.98 +{
    1.99 +	animated=b;
   1.100 +	if (b) n=0;
   1.101 +}
   1.102 +
   1.103 +bool AnimPoint::isAnimated()
   1.104 +{
   1.105 +	return animated;
   1.106 +}
   1.107 +
   1.108 +bool AnimPoint::animate()
   1.109 +{
   1.110 +	if (!animated) return animated;
   1.111 +	n++;
   1.112 +	if (n>animTicks)
   1.113 +	{
   1.114 +		vector=QPointF(0,0);
   1.115 +		animated=false;
   1.116 +		return animated;
   1.117 +	}
   1.118 +
   1.119 +	// Some math slow down the movement
   1.120 +	qreal f=1-n/animTicks;
   1.121 +	qreal ff=1-f*f*f;
   1.122 +	setX (startPos.x() + vector.x()*ff );
   1.123 +	setY (startPos.y() + vector.y()*ff );
   1.124 +
   1.125 +	return animated;
   1.126 +}
   1.127 +
   1.128 +void AnimPoint::initVector()
   1.129 +{
   1.130 +	vector.setX (destPos.x()-startPos.x() );
   1.131 +	vector.setY (destPos.y()-startPos.y() );
   1.132 +}
   1.133 +
   1.134 +
     2.1 --- a/version.h	Mon Aug 04 06:52:15 2008 +0000
     2.2 +++ b/version.h	Thu Aug 07 10:56:52 2008 +0000
     2.3 @@ -7,7 +7,7 @@
     2.4  #define __VYM_VERSION "1.12.1"
     2.5  #define __VYM_CODENAME "Maintenance Update"
     2.6  //#define __VYM_CODENAME "Codename: development version"
     2.7 -#define __VYM_BUILD_DATE "2008-07-30"
     2.8 +#define __VYM_BUILD_DATE "2008-08-37"
     2.9  
    2.10  
    2.11  bool checkVersion(const QString &);