1 #pragma once
2 
3 #ifndef PARAMFIELD_H
4 #define PARAMFIELD_H
5 
6 #ifdef _MSC_VER
7 #pragma warning(disable : 4251)
8 #endif
9 
10 #include "tcommon.h"
11 #include <QWidget>
12 #include <QSpinBox>
13 #include <QSlider>
14 #include <QCheckBox>
15 #include <QButtonGroup>
16 #include <QRadioButton>
17 #include <QPushButton>
18 #include <QTextEdit>
19 #include <QPainterPath>
20 
21 #include "tgeometry.h"
22 #include "tparam.h"
23 #include "tnotanimatableparam.h"
24 #include "tspectrumparam.h"
25 #include "ttonecurveparam.h"
26 #include "tdoubleparam.h"
27 #include "toonz/tfxhandle.h"
28 #include "historytypes.h"
29 
30 #undef DVAPI
31 #undef DVVAR
32 #ifdef TOONZQT_EXPORTS
33 #define DVAPI DV_EXPORT_API
34 #define DVVAR DV_EXPORT_VAR
35 #else
36 #define DVAPI DV_IMPORT_API
37 #define DVVAR DV_IMPORT_VAR
38 #endif
39 
40 // forward declaration
41 class QString;
42 class QComboBox;
43 class QHBoxLayout;
44 class TFxHandle;
45 class QFontComboBox;
46 
47 namespace DVGui {
48 class LineEdit;
49 class IntField;
50 class DoubleField;
51 class MeasuredDoubleField;
52 class MeasuredDoublePairField;
53 class ColorField;
54 class SpectrumField;
55 class ToneCurveField;
56 class CheckBox;
57 }  // namespace DVGui
58 
59 //=============================================================================
60 /*! \brief ParamField.
61 
62                 Inherits \b QWidget.
63 */
64 class DVAPI ParamField : public QWidget {
65   Q_OBJECT
66 
67 protected:
68   QHBoxLayout *m_layout;
69   QString m_paramName;
70 
71   static TFxHandle *m_fxHandleStat;
72   QString m_interfaceName;
73   QString m_description;
74 
75 public:
76   ParamField(QWidget *parent, QString paramName, const TParamP &param,
77              bool addEmptyLabel = true);
78   ~ParamField();
79 
getParamName()80   QString getParamName() const { return m_paramName; }
getUIName()81   QString getUIName() const { return m_interfaceName; }
getDescription()82   QString getDescription() const { return m_description; }
83 
84   virtual void setParam(const TParamP &current, const TParamP &actual,
85                         int frame) = 0;
86 
87   virtual void update(int frame) = 0;
88 
89   static ParamField *create(QWidget *parent, QString name,
90                             const TParamP &param);
91 
setPointValue(const TPointD & p)92   virtual void setPointValue(const TPointD &p){};
93 
getPreferedSize()94   virtual QSize getPreferedSize() { return QSize(200, 28); }
95 
96   static void setFxHandle(TFxHandle *fxHandle);
97 
setPrecision(int precision)98   virtual void setPrecision(int precision) {}
99 signals:
100   void currentParamChanged();
101   void actualParamChanged();
102   void paramKeyToggle();
103 };
104 
105 //=============================================================================
106 // ParamFieldKeyToggle
107 //-----------------------------------------------------------------------------
108 
109 class DVAPI ParamFieldKeyToggle final : public QWidget {
110   Q_OBJECT
111 public:
112   QPixmap m_pixmap;
113 
114   // keyframe colors
115   QColor m_keyBorderOffColor;
116   QColor m_keyBorderOnColor;
117   QColor m_keyBorderModifiedColor;
118   QColor m_keyBorderInbetweenColor;
119   QColor m_keyBorderHighlightColor;
120   QColor m_keyOffColor;
121   QColor m_keyOnColor;
122   QColor m_keyModifiedColor;
123   QColor m_keyHighlightColor;
124   QColor m_keyInbetweenColor;
125 
126   // keyframe colors
127   Q_PROPERTY(QColor KeyBorderOffColor READ getKeyBorderOffColor WRITE
128                  setKeyBorderOffColor)
129   Q_PROPERTY(QColor KeyBorderOnColor READ getKeyBorderOnColor WRITE
130                  setKeyBorderOnColor)
131   Q_PROPERTY(QColor KeyBorderModifiedColor READ getKeyBorderModifiedColor WRITE
132                  setKeyBorderModifiedColor)
133   Q_PROPERTY(QColor KeyBorderInbetweenColor READ getKeyBorderInbetweenColor
134                  WRITE setKeyBorderInbetweenColor)
135   Q_PROPERTY(QColor KeyBorderHighlightColor READ getKeyBorderHighlightColor
136                  WRITE setKeyBorderHighlightColor)
137   Q_PROPERTY(QColor KeyOffColor READ getKeyOffColor WRITE setKeyOffColor)
138   Q_PROPERTY(QColor KeyOnColor READ getKeyOnColor WRITE setKeyOnColor)
139   Q_PROPERTY(QColor KeyModifiedColor READ getKeyModifiedColor WRITE
140                  setKeyModifiedColor)
141   Q_PROPERTY(QColor KeyInbetweenColor READ getKeyInbetweenColor WRITE
142                  setKeyInbetweenColor)
143   Q_PROPERTY(QColor KeyHighlightColor READ getKeyHighlightColor WRITE
144                  setKeyHighlightColor)
145 
146   enum Status { NOT_ANIMATED, NOT_KEYFRAME, MODIFIED, KEYFRAME };
147 
148 private:
149   Status m_status;
150   bool m_highlighted;
151 
152 public:
153   ParamFieldKeyToggle(QWidget *parent,
154                       std::string name = "ParamFieldKeyToggle");
155 
156   void setStatus(Status status);
157   Status getStatus() const;
158 
159   void setStatus(bool hasKeyframe, bool isKeyframe, bool hasBeenChanged);
160 
161 protected:
162   void paintEvent(QPaintEvent *) override;
163   void mousePressEvent(QMouseEvent *) override;
164   void enterEvent(QEvent *) override;
165   void leaveEvent(QEvent *) override;
166 
167   // keyframe colors
setKeyBorderOffColor(const QColor & color)168   void setKeyBorderOffColor(const QColor &color) {
169     m_keyBorderOffColor = color;
170   }
getKeyBorderOffColor()171   QColor getKeyBorderOffColor() const { return m_keyBorderOffColor; }
setKeyBorderOnColor(const QColor & color)172   void setKeyBorderOnColor(const QColor &color) { m_keyBorderOnColor = color; }
getKeyBorderOnColor()173   QColor getKeyBorderOnColor() const { return m_keyBorderOnColor; }
setKeyBorderModifiedColor(const QColor & color)174   void setKeyBorderModifiedColor(const QColor &color) {
175     m_keyBorderModifiedColor = color;
176   }
getKeyBorderModifiedColor()177   QColor getKeyBorderModifiedColor() const { return m_keyBorderModifiedColor; }
setKeyBorderInbetweenColor(const QColor & color)178   void setKeyBorderInbetweenColor(const QColor &color) {
179     m_keyBorderInbetweenColor = color;
180   }
getKeyBorderInbetweenColor()181   QColor getKeyBorderInbetweenColor() const {
182     return m_keyBorderInbetweenColor;
183   }
setKeyBorderHighlightColor(const QColor & color)184   void setKeyBorderHighlightColor(const QColor &color) {
185     m_keyBorderHighlightColor = color;
186   }
getKeyBorderHighlightColor()187   QColor getKeyBorderHighlightColor() const {
188     return m_keyBorderHighlightColor;
189   }
setKeyOffColor(const QColor & color)190   void setKeyOffColor(const QColor &color) { m_keyOffColor = color; }
getKeyOffColor()191   QColor getKeyOffColor() const { return m_keyOffColor; }
setKeyOnColor(const QColor & color)192   void setKeyOnColor(const QColor &color) { m_keyOnColor = color; }
getKeyOnColor()193   QColor getKeyOnColor() const { return m_keyOnColor; }
setKeyModifiedColor(const QColor & color)194   void setKeyModifiedColor(const QColor &color) { m_keyModifiedColor = color; }
getKeyModifiedColor()195   QColor getKeyModifiedColor() const { return m_keyModifiedColor; }
setKeyHighlightColor(const QColor & color)196   void setKeyHighlightColor(const QColor &color) {
197     m_keyHighlightColor = color;
198   }
getKeyHighlightColor()199   QColor getKeyHighlightColor() const { return m_keyHighlightColor; }
setKeyInbetweenColor(const QColor & color)200   void setKeyInbetweenColor(const QColor &color) {
201     m_keyInbetweenColor = color;
202   }
getKeyInbetweenColor()203   QColor getKeyInbetweenColor() const { return m_keyInbetweenColor; }
204 
205 signals:
206   void keyToggled();
207 };
208 
209 //=============================================================================
210 // FxSettingsKeyToggleUndo
211 //=============================================================================
212 template <class T, class ParamP>
213 class FxSettingsKeyToggleUndo final : public TUndo {
214   TFxHandle *m_fxHandle;
215   QString m_name;
216   bool m_wasKeyframe;
217   int m_frame;
218 
219   ParamP m_param;
220   T m_currentValue;
221 
222 public:
FxSettingsKeyToggleUndo(ParamP param,T currentValue,bool wasKeyFrame,QString name,int frame,TFxHandle * fxHandle)223   FxSettingsKeyToggleUndo(ParamP param, T currentValue, bool wasKeyFrame,
224                           QString name, int frame, TFxHandle *fxHandle)
225       : m_param(param)
226       , m_currentValue(currentValue)
227       , m_wasKeyframe(wasKeyFrame)
228       , m_name(name)
229       , m_frame(frame)
230       , m_fxHandle(fxHandle) {}
231 
232   // void notify();
233 
undo()234   void undo() const override {
235     if (m_wasKeyframe)
236       m_param->setValue(m_frame, m_currentValue);
237     else
238       m_param->deleteKeyframe(m_frame);
239 
240     if (m_fxHandle) m_fxHandle->notifyFxChanged();
241   }
242 
redo()243   void redo() const override {
244     if (m_wasKeyframe)
245       m_param->deleteKeyframe(m_frame);
246     else
247       m_param->setValue(m_frame, m_currentValue);
248 
249     if (m_fxHandle) m_fxHandle->notifyFxChanged();
250   }
251 
getSize()252   int getSize() const override { return sizeof(*this); }
getHistoryType()253   int getHistoryType() override { return HistoryType::Fx; }
getHistoryString()254   QString getHistoryString() override {
255     QString str =
256         QObject::tr("Modify Fx Param : %1 Key : %2  Frame %3")
257             .arg((m_wasKeyframe) ? QObject::tr("Delete") : QObject::tr("Set"))
258             .arg(m_name)
259             .arg(QString::number(m_frame + 1));
260 
261     return str;
262   }
263 };
264 
265 //=============================================================================
266 // AnimatedParamField
267 //-----------------------------------------------------------------------------
268 
269 template <class T, class ParamP>
270 class DVAPI AnimatedParamField : public ParamField {
271 protected:
272   ParamP m_currentParam, m_actualParam;
273   int m_frame;
274   ParamFieldKeyToggle *m_keyToggle;
275 
276 public:
277   AnimatedParamField(QWidget *parent, QString name, const ParamP &param,
278                      bool addEmptyLabel = true)
ParamField(parent,name,param,addEmptyLabel)279       : ParamField(parent, name, param, addEmptyLabel), m_frame(0) {
280     m_keyToggle = new ParamFieldKeyToggle(this);
281   }
282 
283   virtual void updateField(T value) = 0;
284 
setParam(const TParamP & current,const TParamP & actual,int frame)285   void setParam(const TParamP &current, const TParamP &actual,
286                 int frame) override {
287     m_currentParam = current;
288     m_actualParam  = actual;
289     assert(m_currentParam);
290     assert(m_actualParam);
291     update(frame);
292   }
update(int frame)293   void update(int frame) override {
294     m_frame = frame;
295     if (!m_actualParam || !m_currentParam) return;
296     T value = m_actualParam->getValue(m_frame);
297     if (m_actualParam->isKeyframe(m_frame))
298       m_currentParam->setValue(m_frame, value);
299     else if (!m_actualParam.getPointer()->hasKeyframes())
300       m_currentParam->setDefaultValue(value);
301     updateField(value);
302     updateKeyToggle();
303   }
304 
updateKeyToggle()305   void updateKeyToggle() {
306     T stroke  = m_actualParam->getValue(m_frame);
307     T stroke2 = m_currentParam->getValue(m_frame);
308     m_keyToggle->setStatus(
309         m_actualParam->hasKeyframes(), m_actualParam->isKeyframe(m_frame),
310         m_actualParam->getValue(m_frame) != m_currentParam->getValue(m_frame));
311   }
312 
313   /*--
314    * エフェクトの位置パラメータをSwatchViewerでドラッグして編集するときに呼ばれる
315    * ---*/
setValue(T value)316   void setValue(T value) {
317     if (m_currentParam->getValue(m_frame) == value) return;
318     m_currentParam->setValue(m_frame, value);
319     /*-- キーフレーム上で操作した場合 --*/
320     if (m_actualParam->isKeyframe(m_frame)) {
321       m_actualParam->setValue(m_frame, value);
322       emit actualParamChanged();
323     }
324     /*-- キーフレーム無い場合 --*/
325     else if (!m_actualParam.getPointer()->hasKeyframes()) {
326       m_actualParam->setDefaultValue(value);
327       emit actualParamChanged();
328     }
329     /*-- 他にキーフレームがあって、キーフレーム以外のフレームで操作した場合 --*/
330     emit currentParamChanged();
331     updateKeyToggle();
332   }
333 
onKeyToggle()334   void onKeyToggle() {
335     T currentVal = m_currentParam->getValue(m_frame);
336     bool wasKeyFrame;
337 
338     if (m_keyToggle->getStatus() == ParamFieldKeyToggle::KEYFRAME) {
339       m_actualParam->deleteKeyframe(m_frame);
340       update(m_frame);
341       wasKeyFrame = true;
342     } else {
343       m_actualParam->setValue(m_frame, m_currentParam->getValue(m_frame));
344       updateKeyToggle();
345       wasKeyFrame = false;
346     }
347     emit actualParamChanged();
348     emit paramKeyToggle();
349 
350     TUndoManager::manager()->add(new FxSettingsKeyToggleUndo<T, ParamP>(
351         m_actualParam, currentVal, wasKeyFrame, m_interfaceName, m_frame,
352         ParamField::m_fxHandleStat));
353   }
354 };
355 
356 //=============================================================================
357 // MeasuredDoubleParamField
358 //-----------------------------------------------------------------------------
359 
360 class DVAPI MeasuredDoubleParamField final
361     : public AnimatedParamField<double, TDoubleParamP> {
362   Q_OBJECT
363 
364   DVGui::MeasuredDoubleField *m_measuredDoubleField;
365 
366 public:
367   MeasuredDoubleParamField(QWidget *parent, QString name,
368                            const TDoubleParamP &param);
369 
370   void updateField(double value) override;
371 
getPreferedSize()372   QSize getPreferedSize() override { return QSize(260, 28); }
373 
374 protected slots:
375   void onChange(bool);
376   void onKeyToggled();
377 };
378 
379 //=============================================================================
380 // RangeParamField
381 //-----------------------------------------------------------------------------
382 
383 class DVAPI MeasuredRangeParamField final
384     : public AnimatedParamField<DoublePair, TRangeParamP> {
385   Q_OBJECT
386 
387   DVGui::MeasuredDoublePairField *m_valueField;
388 
389 public:
390   MeasuredRangeParamField(QWidget *parent, QString name,
391                           const TRangeParamP &param);
392 
393   void updateField(DoublePair value) override;
394 
getPreferedSize()395   QSize getPreferedSize() override { return QSize(300, 20); }
396   void setPrecision(int precision) override;
397 
398 protected slots:
399   void onChange(bool);
400   void onKeyToggled();
401 };
402 
403 //=============================================================================
404 // PointParamField
405 //-----------------------------------------------------------------------------
406 
407 class DVAPI PointParamField final
408     : public AnimatedParamField<TPointD, TPointParamP> {
409   Q_OBJECT
410 
411   DVGui::MeasuredDoubleField *m_xFld, *m_yFld;
412 
413 public:
414   PointParamField(QWidget *parent, QString name, const TPointParamP &param);
415 
416   void setPointValue(const TPointD &p) override;
417 
418   void updateField(TPointD value) override;
419 
getPreferedSize()420   QSize getPreferedSize() override { return QSize(270, 28); }
421 
422 protected slots:
423   void onChange(bool);
424   void onKeyToggled();
425 };
426 
427 //=============================================================================
428 // PixelParamField
429 //-----------------------------------------------------------------------------
430 
431 class DVAPI PixelParamField final
432     : public AnimatedParamField<TPixel32, TPixelParamP> {
433   Q_OBJECT
434 
435   DVGui::ColorField *m_colorField;
436 
437 public:
438   PixelParamField(QWidget *parent, QString name, const TPixelParamP &param);
439 
440   void updateField(TPixel32 value) override;
441 
getPreferedSize()442   QSize getPreferedSize() override { return QSize(480, 40); }
443 
444   /*-- RgbLinkButtonの実行のため --*/
445   TPixel32 getColor();
446   void setColor(TPixel32 value);
447 
448 protected:
449   void setParams();
450 
451 protected slots:
452   void onChange(const TPixel32 &value, bool isDragging);
453   void onKeyToggled();
454 };
455 
456 //=============================================================================
457 // RGB Link Button
458 //-----------------------------------------------------------------------------
459 
460 class DVAPI RgbLinkButtons final : public QWidget {
461   Q_OBJECT
462   PixelParamField *m_field1, *m_field2;
463 
464 public:
465   RgbLinkButtons(QString str1, QString str2, QWidget *parent,
466                  PixelParamField *field1, PixelParamField *field2);
467 
468 protected slots:
469   void onCopyButtonClicked();
470   void onSwapButtonClicked();
471 };
472 
473 //=============================================================================
474 // SpectrumParamField
475 //-----------------------------------------------------------------------------
476 
477 class DVAPI SpectrumParamField final
478     : public AnimatedParamField<TSpectrum, TSpectrumParamP> {
479   Q_OBJECT
480 
481   DVGui::SpectrumField *m_spectrumField;
482 
483 public:
484   SpectrumParamField(QWidget *parent, QString name,
485                      const TSpectrumParamP &param);
486 
487   void updateField(TSpectrum value) override;
488 
489   void setParams();
490 
getPreferedSize()491   QSize getPreferedSize() override { return QSize(477, 60); }
492 
493 protected slots:
494   void onKeyToggled();
495   void onChange(bool isDragging);
496   void onKeyAdded(int keyIndex);
497   void onKeyRemoved(int keyIndex);
498 };
499 
500 //=============================================================================
501 // Mode Sensitive Box
502 //-----------------------------------------------------------------------------
503 
504 class ModeChangerParamField : public ParamField {
505   Q_OBJECT
506 public:
507   ModeChangerParamField(QWidget *parent, QString paramName,
508                         const TParamP &param, bool addEmptyLabel = true)
ParamField(parent,paramName,param,addEmptyLabel)509       : ParamField(parent, paramName, param, addEmptyLabel) {}
510 signals:
511   void modeChanged(int);
512 };
513 
514 class DVAPI ModeSensitiveBox final : public QWidget {
515   Q_OBJECT
516   QList<int> m_modes;
517 
518 public:
519   ModeSensitiveBox(QWidget *parent, ModeChangerParamField *modeChanger,
520                    QList<int> modes);
modes()521   QList<int> modes() { return m_modes; }
522 protected slots:
523   void onModeChanged(int mode);
524 };
525 
526 //=============================================================================
527 // EnumParamField
528 //-----------------------------------------------------------------------------
529 
530 class EnumParamField final : public ModeChangerParamField {
531   Q_OBJECT
532 
533   TIntEnumParamP m_currentParam, m_actualParam;
534   QComboBox *m_om;
535 
536 public:
537   EnumParamField(QWidget *parent, QString name, const TIntEnumParamP &param);
538 
539   void setParam(const TParamP &current, const TParamP &actual,
540                 int frame) override;
541   void update(int frame) override;
542 
getPreferedSize()543   QSize getPreferedSize() override { return QSize(150, 20); }
544 
545 protected slots:
546   void onChange(const QString &str);
547 };
548 
549 //=============================================================================
550 // BoolParamField
551 //-----------------------------------------------------------------------------
552 
553 class DVAPI BoolParamField final : public ModeChangerParamField {
554   Q_OBJECT
555 
556   TBoolParamP m_currentParam, m_actualParam;
557   DVGui::CheckBox *m_checkBox;
558 
559 public:
560   BoolParamField(QWidget *parent, QString name, const TBoolParamP &param);
561 
562   void setParam(const TParamP &current, const TParamP &actual,
563                 int frame) override;
564   void update(int frame) override;
565 
getPreferedSize()566   QSize getPreferedSize() override { return QSize(20, 15); }
567 
568 protected slots:
569   void onToggled(bool checked);
570 
571   /*-- visibleToggle UIで使用する --*/
572 signals:
573   void toggled(bool);
574 };
575 
576 //=============================================================================
577 // IntParamField
578 //-----------------------------------------------------------------------------
579 
580 class DVAPI IntParamField final : public ParamField {
581   Q_OBJECT
582 
583   TIntParamP m_currentParam, m_actualParam;
584   DVGui::IntField *m_intField;
585   typedef IntParamField This;
586 
587 public:
588   IntParamField(QWidget *parent = 0, QString name = 0,
589                 const TIntParamP &param = 0);
590 
591   void setParam(const TParamP &current, const TParamP &actual,
592                 int frame) override;
593   void update(int frame) override;
594 
getPreferedSize()595   QSize getPreferedSize() override { return QSize(50, 20); }
596 
597 protected slots:
598   void onChange(bool isDragging = false);
599 };
600 
601 //=============================================================================
602 // StringParamField
603 //-----------------------------------------------------------------------------
604 
605 namespace component {
606 class MyTextEdit : public QTextEdit {
607   Q_OBJECT
608 public:
609   MyTextEdit(const QString &text, QWidget *parent = Q_NULLPTR)
QTextEdit(text,parent)610       : QTextEdit(text, parent) {}
611 
612 protected:
613   void keyPressEvent(QKeyEvent *event) override;
614   void focusOutEvent(QFocusEvent *e) override;
615 
616 signals:
617   void edited();
618 };
619 };  // namespace component
620 
621 class DVAPI StringParamField final : public ParamField {
622   Q_OBJECT
623 
624   TStringParamP m_currentParam, m_actualParam;
625   DVGui::LineEdit *m_textFld            = nullptr;
626   component::MyTextEdit *m_multiTextFld = nullptr;
627 
628 public:
629   StringParamField(QWidget *parent, QString name, const TStringParamP &param);
630 
631   void setParam(const TParamP &current, const TParamP &actual,
632                 int frame) override;
633   void update(int frame) override;
634 
getPreferedSize()635   QSize getPreferedSize() override {
636     if (m_textFld)
637       return QSize(100, 20);
638     else
639       return QSize(100, 80);
640   }
641 protected slots:
642   void onChange();
643 };
644 
645 //=============================================================================
646 // FontParamField
647 //-----------------------------------------------------------------------------
648 
649 class FontParamField final : public ParamField {
650   Q_OBJECT
651 
652   TFontParamP m_currentParam, m_actualParam;
653 
654   QFontComboBox *m_fontCombo;
655   QComboBox *m_styleCombo;
656   DVGui::IntField *m_sizeField;
657 
658 public:
659   FontParamField(QWidget *parent, QString name, const TFontParamP &param);
660 
661   void setParam(const TParamP &current, const TParamP &actual,
662                 int frame) override;
663   void update(int frame) override;
664 
getPreferedSize()665   QSize getPreferedSize() override { return QSize(150, 20); }
666 
667 protected slots:
668   void findStyles(const QFont &font);
669   void onSizeChange(bool);
670   void onChange();
671 };
672 
673 //=============================================================================
674 // ToneCurveParamField
675 //-----------------------------------------------------------------------------
676 
677 class DVAPI ToneCurveParamField final
678     : public AnimatedParamField<const QList<TPointD>, TToneCurveParamP> {
679   Q_OBJECT
680 
681   DVGui::ToneCurveField *m_toneCurveField;
682 
683 public:
684   ToneCurveParamField(QWidget *parent, QString name,
685                       const TToneCurveParamP &param);
686 
687   void updateField(const QList<TPointD> value) override;
688 
689   void setParams();
690 
691   QSize getPreferedSize() override;
692 
693 protected slots:
694   void onChannelChanged(int);
695 
696   void onChange(bool isDragging);
697   void onPointAdded(int index);
698   void onPointRemoved(int index);
699   void onIsLinearChanged(bool);
700 
701   void onKeyToggled();
702 };
703 
704 namespace component {
705 class DVAPI LineEdit_double final : public ParamField {
706   Q_OBJECT;  // could not use templates for Q_OBJECT
707 
708   int frame_;
709   TDoubleParamP current_;
710   TDoubleParamP actual_;
711   QLineEdit *value_;
712 
713 public:
714   LineEdit_double(QWidget *parent, QString name, TDoubleParamP const &param);
715 
716   void setParam(TParamP const &current, TParamP const &actual,
717                 int frame) override;
718   void update(int frame) override;
719 
720 protected slots:
721   void update_value(QString const &text);  // could not use MACROs for slots
722 };
723 
724 class DVAPI Slider_double final : public ParamField {
725   Q_OBJECT;
726 
727   int frame_;
728   TDoubleParamP current_;
729   TDoubleParamP actual_;
730   QSlider *value_;
731 
732 public:
733   Slider_double(QWidget *parent, QString name, TDoubleParamP const &param);
734 
735   void setParam(TParamP const &current, TParamP const &actual,
736                 int frame) override;
737   void update(int frame) override;
738 
739 protected slots:
740   void update_value(int);
741 };
742 
743 class DVAPI SpinBox_double final : public ParamField {
744   Q_OBJECT;
745 
746   int frame_;
747   TDoubleParamP current_;
748   TDoubleParamP actual_;
749   QDoubleSpinBox *value_;
750 
751 public:
752   SpinBox_double(QWidget *parent, QString name, TDoubleParamP const &param);
753 
754   void setParam(TParamP const &current, TParamP const &actual,
755                 int frame) override;
756   void update(int frame) override;
757 
758 protected slots:
759   void update_value(double);
760 };
761 }  // namespace component
762 
763 namespace component {
764 class DVAPI LineEdit_int final : public ParamField {
765   Q_OBJECT;
766 
767   int frame_;
768   TIntParamP current_;
769   TIntParamP actual_;
770   QLineEdit *value_;
771 
772 public:
773   LineEdit_int(QWidget *parent, QString name, TIntParamP const &param);
774 
775   void setParam(TParamP const &current, TParamP const &actual,
776                 int frame) override;
777   void update(int frame) override;
778 
779 protected slots:
780   void update_value(QString const &text);
781 };
782 
783 class DVAPI Slider_int final : public ParamField {
784   Q_OBJECT;
785 
786   int frame_;
787   TIntParamP current_;
788   TIntParamP actual_;
789   QSlider *value_;
790 
791 public:
792   Slider_int(QWidget *parent, QString name, TIntParamP const &param);
793 
794   void setParam(TParamP const &current, TParamP const &actual,
795                 int frame) override;
796   void update(int frame) override;
797 
798 protected slots:
799   void update_value(int);
800 };
801 
802 class DVAPI SpinBox_int final : public ParamField {
803   Q_OBJECT;
804 
805   int frame_;
806   TIntParamP current_;
807   TIntParamP actual_;
808   QSpinBox *value_;
809 
810 public:
811   SpinBox_int(QWidget *parent, QString name, TIntParamP const &param);
812 
813   void setParam(TParamP const &current, TParamP const &actual,
814                 int frame) override;
815   void update(int frame) override;
816 
817 protected slots:
818   void update_value(int);
819 };
820 
821 }  // end of namespace component
822 
823 namespace component {
824 class DVAPI CheckBox_bool final : public ParamField {
825   Q_OBJECT;
826 
827   int frame_;
828   TBoolParamP current_;
829   TBoolParamP actual_;
830   QCheckBox *value_;
831 
832 public:
833   CheckBox_bool(QWidget *parent, QString name, TBoolParamP const &param);
834 
835   void setParam(TParamP const &current, TParamP const &actual,
836                 int frame) override;
837   void update(int frame) override;
838 
839 protected slots:
840   void update_value(int);
841 };
842 
843 }  // end of namespace component
844 
845 namespace component {
846 class DVAPI RadioButton_enum final : public ParamField {
847   Q_OBJECT;
848 
849   int frame_;
850   TIntEnumParamP current_;
851   TIntEnumParamP actual_;
852   QButtonGroup *value_;
853 
854 public:
855   RadioButton_enum(QWidget *parent, QString name, TIntEnumParamP const &param);
856 
857   void setParam(TParamP const &current, TParamP const &actual,
858                 int frame) override;
859   void update(int frame) override;
860 
861 protected slots:
862   void update_value(int);
863 };
864 
865 class DVAPI ComboBox_enum final : public ParamField {
866   Q_OBJECT;
867 
868   int frame_;
869   TIntEnumParamP current_;
870   TIntEnumParamP actual_;
871   QComboBox *value_;
872 
873 public:
874   ComboBox_enum(QWidget *parent, QString name, TIntEnumParamP const &param);
875 
876   void setParam(TParamP const &current, TParamP const &actual,
877                 int frame) override;
878   void update(int frame) override;
879 
880 protected slots:
881   void update_value(int);
882 };
883 }  // end of namespace component
884 
885 namespace component {
886 class DVAPI LineEdit_string final : public ParamField {
887   Q_OBJECT;
888 
889   int frame_;
890   TStringParamP current_;
891   TStringParamP actual_;
892   QLineEdit *value_;
893 
894 public:
895   LineEdit_string(QWidget *parent, QString name, TStringParamP const &param);
896 
897   void setParam(TParamP const &current, TParamP const &actual,
898                 int frame) override;
899   void update(int frame) override;
900 
901 protected slots:
902   void update_value(QString const &);
903 };
904 }  // end of namespace component
905 
906 #ifdef __cplusplus
907 extern "C" {
908 #endif
909 
910 #define TOONZ_DECLARE_MAKE_WIDGET(NAME)                                        \
911   ParamField *NAME(QWidget *parent, QString name, TParamP const &param)
912 
913 TOONZ_DECLARE_MAKE_WIDGET(make_lineedit);
914 TOONZ_DECLARE_MAKE_WIDGET(make_slider);
915 TOONZ_DECLARE_MAKE_WIDGET(make_spinbox);
916 TOONZ_DECLARE_MAKE_WIDGET(make_checkbox);
917 TOONZ_DECLARE_MAKE_WIDGET(make_radiobutton);
918 TOONZ_DECLARE_MAKE_WIDGET(make_combobox);
919 
920 #ifdef __cplusplus
921 }
922 #endif
923 
924 #endif  // PARAMFIELD_H
925