tahoma2d/toonz/sources/include/toonzqt/paramfield.h

862 lines
22 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef PARAMFIELD_H
#define PARAMFIELD_H
#ifdef _MSC_VER
2016-03-19 06:57:51 +13:00
#pragma warning(disable : 4251)
#endif
#include "tcommon.h"
#include <QWidget>
#include <QSpinBox>
#include <QSlider>
#include <QCheckBox>
#include <QButtonGroup>
#include <QRadioButton>
#include <QPushButton>
#include <QTextEdit>
2016-03-19 06:57:51 +13:00
#include "tgeometry.h"
#include "tparam.h"
#include "tnotanimatableparam.h"
#include "tspectrumparam.h"
#include "ttonecurveparam.h"
#include "tdoubleparam.h"
#include "toonz/tfxhandle.h"
#include "historytypes.h"
#undef DVAPI
#undef DVVAR
#ifdef TOONZQT_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
// forward declaration
class QString;
class QComboBox;
class QHBoxLayout;
class TFxHandle;
class QFontComboBox;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
namespace DVGui {
2016-03-19 06:57:51 +13:00
class LineEdit;
class IntField;
class DoubleField;
class MeasuredDoubleField;
class MeasuredDoublePairField;
class ColorField;
class SpectrumField;
class ToneCurveField;
class CheckBox;
2019-09-19 20:19:58 +12:00
} // namespace DVGui
2016-03-19 06:57:51 +13:00
//=============================================================================
/*! \brief ParamField.
2016-06-15 18:43:10 +12:00
Inherits \b QWidget.
2016-03-19 06:57:51 +13:00
*/
2016-06-15 18:43:10 +12:00
class DVAPI ParamField : public QWidget {
Q_OBJECT
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
QHBoxLayout *m_layout;
QString m_paramName;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
static TFxHandle *m_fxHandleStat;
QString m_interfaceName;
QString m_description;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
ParamField(QWidget *parent, QString paramName, const TParamP &param,
bool addEmptyLabel = true);
~ParamField();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QString getParamName() const { return m_paramName; }
QString getUIName() const { return m_interfaceName; }
QString getDescription() const { return m_description; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
virtual void setParam(const TParamP &current, const TParamP &actual,
int frame) = 0;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
virtual void update(int frame) = 0;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
static ParamField *create(QWidget *parent, QString name,
const TParamP &param);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
virtual void setPointValue(const TPointD &p){};
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
virtual QSize getPreferedSize() { return QSize(200, 28); }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
static void setFxHandle(TFxHandle *fxHandle);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
virtual void setPrecision(int precision) {}
2016-03-19 06:57:51 +13:00
signals:
2016-06-15 18:43:10 +12:00
void currentParamChanged();
void actualParamChanged();
void paramKeyToggle();
2016-03-19 06:57:51 +13:00
};
//=============================================================================
// ParamFieldKeyToggle
//-----------------------------------------------------------------------------
class DVAPI ParamFieldKeyToggle final : public QWidget {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
enum Status { NOT_ANIMATED, NOT_KEYFRAME, MODIFIED, KEYFRAME };
2020-06-05 16:40:15 +12:00
QPixmap m_pixmap;
QIcon m_icon;
// keyframe colors
QColor m_keyOffColor;
QColor m_keyOnColor;
QColor m_keyModifiedColor;
QColor m_keyHighlightColor;
QColor m_keyInbetweenColor;
// keyframe colors
Q_PROPERTY(QColor KeyOffColor READ getKeyOffColor WRITE setKeyOffColor)
Q_PROPERTY(QColor KeyOnColor READ getKeyOnColor WRITE setKeyOnColor)
Q_PROPERTY(QColor KeyModifiedColor READ getKeyModifiedColor WRITE
setKeyModifiedColor)
Q_PROPERTY(QColor KeyInbetweenColor READ getKeyInbetweenColor WRITE
setKeyInbetweenColor)
Q_PROPERTY(QColor KeyHighlightColor READ getKeyHighlightColor WRITE
setKeyHighlightColor)
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
Status m_status;
bool m_highlighted;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
ParamFieldKeyToggle(QWidget *parent,
std::string name = "ParamFieldKeyToggle");
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setStatus(Status status);
Status getStatus() const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setStatus(bool hasKeyframe, bool isKeyframe, bool hasBeenChanged);
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void paintEvent(QPaintEvent *) override;
void mousePressEvent(QMouseEvent *) override;
void enterEvent(QEvent *) override;
void leaveEvent(QEvent *) override;
2016-03-19 06:57:51 +13:00
2020-06-05 16:40:15 +12:00
// keyframe colors
void setKeyOffColor(const QColor &color) { m_keyOffColor = color; }
QColor getKeyOffColor() const { return m_keyOffColor; }
void setKeyOnColor(const QColor &color) { m_keyOnColor = color; }
QColor getKeyOnColor() const { return m_keyOnColor; }
void setKeyModifiedColor(const QColor &color) { m_keyModifiedColor = color; }
QColor getKeyModifiedColor() const { return m_keyModifiedColor; }
void setKeyHighlightColor(const QColor &color) {
m_keyHighlightColor = color;
}
QColor getKeyHighlightColor() const { return m_keyHighlightColor; }
void setKeyInbetweenColor(const QColor &color) {
m_keyInbetweenColor = color;
}
QColor getKeyInbetweenColor() const { return m_keyInbetweenColor; }
2016-03-19 06:57:51 +13:00
signals:
2016-06-15 18:43:10 +12:00
void keyToggled();
2016-03-19 06:57:51 +13:00
};
//=============================================================================
// FxSettingsKeyToggleUndo
//=============================================================================
template <class T, class ParamP>
class FxSettingsKeyToggleUndo final : public TUndo {
2016-06-15 18:43:10 +12:00
TFxHandle *m_fxHandle;
QString m_name;
bool m_wasKeyframe;
int m_frame;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
ParamP m_param;
T m_currentValue;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FxSettingsKeyToggleUndo(ParamP param, T currentValue, bool wasKeyFrame,
QString name, int frame, TFxHandle *fxHandle)
: m_param(param)
, m_currentValue(currentValue)
, m_wasKeyframe(wasKeyFrame)
, m_name(name)
, m_frame(frame)
, m_fxHandle(fxHandle) {}
// void notify();
2016-06-19 20:06:29 +12:00
void undo() const override {
2016-06-15 18:43:10 +12:00
if (m_wasKeyframe)
m_param->setValue(m_frame, m_currentValue);
else
m_param->deleteKeyframe(m_frame);
if (m_fxHandle) m_fxHandle->notifyFxChanged();
}
2016-06-19 20:06:29 +12:00
void redo() const override {
2016-06-15 18:43:10 +12:00
if (m_wasKeyframe)
m_param->deleteKeyframe(m_frame);
else
m_param->setValue(m_frame, m_currentValue);
if (m_fxHandle) m_fxHandle->notifyFxChanged();
}
2016-06-19 20:06:29 +12:00
int getSize() const override { return sizeof(*this); }
int getHistoryType() override { return HistoryType::Fx; }
QString getHistoryString() override {
2016-06-15 18:43:10 +12:00
QString str =
QObject::tr("Modify Fx Param : %1 Key : %2 Frame %3")
.arg((m_wasKeyframe) ? QObject::tr("Delete") : QObject::tr("Set"))
.arg(m_name)
.arg(QString::number(m_frame + 1));
return str;
}
2016-03-19 06:57:51 +13:00
};
//=============================================================================
// AnimatedParamField
//-----------------------------------------------------------------------------
template <class T, class ParamP>
2016-06-15 18:43:10 +12:00
class DVAPI AnimatedParamField : public ParamField {
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
ParamP m_currentParam, m_actualParam;
int m_frame;
ParamFieldKeyToggle *m_keyToggle;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
AnimatedParamField(QWidget *parent, QString name, const ParamP &param,
bool addEmptyLabel = true)
: ParamField(parent, name, param, addEmptyLabel), m_frame(0) {
m_keyToggle = new ParamFieldKeyToggle(this);
}
virtual void updateField(T value) = 0;
2016-06-20 14:23:05 +12:00
void setParam(const TParamP &current, const TParamP &actual,
int frame) override {
2016-06-15 18:43:10 +12:00
m_currentParam = current;
m_actualParam = actual;
assert(m_currentParam);
assert(m_actualParam);
update(frame);
}
2016-06-19 20:06:29 +12:00
void update(int frame) override {
2016-06-15 18:43:10 +12:00
m_frame = frame;
if (!m_actualParam || !m_currentParam) return;
T value = m_actualParam->getValue(m_frame);
if (m_actualParam->isKeyframe(m_frame))
m_currentParam->setValue(m_frame, value);
else if (!m_actualParam.getPointer()->hasKeyframes())
m_currentParam->setDefaultValue(value);
updateField(value);
updateKeyToggle();
}
void updateKeyToggle() {
T stroke = m_actualParam->getValue(m_frame);
T stroke2 = m_currentParam->getValue(m_frame);
m_keyToggle->setStatus(
m_actualParam->hasKeyframes(), m_actualParam->isKeyframe(m_frame),
m_actualParam->getValue(m_frame) != m_currentParam->getValue(m_frame));
}
/*--
* SwatchViewerでドラッグして編集するときに呼ばれる
* ---*/
void setValue(T value) {
if (m_currentParam->getValue(m_frame) == value) return;
m_currentParam->setValue(m_frame, value);
/*-- キーフレーム上で操作した場合 --*/
if (m_actualParam->isKeyframe(m_frame)) {
m_actualParam->setValue(m_frame, value);
emit actualParamChanged();
}
/*-- キーフレーム無い場合 --*/
else if (!m_actualParam.getPointer()->hasKeyframes()) {
m_actualParam->setDefaultValue(value);
emit actualParamChanged();
}
/*-- 他にキーフレームがあって、キーフレーム以外のフレームで操作した場合 --*/
emit currentParamChanged();
updateKeyToggle();
}
void onKeyToggle() {
T currentVal = m_currentParam->getValue(m_frame);
bool wasKeyFrame;
if (m_keyToggle->getStatus() == ParamFieldKeyToggle::KEYFRAME) {
m_actualParam->deleteKeyframe(m_frame);
update(m_frame);
wasKeyFrame = true;
} else {
m_actualParam->setValue(m_frame, m_currentParam->getValue(m_frame));
updateKeyToggle();
wasKeyFrame = false;
}
emit actualParamChanged();
emit paramKeyToggle();
TUndoManager::manager()->add(new FxSettingsKeyToggleUndo<T, ParamP>(
m_actualParam, currentVal, wasKeyFrame, m_interfaceName, m_frame,
ParamField::m_fxHandleStat));
}
2016-03-19 06:57:51 +13:00
};
//=============================================================================
// MeasuredDoubleParamField
//-----------------------------------------------------------------------------
class DVAPI MeasuredDoubleParamField final
2016-06-15 18:43:10 +12:00
: public AnimatedParamField<double, TDoubleParamP> {
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
DVGui::MeasuredDoubleField *m_measuredDoubleField;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
MeasuredDoubleParamField(QWidget *parent, QString name,
const TDoubleParamP &param);
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void updateField(double value) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QSize getPreferedSize() override { return QSize(260, 28); }
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onChange(bool);
void onKeyToggled();
2016-03-19 06:57:51 +13:00
};
//=============================================================================
// RangeParamField
//-----------------------------------------------------------------------------
class DVAPI MeasuredRangeParamField final
2016-06-15 18:43:10 +12:00
: public AnimatedParamField<DoublePair, TRangeParamP> {
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
DVGui::MeasuredDoublePairField *m_valueField;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
MeasuredRangeParamField(QWidget *parent, QString name,
const TRangeParamP &param);
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void updateField(DoublePair value) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QSize getPreferedSize() override { return QSize(300, 20); }
void setPrecision(int precision) override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onChange(bool);
void onKeyToggled();
2016-03-19 06:57:51 +13:00
};
//=============================================================================
// PointParamField
//-----------------------------------------------------------------------------
class DVAPI PointParamField final
: public AnimatedParamField<TPointD, TPointParamP> {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
DVGui::MeasuredDoubleField *m_xFld, *m_yFld;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
PointParamField(QWidget *parent, QString name, const TPointParamP &param);
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void setPointValue(const TPointD &p) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void updateField(TPointD value) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QSize getPreferedSize() override { return QSize(270, 28); }
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onChange(bool);
void onKeyToggled();
2016-03-19 06:57:51 +13:00
};
//=============================================================================
// PixelParamField
//-----------------------------------------------------------------------------
class DVAPI PixelParamField final
2016-06-15 18:43:10 +12:00
: public AnimatedParamField<TPixel32, TPixelParamP> {
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
DVGui::ColorField *m_colorField;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
PixelParamField(QWidget *parent, QString name, const TPixelParamP &param);
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void updateField(TPixel32 value) override;
2016-03-19 06:57:51 +13:00
2017-09-29 22:55:10 +13:00
QSize getPreferedSize() override { return QSize(480, 40); }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
/*-- RgbLinkButtonの実行のため --*/
TPixel32 getColor();
void setColor(TPixel32 value);
2016-03-19 06:57:51 +13:00
protected:
2016-06-15 18:43:10 +12:00
void setParams();
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onChange(const TPixel32 &value, bool isDragging);
void onKeyToggled();
2016-03-19 06:57:51 +13:00
};
//=============================================================================
// RGB Link Button
//-----------------------------------------------------------------------------
2019-09-19 20:19:58 +12:00
class DVAPI RgbLinkButtons final : public QWidget {
2016-06-15 18:43:10 +12:00
Q_OBJECT
PixelParamField *m_field1, *m_field2;
2016-03-19 06:57:51 +13:00
public:
2019-09-19 20:19:58 +12:00
RgbLinkButtons(QString str1, QString str2, QWidget *parent,
PixelParamField *field1, PixelParamField *field2);
2016-03-19 06:57:51 +13:00
protected slots:
2019-09-19 20:19:58 +12:00
void onCopyButtonClicked();
void onSwapButtonClicked();
2016-03-19 06:57:51 +13:00
};
//=============================================================================
// SpectrumParamField
//-----------------------------------------------------------------------------
class DVAPI SpectrumParamField final
2016-06-15 18:43:10 +12:00
: public AnimatedParamField<TSpectrum, TSpectrumParamP> {
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
DVGui::SpectrumField *m_spectrumField;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
SpectrumParamField(QWidget *parent, QString name,
const TSpectrumParamP &param);
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void updateField(TSpectrum value) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setParams();
2016-03-19 06:57:51 +13:00
2017-09-29 22:55:10 +13:00
QSize getPreferedSize() override { return QSize(477, 60); }
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onKeyToggled();
void onChange(bool isDragging);
void onKeyAdded(int keyIndex);
void onKeyRemoved(int keyIndex);
2016-03-19 06:57:51 +13:00
};
//=============================================================================
// EnumParamField
//-----------------------------------------------------------------------------
class EnumParamField final : public ParamField {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TIntEnumParamP m_currentParam, m_actualParam;
QComboBox *m_om;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
EnumParamField(QWidget *parent, QString name, const TIntEnumParamP &param);
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
void setParam(const TParamP &current, const TParamP &actual,
int frame) override;
2016-06-19 20:06:29 +12:00
void update(int frame) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QSize getPreferedSize() override { return QSize(150, 20); }
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onChange(const QString &str);
2016-03-19 06:57:51 +13:00
};
//=============================================================================
// BoolParamField
//-----------------------------------------------------------------------------
class DVAPI BoolParamField final : public ParamField {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TBoolParamP m_currentParam, m_actualParam;
DVGui::CheckBox *m_checkBox;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
BoolParamField(QWidget *parent, QString name, const TBoolParamP &param);
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
void setParam(const TParamP &current, const TParamP &actual,
int frame) override;
2016-06-19 20:06:29 +12:00
void update(int frame) override;
2016-03-19 06:57:51 +13:00
2017-09-29 22:55:10 +13:00
QSize getPreferedSize() override { return QSize(20, 15); }
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onToggled(bool checked);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
/*-- visibleToggle UIで使用する --*/
2016-03-19 06:57:51 +13:00
signals:
2016-06-15 18:43:10 +12:00
void toggled(bool);
2016-03-19 06:57:51 +13:00
};
//=============================================================================
// IntParamField
//-----------------------------------------------------------------------------
class DVAPI IntParamField final : public ParamField {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TIntParamP m_currentParam, m_actualParam;
DVGui::IntField *m_intField;
typedef IntParamField This;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
IntParamField(QWidget *parent = 0, QString name = 0,
const TIntParamP &param = 0);
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
void setParam(const TParamP &current, const TParamP &actual,
int frame) override;
2016-06-19 20:06:29 +12:00
void update(int frame) override;
2016-03-19 06:57:51 +13:00
2017-09-29 22:55:10 +13:00
QSize getPreferedSize() override { return QSize(50, 20); }
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onChange(bool isDragging = false);
2016-03-19 06:57:51 +13:00
};
//=============================================================================
// StringParamField
//-----------------------------------------------------------------------------
namespace component {
class MyTextEdit : public QTextEdit {
Q_OBJECT
public:
MyTextEdit(const QString &text, QWidget *parent = Q_NULLPTR)
: QTextEdit(text, parent) {}
protected:
void keyPressEvent(QKeyEvent *event) override;
void focusOutEvent(QFocusEvent *e) override;
signals:
void edited();
};
2019-09-19 20:19:58 +12:00
}; // namespace component
class DVAPI StringParamField final : public ParamField {
2016-06-15 18:43:10 +12:00
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TStringParamP m_currentParam, m_actualParam;
DVGui::LineEdit *m_textFld = nullptr;
component::MyTextEdit *m_multiTextFld = nullptr;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
StringParamField(QWidget *parent, QString name, const TStringParamP &param);
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
void setParam(const TParamP &current, const TParamP &actual,
int frame) override;
2016-06-19 20:06:29 +12:00
void update(int frame) override;
2016-03-19 06:57:51 +13:00
QSize getPreferedSize() override {
if (m_textFld)
return QSize(100, 20);
else
return QSize(100, 80);
}
protected slots:
void onChange();
};
//=============================================================================
// FontParamField
//-----------------------------------------------------------------------------
class FontParamField final : public ParamField {
Q_OBJECT
TFontParamP m_currentParam, m_actualParam;
QFontComboBox *m_fontCombo;
QComboBox *m_styleCombo;
DVGui::IntField *m_sizeField;
public:
FontParamField(QWidget *parent, QString name, const TFontParamP &param);
void setParam(const TParamP &current, const TParamP &actual,
int frame) override;
void update(int frame) override;
QSize getPreferedSize() override { return QSize(150, 20); }
2016-03-19 06:57:51 +13:00
protected slots:
void findStyles(const QFont &font);
void onSizeChange(bool);
2016-06-15 18:43:10 +12:00
void onChange();
2016-03-19 06:57:51 +13:00
};
//=============================================================================
// ToneCurveParamField
//-----------------------------------------------------------------------------
class DVAPI ToneCurveParamField final
2016-06-15 18:43:10 +12:00
: public AnimatedParamField<const QList<TPointD>, TToneCurveParamP> {
Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
DVGui::ToneCurveField *m_toneCurveField;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
ToneCurveParamField(QWidget *parent, QString name,
const TToneCurveParamP &param);
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void updateField(const QList<TPointD> value) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setParams();
2016-03-19 06:57:51 +13:00
2020-03-16 14:37:10 +13:00
QSize getPreferedSize() override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void onChannelChanged(int);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void onChange(bool isDragging);
void onPointAdded(int index);
void onPointRemoved(int index);
void onIsLinearChanged(bool);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void onKeyToggled();
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
namespace component {
class DVAPI LineEdit_double final : public ParamField {
2016-06-15 18:43:10 +12:00
Q_OBJECT; // could not use templates for Q_OBJECT
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int frame_;
TDoubleParamP current_;
TDoubleParamP actual_;
QLineEdit *value_;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
LineEdit_double(QWidget *parent, QString name, TDoubleParamP const &param);
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
void setParam(TParamP const &current, TParamP const &actual,
int frame) override;
2016-06-19 20:06:29 +12:00
void update(int frame) override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void update_value(QString const &text); // could not use MACROs for slots
2016-03-19 06:57:51 +13:00
};
class DVAPI Slider_double final : public ParamField {
2016-06-15 18:43:10 +12:00
Q_OBJECT;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int frame_;
TDoubleParamP current_;
TDoubleParamP actual_;
QSlider *value_;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
Slider_double(QWidget *parent, QString name, TDoubleParamP const &param);
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
void setParam(TParamP const &current, TParamP const &actual,
int frame) override;
2016-06-19 20:06:29 +12:00
void update(int frame) override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void update_value(int);
2016-03-19 06:57:51 +13:00
};
class DVAPI SpinBox_double final : public ParamField {
2016-06-15 18:43:10 +12:00
Q_OBJECT;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int frame_;
TDoubleParamP current_;
TDoubleParamP actual_;
QDoubleSpinBox *value_;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
SpinBox_double(QWidget *parent, QString name, TDoubleParamP const &param);
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
void setParam(TParamP const &current, TParamP const &actual,
int frame) override;
2016-06-19 20:06:29 +12:00
void update(int frame) override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void update_value(double);
2016-03-19 06:57:51 +13:00
};
2019-09-19 20:19:58 +12:00
} // namespace component
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
namespace component {
class DVAPI LineEdit_int final : public ParamField {
2016-06-15 18:43:10 +12:00
Q_OBJECT;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int frame_;
TIntParamP current_;
TIntParamP actual_;
QLineEdit *value_;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
LineEdit_int(QWidget *parent, QString name, TIntParamP const &param);
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
void setParam(TParamP const &current, TParamP const &actual,
int frame) override;
2016-06-19 20:06:29 +12:00
void update(int frame) override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void update_value(QString const &text);
2016-03-19 06:57:51 +13:00
};
class DVAPI Slider_int final : public ParamField {
2016-06-15 18:43:10 +12:00
Q_OBJECT;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int frame_;
TIntParamP current_;
TIntParamP actual_;
QSlider *value_;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
Slider_int(QWidget *parent, QString name, TIntParamP const &param);
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
void setParam(TParamP const &current, TParamP const &actual,
int frame) override;
2016-06-19 20:06:29 +12:00
void update(int frame) override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void update_value(int);
2016-03-19 06:57:51 +13:00
};
class DVAPI SpinBox_int final : public ParamField {
2016-06-15 18:43:10 +12:00
Q_OBJECT;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int frame_;
TIntParamP current_;
TIntParamP actual_;
QSpinBox *value_;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
SpinBox_int(QWidget *parent, QString name, TIntParamP const &param);
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
void setParam(TParamP const &current, TParamP const &actual,
int frame) override;
2016-06-19 20:06:29 +12:00
void update(int frame) override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void update_value(int);
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
} // end of namespace component
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
namespace component {
class DVAPI CheckBox_bool final : public ParamField {
2016-06-15 18:43:10 +12:00
Q_OBJECT;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int frame_;
TBoolParamP current_;
TBoolParamP actual_;
QCheckBox *value_;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
CheckBox_bool(QWidget *parent, QString name, TBoolParamP const &param);
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
void setParam(TParamP const &current, TParamP const &actual,
int frame) override;
2016-06-19 20:06:29 +12:00
void update(int frame) override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void update_value(int);
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
} // end of namespace component
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
namespace component {
class DVAPI RadioButton_enum final : public ParamField {
2016-06-15 18:43:10 +12:00
Q_OBJECT;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int frame_;
TIntEnumParamP current_;
TIntEnumParamP actual_;
QButtonGroup *value_;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
RadioButton_enum(QWidget *parent, QString name, TIntEnumParamP const &param);
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
void setParam(TParamP const &current, TParamP const &actual,
int frame) override;
2016-06-19 20:06:29 +12:00
void update(int frame) override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void update_value(int);
2016-03-19 06:57:51 +13:00
};
class DVAPI ComboBox_enum final : public ParamField {
2016-06-15 18:43:10 +12:00
Q_OBJECT;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int frame_;
TIntEnumParamP current_;
TIntEnumParamP actual_;
QComboBox *value_;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
ComboBox_enum(QWidget *parent, QString name, TIntEnumParamP const &param);
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
void setParam(TParamP const &current, TParamP const &actual,
int frame) override;
2016-06-19 20:06:29 +12:00
void update(int frame) override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void update_value(int);
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
} // end of namespace component
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
namespace component {
class DVAPI LineEdit_string final : public ParamField {
2016-06-15 18:43:10 +12:00
Q_OBJECT;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int frame_;
TStringParamP current_;
TStringParamP actual_;
QLineEdit *value_;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
LineEdit_string(QWidget *parent, QString name, TStringParamP const &param);
2016-03-19 06:57:51 +13:00
2016-06-20 14:23:05 +12:00
void setParam(TParamP const &current, TParamP const &actual,
int frame) override;
2016-06-19 20:06:29 +12:00
void update(int frame) override;
2016-03-19 06:57:51 +13:00
protected slots:
2016-06-15 18:43:10 +12:00
void update_value(QString const &);
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
} // end of namespace component
2016-03-19 06:57:51 +13:00
#ifdef __cplusplus
extern "C" {
#endif
2016-06-15 18:43:10 +12:00
#define TOONZ_DECLARE_MAKE_WIDGET(NAME) \
ParamField *NAME(QWidget *parent, QString name, TParamP const &param)
2016-03-19 06:57:51 +13:00
TOONZ_DECLARE_MAKE_WIDGET(make_lineedit);
TOONZ_DECLARE_MAKE_WIDGET(make_slider);
TOONZ_DECLARE_MAKE_WIDGET(make_spinbox);
TOONZ_DECLARE_MAKE_WIDGET(make_checkbox);
TOONZ_DECLARE_MAKE_WIDGET(make_radiobutton);
TOONZ_DECLARE_MAKE_WIDGET(make_combobox);
#ifdef __cplusplus
}
#endif
2016-06-15 18:43:10 +12:00
#endif // PARAMFIELD_H