Qt 4.8
Classes | Functions
qeasingcurve.cpp File Reference
#include "qeasingcurve.h"
#include <QtCore/qdebug.h>
#include <QtCore/qstring.h>
#include <QtCore/qdatastream.h>
#include "../../3rdparty/easing/easing.cpp"

Go to the source code of this file.

Classes

struct  BackEase
 
struct  BounceEase
 
struct  ElasticEase
 
class  QEasingCurveFunction
 
class  QEasingCurvePrivate
 

Functions

static QEasingCurve::EasingFunction curveToFunc (QEasingCurve::Type curve)
 
static QEasingCurveFunctioncurveToFunctionObject (QEasingCurve::Type type)
 
static bool isConfigFunction (QEasingCurve::Type type)
 
QDebug operator<< (QDebug debug, const QEasingCurve &item)
 
QDataStreamoperator<< (QDataStream &stream, const QEasingCurve &easing)
 
QDataStreamoperator>> (QDataStream &stream, QEasingCurve &easing)
 

Function Documentation

◆ curveToFunc()

static QEasingCurve::EasingFunction curveToFunc ( QEasingCurve::Type  curve)
static

Definition at line 490 of file qeasingcurve.cpp.

Referenced by QEasingCurvePrivate::setType_helper().

491 {
492  switch(curve) {
494  return &easeNone;
496  return &easeInQuad;
498  return &easeOutQuad;
500  return &easeInOutQuad;
502  return &easeOutInQuad;
504  return &easeInCubic;
506  return &easeOutCubic;
508  return &easeInOutCubic;
510  return &easeOutInCubic;
512  return &easeInQuart;
514  return &easeOutQuart;
516  return &easeInOutQuart;
518  return &easeOutInQuart;
520  return &easeInQuint;
522  return &easeOutQuint;
524  return &easeInOutQuint;
526  return &easeOutInQuint;
528  return &easeInSine;
530  return &easeOutSine;
532  return &easeInOutSine;
534  return &easeOutInSine;
536  return &easeInExpo;
538  return &easeOutExpo;
540  return &easeInOutExpo;
542  return &easeOutInExpo;
544  return &easeInCirc;
546  return &easeOutCirc;
548  return &easeInOutCirc;
550  return &easeOutInCirc;
551  // Internal for, compatibility with QTimeLine only ??
553  return &easeInCurve;
555  return &easeOutCurve;
557  return &easeSineCurve;
559  return &easeCosineCurve;
560  default:
561  return 0;
562  };
563 }

◆ curveToFunctionObject()

static QEasingCurveFunction* curveToFunctionObject ( QEasingCurve::Type  type)
static

Definition at line 565 of file qeasingcurve.cpp.

Referenced by operator>>(), QEasingCurve::setAmplitude(), QEasingCurve::setOvershoot(), QEasingCurve::setPeriod(), and QEasingCurvePrivate::setType_helper().

566 {
567  QEasingCurveFunction *curveFunc = 0;
568  switch(type) {
570  curveFunc = new ElasticEase(ElasticEase::In);
571  break;
573  curveFunc = new ElasticEase(ElasticEase::Out);
574  break;
576  curveFunc = new ElasticEase(ElasticEase::InOut);
577  break;
579  curveFunc = new ElasticEase(ElasticEase::OutIn);
580  break;
582  curveFunc = new BounceEase(BounceEase::Out);
583  break;
585  curveFunc = new BounceEase(BounceEase::In);
586  break;
588  curveFunc = new BounceEase(BounceEase::OutIn);
589  break;
591  curveFunc = new BounceEase(BounceEase::InOut);
592  break;
594  curveFunc = new BackEase(BackEase::In);
595  break;
597  curveFunc = new BackEase(BackEase::Out);
598  break;
600  curveFunc = new BackEase(BackEase::InOut);
601  break;
603  curveFunc = new BackEase(BackEase::OutIn);
604  break;
605  default:
606  curveFunc = new QEasingCurveFunction(QEasingCurveFunction::In, qreal(0.3), qreal(1.0), qreal(1.70158));
607  }
608 
609  return curveFunc;
610 }
int type
Definition: qmetatype.cpp:239
double qreal
Definition: qglobal.h:1193

◆ isConfigFunction()

static bool isConfigFunction ( QEasingCurve::Type  type)
static

◆ operator<<() [1/2]

QDebug operator<< ( QDebug  debug,
const QEasingCurve item 
)

Definition at line 870 of file qeasingcurve.cpp.

871 {
872  debug << "type:" << item.d_ptr->type
873  << "func:" << item.d_ptr->func;
874  if (item.d_ptr->config) {
875  debug << QString::fromAscii("period:%1").arg(item.d_ptr->config->_p, 0, 'f', 20)
876  << QString::fromAscii("amp:%1").arg(item.d_ptr->config->_a, 0, 'f', 20)
877  << QString::fromAscii("overshoot:%1").arg(item.d_ptr->config->_o, 0, 'f', 20);
878  }
879  return debug;
880 }
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
QEasingCurve::EasingFunction func
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
QEasingCurve::Type type

◆ operator<<() [2/2]

QDataStream& operator<< ( QDataStream stream,
const QEasingCurve easing 
)

Definition at line 897 of file qeasingcurve.cpp.

898 {
899  stream << quint8(easing.d_ptr->type);
900  stream << quint64(quintptr(easing.d_ptr->func));
901 
902  bool hasConfig = easing.d_ptr->config;
903  stream << hasConfig;
904  if (hasConfig) {
905  stream << easing.d_ptr->config->_p;
906  stream << easing.d_ptr->config->_a;
907  stream << easing.d_ptr->config->_o;
908  }
909  return stream;
910 }
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
unsigned char quint8
Definition: qglobal.h:934
QEasingCurve::EasingFunction func
static FILE * stream
unsigned __int64 quint64
Definition: qglobal.h:943
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config
QEasingCurve::Type type

◆ operator>>()

QDataStream& operator>> ( QDataStream stream,
QEasingCurve easing 
)
related

Definition at line 925 of file qeasingcurve.cpp.

926 {
928  quint8 int_type;
929  stream >> int_type;
930  type = static_cast<QEasingCurve::Type>(int_type);
931  easing.setType(type);
932 
933  quint64 ptr_func;
934  stream >> ptr_func;
935  easing.d_ptr->func = QEasingCurve::EasingFunction(quintptr(ptr_func));
936 
937  bool hasConfig;
938  stream >> hasConfig;
939  if (hasConfig) {
941  stream >> config->_p;
942  stream >> config->_a;
943  stream >> config->_o;
944  easing.d_ptr->config = config;
945  }
946  return stream;
947 }
int type
Definition: qmetatype.cpp:239
QIntegerForSizeof< void * >::Unsigned quintptr
Definition: qglobal.h:986
unsigned char quint8
Definition: qglobal.h:934
QEasingCurve::EasingFunction func
static FILE * stream
unsigned __int64 quint64
Definition: qglobal.h:943
QEasingCurvePrivate * d_ptr
Definition: qeasingcurve.h:102
QEasingCurveFunction * config
static QEasingCurveFunction * curveToFunctionObject(QEasingCurve::Type type)
Type
The type of easing curve.
Definition: qeasingcurve.h:60
void setType(Type type)
Sets the type of the easing curve to type.
qreal(* EasingFunction)(qreal progress)
This is a typedef for a pointer to a function with the following signature:
Definition: qeasingcurve.h:96