Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

mode sensitive fx settings

shun-iwasawa6e910bce6ace
diff --git a/stuff/profiles/layouts/fxs/STD_iwa_TextFx.xml b/stuff/profiles/layouts/fxs/STD_iwa_TextFx.xml
index aab4c546a..528a508e5 100644
--- a/stuff/profiles/layouts/fxs/STD_iwa_TextFx.xml
+++ b/stuff/profiles/layouts/fxs/STD_iwa_TextFx.xml
@@ -2,8 +2,12 @@
<page name="Text Iwa">
<vbox>
<control>targetType</control>
- <control>columnIndex</control>
- <control>text</control>
+ <vbox modeSensitive="targetType" mode="1">
+ <control>columnIndex</control>
+ </vbox>
+ <vbox modeSensitive="targetType" mode="2">
+ <control>text</control>
+ </vbox>
<control>hAlign</control>
<control>center</control>
<control>width</control>
diff --git a/stuff/profiles/layouts/fxs/STD_iwa_TimeCodeFx.xml b/stuff/profiles/layouts/fxs/STD_iwa_TimeCodeFx.xml
index 87d366270..803470df7 100644
--- a/stuff/profiles/layouts/fxs/STD_iwa_TimeCodeFx.xml
+++ b/stuff/profiles/layouts/fxs/STD_iwa_TimeCodeFx.xml
@@ -2,13 +2,17 @@
<page name="TimeCode Iwa">
<vbox>
<control>displayType</control>
- <control>frameRate</control>
+ <vbox modeSensitive="displayType" mode="0,2">
+ <control>frameRate</control>
+ </vbox>
<control>startFrame</control>
<control>position</control>
<control>size</control>
<control>textColor</control>
<control>showBox</control>
- <control>boxColor</control>
+ <vbox modeSensitive="showBox" mode="1">
+ <control>boxColor</control>
+ </vbox>
</vbox>
</page>
</fxlayout>
diff --git a/toonz/sources/include/toonzqt/paramfield.h b/toonz/sources/include/toonzqt/paramfield.h
index 5de4fb350..01ad39e89 100644
--- a/toonz/sources/include/toonzqt/paramfield.h
+++ b/toonz/sources/include/toonzqt/paramfield.h
@@ -425,11 +425,37 @@ protected slots:
void onKeyRemoved(int keyIndex);
};
+//=============================================================================
+// Mode Sensitive Box
+//-----------------------------------------------------------------------------
+
+class ModeChangerParamField : public ParamField {
+ Q_OBJECT
+public:
+ ModeChangerParamField(QWidget *parent, QString paramName,
+ const TParamP &param, bool addEmptyLabel = true)
+ : ParamField(parent, paramName, param, addEmptyLabel) {}
+signals:
+ void modeChanged(int);
+};
+
+class DVAPI ModeSensitiveBox final : public QWidget {
+ Q_OBJECT
+ QList<int> m_modes;
+
+public:
+ ModeSensitiveBox(QWidget *parent, ModeChangerParamField *modeChanger,
+ QList<int> modes);
+ QList<int> modes() { return m_modes; }
+protected slots:
+ void onModeChanged(int mode);
+};
+
//=============================================================================
// EnumParamField
//-----------------------------------------------------------------------------
-class EnumParamField final : public ParamField {
+class EnumParamField final : public ModeChangerParamField {
Q_OBJECT
TIntEnumParamP m_currentParam, m_actualParam;
@@ -452,7 +478,7 @@ protected slots:
// BoolParamField
//-----------------------------------------------------------------------------
-class DVAPI BoolParamField final : public ParamField {
+class DVAPI BoolParamField final : public ModeChangerParamField {
Q_OBJECT
TBoolParamP m_currentParam, m_actualParam;
diff --git a/toonz/sources/toonzqt/fxsettings.cpp b/toonz/sources/toonzqt/fxsettings.cpp
index 241b39bd0..e311e87ea 100644
--- a/toonz/sources/toonzqt/fxsettings.cpp
+++ b/toonz/sources/toonzqt/fxsettings.cpp
@@ -243,41 +243,67 @@ void ParamsPage::setPageField(TIStream &is, const TFxP &fx, bool isVertical) {
setPageField(is, fx, false);
m_mainLayout->addLayout(m_horizontalLayout, currentRow, 1, 1, 2);
} else if (tagName == "vbox") {
- int shrink = 0;
- std::string shrinkStr = is.getTagAttribute("shrink");
- if (shrinkStr != "") {
- shrink = QString::fromStdString(shrinkStr).toInt();
- std::string label = is.getTagAttribute("label");
- QCheckBox *checkBox = new QCheckBox(this);
- QHBoxLayout *sepLay = new QHBoxLayout();
- sepLay->setMargin(0);
- sepLay->setSpacing(5);
- sepLay->addWidget(checkBox, 0);
- sepLay->addWidget(new Separator(QString::fromStdString(label), this),
- 1);
- int currentRow = m_mainLayout->rowCount();
- m_mainLayout->addLayout(sepLay, currentRow, 0, 1, 2);
- m_mainLayout->setRowStretch(currentRow, 0);
+ int shrink = 0;
+ std::string shrinkStr = is.getTagAttribute("shrink");
+ std::string modeSensitiveStr = is.getTagAttribute("modeSensitive");
+ if (shrinkStr != "" || modeSensitiveStr != "") {
+ QWidget *tmpWidget;
+ if (shrinkStr != "") {
+ tmpWidget = new QWidget(this);
+ shrink = QString::fromStdString(shrinkStr).toInt();
+ std::string label = is.getTagAttribute("label");
+ QCheckBox *checkBox = new QCheckBox(this);
+ QHBoxLayout *sepLay = new QHBoxLayout();
+ sepLay->setMargin(0);
+ sepLay->setSpacing(5);
+ sepLay->addWidget(checkBox, 0);
+ sepLay->addWidget(new Separator(QString::fromStdString(label), this),
+ 1);
+ int currentRow = m_mainLayout->rowCount();
+ m_mainLayout->addLayout(sepLay, currentRow, 0, 1, 2);
+ m_mainLayout->setRowStretch(currentRow, 0);
+ //--- signal-slot connection
+ connect(checkBox, SIGNAL(toggled(bool)), tmpWidget,
+ SLOT(setVisible(bool)));
+ checkBox->setChecked(shrink == 1);
+ tmpWidget->setVisible(shrink == 1);
+ } else { // modeSensitiveStr != ""
+ QList<int> modes;
+ QStringList modeListStr =
+ QString::fromStdString(is.getTagAttribute("mode"))
+ .split(',', QString::SkipEmptyParts);
+ for (QString modeNum : modeListStr) modes.push_back(modeNum.toInt());
+ // find the mode combobox
+ ModeChangerParamField *modeChanger = nullptr;
+ for (int r = 0; r < m_mainLayout->rowCount(); r++) {
+ QLayoutItem *li = m_mainLayout->itemAtPosition(r, 1);
+ if (!li || !li->widget()) continue;
+ ModeChangerParamField *field =
+ dynamic_cast<ModeChangerParamField *>(li->widget());
+ if (!field ||
+ field->getParamName().toStdString() != modeSensitiveStr)
+ continue;
+ modeChanger = field;
+ break;
+ }
+ assert(modeChanger);
+ tmpWidget = new ModeSensitiveBox(this, modeChanger, modes);
+ }
+
+ int currentRow = m_mainLayout->rowCount();
QGridLayout *keepMainLay = m_mainLayout;
- /*-- レイアウトを一時的に差し替え --*/
- m_mainLayout = new QGridLayout(this);
- m_mainLayout->setMargin(12);
+ // temporary switch the layout
+ m_mainLayout = new QGridLayout();
+ m_mainLayout->setMargin(0);
m_mainLayout->setVerticalSpacing(10);
m_mainLayout->setHorizontalSpacing(5);
m_mainLayout->setColumnStretch(0, 0);
m_mainLayout->setColumnStretch(1, 1);
setPageField(is, fx, true);
-
- QWidget *tmpWidget = new QWidget(this);
tmpWidget->setLayout(m_mainLayout);
- /*-- レイアウト戻し --*/
+ // turn back the layout
m_mainLayout = keepMainLay;
- m_mainLayout->addWidget(tmpWidget, currentRow + 1, 0, 1, 2);
- //--- signal-slot connection
- connect(checkBox, SIGNAL(toggled(bool)), tmpWidget,
- SLOT(setVisible(bool)));
- checkBox->setChecked(shrink == 1);
- tmpWidget->setVisible(shrink == 1);
+ m_mainLayout->addWidget(tmpWidget, currentRow, 0, 1, 2);
} else
setPageField(is, fx, true);
}
@@ -611,6 +637,8 @@ void updateMaximumPageSize(QGridLayout *layout, int &maxLabelWidth,
}
/*-- Widget側の最適な縦サイズおよび横幅の最大値を得る --*/
+ QMap<int, int> heightsByMode;
+ int maxModeHeight = 0;
for (int r = 0; r < layout->rowCount(); r++) {
/*-- Column1にある可能性のあるもの:ParamField, Histogram, Layout,
* RgbLinkButtons --*/
@@ -618,10 +646,28 @@ void updateMaximumPageSize(QGridLayout *layout, int &maxLabelWidth,
QLayoutItem *item = layout->itemAtPosition(r, 1);
if (!item) continue;
+ ModeSensitiveBox *box = dynamic_cast<ModeSensitiveBox *>(item->widget());
+ if (box) {
+ // if (box->isHidden()) continue;
+ QGridLayout *innerLay = dynamic_cast<QGridLayout *>(box->layout());
+ if (!innerLay) continue;
+ int tmpHeight = 0;
+ updateMaximumPageSize(innerLay, maxLabelWidth, maxWidgetWidth, tmpHeight);
+ for (int mode : box->modes()) {
+ heightsByMode[mode] += tmpHeight;
+ maxModeHeight = std::max(maxModeHeight, heightsByMode[mode]);
+ }
+
+ // attempt to align the label column
+ innerLay->setColumnMinimumWidth(0, maxLabelWidth);
+ continue;
+ }
+
QSize itemSize = getItemSize(item);
if (maxWidgetWidth < itemSize.width()) maxWidgetWidth = itemSize.width();
fieldsHeight += itemSize.height();
}
+ if (maxModeHeight > 0) fieldsHeight += maxModeHeight;
if (layout->rowCount() > 1) fieldsHeight += (layout->rowCount() - 1) * 10;
}
diff --git a/toonz/sources/toonzqt/paramfield.cpp b/toonz/sources/toonzqt/paramfield.cpp
index 3af0729d1..fc826bf49 100644
--- a/toonz/sources/toonzqt/paramfield.cpp
+++ b/toonz/sources/toonzqt/paramfield.cpp
@@ -1242,13 +1242,31 @@ void SpectrumParamField::onKeyRemoved(int keyIndex) {
if (undo) TUndoManager::manager()->add(undo);
}
+//=============================================================================
+// Mode Sensitive Box
+//-----------------------------------------------------------------------------
+
+ModeSensitiveBox::ModeSensitiveBox(QWidget *parent,
+ ModeChangerParamField *modeChanger,
+ QList<int> modes)
+ : QWidget(parent), m_modes(modes) {
+ connect(modeChanger, SIGNAL(modeChanged(int)), this,
+ SLOT(onModeChanged(int)));
+}
+
+//-----------------------------------------------------------------------------
+
+void ModeSensitiveBox::onModeChanged(int modeValue) {
+ setVisible(m_modes.contains(modeValue));
+}
+
//=============================================================================
// EnumParamField
//-----------------------------------------------------------------------------
EnumParamField::EnumParamField(QWidget *parent, QString name,
const TIntEnumParamP &param)
- : ParamField(parent, name, param) {
+ : ModeChangerParamField(parent, name, param) {
QString str;
m_paramName = str.fromStdString(param->getName());
m_om = new QComboBox(this);
@@ -1300,6 +1318,8 @@ void EnumParamField::onChange(const QString &str) {
emit currentParamChanged();
emit actualParamChanged();
+ emit modeChanged(m_actualParam->getValue());
+
if (undo) TUndoManager::manager()->add(undo);
}
@@ -1312,6 +1332,7 @@ void EnumParamField::setParam(const TParamP &current, const TParamP &actual,
assert(m_currentParam);
assert(m_actualParam);
update(frame);
+ emit modeChanged(m_actualParam->getValue());
}
//-----------------------------------------------------------------------------
@@ -1336,7 +1357,7 @@ void EnumParamField::update(int frame) {
BoolParamField::BoolParamField(QWidget *parent, QString name,
const TBoolParamP &param)
- : ParamField(parent, name, param) {
+ : ModeChangerParamField(parent, name, param) {
QString str;
m_paramName = str.fromStdString(param->getName());
if (!param->hasUILabel()) m_interfaceName = name;
@@ -1362,6 +1383,8 @@ void BoolParamField::onToggled(bool checked) {
emit currentParamChanged();
emit actualParamChanged();
+ emit modeChanged((checked) ? 1 : 0);
+
TBoolParamP boolParam = m_actualParam;
if (boolParam)
TUndoManager::manager()->add(new BoolParamFieldUndo(
@@ -1377,6 +1400,7 @@ void BoolParamField::setParam(const TParamP &current, const TParamP &actual,
assert(m_currentParam);
assert(m_actualParam);
update(frame);
+ emit modeChanged((m_actualParam->getValue()) ? 1 : 0);
}
//-----------------------------------------------------------------------------