00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _SeExprEdSlider_h_
00011 #define _SeExprEdSlider_h_
00012 #include <QtGui/QTextBrowser>
00013 #include <QtGui/QPlainTextEdit>
00014 #include <QtGui/QDialog>
00015 #include <QtCore/QTimer>
00016 #include <QtCore/QRegExp>
00017 #include <QtGui/QLineEdit>
00018 #include <QtGui/QCheckBox>
00019 #include <QtGui/QSlider>
00020
00021 #include "SeExprEdCurve.h"
00022 #include "SeExprEdColorCurve.h"
00023
00024 class SeExprEditor;
00025 class QLabel;
00026 class SeExprEdColorCurve;
00027 class QHBoxLayout;
00028 class SeExprEdCSwatchFrame;
00029 class SeExprEdEditable;
00030 class SeExprEdStringEditable;
00031 class SeExprEdVectorEditable;
00032 class SeExprEdNumberEditable;
00033 class SeExprEdAnimCurveEditable;
00034 template<class TVAL> struct SeExprEdGenericCurveEditable;
00035 typedef SeExprEdGenericCurveEditable<SeVec3d> SeExprEdColorCurveEditable;
00036 typedef SeExprEdGenericCurveEditable<double> SeExprEdCurveEditable;
00037
00038 namespace animlib{
00039 class AnimCurve;
00040 }
00041
00043 class SeExprEdControl:public QWidget
00044 {
00045 Q_OBJECT;
00046
00047 protected:
00048 int _id;
00049 bool _updating;
00050 QHBoxLayout* hbox;
00051 QCheckBox* _colorLinkCB;
00052 QLabel* _label;
00053
00054 SeExprEdEditable* _editable;
00055
00056 public:
00057 SeExprEdControl(int id,SeExprEdEditable* editable,bool showColorLink);
00058 virtual ~SeExprEdControl(){}
00059
00061 virtual QColor getColor(){return QColor();}
00063 virtual void setColor(QColor color){Q_UNUSED(color)};
00064
00065 signals:
00066
00067 void controlChanged(int id);
00068
00069 void linkColorEdited(int id,QColor color);
00070
00071 void linkColorLink(int id);
00072 public slots:
00073
00074 void linkStateChange(int state);
00075 public:
00076
00077 void linkDisconnect(int newId);
00078 };
00079
00080
00082 template<class T,class T2,class T3> T clamp(const T val,const T2 minval,const T3 maxval)
00083 {
00084 if(val<minval) return minval;
00085 else if(val>maxval) return maxval;
00086 return val;
00087 }
00088
00090
00091 class SeExprEdLineEdit : public QLineEdit
00092 {
00093 Q_OBJECT
00094 public:
00095 SeExprEdLineEdit(int id, QWidget* parent);
00096 virtual void setText(const QString& t)
00097 {
00098 if (_signaling) return;
00099 QLineEdit::setText(t);
00100 }
00101
00102 signals:
00103 void textChanged(int id, const QString& text);
00104
00105 private slots:
00106 void textChangedCB(const QString& text);
00107
00108 private:
00109 int _id;
00110 bool _signaling;
00111 };
00112
00114 class SeExprEdSlider : public QSlider
00115 {
00116 Q_OBJECT
00117 public:
00118 SeExprEdSlider(QWidget* parent = 0) : QSlider(parent) {}
00119 SeExprEdSlider(Qt::Orientation orientation, QWidget* parent = 0)
00120 : QSlider(orientation, parent) {}
00121 virtual void mousePressEvent(QMouseEvent* e);
00122 virtual void mouseMoveEvent(QMouseEvent* e);
00123 virtual void paintEvent(QPaintEvent* e);
00124 virtual void leaveEvent(QEvent* event ) { Q_UNUSED(event); update(); }
00125 virtual void enterEvent(QEvent* event ) { Q_UNUSED(event); update(); }
00126 virtual void wheelEvent(QWheelEvent* e) { e->ignore(); }
00127 };
00128
00130 class SeExprEdChannelSlider : public QWidget
00131 {
00132 Q_OBJECT
00133 public:
00134 SeExprEdChannelSlider(int id, QWidget* parent);
00135 virtual void paintEvent(QPaintEvent* e);
00136 virtual void mousePressEvent(QMouseEvent* e);
00137 virtual void mouseMoveEvent(QMouseEvent* e);
00138 virtual void wheelEvent(QWheelEvent* e) { e->ignore(); }
00139 float value() const { return _value; }
00140 void setDisplayColor( QColor c ) { _col = c; }
00141
00142 public slots:
00143 void setValue(float value);
00144
00145 signals:
00146 void valueChanged(int id, float value);
00147 private:
00148 int _id;
00149 float _value;
00150 QColor _col;
00151 };
00152
00154 class SeExprEdNumberControl:public SeExprEdControl
00155 {
00156 Q_OBJECT
00157
00159 SeExprEdNumberEditable* _numberEditable;
00161 SeExprEdSlider* _slider;
00163 SeExprEdLineEdit* _edit;
00164 public:
00165 SeExprEdNumberControl(int id,SeExprEdNumberEditable* number);
00166 private:
00168 void setValue(float value);
00170 void updateControl();
00171 private slots:
00172 void sliderChanged(int val);
00173 void editChanged(int id,const QString& text);
00174 };
00175
00177 class SeExprEdVectorControl:public SeExprEdControl
00178 {
00179 Q_OBJECT
00180
00182 SeExprEdVectorEditable* _numberEditable;
00184 SeExprEdLineEdit* _edits[3];
00185 SeExprEdCSwatchFrame* _swatch;;
00187 SeExprEdChannelSlider* _sliders[3];
00188 public:
00189 SeExprEdVectorControl(int id,SeExprEdVectorEditable* number);
00190
00191 QColor getColor();
00192 void setColor(QColor color);
00193 private:
00195 void setValue(int id,float value);
00197 void updateControl();
00198 private slots:
00199 void sliderChanged(int id,float val);
00200 void editChanged(int id,const QString& text);
00201 void swatchChanged(QColor color);
00202 };
00203
00205 class SeExprEdStringControl:public SeExprEdControl
00206 {
00207 Q_OBJECT
00208
00210 SeExprEdStringEditable* _stringEditable;
00212 QLineEdit* _edit;
00213 public:
00214 SeExprEdStringControl(int id,SeExprEdStringEditable* stringEditable);
00215 private:
00216 void updateControl();
00217 private slots:
00218 void textChanged(const QString& newText);
00219 void fileBrowse();
00220 void directoryBrowse();
00221 };
00222
00224 class SeExprEdCurveControl:public SeExprEdControl
00225 {
00226 Q_OBJECT
00227
00229 SeExprEdCurveEditable* _curveEditable;
00231 SeExprEdCurve* _curve;
00232 public:
00233 SeExprEdCurveControl(int id,SeExprEdCurveEditable* stringEditable);
00234 private slots:
00235 void curveChanged();
00236 };
00237
00239 class SeExprEdCCurveControl:public SeExprEdControl
00240 {
00241 Q_OBJECT
00242
00244 SeExprEdColorCurveEditable* _curveEditable;
00246 SeExprEdColorCurve* _curve;
00247 public:
00248 SeExprEdCCurveControl(int id,SeExprEdColorCurveEditable* stringEditable);
00249 QColor getColor();
00250 void setColor(QColor color);
00251 private slots:
00252 void curveChanged();
00253 };
00254
00256 class SeExprEdGraphPreview;
00257 class SeExprEdAnimCurveControl:public SeExprEdControl
00258 {
00259 Q_OBJECT;
00260
00261 SeExprEdAnimCurveEditable* _editable;
00262 SeExprEdGraphPreview* _preview;
00263 public:
00264 SeExprEdAnimCurveControl(int id,SeExprEdAnimCurveEditable* curveEditable);
00265 typedef void (*AnimCurveCallback)(const std::string&,animlib::AnimCurve& curve);
00266 static void setAnimCurveCallback(AnimCurveCallback callback);
00267
00268 public slots:
00269 void editGraphClicked();
00270
00271 private slots:
00272 void refreshClicked();
00273
00274 private:
00275 static AnimCurveCallback callback;
00276 };
00277
00278 #endif