mkRPG
src/editor/GUI/Tabs/Docks/intertie.h
Go to the documentation of this file.
00001 #ifndef INTERTIE_H
00002 #define INTERTIE_H
00003 
00004 #include <QObject>
00005 #include <QTimer>
00006 #include <QStateMachine>
00007 
00008 
00009 #define Min(a,b) ((a)<(b) ? (a) : (b))
00010 #define Max(a,b) ((a)>(b) ? (a) : (b))
00011 #define MinMax(a,x,b) Min(Max(a,x),b)
00012 
00013 
00026 class Intertie : public QObject
00027 {
00028     Q_OBJECT
00029 public:
00030     explicit Intertie(QObject *parent = 0);
00031     int value() const;
00032     void link(QObject *obj, const char *prop);
00033 
00034 
00035 signals:
00036     void modificationFinished(int);
00037     void valueChanged(int);
00038 
00039 public slots:
00040     void setValue(int v, bool inert = true);
00041     void setMaximumSpeed(int vM);
00042     void setAcceleration(int a);
00043     void setUpdateInterval(int d);
00044 
00045 private slots:
00046     void updateValue();
00047 
00048 private:
00049     inline void updateLinkedProperties() const;
00050     int objective;
00051     int currentValue;
00052     int speed;
00053     int acceleration;
00054     int maximumSpeed;
00055     QTimer *ti;
00056     QList<QPair<QObject*, const char*>> linkedProperties;
00057     bool running;
00058 };
00059 
00060 
00065 class BinaryStateMachine : public QStateMachine
00066 {
00067     Q_OBJECT
00068 
00069 public:
00070     explicit BinaryStateMachine(QObject *parent = 0);
00071     void defineProperty(QObject* obj, const char* prop, QVariant yesValue, QVariant noValue);
00072     void defineProperty(QObject* obj, const char* prop);
00073     bool isPositive() const;
00074     bool isNegative() const;
00075 
00076 signals:
00077     void swapped(bool);
00078     void __swap();
00079 
00080 public slots:
00081     void swap();                // Pas de SIGNAL(echange(bool))
00082     void setPositive(bool p);   // SIGNAL(echange(bool))
00083     void setNegative(bool n);
00084 
00085 private:
00086     QState *yes, *no;
00087 
00088 };
00089 
00090 
00091 #endif // INTERTIE_H
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Defines