@@ -243,41 +243,67 @@ void ParamsPage::setPageField(TIStream &is, const TFxP &fx, bool isVertical) {
243243 setPageField (is, fx, false );
244244 m_mainLayout->addLayout (m_horizontalLayout, currentRow, 1 , 1 , 2 );
245245 } else if (tagName == " vbox" ) {
246- int shrink = 0 ;
247- std::string shrinkStr = is.getTagAttribute (" shrink" );
248- if (shrinkStr != " " ) {
249- shrink = QString::fromStdString (shrinkStr).toInt ();
250- std::string label = is.getTagAttribute (" label" );
251- QCheckBox *checkBox = new QCheckBox (this );
252- QHBoxLayout *sepLay = new QHBoxLayout ();
253- sepLay->setMargin (0 );
254- sepLay->setSpacing (5 );
255- sepLay->addWidget (checkBox, 0 );
256- sepLay->addWidget (new Separator (QString::fromStdString (label), this ),
257- 1 );
258- int currentRow = m_mainLayout->rowCount ();
259- m_mainLayout->addLayout (sepLay, currentRow, 0 , 1 , 2 );
260- m_mainLayout->setRowStretch (currentRow, 0 );
246+ int shrink = 0 ;
247+ std::string shrinkStr = is.getTagAttribute (" shrink" );
248+ std::string modeSensitiveStr = is.getTagAttribute (" modeSensitive" );
249+ if (shrinkStr != " " || modeSensitiveStr != " " ) {
250+ QWidget *tmpWidget;
251+ if (shrinkStr != " " ) {
252+ tmpWidget = new QWidget (this );
253+ shrink = QString::fromStdString (shrinkStr).toInt ();
254+ std::string label = is.getTagAttribute (" label" );
255+ QCheckBox *checkBox = new QCheckBox (this );
256+ QHBoxLayout *sepLay = new QHBoxLayout ();
257+ sepLay->setMargin (0 );
258+ sepLay->setSpacing (5 );
259+ sepLay->addWidget (checkBox, 0 );
260+ sepLay->addWidget (new Separator (QString::fromStdString (label), this ),
261+ 1 );
262+ int currentRow = m_mainLayout->rowCount ();
263+ m_mainLayout->addLayout (sepLay, currentRow, 0 , 1 , 2 );
264+ m_mainLayout->setRowStretch (currentRow, 0 );
265+ // --- signal-slot connection
266+ connect (checkBox, SIGNAL (toggled (bool )), tmpWidget,
267+ SLOT (setVisible (bool )));
268+ checkBox->setChecked (shrink == 1 );
269+ tmpWidget->setVisible (shrink == 1 );
270+ } else { // modeSensitiveStr != ""
271+ QList<int > modes;
272+ QStringList modeListStr =
273+ QString::fromStdString (is.getTagAttribute (" mode" ))
274+ .split (' ,' , QString::SkipEmptyParts);
275+ for (QString modeNum : modeListStr) modes.push_back (modeNum.toInt ());
276+ // find the mode combobox
277+ ModeChangerParamField *modeChanger = nullptr ;
278+ for (int r = 0 ; r < m_mainLayout->rowCount (); r++) {
279+ QLayoutItem *li = m_mainLayout->itemAtPosition (r, 1 );
280+ if (!li || !li->widget ()) continue ;
281+ ModeChangerParamField *field =
282+ dynamic_cast <ModeChangerParamField *>(li->widget ());
283+ if (!field ||
284+ field->getParamName ().toStdString () != modeSensitiveStr)
285+ continue ;
286+ modeChanger = field;
287+ break ;
288+ }
289+ assert (modeChanger);
290+ tmpWidget = new ModeSensitiveBox (this , modeChanger, modes);
291+ }
292+
293+ int currentRow = m_mainLayout->rowCount ();
261294 QGridLayout *keepMainLay = m_mainLayout;
262- /* -- レイアウトを一時的に差し替え -- */
263- m_mainLayout = new QGridLayout (this );
264- m_mainLayout->setMargin (12 );
295+ // temporary switch the layout
296+ m_mainLayout = new QGridLayout ();
297+ m_mainLayout->setMargin (0 );
265298 m_mainLayout->setVerticalSpacing (10 );
266299 m_mainLayout->setHorizontalSpacing (5 );
267300 m_mainLayout->setColumnStretch (0 , 0 );
268301 m_mainLayout->setColumnStretch (1 , 1 );
269302 setPageField (is, fx, true );
270-
271- QWidget *tmpWidget = new QWidget (this );
272303 tmpWidget->setLayout (m_mainLayout);
273- /* -- レイアウト戻し -- */
304+ // turn back the layout
274305 m_mainLayout = keepMainLay;
275- m_mainLayout->addWidget (tmpWidget, currentRow + 1 , 0 , 1 , 2 );
276- // --- signal-slot connection
277- connect (checkBox, SIGNAL (toggled (bool )), tmpWidget,
278- SLOT (setVisible (bool )));
279- checkBox->setChecked (shrink == 1 );
280- tmpWidget->setVisible (shrink == 1 );
306+ m_mainLayout->addWidget (tmpWidget, currentRow, 0 , 1 , 2 );
281307 } else
282308 setPageField (is, fx, true );
283309 }
@@ -611,17 +637,37 @@ void updateMaximumPageSize(QGridLayout *layout, int &maxLabelWidth,
611637 }
612638
613639 /* -- Widget側の最適な縦サイズおよび横幅の最大値を得る --*/
640+ QMap<int , int > heightsByMode;
641+ int maxModeHeight = 0 ;
614642 for (int r = 0 ; r < layout->rowCount (); r++) {
615643 /* -- Column1にある可能性のあるもの:ParamField, Histogram, Layout,
616644 * RgbLinkButtons --*/
617645
618646 QLayoutItem *item = layout->itemAtPosition (r, 1 );
619647 if (!item) continue ;
620648
649+ ModeSensitiveBox *box = dynamic_cast <ModeSensitiveBox *>(item->widget ());
650+ if (box) {
651+ // if (box->isHidden()) continue;
652+ QGridLayout *innerLay = dynamic_cast <QGridLayout *>(box->layout ());
653+ if (!innerLay) continue ;
654+ int tmpHeight = 0 ;
655+ updateMaximumPageSize (innerLay, maxLabelWidth, maxWidgetWidth, tmpHeight);
656+ for (int mode : box->modes ()) {
657+ heightsByMode[mode] += tmpHeight;
658+ maxModeHeight = std::max (maxModeHeight, heightsByMode[mode]);
659+ }
660+
661+ // attempt to align the label column
662+ innerLay->setColumnMinimumWidth (0 , maxLabelWidth);
663+ continue ;
664+ }
665+
621666 QSize itemSize = getItemSize (item);
622667 if (maxWidgetWidth < itemSize.width ()) maxWidgetWidth = itemSize.width ();
623668 fieldsHeight += itemSize.height ();
624669 }
670+ if (maxModeHeight > 0 ) fieldsHeight += maxModeHeight;
625671
626672 if (layout->rowCount () > 1 ) fieldsHeight += (layout->rowCount () - 1 ) * 10 ;
627673}
0 commit comments