Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonzqt/fxsettings.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/gutil.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/keyframenavigator.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/dvdialog.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/fxhistogramrender.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/histogram.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tmacrofx.h"
Toshihiro Shimizu 890ddd
#include "tstream.h"
Toshihiro Shimizu 890ddd
#include "tparamcontainer.h"
Toshihiro Shimizu 890ddd
#include "tspectrumparam.h"
Toshihiro Shimizu 890ddd
#include "tfxattributes.h"
Toshihiro Shimizu 890ddd
#include "toutputproperties.h"
Toshihiro Shimizu 890ddd
#include "pluginhost.h"
Toshihiro Shimizu 890ddd
#include "tenv.h"
shun-iwasawa 5b724a
#include "tsystem.h"
manongjohn b13816
#include "docklayout.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonz/tcamera.h"
Toshihiro Shimizu 890ddd
#include "toonz/toonzfolders.h"
Toshihiro Shimizu 890ddd
#include "toonz/tcolumnfx.h"
Toshihiro Shimizu 890ddd
#include "toonz/tscenehandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/txshlevelhandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/tobjecthandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/scenefx.h"
Toshihiro Shimizu 890ddd
#include "toonz/toonzscene.h"
Toshihiro Shimizu 890ddd
#include "toonz/sceneproperties.h"
Toshihiro Shimizu 890ddd
#include "toonz/preferences.h"
Toshihiro Shimizu 890ddd
#include "tw/stringtable.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qvboxlayout></qvboxlayout>
Toshihiro Shimizu 890ddd
#include <qtoolbar></qtoolbar>
Toshihiro Shimizu 890ddd
#include <qicon></qicon>
Toshihiro Shimizu 890ddd
#include <qaction></qaction>
Toshihiro Shimizu 890ddd
#include <qstackedwidget></qstackedwidget>
Toshihiro Shimizu 890ddd
#include <qlabel></qlabel>
Toshihiro Shimizu 890ddd
#include <qmap></qmap>
Toshihiro Shimizu 890ddd
#include <qpainter></qpainter>
Toshihiro Shimizu 890ddd
#include <qcheckbox></qcheckbox>
Toshihiro Shimizu 890ddd
#include <qpushbutton></qpushbutton>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qdesktopservices></qdesktopservices>
Toshihiro Shimizu 890ddd
#include <qurl></qurl>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
using namespace DVGui;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace {
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TFxP getCurrentFx(const TFxP ¤tFx, std::wstring actualId) {
Shinya Kitaoka 120a6e
  if (currentFx->getFxId() == actualId) return currentFx;
Shinya Kitaoka 120a6e
  int i;
Shinya Kitaoka 120a6e
  for (i = 0; i < currentFx->getInputPortCount(); i++) {
Shinya Kitaoka 120a6e
    TFxP fx = getCurrentFx(currentFx->getInputPort(i)->getFx(), actualId);
Shinya Kitaoka 120a6e
    if (fx.getPointer()) return fx;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  return 0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool hasEmptyInputPort(const TFxP ¤tFx) {
Shinya Kitaoka 120a6e
  if (!currentFx.getPointer()) return true;
Shinya Kitaoka 120a6e
  if (currentFx->getInputPortCount() == 0) return false;
Shinya Kitaoka 120a6e
  return hasEmptyInputPort(currentFx->getInputPort(0)->getFx());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
/*
Toshihiro Shimizu 890ddd
TFxP cloneInputPort(const TFxP ¤tFx)
Toshihiro Shimizu 890ddd
{
Shinya Kitaoka 120a6e
        int i;
Toshihiro Shimizu 890ddd
  for (i=0; i
Toshihiro Shimizu 890ddd
  {
Shinya Kitaoka 120a6e
                TFx *inputFx = sceneFx->getInputPort(i)->getFx();
Shinya Kitaoka 120a6e
                if(inputFx)
Shinya Kitaoka 120a6e
                {
Shinya Kitaoka 120a6e
                        if(TLevelColumnFx* affFx = dynamic_cast
Shinya Kitaoka 120a6e
>(inputFx))
Shinya Kitaoka 120a6e
                                currentFx->getInputPort(i)->setFx(inputFx);
Shinya Kitaoka 120a6e
                        else
Shinya Kitaoka 120a6e
                                currentFx->getInputPort(i)->setFx(cloneInputPort());
Shinya Kitaoka 120a6e
                }
Shinya Kitaoka 120a6e
                TFxPort *port = getInputPort(i);
Shinya Kitaoka 120a6e
                if (port->getFx())
Shinya Kitaoka 120a6e
                        fx->connect(getInputPortName(i),
Shinya Kitaoka 120a6e
cloneInputPort(port->getFx()));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
void setLevelFxInputPort(const TFxP ¤tFx, const TFxP &sceneFx)
Toshihiro Shimizu 890ddd
{
Shinya Kitaoka 120a6e
        for (int i=0; i<scenefx->getInputPortCount(); ++i)</scenefx->
Shinya Kitaoka 120a6e
        {
Shinya Kitaoka 120a6e
                TFx *inputFx = sceneFx->getInputPort(i)->getFx();
Shinya Kitaoka 120a6e
                if(inputFx)
Shinya Kitaoka 120a6e
                {
Shinya Kitaoka 120a6e
                        if(TLevelColumnFx* affFx = dynamic_cast
Shinya Kitaoka 120a6e
>(inputFx))
Shinya Kitaoka 120a6e
                                currentFx->getInputPort(i)->setFx(inputFx);
Shinya Kitaoka 120a6e
                        else
Shinya Kitaoka 120a6e
                                setLevelFxInputPort(currentFx->getInputPort(i)->getFx(),
Shinya Kitaoka 120a6e
inputFx);
Shinya Kitaoka 120a6e
                }
Shinya Kitaoka 120a6e
        }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
*/
shun-iwasawa cac18a
}  // namespace
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// ParamViewer
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
ParamsPage::ParamsPage(QWidget *parent, ParamViewer *paramViewer)
Shinya Kitaoka 120a6e
    : QFrame(parent)
Shinya Kitaoka 120a6e
    , m_paramViewer(paramViewer)
Shinya Kitaoka 120a6e
    , m_horizontalLayout(NULL)
Shinya Kitaoka 120a6e
    , m_groupLayout(NULL) {
Shinya Kitaoka 120a6e
  m_fxHistogramRender = new FxHistogramRender();
Shinya Kitaoka 120a6e
  setFrameStyle(QFrame::StyledPanel);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_mainLayout = new QGridLayout(this);
Shinya Kitaoka 120a6e
  m_mainLayout->setMargin(12);
Shinya Kitaoka 120a6e
  m_mainLayout->setVerticalSpacing(10);
Shinya Kitaoka 120a6e
  m_mainLayout->setHorizontalSpacing(5);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_mainLayout->setColumnStretch(0, 0);
Shinya Kitaoka 120a6e
  m_mainLayout->setColumnStretch(1, 1);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  setLayout(m_mainLayout);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ParamsPage::~ParamsPage() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamsPage::setPageField(TIStream &is, const TFxP &fx, bool isVertical) {
Shinya Kitaoka 120a6e
  // m_horizontalLayout dovrebbe essere stato inizializzato prima di entrare nel
Shinya Kitaoka 120a6e
  // metodo, per sicurezza verifico.
Shinya Kitaoka 120a6e
  if (isVertical == false && !m_horizontalLayout) {
Shinya Kitaoka 120a6e
    m_horizontalLayout = new QHBoxLayout();
Shinya Kitaoka 120a6e
    m_horizontalLayout->setMargin(0);
Shinya Kitaoka 120a6e
    m_horizontalLayout->setSpacing(5);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*--
Shinya Kitaoka 120a6e
   * HBoxLayoutを挿入するとき、最初のパラメータ名はGridlayoutのColumn0に入れるため
Shinya Kitaoka 120a6e
   * --*/
Shinya Kitaoka 120a6e
  bool isFirstParamInRow = true;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  while (!is.matchEndTag()) {
Shinya Kitaoka 120a6e
    std::string tagName;
Shinya Kitaoka 120a6e
    if (!is.matchTag(tagName)) throw TException("expected tag");
Shinya Kitaoka 120a6e
    if (tagName == "control") {
Shinya Kitaoka 120a6e
      /*--- 設定ファイルからインタフェースの桁数を決める (PairSliderのみ実装。)
Shinya Kitaoka 120a6e
       * ---*/
Shinya Kitaoka 120a6e
      int decimals            = 0;
Shinya Kitaoka 120a6e
      std::string decimalsStr = is.getTagAttribute("decimals");
Shinya Kitaoka 120a6e
      if (decimalsStr != "") {
Shinya Kitaoka 120a6e
        decimals = QString::fromStdString(decimalsStr).toInt();
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      std::string name;
Shinya Kitaoka 120a6e
      is >> name;
Shinya Kitaoka 120a6e
      is.matchEndTag();
Shinya Kitaoka 120a6e
      /*-- Layout設定名とFxParameterの名前が一致するものを取得 --*/
Shinya Kitaoka 120a6e
      TParamP param = fx->getParams()->getParam(name);
Shinya Kitaoka 120a6e
      if (param) {
Shinya Kitaoka 120a6e
        std::string paramName = fx->getFxType() + "." + name;
Shinya Kitaoka 120a6e
        QString str =
Shinya Kitaoka 120a6e
            QString::fromStdWString(TStringTable::translate(paramName));
Shinya Kitaoka 120a6e
        ParamField *field = ParamField::create(this, str, param);
Shinya Kitaoka 120a6e
        if (field) {
Shinya Kitaoka 120a6e
          if (decimals) field->setPrecision(decimals);
Shinya Kitaoka 120a6e
          m_fields.push_back(field);
Shinya Kitaoka 120a6e
          /*-- hboxタグに挟まれているとき --*/
Shinya Kitaoka 120a6e
          if (isVertical == false) {
Shinya Kitaoka 120a6e
            assert(m_horizontalLayout);
Shinya Kitaoka 120a6e
            QLabel *label = new QLabel(str, this);
Shinya Kitaoka 120a6e
            label->setObjectName("FxSettingsLabel");
Shinya Kitaoka 120a6e
            if (isFirstParamInRow) {
Shinya Kitaoka 120a6e
              int currentRow = m_mainLayout->rowCount();
Shinya Kitaoka 120a6e
              m_mainLayout->addWidget(label, currentRow, 0,
Shinya Kitaoka 120a6e
                                      Qt::AlignRight | Qt::AlignVCenter);
Shinya Kitaoka 120a6e
              isFirstParamInRow = false;
Shinya Kitaoka 120a6e
            } else
Shinya Kitaoka 120a6e
              m_horizontalLayout->addWidget(label, 0,
Shinya Kitaoka 120a6e
                                            Qt::AlignRight | Qt::AlignVCenter);
Shinya Kitaoka 120a6e
            m_horizontalLayout->addWidget(field);
Shinya Kitaoka 120a6e
            m_horizontalLayout->addSpacing(10);
Shinya Kitaoka 120a6e
          } else {
Shinya Kitaoka 120a6e
            int currentRow = m_mainLayout->rowCount();
Shinya Kitaoka 120a6e
            QLabel *label  = new QLabel(str, this);
Shinya Kitaoka 120a6e
            label->setObjectName("FxSettingsLabel");
Shinya Kitaoka 120a6e
            m_mainLayout->addWidget(label, currentRow, 0,
Shinya Kitaoka 120a6e
                                    Qt::AlignRight | Qt::AlignVCenter);
Shinya Kitaoka 120a6e
            m_mainLayout->addWidget(field, currentRow, 1);
Shinya Kitaoka 120a6e
          }
Shinya Kitaoka 120a6e
          connect(field, SIGNAL(currentParamChanged()), m_paramViewer,
Shinya Kitaoka 120a6e
                  SIGNAL(currentFxParamChanged()));
Shinya Kitaoka 120a6e
          connect(field, SIGNAL(actualParamChanged()), m_paramViewer,
Shinya Kitaoka 120a6e
                  SIGNAL(actualFxParamChanged()));
Shinya Kitaoka 120a6e
          connect(field, SIGNAL(paramKeyToggle()), m_paramViewer,
Shinya Kitaoka 120a6e
                  SIGNAL(paramKeyChanged()));
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    } else if (tagName == "label") {
Shinya Kitaoka 120a6e
      std::string name;
Shinya Kitaoka 120a6e
      is >> name;
Shinya Kitaoka 120a6e
      is.matchEndTag();
Shinya Kitaoka 120a6e
      QString str;
Shinya Kitaoka 120a6e
      if (isVertical == false) {
Shinya Kitaoka 120a6e
        assert(m_horizontalLayout);
Shinya Kitaoka 120a6e
        m_horizontalLayout->addWidget(new QLabel(str.fromStdString(name)));
Shinya Kitaoka 120a6e
      } else {
Shinya Kitaoka 120a6e
        int currentRow = m_mainLayout->rowCount();
Shinya Kitaoka 120a6e
        m_mainLayout->addWidget(new QLabel(str.fromStdString(name)), currentRow,
Shinya Kitaoka 120a6e
                                0, 1, 2);
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    } else if (tagName == "separator") {
Shinya Kitaoka 120a6e
      // <separator> o <separator label="xxx"></separator></separator>
Shinya Kitaoka 120a6e
      std::string label = is.getTagAttribute("label");
Shinya Kitaoka 120a6e
      QString str;
Shinya Kitaoka 120a6e
      Separator *sep = new Separator(str.fromStdString(label), this);
Shinya Kitaoka 120a6e
      int currentRow = m_mainLayout->rowCount();
Shinya Kitaoka 120a6e
      m_mainLayout->addWidget(sep, currentRow, 0, 1, 2);
Shinya Kitaoka 120a6e
      m_mainLayout->setRowStretch(currentRow, 0);
Shinya Kitaoka 120a6e
    } else if (tagName == "histogram") {
Shinya Kitaoka 120a6e
      Histogram *histogram = new Histogram();
Shinya Kitaoka 120a6e
      m_fxHistogramRender->setHistograms(histogram->getHistograms());
Shinya Kitaoka 120a6e
      if (isVertical == false) {
Shinya Kitaoka 120a6e
        assert(m_horizontalLayout);
Shinya Kitaoka 120a6e
        m_horizontalLayout->addWidget(histogram);
Shinya Kitaoka 120a6e
      } else {
Shinya Kitaoka 120a6e
        int currentRow = m_mainLayout->rowCount();
Shinya Kitaoka 120a6e
        m_mainLayout->addWidget(histogram, currentRow, 0, 1, 2);
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    } else if (tagName == "test") {
Shinya Kitaoka 120a6e
      // <test></test>
Shinya Kitaoka 120a6e
      // box->add(new WidgetBox(new TestSeparator(page)));
Shinya Kitaoka 120a6e
    } else if (tagName == "hbox") {
Shinya Kitaoka 120a6e
      int currentRow     = m_mainLayout->rowCount();
Shinya Kitaoka 120a6e
      m_horizontalLayout = new QHBoxLayout();
Shinya Kitaoka 120a6e
      m_horizontalLayout->setMargin(0);
Shinya Kitaoka 120a6e
      m_horizontalLayout->setSpacing(5);
Shinya Kitaoka 120a6e
      setPageField(is, fx, false);
shun_iwasawa a0fb33
      m_mainLayout->addLayout(m_horizontalLayout, currentRow, 1, 1, 2);
Shinya Kitaoka 120a6e
    } else if (tagName == "vbox") {
shun-iwasawa 6e910b
      int shrink                   = 0;
shun-iwasawa 6e910b
      std::string shrinkStr        = is.getTagAttribute("shrink");
shun-iwasawa 6e910b
      std::string modeSensitiveStr = is.getTagAttribute("modeSensitive");
shun-iwasawa 6e910b
      if (shrinkStr != "" || modeSensitiveStr != "") {
shun-iwasawa 6e910b
        QWidget *tmpWidget;
shun-iwasawa 6e910b
        if (shrinkStr != "") {
shun-iwasawa 6e910b
          tmpWidget           = new QWidget(this);
shun-iwasawa 6e910b
          shrink              = QString::fromStdString(shrinkStr).toInt();
shun-iwasawa 6e910b
          std::string label   = is.getTagAttribute("label");
shun-iwasawa 6e910b
          QCheckBox *checkBox = new QCheckBox(this);
shun-iwasawa 6e910b
          QHBoxLayout *sepLay = new QHBoxLayout();
shun-iwasawa 6e910b
          sepLay->setMargin(0);
shun-iwasawa 6e910b
          sepLay->setSpacing(5);
shun-iwasawa 6e910b
          sepLay->addWidget(checkBox, 0);
shun-iwasawa 6e910b
          sepLay->addWidget(new Separator(QString::fromStdString(label), this),
shun-iwasawa 6e910b
                            1);
shun-iwasawa 6e910b
          int currentRow = m_mainLayout->rowCount();
shun-iwasawa 6e910b
          m_mainLayout->addLayout(sepLay, currentRow, 0, 1, 2);
shun-iwasawa 6e910b
          m_mainLayout->setRowStretch(currentRow, 0);
shun-iwasawa 6e910b
          //--- signal-slot connection
shun-iwasawa 6e910b
          connect(checkBox, SIGNAL(toggled(bool)), tmpWidget,
shun-iwasawa 6e910b
                  SLOT(setVisible(bool)));
shun-iwasawa 6e910b
          checkBox->setChecked(shrink == 1);
shun-iwasawa 6e910b
          tmpWidget->setVisible(shrink == 1);
shun-iwasawa 6e910b
        } else {  // modeSensitiveStr != ""
shun-iwasawa 6e910b
          QList<int> modes;</int>
shun-iwasawa 6e910b
          QStringList modeListStr =
shun-iwasawa 6e910b
              QString::fromStdString(is.getTagAttribute("mode"))
shun-iwasawa 6e910b
                  .split(',', QString::SkipEmptyParts);
shun-iwasawa 6e910b
          for (QString modeNum : modeListStr) modes.push_back(modeNum.toInt());
shun-iwasawa 6e910b
          // find the mode combobox
shun-iwasawa 6e910b
          ModeChangerParamField *modeChanger = nullptr;
shun-iwasawa 6e910b
          for (int r = 0; r < m_mainLayout->rowCount(); r++) {
shun-iwasawa 6e910b
            QLayoutItem *li = m_mainLayout->itemAtPosition(r, 1);
shun-iwasawa 6e910b
            if (!li || !li->widget()) continue;
shun-iwasawa 6e910b
            ModeChangerParamField *field =
shun-iwasawa 6e910b
                dynamic_cast<modechangerparamfield *="">(li->widget());</modechangerparamfield>
shun-iwasawa 6e910b
            if (!field ||
shun-iwasawa 6e910b
                field->getParamName().toStdString() != modeSensitiveStr)
shun-iwasawa 6e910b
              continue;
shun-iwasawa 6e910b
            modeChanger = field;
shun-iwasawa 6e910b
            break;
shun-iwasawa 6e910b
          }
shun-iwasawa 6e910b
          assert(modeChanger);
shun-iwasawa 6e910b
          tmpWidget = new ModeSensitiveBox(this, modeChanger, modes);
shun-iwasawa 6e910b
        }
shun-iwasawa 6e910b
shun-iwasawa 6e910b
        int currentRow           = m_mainLayout->rowCount();
Shinya Kitaoka 120a6e
        QGridLayout *keepMainLay = m_mainLayout;
shun-iwasawa 6e910b
        // temporary switch the layout
shun-iwasawa 6e910b
        m_mainLayout = new QGridLayout();
shun-iwasawa 6e910b
        m_mainLayout->setMargin(0);
Shinya Kitaoka 120a6e
        m_mainLayout->setVerticalSpacing(10);
Shinya Kitaoka 120a6e
        m_mainLayout->setHorizontalSpacing(5);
Shinya Kitaoka 120a6e
        m_mainLayout->setColumnStretch(0, 0);
Shinya Kitaoka 120a6e
        m_mainLayout->setColumnStretch(1, 1);
Shinya Kitaoka 120a6e
        setPageField(is, fx, true);
Shinya Kitaoka 120a6e
        tmpWidget->setLayout(m_mainLayout);
shun-iwasawa 6e910b
        // turn back the layout
Shinya Kitaoka 120a6e
        m_mainLayout = keepMainLay;
shun-iwasawa 6e910b
        m_mainLayout->addWidget(tmpWidget, currentRow, 0, 1, 2);
Shinya Kitaoka 120a6e
      } else
Shinya Kitaoka 120a6e
        setPageField(is, fx, true);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    /*-- PixelParamFieldが2つあるとき、一方のRGB値を他方にコピーするボタン --*/
Shinya Kitaoka 120a6e
    else if (tagName == "rgb_link_button") {
Shinya Kitaoka 120a6e
      /*-- リンクさせたいパラメータを2つ得る --*/
Shinya Kitaoka 120a6e
      std::string name1, name2;
Shinya Kitaoka 120a6e
      is >> name1;
Shinya Kitaoka 120a6e
      is >> name2;
Shinya Kitaoka 120a6e
      is.matchEndTag();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      /*-- 既に作ってあるGUIを探索し、対応する2つを得て格納 --*/
Shinya Kitaoka 120a6e
      PixelParamField *ppf1 = 0;
Shinya Kitaoka 120a6e
      PixelParamField *ppf2 = 0;
Shinya Kitaoka 120a6e
      for (int r = 0; r < m_mainLayout->rowCount(); r++) {
Shinya Kitaoka 120a6e
        QLayoutItem *li = m_mainLayout->itemAtPosition(r, 1);
Shinya Kitaoka 120a6e
        if (!li) continue;
Shinya Kitaoka 120a6e
        QWidget *w = li->widget();
Shinya Kitaoka 120a6e
        if (!w) continue;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        ParamField *pf = dynamic_cast<paramfield *="">(w);</paramfield>
Shinya Kitaoka 120a6e
        if (pf) {
Shinya Kitaoka 120a6e
          PixelParamField *ppf = dynamic_cast<pixelparamfield *="">(pf);</pixelparamfield>
Shinya Kitaoka 120a6e
          if (ppf) {
Shinya Kitaoka 120a6e
            if (ppf1 == 0 && ppf->getParamName().toStdString() == name1)
Shinya Kitaoka 120a6e
              ppf1 = ppf;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
            if (ppf2 == 0 && ppf->getParamName().toStdString() == name2)
Shinya Kitaoka 120a6e
              ppf2 = ppf;
Shinya Kitaoka 120a6e
          }
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
      if (ppf1 == 0 || ppf2 == 0) continue;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      /*-- ボタンのラベルのため 翻訳する --*/
Shinya Kitaoka 120a6e
      std::string paramName1 = fx->getFxType() + "." + name1;
Shinya Kitaoka 120a6e
      std::string paramName2 = fx->getFxType() + "." + name2;
Shinya Kitaoka 120a6e
      QString str1 =
Shinya Kitaoka 120a6e
          QString::fromStdWString(TStringTable::translate(paramName1));
Shinya Kitaoka 120a6e
      QString str2 =
Shinya Kitaoka 120a6e
          QString::fromStdWString(TStringTable::translate(paramName2));
Shinya Kitaoka 120a6e
shun-iwasawa cac18a
      RgbLinkButtons *linkBut =
shun-iwasawa cac18a
          new RgbLinkButtons(str1, str2, this, ppf1, ppf2);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      int currentRow = m_mainLayout->rowCount();
Shinya Kitaoka 120a6e
      m_mainLayout->addWidget(linkBut, currentRow, 1,
Shinya Kitaoka 120a6e
                              Qt::AlignLeft | Qt::AlignVCenter);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    /*-- チェックボックスによって他のインタフェースを表示/非表示させる ---*/
Shinya Kitaoka 120a6e
    else if (tagName == "visibleToggle") {
Shinya Kitaoka 120a6e
      BoolParamField *controller_bpf = 0;
Shinya Kitaoka 120a6e
      QList<qwidget *=""> on_items;</qwidget>
Shinya Kitaoka 120a6e
      QList<qwidget *=""> off_items;</qwidget>
Shinya Kitaoka 120a6e
      while (!is.matchEndTag()) {
Shinya Kitaoka 120a6e
        std::string tagName;
Shinya Kitaoka 120a6e
        if (!is.matchTag(tagName)) throw TException("expected tag");
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        if (tagName ==
Shinya Kitaoka 120a6e
                "controller" || /*-- 表示をコントロールするチェックボックス --*/
Shinya Kitaoka 120a6e
            tagName == "on" || /*-- ONのとき表示されるインタフェース --*/
Shinya Kitaoka 120a6e
            tagName == "off") /*-- OFFのとき表示されるインタフェース --*/
Shinya Kitaoka 120a6e
        {
Shinya Kitaoka 120a6e
          std::string name;
Shinya Kitaoka 120a6e
          is >> name;
Shinya Kitaoka 120a6e
          is.matchEndTag();
Shinya Kitaoka 120a6e
          for (int r = 0; r < m_mainLayout->rowCount(); r++) {
Shinya Kitaoka 120a6e
            QLayoutItem *li = m_mainLayout->itemAtPosition(r, 1);
Shinya Kitaoka 120a6e
            if (!li) continue;
Shinya Kitaoka 120a6e
            QWidget *w = li->widget();
Shinya Kitaoka 120a6e
            if (!w) continue;
Shinya Kitaoka 120a6e
            ParamField *pf = dynamic_cast<paramfield *="">(w);</paramfield>
Shinya Kitaoka 120a6e
            if (pf) {
Shinya Kitaoka 120a6e
              if (pf->getParamName().toStdString() == name) {
Shinya Kitaoka 120a6e
                if (tagName == "controller")
Shinya Kitaoka 120a6e
                  controller_bpf = dynamic_cast<boolparamfield *="">(pf);</boolparamfield>
Shinya Kitaoka 120a6e
                else if (tagName == "on") {
Shinya Kitaoka 120a6e
                  on_items.push_back(w);
Shinya Kitaoka 120a6e
                  on_items.push_back(
Shinya Kitaoka 120a6e
                      m_mainLayout->itemAtPosition(r, 0)->widget());
Shinya Kitaoka 120a6e
                } else if (tagName == "off") {
Shinya Kitaoka 120a6e
                  off_items.push_back(w);
Shinya Kitaoka 120a6e
                  off_items.push_back(
Shinya Kitaoka 120a6e
                      m_mainLayout->itemAtPosition(r, 0)->widget());
Shinya Kitaoka 120a6e
                }
Shinya Kitaoka 120a6e
              }
Shinya Kitaoka 120a6e
            }
Shinya Kitaoka 120a6e
            /*-- 入れ子のLayoutも1段階探す --*/
Shinya Kitaoka 120a6e
            else {
Shinya Kitaoka 120a6e
              QGridLayout *gridLay = dynamic_cast<qgridlayout *="">(w->layout());</qgridlayout>
Shinya Kitaoka 120a6e
              if (!gridLay) continue;
Shinya Kitaoka 120a6e
              for (int r_s = 0; r_s < gridLay->rowCount(); r_s++) {
Shinya Kitaoka 120a6e
                QLayoutItem *li_s = gridLay->itemAtPosition(r_s, 1);
Shinya Kitaoka 120a6e
                if (!li_s) continue;
Shinya Kitaoka 120a6e
                ParamField *pf_s = dynamic_cast<paramfield *="">(li_s->widget());</paramfield>
Shinya Kitaoka 120a6e
                if (pf_s) {
Shinya Kitaoka 120a6e
                  if (pf_s->getParamName().toStdString() == name) {
Shinya Kitaoka 120a6e
                    if (tagName == "controller")
Shinya Kitaoka 120a6e
                      controller_bpf = dynamic_cast<boolparamfield *="">(pf_s);</boolparamfield>
Shinya Kitaoka 120a6e
                    else if (tagName == "on") {
Shinya Kitaoka 120a6e
                      on_items.push_back(pf_s);
Shinya Kitaoka 120a6e
                      on_items.push_back(
Shinya Kitaoka 120a6e
                          gridLay->itemAtPosition(r_s, 0)->widget());
Shinya Kitaoka 120a6e
                    } else if (tagName == "off") {
Shinya Kitaoka 120a6e
                      off_items.push_back(pf_s);
Shinya Kitaoka 120a6e
                      off_items.push_back(
Shinya Kitaoka 120a6e
                          gridLay->itemAtPosition(r_s, 0)->widget());
Shinya Kitaoka 120a6e
                    }
Shinya Kitaoka 120a6e
                  }
Shinya Kitaoka 120a6e
                }
Shinya Kitaoka 120a6e
              }
Shinya Kitaoka 120a6e
            }
Shinya Kitaoka 120a6e
          }
Shinya Kitaoka 120a6e
        } else
Shinya Kitaoka 120a6e
          throw TException("unexpected tag " + tagName);
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
      /*-- 表示コントロールをconnect --*/
Shinya Kitaoka 120a6e
      if (controller_bpf) {
Shinya Kitaoka 120a6e
        /*-- ラベルとWidgetを両方表示/非表示 --*/
Shinya Kitaoka 120a6e
        for (int i = 0; i < on_items.size(); i++) {
Shinya Kitaoka 120a6e
          connect(controller_bpf, SIGNAL(toggled(bool)), on_items[i],
Shinya Kitaoka 120a6e
                  SLOT(setVisible(bool)));
Shinya Kitaoka 120a6e
          on_items[i]->hide();
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
        for (int i = 0; i < off_items.size(); i++) {
Shinya Kitaoka 120a6e
          connect(controller_bpf, SIGNAL(toggled(bool)), off_items[i],
Shinya Kitaoka 120a6e
                  SLOT(setHidden(bool)));
Shinya Kitaoka 120a6e
          off_items[i]->show();
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
      } else
Shinya Kitaoka 120a6e
        std::cout << "controller_bpf NOT found!" << std::endl;
Shinya Kitaoka 120a6e
    } else
Shinya Kitaoka 120a6e
      throw TException("unexpected tag " + tagName);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (isVertical == false && m_horizontalLayout) {
Shinya Kitaoka 120a6e
    m_horizontalLayout->addStretch(1);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamsPage::setPageSpace() {
Shinya Kitaoka 120a6e
  if (m_fields.count() != 0) {
Shinya Kitaoka 120a6e
    QWidget *spaceWidget = new QWidget();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    int currentRow = m_mainLayout->rowCount();
Shinya Kitaoka 120a6e
    m_mainLayout->addWidget(spaceWidget, currentRow, 0, 1, 2);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    for (int i = 0; i < currentRow; i++) m_mainLayout->setRowStretch(i, 0);
Shinya Kitaoka 120a6e
    m_mainLayout->setRowStretch(currentRow, 1);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
void ParamsPage::beginGroup(const char *name) {
Shinya Kitaoka 120a6e
  m_groupLayout = new QGridLayout();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  QGroupBox *group = new QGroupBox(QString::fromUtf8(name), this);
Shinya Kitaoka 120a6e
  group->setLayout(m_groupLayout);
Shinya Kitaoka 120a6e
  m_mainLayout->addWidget(group, m_mainLayout->rowCount(), 0, 1, 2);
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void ParamsPage::endGroup() { m_groupLayout = NULL; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void ParamsPage::addWidget(QWidget *field, bool isVertical) {
Shinya Kitaoka 120a6e
  QLabel *label  = NULL;
Shinya Kitaoka 120a6e
  ParamField *pf = qobject_cast<paramfield *="">(field);</paramfield>
Shinya Kitaoka 120a6e
  if (pf) {
Shinya Kitaoka 120a6e
    label = new QLabel(pf->getUIName(), this);
Shinya Kitaoka 120a6e
    label->setObjectName("FxSettingsLabel");
Shinya Kitaoka 120a6e
    if (!pf->getDescription().isEmpty())
Shinya Kitaoka 120a6e
      label->setToolTip(pf->getDescription());
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (isVertical) {
Shinya Kitaoka 120a6e
    if (m_groupLayout) {
Shinya Kitaoka 120a6e
      int row = m_groupLayout->rowCount();
Shinya Kitaoka 120a6e
      if (label)
Shinya Kitaoka 120a6e
        m_groupLayout->addWidget(label, row, 0,
Shinya Kitaoka 120a6e
                                 Qt::AlignRight | Qt::AlignVCenter);
Shinya Kitaoka 120a6e
      m_groupLayout->addWidget(field, row, 1);
Shinya Kitaoka 120a6e
    } else {
Shinya Kitaoka 120a6e
      int row = m_mainLayout->rowCount();
Shinya Kitaoka 120a6e
      if (label)
Shinya Kitaoka 120a6e
        m_mainLayout->addWidget(label, row, 0,
Shinya Kitaoka 120a6e
                                Qt::AlignRight | Qt::AlignVCenter);
Shinya Kitaoka 120a6e
      m_mainLayout->addWidget(field, row, 1);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    if (!m_horizontalLayout) {
Shinya Kitaoka 120a6e
      m_horizontalLayout = new QHBoxLayout();
Shinya Kitaoka 120a6e
      m_horizontalLayout->setMargin(0);
Shinya Kitaoka 120a6e
      m_horizontalLayout->setSpacing(5);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    m_horizontalLayout->addWidget(field);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
#define TOONZ_DEFINE_NEW_COMPONENT(NAME, MAKE)                                 \
Shinya Kitaoka 120a6e
  QWidget *ParamsPage::NAME(TFx *fx, const char *name) {                       \
Shinya Kitaoka 120a6e
    TParamP param = fx->getParams()->getParam(name);                           \
Shinya Kitaoka 120a6e
    if (!param) return NULL;                                                   \
Shinya Kitaoka 120a6e
    QString const paramName =                                                  \
Shinya Kitaoka 120a6e
        QString::fromStdString(fx->getFxType() + "." + name);                  \
Shinya Kitaoka 120a6e
    ParamField *field = MAKE(this, paramName, param);                          \
Shinya Kitaoka 120a6e
    if (!field) return NULL;                                                   \
Shinya Kitaoka 120a6e
    m_fields.push_back(field);                                                 \
Shinya Kitaoka 120a6e
    connect(field, SIGNAL(currentParamChanged()), m_paramViewer,               \
Shinya Kitaoka 120a6e
            SIGNAL(currentFxParamChanged()));                                  \
Shinya Kitaoka 120a6e
    connect(field, SIGNAL(actualParamChanged()), m_paramViewer,                \
Shinya Kitaoka 120a6e
            SIGNAL(actualFxParamChanged()));                                   \
Shinya Kitaoka 120a6e
    connect(field, SIGNAL(paramKeyToggle()), m_paramViewer,                    \
Shinya Kitaoka 120a6e
            SIGNAL(paramKeyChanged()));                                        \
Shinya Kitaoka 120a6e
    return field;                                                              \
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TOONZ_DEFINE_NEW_COMPONENT(newParamField, ParamField::create);
Toshihiro Shimizu 890ddd
TOONZ_DEFINE_NEW_COMPONENT(newLineEdit, make_lineedit);
Toshihiro Shimizu 890ddd
TOONZ_DEFINE_NEW_COMPONENT(newSlider, make_slider);
Toshihiro Shimizu 890ddd
TOONZ_DEFINE_NEW_COMPONENT(newSpinBox, make_spinbox);
Toshihiro Shimizu 890ddd
TOONZ_DEFINE_NEW_COMPONENT(newCheckBox, make_checkbox);
Toshihiro Shimizu 890ddd
TOONZ_DEFINE_NEW_COMPONENT(newRadioButton, make_radiobutton);
Toshihiro Shimizu 890ddd
TOONZ_DEFINE_NEW_COMPONENT(newComboBox, make_combobox);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 810553
#undef TOONZ_DEFINE_NEW_COMPONENT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamsPage::setFx(const TFxP ¤tFx, const TFxP &actualFx, int frame) {
Shinya Kitaoka 120a6e
  assert(currentFx);
Shinya Kitaoka 120a6e
  assert(actualFx);
Shinya Kitaoka 120a6e
  for (int i = 0; i < (int)m_fields.size(); i++) {
Shinya Kitaoka 120a6e
    ParamField *field = m_fields[i];
Shinya Kitaoka 120a6e
    QString fieldName = field->getParamName();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TFxP fx = getCurrentFx(currentFx, actualFx->getFxId());
Shinya Kitaoka 120a6e
    assert(fx.getPointer());
Shinya Kitaoka 120a6e
    TParamP currentParam =
Shinya Kitaoka 120a6e
        currentFx->getParams()->getParam(fieldName.toStdString());
Shinya Kitaoka 120a6e
    TParamP actualParam =
Shinya Kitaoka 120a6e
        actualFx->getParams()->getParam(fieldName.toStdString());
Shinya Kitaoka 120a6e
    assert(currentParam);
Shinya Kitaoka 120a6e
    assert(actualParam);
Shinya Kitaoka 120a6e
    field->setParam(currentParam, actualParam, frame);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (actualFx->getInputPortCount() > 0)
Shinya Kitaoka 120a6e
    m_fxHistogramRender->computeHistogram(actualFx->getInputPort(0)->getFx(),
Shinya Kitaoka 120a6e
                                          frame);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamsPage::setPointValue(int index, const TPointD &p) {
Shinya Kitaoka 120a6e
  if (0 <= index && index < (int)m_fields.size())
Shinya Kitaoka 120a6e
    m_fields[index]->setPointValue(p);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamsPage::update(int frame) {
Shinya Kitaoka 120a6e
  int i;
Shinya Kitaoka 120a6e
  for (i = 0; i < (int)m_fields.size(); i++) {
Shinya Kitaoka 120a6e
    ParamField *field = m_fields[i];
Shinya Kitaoka 120a6e
    field->update(frame);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace {
Shinya Kitaoka 120a6e
shun_iwasawa a0fb33
QSize getItemSize(QLayoutItem *item) {
shun_iwasawa a0fb33
  // layout case
shun_iwasawa a0fb33
  QHBoxLayout *hLay = dynamic_cast<qhboxlayout *="">(item->layout());</qhboxlayout>
shun_iwasawa a0fb33
  if (hLay) {
shun_iwasawa a0fb33
    int tmpWidth = 0, tmpHeight = 0;
shun_iwasawa a0fb33
    for (int c = 0; c < hLay->count(); c++) {
shun_iwasawa a0fb33
      QLayoutItem *subItem = hLay->itemAt(c);
shun_iwasawa a0fb33
      if (!subItem) continue;
shun_iwasawa a0fb33
      QSize subItemSize = getItemSize(subItem);
shun_iwasawa a0fb33
      tmpWidth += subItemSize.width();
shun_iwasawa a0fb33
      if (tmpHeight < subItemSize.height()) tmpHeight = subItemSize.height();
shun_iwasawa a0fb33
    }
shun_iwasawa a0fb33
    tmpWidth += (hLay->count() - 1) * 5;
shun_iwasawa a0fb33
    return QSize(tmpWidth, tmpHeight);
shun_iwasawa a0fb33
  }
shun_iwasawa a0fb33
shun_iwasawa a0fb33
  ParamField *pF = dynamic_cast<paramfield *="">(item->widget());</paramfield>
shun_iwasawa a0fb33
  if (pF) return pF->getPreferedSize();
shun_iwasawa a0fb33
shun_iwasawa a0fb33
  Separator *sep = dynamic_cast<separator *="">(item->widget());</separator>
shun_iwasawa a0fb33
  if (sep) return QSize(0, 16);
shun_iwasawa a0fb33
shun_iwasawa a0fb33
  Histogram *histo = dynamic_cast<histogram *="">(item->widget());</histogram>
shun_iwasawa a0fb33
  if (histo) return QSize(278, 162);
shun_iwasawa a0fb33
shun-iwasawa cac18a
  RgbLinkButtons *linkBut = dynamic_cast<rgblinkbuttons *="">(item->widget());</rgblinkbuttons>
shun_iwasawa a0fb33
  if (linkBut) return QSize(0, 21);
shun_iwasawa a0fb33
shun_iwasawa a0fb33
  return QSize();
shun_iwasawa a0fb33
}
shun_iwasawa a0fb33
Shinya Kitaoka 120a6e
void updateMaximumPageSize(QGridLayout *layout, int &maxLabelWidth,
Shinya Kitaoka 120a6e
                           int &maxWidgetWidth, int &fieldsHeight) {
Shinya Kitaoka 120a6e
  /*-- Label側の横幅の最大値を得る --*/
Shinya Kitaoka 120a6e
  for (int r = 0; r < layout->rowCount(); r++) {
Shinya Kitaoka 120a6e
    /*-- アイテムが無ければ次の行へ --*/
Shinya Kitaoka 120a6e
    if (!layout->itemAtPosition(r, 0)) continue;
Shinya Kitaoka 120a6e
    /*-- ラベルの横幅を得て、最大値を更新していく --*/
Shinya Kitaoka 120a6e
    QLabel *label =
Shinya Kitaoka 120a6e
        dynamic_cast<qlabel *="">(layout->itemAtPosition(r, 0)->widget());</qlabel>
Shinya Kitaoka 120a6e
    QGroupBox *gBox =
Shinya Kitaoka 120a6e
        dynamic_cast<qgroupbox *="">(layout->itemAtPosition(r, 0)->widget());</qgroupbox>
Shinya Kitaoka 120a6e
    if (label) {
Shinya Kitaoka 120a6e
      int tmpWidth = label->fontMetrics().width(label->text());
Shinya Kitaoka 120a6e
      if (maxLabelWidth < tmpWidth) maxLabelWidth = tmpWidth;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    /*-- PlugInFxのGroupパラメータのサイズ --*/
Shinya Kitaoka 120a6e
    else if (gBox) {
Shinya Kitaoka 120a6e
      QGridLayout *gridLay = dynamic_cast<qgridlayout *="">(gBox->layout());</qgridlayout>
Shinya Kitaoka 120a6e
      if (gridLay) {
Shinya Kitaoka 120a6e
        updateMaximumPageSize(gridLay, maxLabelWidth, maxWidgetWidth,
Shinya Kitaoka 120a6e
                              fieldsHeight);
Shinya Kitaoka 120a6e
        /*-- GroupBoxのマージン --*/
Shinya Kitaoka 120a6e
        maxLabelWidth += 10;
Shinya Kitaoka 120a6e
        maxWidgetWidth += 10;
Shinya Kitaoka 120a6e
        fieldsHeight += 20;
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*-- Widget側の最適な縦サイズおよび横幅の最大値を得る --*/
shun-iwasawa 6e910b
  QMap<int, int=""> heightsByMode;</int,>
shun-iwasawa 6e910b
  int maxModeHeight = 0;
Shinya Kitaoka 120a6e
  for (int r = 0; r < layout->rowCount(); r++) {
Shinya Kitaoka 120a6e
    /*-- Column1にある可能性のあるもの:ParamField, Histogram, Layout,
shun-iwasawa cac18a
     * RgbLinkButtons --*/
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    QLayoutItem *item = layout->itemAtPosition(r, 1);
Shinya Kitaoka 120a6e
    if (!item) continue;
shun_iwasawa a0fb33
shun-iwasawa 6e910b
    ModeSensitiveBox *box = dynamic_cast<modesensitivebox *="">(item->widget());</modesensitivebox>
shun-iwasawa 6e910b
    if (box) {
shun-iwasawa 6e910b
      // if (box->isHidden()) continue;
shun-iwasawa 6e910b
      QGridLayout *innerLay = dynamic_cast<qgridlayout *="">(box->layout());</qgridlayout>
shun-iwasawa 6e910b
      if (!innerLay) continue;
shun-iwasawa 6e910b
      int tmpHeight = 0;
shun-iwasawa 6e910b
      updateMaximumPageSize(innerLay, maxLabelWidth, maxWidgetWidth, tmpHeight);
shun-iwasawa 6e910b
      for (int mode : box->modes()) {
shun-iwasawa 6e910b
        heightsByMode[mode] += tmpHeight;
shun-iwasawa 6e910b
        maxModeHeight = std::max(maxModeHeight, heightsByMode[mode]);
shun-iwasawa 6e910b
      }
shun-iwasawa 6e910b
shun-iwasawa 6e910b
      // attempt to align the label column
shun-iwasawa 6e910b
      innerLay->setColumnMinimumWidth(0, maxLabelWidth);
shun-iwasawa 6e910b
      continue;
shun-iwasawa 6e910b
    }
shun-iwasawa 6e910b
shun-iwasawa cac18a
    QSize itemSize = getItemSize(item);
shun_iwasawa a0fb33
    if (maxWidgetWidth < itemSize.width()) maxWidgetWidth = itemSize.width();
shun_iwasawa a0fb33
    fieldsHeight += itemSize.height();
Shinya Kitaoka 120a6e
  }
shun-iwasawa 6e910b
  if (maxModeHeight > 0) fieldsHeight += maxModeHeight;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (layout->rowCount() > 1) fieldsHeight += (layout->rowCount() - 1) * 10;
Toshihiro Shimizu 890ddd
}
shun-iwasawa cac18a
};  // namespace
Toshihiro Shimizu 890ddd
shun-iwasawa 0ed559
QSize ParamsPage::getPreferredSize() {
Shinya Kitaoka 120a6e
  int maxLabelWidth  = 0;
Shinya Kitaoka 120a6e
  int maxWidgetWidth = 0;
Shinya Kitaoka 120a6e
  int fieldsHeight   = 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  updateMaximumPageSize(m_mainLayout, maxLabelWidth, maxWidgetWidth,
Shinya Kitaoka 120a6e
                        fieldsHeight);
shun_iwasawa a0fb33
  return QSize(maxLabelWidth + maxWidgetWidth +
shun_iwasawa a0fb33
                   m_mainLayout->horizontalSpacing() +
shun_iwasawa a0fb33
                   2 * m_mainLayout->margin(),
shun_iwasawa a0fb33
               fieldsHeight + 2 * m_mainLayout->margin() +
shun_iwasawa a0fb33
                   31 /* spacing for the swatch */);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// ParamsPageSet
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#if QT_VERSION >= 0x050500
Toshihiro Shimizu 890ddd
ParamsPageSet::ParamsPageSet(QWidget *parent, Qt::WindowFlags flags)
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
ParamsPageSet::ParamsPageSet(QWidget *parent, Qt::WFlags flags)
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
    : QWidget(parent, flags)
shun-iwasawa 0ed559
    , m_preferredSize(0, 0)
Shinya Kitaoka 120a6e
    , m_helpFilePath("")
Shinya Kitaoka 120a6e
    , m_helpCommand("") {
Shinya Kitaoka 120a6e
  // TabBar
Shinya Kitaoka 120a6e
  m_tabBar = new TabBar(this);
Shinya Kitaoka 120a6e
  // This widget is used to set the background color of the tabBar
Kite 521c84
  // using the styleSheet and to draw the two lines on the bottom size.
Shinya Kitaoka 120a6e
  m_tabBarContainer = new TabBarContainter(this);
Shinya Kitaoka 120a6e
  m_pagesList       = new QStackedWidget(this);
Shinya Kitaoka 120a6e
Kite 521c84
  m_helpButton = new QPushButton(tr(""), this);
Kite 521c84
  m_helpButton->setIconSize(QSize(20, 20));
Kite 521c84
  m_helpButton->setIcon(createQIcon("help"));
Kite 521c84
  m_helpButton->setFixedWidth(28);
Kite 521c84
  m_helpButton->setToolTip(tr("View help page"));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_parent = dynamic_cast<paramviewer *="">(parent);</paramviewer>
Shinya Kitaoka 120a6e
  m_pageFxIndexTable.clear();
Shinya Kitaoka 120a6e
  m_tabBar->setDrawBase(false);
Shinya Kitaoka 120a6e
  m_tabBar->setObjectName("FxSettingsTabBar");
Shinya Kitaoka 120a6e
  m_helpButton->setFixedHeight(20);
Shinya Kitaoka 120a6e
  m_helpButton->setObjectName("FxSettingsHelpButton");
Shinya Kitaoka 120a6e
  m_helpButton->setFocusPolicy(Qt::NoFocus);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //----layout
Shinya Kitaoka 120a6e
  QVBoxLayout *mainLayout = new QVBoxLayout();
Kite 521c84
  mainLayout->setMargin(0);
Shinya Kitaoka 120a6e
  mainLayout->setSpacing(0);
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    QHBoxLayout *hLayout = new QHBoxLayout();
Shinya Kitaoka 120a6e
    hLayout->setMargin(0);
Kite 521c84
    hLayout->addSpacing(0);
Shinya Kitaoka 120a6e
    {
Shinya Kitaoka 120a6e
      hLayout->addWidget(m_tabBar);
Shinya Kitaoka 120a6e
      hLayout->addStretch(1);
Shinya Kitaoka 120a6e
      hLayout->addWidget(m_helpButton);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    m_tabBarContainer->setLayout(hLayout);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    mainLayout->addWidget(m_tabBarContainer);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    mainLayout->addWidget(m_pagesList);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    mainLayout->addWidget(new Separator("", this), 0);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  setLayout(mainLayout);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  connect(m_tabBar, SIGNAL(currentChanged(int)), this, SLOT(setPage(int)));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_helpButton->hide();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ParamsPageSet::~ParamsPageSet() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamsPageSet::setPage(int index) {
Shinya Kitaoka 120a6e
  if (m_tabBar->count() == 0 || m_pagesList->count() == 0) return;
Shinya Kitaoka 120a6e
  assert(index >= 0 && index < m_pagesList->count());
Shinya Kitaoka 120a6e
  m_pagesList->setCurrentIndex(index);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamsPageSet::setFx(const TFxP ¤tFx, const TFxP &actualFx,
Shinya Kitaoka 120a6e
                          int frame) {
Shinya Kitaoka 120a6e
  TMacroFx *currentFxMacro = dynamic_cast<tmacrofx *="">(currentFx.getPointer());</tmacrofx>
Shinya Kitaoka 120a6e
  if (currentFxMacro) {
Shinya Kitaoka 120a6e
    TMacroFx *actualFxMacro = dynamic_cast<tmacrofx *="">(actualFx.getPointer());</tmacrofx>
Shinya Kitaoka 120a6e
    assert(actualFxMacro);
Shinya Kitaoka 120a6e
    const std::vector<tfxp> ¤tFxMacroFxs = currentFxMacro->getFxs();</tfxp>
Shinya Kitaoka 120a6e
    const std::vector<tfxp> &actualFxMacroFxs  = actualFxMacro->getFxs();</tfxp>
Shinya Kitaoka 120a6e
    assert(currentFxMacroFxs.size() == actualFxMacroFxs.size());
Shinya Kitaoka 120a6e
    for (int i = 0; i < m_pagesList->count(); i++) {
Shinya Kitaoka 120a6e
      ParamsPage *page = getParamsPage(i);
Shinya Kitaoka 120a6e
      if (!page || !m_pageFxIndexTable.contains(page)) continue;
Shinya Kitaoka 120a6e
      int index = m_pageFxIndexTable[page];
Shinya Kitaoka 120a6e
      page->setFx(currentFxMacroFxs[index], actualFxMacroFxs[index], frame);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    for (int i = 0; i < m_pagesList->count(); i++) {
Shinya Kitaoka 120a6e
      ParamsPage *page = getParamsPage(i);
Shinya Kitaoka 120a6e
      if (!page) continue;
Shinya Kitaoka 120a6e
      page->setFx(currentFx, actualFx, frame);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamsPageSet::updatePage(int frame, bool onlyParam) {
Shinya Kitaoka 120a6e
  if (!m_pagesList) return;
Shinya Kitaoka 120a6e
  int i;
Shinya Kitaoka 120a6e
  for (i = 0; i < m_pagesList->count(); i++) {
Shinya Kitaoka 120a6e
    ParamsPage *page = getParamsPage(i);
Shinya Kitaoka 120a6e
    if (!page) continue;
Shinya Kitaoka 120a6e
    page->update(frame);
Shinya Kitaoka 120a6e
    if (!onlyParam) page->getFxHistogramRender()->invalidateFrame(frame);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamsPageSet::setScene(ToonzScene *scene) {
Shinya Kitaoka 120a6e
  if (!m_pagesList) return;
Shinya Kitaoka 120a6e
  int i;
Shinya Kitaoka 120a6e
  for (i = 0; i < m_pagesList->count(); i++) {
Shinya Kitaoka 120a6e
    ParamsPage *page = getParamsPage(i);
Shinya Kitaoka 120a6e
    if (!page) continue;
Shinya Kitaoka 120a6e
    page->getFxHistogramRender()->setScene(scene);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamsPageSet::setIsCameraViewMode(bool isCameraViewMode) {
Shinya Kitaoka 120a6e
  if (!m_pagesList) return;
Shinya Kitaoka 120a6e
  int i;
Shinya Kitaoka 120a6e
  for (i = 0; i < m_pagesList->count(); i++) {
Shinya Kitaoka 120a6e
    ParamsPage *page = getParamsPage(i);
Shinya Kitaoka 120a6e
    if (!page) continue;
Shinya Kitaoka 120a6e
    page->getFxHistogramRender()->setIsCameraViewMode(isCameraViewMode);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ParamsPage *ParamsPageSet::createParamsPage() {
Shinya Kitaoka 120a6e
  return new ParamsPage(this, m_parent);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamsPageSet::addParamsPage(ParamsPage *page, const char *name) {
Shinya Kitaoka 120a6e
  /*-- このFxで最大サイズのページに合わせてダイアログをリサイズ --*/
shun-iwasawa 0ed559
  QSize pagePreferredSize = page->getPreferredSize();
shun-iwasawa 0ed559
  m_preferredSize         = m_preferredSize.expandedTo(
shun-iwasawa 0ed559
      pagePreferredSize + QSize(m_tabBarContainer->height() + 2,
shun-iwasawa 0ed559
                                2)); /*-- 2は上下左右のマージン --*/
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  QScrollArea *pane = new QScrollArea(this);
Shinya Kitaoka 120a6e
  pane->setWidgetResizable(true);
Shinya Kitaoka 120a6e
  pane->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
Shinya Kitaoka 120a6e
  pane->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
Shinya Kitaoka 120a6e
  pane->setWidget(page);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_tabBar->addSimpleTab(QString::fromUtf8(name));
Shinya Kitaoka 120a6e
  m_pagesList->addWidget(pane);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamsPageSet::createControls(const TFxP &fx, int index) {
Shinya Kitaoka 120a6e
  if (TMacroFx *macroFx = dynamic_cast<tmacrofx *="">(fx.getPointer())) {</tmacrofx>
Shinya Kitaoka 120a6e
    const std::vector<tfxp> &fxs = macroFx->getFxs();</tfxp>
Shinya Kitaoka 120a6e
    for (int i = 0; i < (int)fxs.size(); i++) createControls(fxs[i], i);
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (RasterFxPluginHost *plugin =
Shinya Kitaoka 120a6e
          dynamic_cast<rasterfxpluginhost *="">(fx.getPointer())) {</rasterfxpluginhost>
Shinya Kitaoka 120a6e
    plugin->build(this);
Shinya Kitaoka 120a6e
    std::string url = plugin->getUrl();
Shinya Kitaoka 120a6e
    if (!url.empty()) {
Shinya Kitaoka 120a6e
      connect(m_helpButton, SIGNAL(pressed()), this, SLOT(openHelpUrl()));
Shinya Kitaoka 120a6e
      m_helpButton->show();
Shinya Kitaoka 120a6e
      m_helpUrl = url;
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TFilePath fp = ToonzFolder::getProfileFolder() + "layouts" + "fxs" +
Shinya Kitaoka 120a6e
                 (fx->getFxType() + ".xml");
shun-iwasawa 5b724a
Shinya Kitaoka 120a6e
  TIStream is(fp);
Shinya Kitaoka 120a6e
  if (!is) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (fx->getParams()->getParamCount()) {
Shinya Kitaoka 120a6e
    try {
Shinya Kitaoka 120a6e
      std::string tagName;
Shinya Kitaoka 120a6e
      if (!is.matchTag(tagName) || tagName != "fxlayout")
Shinya Kitaoka 120a6e
        throw TException("expected <fxlayout>");</fxlayout>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      m_helpFilePath = is.getTagAttribute("help_file");
Shinya Kitaoka 120a6e
      if (m_helpFilePath != "") {
Shinya Kitaoka 120a6e
        connect(m_helpButton, SIGNAL(pressed()), this, SLOT(openHelpFile()));
Shinya Kitaoka 120a6e
        m_helpButton->show();
Shinya Kitaoka 120a6e
        /*-- pdfファイルのページ指定など、引数が必要な場合の追加fragmentを取得
Shinya Kitaoka 120a6e
         * --*/
Shinya Kitaoka 120a6e
        m_helpCommand = is.getTagAttribute("help_command");
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      while (!is.matchEndTag()) createPage(is, fx, index);
Shinya Kitaoka 120a6e
    } catch (TException const &) {
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  // else createEmptyPage();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ParamsPage *ParamsPageSet::getCurrentParamsPage() const {
Shinya Kitaoka 120a6e
  QScrollArea *scrollAreaPage =
Shinya Kitaoka 120a6e
      dynamic_cast<qscrollarea *="">(m_pagesList->currentWidget());</qscrollarea>
Shinya Kitaoka 120a6e
  assert(scrollAreaPage);
Shinya Kitaoka 120a6e
  return dynamic_cast<paramspage *="">(scrollAreaPage->widget());</paramspage>
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ParamsPage *ParamsPageSet::getParamsPage(int index) const {
Shinya Kitaoka 120a6e
  QScrollArea *scrollAreaPage =
Shinya Kitaoka 120a6e
      dynamic_cast<qscrollarea *="">(m_pagesList->widget(index));</qscrollarea>
Shinya Kitaoka 120a6e
  assert(scrollAreaPage);
Shinya Kitaoka 120a6e
  return dynamic_cast<paramspage *="">(scrollAreaPage->widget());</paramspage>
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamsPageSet::createPage(TIStream &is, const TFxP &fx, int index) {
Shinya Kitaoka 120a6e
  std::string tagName;
Shinya Kitaoka 120a6e
  if (!is.matchTag(tagName) || tagName != "page")
Shinya Kitaoka 120a6e
    throw TException("expected <page>");</page>
Kite 521c84
  std::string pageName         = is.getTagAttribute("name");
Shinya Kitaoka 120a6e
  if (pageName == "") pageName = "page";
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ParamsPage *paramsPage = new ParamsPage(this, m_parent);
Shinya Kitaoka 120a6e
  paramsPage->setPage(is, fx);
Shinya Kitaoka 120a6e
shun-iwasawa 0ed559
  connect(paramsPage, SIGNAL(preferredPageSizeChanged()), this,
shun-iwasawa 0ed559
          SLOT(recomputePreferredSize()));
shun-iwasawa 0ed559
Shinya Kitaoka 120a6e
  /*-- このFxで最大サイズのページに合わせてダイアログをリサイズ --*/
shun-iwasawa 0ed559
  QSize pagePreferredSize = paramsPage->getPreferredSize();
shun-iwasawa 0ed559
  m_preferredSize         = m_preferredSize.expandedTo(
shun-iwasawa 0ed559
      pagePreferredSize + QSize(m_tabBarContainer->height() + 2,
shun-iwasawa 0ed559
                                2)); /*-- 2は上下左右のマージン --*/
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  QScrollArea *scrollAreaPage = new QScrollArea(this);
Shinya Kitaoka 120a6e
  scrollAreaPage->setWidgetResizable(true);
Shinya Kitaoka 120a6e
  scrollAreaPage->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
Shinya Kitaoka 120a6e
  scrollAreaPage->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
Shinya Kitaoka 120a6e
  scrollAreaPage->setWidget(paramsPage);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  QString str;
Shinya Kitaoka 120a6e
  m_tabBar->addSimpleTab(str.fromStdString(pageName));
Shinya Kitaoka 120a6e
  m_pagesList->addWidget(scrollAreaPage);
Shinya Kitaoka 120a6e
  if (index >= 0) m_pageFxIndexTable[paramsPage] = index;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
shun-iwasawa 0ed559
void ParamsPageSet::recomputePreferredSize() {
shun-iwasawa 0ed559
  QSize newSize(0, 0);
shun-iwasawa 0ed559
  for (int i = 0; i < m_pagesList->count(); i++) {
shun-iwasawa 0ed559
    QScrollArea *area = dynamic_cast<qscrollarea *="">(m_pagesList->widget(i));</qscrollarea>
shun-iwasawa 0ed559
    if (!area) continue;
shun-iwasawa 0ed559
    ParamsPage *page = dynamic_cast<paramspage *="">(area->widget());</paramspage>
shun-iwasawa 0ed559
    if (!page) continue;
shun-iwasawa 0ed559
    QSize pagePreferredSize = page->getPreferredSize();
shun-iwasawa 0ed559
    newSize                 = newSize.expandedTo(pagePreferredSize +
shun-iwasawa 0ed559
                                 QSize(m_tabBarContainer->height() + 2, 2));
shun-iwasawa 0ed559
  }
shun-iwasawa 0ed559
  if (!newSize.isEmpty()) {
shun-iwasawa 0ed559
    m_preferredSize = newSize;
shun-iwasawa 0ed559
    // resize the parent FxSettings
shun-iwasawa 0ed559
    m_parent->notifyPreferredSizeChanged(m_preferredSize + QSize(2, 50));
shun-iwasawa 0ed559
  }
shun-iwasawa 0ed559
}
shun-iwasawa 0ed559
shun-iwasawa 0ed559
//-----------------------------------------------------------------------------
shun-iwasawa 0ed559
Toshihiro Shimizu 890ddd
/* TODO: Webサイト内のヘルプに対応すべきか検討 2016.02.01 shun_iwasawa */
Shinya Kitaoka 120a6e
void ParamsPageSet::openHelpFile() {
Shinya Kitaoka 120a6e
  if (m_helpFilePath == "") return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // if (m_helpCommand != "")
Shinya Kitaoka 120a6e
  //	commandString += m_helpCommand + " ";
Shinya Kitaoka 120a6e
shun-iwasawa 5b724a
  // Get UI language as set in "Preferences"
shun-iwasawa 5b724a
  QString currentLanguage = Preferences::instance()->getCurrentLanguage();
shun-iwasawa 5b724a
  std::string helpDocLang = currentLanguage.toStdString();
shun-iwasawa 5b724a
shun-iwasawa 5b724a
  // Assume associated language subdir exists
shun-iwasawa 5b724a
  TFilePath helpFp = TEnv::getStuffDir() + "doc" + helpDocLang + m_helpFilePath;
shun-iwasawa 5b724a
shun-iwasawa 5b724a
  // Verify subdir exists; if not, default to standard doc dir
shun-iwasawa 5b724a
  if (!TFileStatus(helpFp).doesExist()) {
shun-iwasawa 5b724a
    helpFp = TEnv::getStuffDir() + "doc" + m_helpFilePath;
shun-iwasawa 5b724a
  }
shun-iwasawa 5b724a
Shinya Kitaoka 120a6e
  // commandString +=
Shinya Kitaoka 120a6e
  // QString::fromStdWString(helpFp.getWideString()).toStdString();
Shinya Kitaoka 120a6e
  // QString command = QString::fromStdString(m_helpFilePath);
Shinya Kitaoka 120a6e
  // system(commandString.c_str());
Shinya Kitaoka 120a6e
  // QProcess process;
Shinya Kitaoka 120a6e
  // process.start(command);
Shinya Kitaoka 120a6e
  QDesktopServices::openUrl(
Shinya Kitaoka 120a6e
      QUrl::fromLocalFile(QString::fromStdWString(helpFp.getWideString())));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamsPageSet::openHelpUrl() {
Shinya Kitaoka 120a6e
  QDesktopServices::openUrl(QUrl(QString(m_helpUrl.c_str())));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// ParamViewer
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#if QT_VERSION >= 0x050500
Toshihiro Shimizu 890ddd
ParamViewer::ParamViewer(QWidget *parent, Qt::WindowFlags flags)
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
ParamViewer::ParamViewer(QWidget *parent, Qt::WFlags flags)
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 120a6e
    : QFrame(parent, flags), m_fx(0) {
Shinya Kitaoka 120a6e
  m_tablePageSet = new QStackedWidget(this);
Shinya Kitaoka 120a6e
  m_tablePageSet->addWidget(new QWidget());
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*-- SwatchViewerを表示/非表示するボタン --*/
Shinya Kitaoka 120a6e
  QPushButton *showSwatchButton = new QPushButton("", this);
Shinya Kitaoka 120a6e
  QLabel *swatchLabel           = new QLabel(tr("Swatch Viewer"), this);
Shinya Kitaoka 120a6e
shun_iwasawa b102ca
  swatchLabel->setObjectName("TitleTxtLabel");
Kite 521c84
  showSwatchButton->setObjectName("menuToggleButton");
Shinya Kitaoka 120a6e
  showSwatchButton->setFixedSize(15, 15);
Kite 521c84
  showSwatchButton->setIcon(createQIcon("menu_toggle"));
Shinya Kitaoka 120a6e
  showSwatchButton->setCheckable(true);
Shinya Kitaoka 120a6e
  showSwatchButton->setChecked(false);
Shinya Kitaoka 120a6e
  showSwatchButton->setFocusPolicy(Qt::NoFocus);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  QVBoxLayout *mainLayout = new QVBoxLayout(this);
Kite 521c84
  mainLayout->setMargin(0);
Shinya Kitaoka 120a6e
  mainLayout->setSpacing(0);
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    mainLayout->addWidget(m_tablePageSet, 1);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    QHBoxLayout *showPreviewButtonLayout = new QHBoxLayout(this);
Shinya Kitaoka 120a6e
    showPreviewButtonLayout->setMargin(3);
Shinya Kitaoka 120a6e
    showPreviewButtonLayout->setSpacing(3);
Shinya Kitaoka 120a6e
    {
Shinya Kitaoka 120a6e
      showPreviewButtonLayout->addWidget(showSwatchButton, 0);
Shinya Kitaoka 120a6e
      showPreviewButtonLayout->addWidget(swatchLabel, 0);
Shinya Kitaoka 120a6e
      showPreviewButtonLayout->addStretch(1);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    mainLayout->addLayout(showPreviewButtonLayout, 0);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  setLayout(mainLayout);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  connect(showSwatchButton, SIGNAL(toggled(bool)), this,
Shinya Kitaoka 120a6e
          SIGNAL(showSwatchButtonToggled(bool)));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ParamViewer::~ParamViewer() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamViewer::setFx(const TFxP ¤tFx, const TFxP &actualFx, int frame,
Shinya Kitaoka 120a6e
                        ToonzScene *scene) {
Shinya Kitaoka 120a6e
  if (!actualFx) {
Shinya Kitaoka 120a6e
    m_tablePageSet->setCurrentIndex(0);
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  std::string name = actualFx->getFxType();
Shinya Kitaoka 120a6e
  if (name == "macroFx") {
Shinya Kitaoka 120a6e
    TMacroFx *macroFx = dynamic_cast<tmacrofx *="">(currentFx.getPointer());</tmacrofx>
Shinya Kitaoka 120a6e
    if (macroFx) name = macroFx->getMacroFxType();
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int currentIndex = -1;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  QMap<std::string, int="">::iterator it;</std::string,>
Shinya Kitaoka 120a6e
  it = m_tableFxIndex.find(name);
Shinya Kitaoka 120a6e
  if (it == m_tableFxIndex.end()) {
Shinya Kitaoka 120a6e
    ParamsPageSet *pageSet = new ParamsPageSet(this);
Shinya Kitaoka 120a6e
    currentIndex           = m_tablePageSet->addWidget(pageSet);
Shinya Kitaoka 120a6e
    m_tableFxIndex[name]   = currentIndex;
Shinya Kitaoka 120a6e
    pageSet->createControls(actualFx);
Shinya Kitaoka 120a6e
  } else
Shinya Kitaoka 120a6e
    currentIndex = it.value();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  assert(currentIndex >= 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_tablePageSet->setCurrentIndex(currentIndex);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  getCurrentPageSet()->setScene(scene);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_fx != currentFx) {
Shinya Kitaoka 120a6e
    getCurrentPageSet()->setFx(currentFx, actualFx, frame);
manongjohn b13816
    if (m_actualFx != actualFx) {
manongjohn b13816
      m_actualFx = actualFx;
shun-iwasawa 0ed559
      QSize pageViewerPreferredSize =
shun-iwasawa 0ed559
          getCurrentPageSet()->getPreferredSize() + QSize(2, 50);
shun-iwasawa 0ed559
      emit preferredSizeChanged(pageViewerPreferredSize);
manongjohn b13816
    }
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamViewer::setScene(ToonzScene *scene) {
Shinya Kitaoka 120a6e
  ParamsPageSet *paramsPageSet = getCurrentPageSet();
Shinya Kitaoka 120a6e
  if (!paramsPageSet) return;
Shinya Kitaoka 120a6e
  paramsPageSet->setScene(scene);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamViewer::setIsCameraViewMode(bool isCameraViewMode) {
Shinya Kitaoka 120a6e
  ParamsPageSet *paramsPageSet = getCurrentPageSet();
Shinya Kitaoka 120a6e
  if (!paramsPageSet) return;
Shinya Kitaoka 120a6e
  paramsPageSet->setIsCameraViewMode(isCameraViewMode);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamViewer::update(int frame, bool onlyParam) {
Shinya Kitaoka 120a6e
  ParamsPageSet *paramsPageSet = getCurrentPageSet();
Shinya Kitaoka 120a6e
  if (!paramsPageSet) return;
Shinya Kitaoka 120a6e
  paramsPageSet->updatePage(frame, onlyParam);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ParamViewer::setPointValue(int index, const TPointD &p) {
Shinya Kitaoka 120a6e
  // Search the index-th param among all pages
Shinya Kitaoka 120a6e
  ParamsPageSet *pageSet = getCurrentPageSet();
Shinya Kitaoka 120a6e
  ParamsPage *page       = 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  for (int i = 0; i < pageSet->getParamsPageCount(); ++i) {
Shinya Kitaoka 120a6e
    page            = pageSet->getParamsPage(i);
Shinya Kitaoka 120a6e
    int paramsCount = page->m_fields.count();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    if (index <= paramsCount) break;
Shinya Kitaoka 120a6e
    index -= paramsCount;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (page) page->setPointValue(index, p);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ParamsPageSet *ParamViewer::getCurrentPageSet() const {
Shinya Kitaoka 120a6e
  return dynamic_cast<paramspageset *="">(m_tablePageSet->currentWidget());</paramspageset>
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// FxSettings
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
FxSettings::FxSettings(QWidget *parent, const TPixel32 &checkCol1,
Shinya Kitaoka 120a6e
                       const TPixel32 &checkCol2)
Shinya Kitaoka 120a6e
    : QSplitter(Qt::Vertical, parent)
Shinya Kitaoka 120a6e
    , m_frameHandle(0)
Shinya Kitaoka 120a6e
    , m_fxHandle(0)
Shinya Kitaoka 120a6e
    , m_xsheetHandle(0)
Shinya Kitaoka 120a6e
    , m_sceneHandle(0)
Shinya Kitaoka 120a6e
    , m_levelHandle(0)
Shinya Kitaoka 120a6e
    , m_objectHandle(0)
Shinya Kitaoka 120a6e
    , m_checkCol1(checkCol1)
Shinya Kitaoka 120a6e
    , m_checkCol2(checkCol2)
Shinya Kitaoka 120a6e
    , m_isCameraModeView(false)
manongjohn b13816
    , m_container_height(184)
manongjohn b13816
    , m_container_width(390) {
Shinya Kitaoka 120a6e
  // param viewer
Shinya Kitaoka 120a6e
  m_paramViewer = new ParamViewer(this);
Shinya Kitaoka 120a6e
  // swatch
Shinya Kitaoka 120a6e
  QWidget *swatchContainer = new QWidget(this);
Shinya Kitaoka 120a6e
  m_viewer                 = new SwatchViewer(swatchContainer);
Shinya Kitaoka 120a6e
  setWhiteBg();
Shinya Kitaoka 120a6e
  createToolBar();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_paramViewer->setMinimumHeight(50);
Shinya Kitaoka 120a6e
  swatchContainer->setSizePolicy(QSizePolicy::MinimumExpanding,
Shinya Kitaoka 120a6e
                                 QSizePolicy::MinimumExpanding);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //---layout
Shinya Kitaoka 120a6e
  addWidget(m_paramViewer);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  QVBoxLayout *swatchLayout = new QVBoxLayout(swatchContainer);
Shinya Kitaoka 120a6e
  swatchLayout->setMargin(0);
Shinya Kitaoka 120a6e
  swatchLayout->setSpacing(0);
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    swatchLayout->addWidget(m_viewer, 0, Qt::AlignHCenter);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    QHBoxLayout *toolBarLayout = new QHBoxLayout(swatchContainer);
Shinya Kitaoka 120a6e
    {
Shinya Kitaoka 120a6e
      toolBarLayout->addWidget(m_toolBar, 0,
Shinya Kitaoka 120a6e
                               Qt::AlignHCenter | Qt::AlignBottom);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    swatchLayout->addLayout(toolBarLayout);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  swatchContainer->setLayout(swatchLayout);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  addWidget(swatchContainer);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //---signal-slot connections
Shinya Kitaoka 120a6e
  bool ret = true;
Shinya Kitaoka 120a6e
  ret      = ret && connect(m_paramViewer, SIGNAL(currentFxParamChanged()),
Shinya Kitaoka 120a6e
                       SLOT(updateViewer()));
Kite 521c84
  ret = ret &&
Shinya Kitaoka 120a6e
        connect(m_viewer, SIGNAL(pointPositionChanged(int, const TPointD &)),
Shinya Kitaoka 120a6e
                SLOT(onPointChanged(int, const TPointD &)));
shun-iwasawa 0ed559
  ret = ret && connect(m_paramViewer, SIGNAL(preferredSizeChanged(QSize)), this,
shun-iwasawa 0ed559
                       SLOT(onPreferredSizeChanged(QSize)));
Shinya Kitaoka 120a6e
  ret = ret && connect(m_paramViewer, SIGNAL(showSwatchButtonToggled(bool)),
Shinya Kitaoka 120a6e
                       this, SLOT(onShowSwatchButtonToggled(bool)));
Shinya Kitaoka 120a6e
  assert(ret);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  swatchContainer->hide();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // Swatch updates should happen only at the end of a separator resize op.
Shinya Kitaoka 120a6e
  setStretchFactor(0, 1);
Shinya Kitaoka 120a6e
  setStretchFactor(1, 0);
Shinya Kitaoka 120a6e
  setOpaqueResize(false);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
FxSettings::~FxSettings() {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::setFxHandle(TFxHandle *fxHandle) {
Shinya Kitaoka 120a6e
  m_fxHandle = fxHandle;
Shinya Kitaoka 120a6e
  m_keyframeNavigator->setFxHandle(m_fxHandle);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ParamField::setFxHandle(m_fxHandle);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::setFrameHandle(TFrameHandle *frameHandle) {
Shinya Kitaoka 120a6e
  m_frameHandle = frameHandle;
Shinya Kitaoka 120a6e
  m_keyframeNavigator->setFrameHandle(m_frameHandle);
Shinya Kitaoka 120a6e
  m_frameNavigator->setFrameHandle(m_frameHandle);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::setXsheetHandle(TXsheetHandle *xsheetHandle) {
Shinya Kitaoka 120a6e
  m_xsheetHandle = xsheetHandle;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::setSceneHandle(TSceneHandle *sceneHandle) {
Shinya Kitaoka 120a6e
  m_sceneHandle = sceneHandle;
Shinya Kitaoka 120a6e
  setCurrentScene();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::setLevelHandle(TXshLevelHandle *levelHandle) {
Shinya Kitaoka 120a6e
  m_levelHandle = levelHandle;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::setObjectHandle(TObjectHandle *objectHandle) {
Shinya Kitaoka 120a6e
  m_objectHandle = objectHandle;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::createToolBar() {
Shinya Kitaoka 120a6e
  m_toolBar = new QToolBar(this);
Shinya Kitaoka 120a6e
  m_toolBar->setMovable(false);
Kite 521c84
  m_toolBar->setFixedHeight(24);
Kite 521c84
  m_toolBar->setIconSize(QSize(20, 20));
shun_iwasawa 4a5f42
  m_toolBar->setObjectName("MediumPaddingToolBar");
Shinya Kitaoka 120a6e
  // m_toolBar->setSizePolicy(QSizePolicy::MinimumExpanding,
Shinya Kitaoka 120a6e
  // QSizePolicy::MinimumExpanding);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // View mode
Shinya Kitaoka 120a6e
  QActionGroup *viewModeActGroup = new QActionGroup(m_toolBar);
Shinya Kitaoka 120a6e
  viewModeActGroup->setExclusive(false);
Shinya Kitaoka 120a6e
  // camera
Kite 521c84
  QIcon camera       = createQIcon("camera");
Shinya Kitaoka 120a6e
  QAction *cameraAct = new QAction(camera, tr("&Camera Preview"), m_toolBar);
Shinya Kitaoka 120a6e
  cameraAct->setCheckable(true);
Shinya Kitaoka 120a6e
  viewModeActGroup->addAction(cameraAct);
Shinya Kitaoka 120a6e
  m_toolBar->addAction(cameraAct);
Shinya Kitaoka 120a6e
  // preview
Kite 521c84
  QIcon preview       = createQIcon("preview");
Shinya Kitaoka 120a6e
  QAction *previewAct = new QAction(preview, tr("&Preview"), m_toolBar);
Shinya Kitaoka 120a6e
  previewAct->setCheckable(true);
Shinya Kitaoka 120a6e
  viewModeActGroup->addAction(previewAct);
Shinya Kitaoka 120a6e
  m_toolBar->addAction(previewAct);
Shinya Kitaoka 120a6e
  connect(viewModeActGroup, SIGNAL(triggered(QAction *)),
Shinya Kitaoka 120a6e
          SLOT(onViewModeChanged(QAction *)));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_toolBar->addSeparator();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  QActionGroup *viewModeGroup = new QActionGroup(m_toolBar);
Shinya Kitaoka 120a6e
  viewModeGroup->setExclusive(true);
Shinya Kitaoka 120a6e
Kite 521c84
  QAction *whiteBg = new QAction(createQIcon("preview_white"),
Shinya Kitaoka 120a6e
                                 tr("&White Background"), m_toolBar);
Shinya Kitaoka 120a6e
  whiteBg->setCheckable(true);
Shinya Kitaoka 120a6e
  whiteBg->setChecked(true);
Shinya Kitaoka 120a6e
  viewModeGroup->addAction(whiteBg);
Shinya Kitaoka 120a6e
  connect(whiteBg, SIGNAL(triggered()), this, SLOT(setWhiteBg()));
Shinya Kitaoka 120a6e
  m_toolBar->addAction(whiteBg);
Shinya Kitaoka 120a6e
Kite 521c84
  QAction *blackBg = new QAction(createQIcon("preview_black"),
Shinya Kitaoka 120a6e
                                 tr("&Black Background"), m_toolBar);
Shinya Kitaoka 120a6e
  blackBg->setCheckable(true);
Shinya Kitaoka 120a6e
  viewModeGroup->addAction(blackBg);
Shinya Kitaoka 120a6e
  connect(blackBg, SIGNAL(triggered()), this, SLOT(setBlackBg()));
Shinya Kitaoka 120a6e
  m_toolBar->addAction(blackBg);
Shinya Kitaoka 120a6e
Kite 521c84
  m_checkboardBg = new QAction(createQIcon("preview_checkboard"),
Shinya Kitaoka 120a6e
                               tr("&Checkered Background"), m_toolBar);
Shinya Kitaoka 120a6e
  m_checkboardBg->setCheckable(true);
Shinya Kitaoka 120a6e
  viewModeGroup->addAction(m_checkboardBg);
Shinya Kitaoka 120a6e
  connect(m_checkboardBg, SIGNAL(triggered()), this, SLOT(setCheckboardBg()));
Shinya Kitaoka 120a6e
  m_toolBar->addAction(m_checkboardBg);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_toolBar->addSeparator();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_keyframeNavigator = new FxKeyframeNavigator(m_toolBar);
Shinya Kitaoka 120a6e
  m_toolBar->addWidget(m_keyframeNavigator);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_toolBar->addSeparator();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_frameNavigator = new FrameNavigator(m_toolBar);
Shinya Kitaoka 120a6e
  m_frameNavigator->setFrameHandle(m_frameHandle);
Shinya Kitaoka 120a6e
  m_toolBar->addWidget(m_frameNavigator);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::setFx(const TFxP ¤tFx, const TFxP &actualFx) {
Shinya Kitaoka 120a6e
  // disconnecting from the fxChanged() signals avoid useless and dangerous
Shinya Kitaoka 120a6e
  // updates!!!
Shinya Kitaoka 120a6e
  if (m_fxHandle)
Shinya Kitaoka 120a6e
    disconnect(m_fxHandle, SIGNAL(fxChanged()), this,
Shinya Kitaoka 120a6e
               SLOT(updateParamViewer()));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TFxP currentFxWithoutCamera = 0;
Shinya Kitaoka 120a6e
  if (currentFx && actualFx)
Shinya Kitaoka 120a6e
    currentFxWithoutCamera = getCurrentFx(currentFx, actualFx->getFxId());
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (currentFxWithoutCamera)
Shinya Kitaoka 120a6e
    TFxUtil::setKeyframe(currentFxWithoutCamera, m_frameHandle->getFrameIndex(),
Shinya Kitaoka 120a6e
                         actualFx, m_frameHandle->getFrameIndex());
Toshihiro Shimizu 890ddd
Kite 521c84
  ToonzScene *scene        = 0;
Shinya Kitaoka 120a6e
  if (m_sceneHandle) scene = m_sceneHandle->getScene();
Toshihiro Shimizu 890ddd
Kite 521c84
  int frameIndex                = 0;
Shinya Kitaoka 120a6e
  if (m_frameHandle) frameIndex = m_frameHandle->getFrameIndex();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_paramViewer->setFx(currentFxWithoutCamera, actualFx, frameIndex, scene);
Shinya Kitaoka 120a6e
  m_paramViewer->setIsCameraViewMode(m_isCameraModeView);
Shinya Kitaoka 120a6e
  m_viewer->setCameraMode(m_isCameraModeView);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TDimension cameraSize = TDimension(-1, -1);
Shinya Kitaoka 120a6e
  if (scene) cameraSize = scene->getCurrentCamera()->getRes();
Shinya Kitaoka 120a6e
  m_viewer->setCameraSize(cameraSize);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_viewer->setFx(currentFx, actualFx, frameIndex);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_fxHandle)
Shinya Kitaoka 120a6e
    connect(m_fxHandle, SIGNAL(fxChanged()), this, SLOT(updateParamViewer()));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::setCurrentFrame() {
Shinya Kitaoka 120a6e
  int frame = m_frameHandle->getFrameIndex();
Shinya Kitaoka 120a6e
  m_paramViewer->update(frame, false);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // if(m_isCameraModeView)
Shinya Kitaoka 120a6e
  setCurrentFx();
Shinya Kitaoka 120a6e
  m_viewer->updateFrame(frame);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::changeTitleBar(TFx *fx) {
manongjohn b13816
  DockWidget *popup = dynamic_cast<dockwidget *="">(parentWidget());</dockwidget>
Shinya Kitaoka 120a6e
  if (!popup) return;
Toshihiro Shimizu 890ddd
shun-iwasawa 86dc52
  QString titleText(tr("Fx Settings"));
Shinya Kitaoka 120a6e
  if (fx) {
Shinya Kitaoka 120a6e
    titleText += tr(" : ");
Shinya Kitaoka 120a6e
    titleText += QString::fromStdWString(fx->getName());
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  popup->setWindowTitle(titleText);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::setCurrentFx() {
Shinya Kitaoka 120a6e
  TFx *currFx = m_fxHandle->getFx();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TFxP actualFx, currentFx;
Shinya Kitaoka 120a6e
  if (!currFx || 0 != dynamic_cast<txsheetfx *="">(currFx)) {</txsheetfx>
Shinya Kitaoka 120a6e
    actualFx = currentFx = TFxP();
Shinya Kitaoka 120a6e
    setFx(actualFx, currentFx);
Shinya Kitaoka 120a6e
    changeTitleBar(currentFx.getPointer());
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  TFxP fx(currFx);
Shinya Kitaoka 120a6e
  bool hasEmptyInput = false;
Shinya Kitaoka 120a6e
  if (TZeraryColumnFx *zfx = dynamic_cast<tzerarycolumnfx *="">(fx.getPointer()))</tzerarycolumnfx>
Shinya Kitaoka 120a6e
    fx = zfx->getZeraryFx();
Shinya Kitaoka 120a6e
  else
Kite 521c84
    hasEmptyInput   = hasEmptyInputPort(fx);
Shinya Kitaoka 120a6e
  int frame         = m_frameHandle->getFrame();
Shinya Kitaoka 120a6e
  ToonzScene *scene = m_sceneHandle->getScene();
Shinya Kitaoka 120a6e
  actualFx          = fx;
Shinya Kitaoka 120a6e
  bool isEnabled    = actualFx->getAttributes()->isEnabled();
Shinya Kitaoka 120a6e
  actualFx->getAttributes()->enable(true);
Shinya Kitaoka 120a6e
  if (hasEmptyInput)
Shinya Kitaoka 120a6e
    currentFx = actualFx;
shun-iwasawa da0933
  else if (m_viewer->isEnabled()) {
Shinya Kitaoka 120a6e
    if (!m_isCameraModeView)
Shinya Kitaoka 120a6e
      currentFx = buildSceneFx(scene, frame, actualFx, false);
Shinya Kitaoka 120a6e
    else {
Shinya Kitaoka 120a6e
      const TRenderSettings rs =
Shinya Kitaoka 120a6e
          scene->getProperties()->getPreviewProperties()->getRenderSettings();
Shinya Kitaoka 120a6e
      currentFx = buildPartialSceneFx(scene, (double)frame, actualFx, 1, false);
Shinya Kitaoka 120a6e
    }
shun-iwasawa da0933
  } else
shun-iwasawa da0933
    currentFx = TFxP();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (currentFx) currentFx = currentFx->clone(true);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // se al frame corrente non c'e' il livello a cui e' applicato l'effetto:
Shinya Kitaoka 120a6e
  // current=0, actual!=0
Shinya Kitaoka 120a6e
  if (!currentFx) currentFx = actualFx->clone(false);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  actualFx->getAttributes()->enable(isEnabled);
Shinya Kitaoka 120a6e
  setFx(currentFx, actualFx);
Shinya Kitaoka 120a6e
  changeTitleBar(currentFx.getPointer());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::setCurrentScene() {
Shinya Kitaoka 120a6e
  ToonzScene *scene = m_sceneHandle->getScene();
Shinya Kitaoka 120a6e
  m_paramViewer->setScene(scene);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::notifySceneChanged() {
Shinya Kitaoka 120a6e
  TPixel32 col1, col2;
Shinya Kitaoka 120a6e
  Preferences::instance()->getChessboardColors(col1, col2);
Shinya Kitaoka 120a6e
  setCheckboardColors(col1, col2);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::showEvent(QShowEvent *event) {
Shinya Kitaoka 120a6e
  setCurrentFx();
Shinya Kitaoka 120a6e
  setCurrentFrame();
Shinya Kitaoka 120a6e
  connect(m_frameHandle, SIGNAL(frameSwitched()), SLOT(setCurrentFrame()));
Shinya Kitaoka 120a6e
  if (m_fxHandle) {
Shinya Kitaoka 120a6e
    connect(m_paramViewer, SIGNAL(actualFxParamChanged()), m_fxHandle,
Shinya Kitaoka 120a6e
            SIGNAL(fxChanged()));
Shinya Kitaoka 120a6e
    connect(m_fxHandle, SIGNAL(fxChanged()), SLOT(updateParamViewer()));
Shinya Kitaoka 120a6e
    connect(m_fxHandle, SIGNAL(fxSettingsShouldBeSwitched()),
Shinya Kitaoka 120a6e
            SLOT(setCurrentFx()));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (m_sceneHandle) {
Shinya Kitaoka 120a6e
    connect(m_sceneHandle, SIGNAL(sceneChanged()), this,
Shinya Kitaoka 120a6e
            SLOT(notifySceneChanged()));
Shinya Kitaoka 120a6e
    connect(m_sceneHandle, SIGNAL(sceneSwitched()), this,
Shinya Kitaoka 120a6e
            SLOT(setCurrentScene()));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (m_xsheetHandle)
Shinya Kitaoka 120a6e
    connect(m_xsheetHandle, SIGNAL(xsheetChanged()), SLOT(setCurrentFx()));
Shinya Kitaoka 120a6e
  if (m_levelHandle)
Shinya Kitaoka 120a6e
    connect(m_levelHandle, SIGNAL(xshLevelChanged()), SLOT(setCurrentFx()));
Shinya Kitaoka 120a6e
  if (m_objectHandle)
Shinya Kitaoka 120a6e
    connect(m_objectHandle, SIGNAL(objectChanged(bool)), SLOT(setCurrentFx()));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::hideEvent(QHideEvent *) {
Shinya Kitaoka 120a6e
  setFx(0, 0);
Shinya Kitaoka 120a6e
  disconnect(m_frameHandle, SIGNAL(frameSwitched()), this,
Shinya Kitaoka 120a6e
             SLOT(setCurrentFrame()));
Shinya Kitaoka 120a6e
  if (m_fxHandle) {
Shinya Kitaoka 120a6e
    disconnect(m_fxHandle, SIGNAL(fxChanged()), this, SLOT(setCurrentFx()));
Shinya Kitaoka 120a6e
    disconnect(m_fxHandle, SIGNAL(fxChanged()), this,
Shinya Kitaoka 120a6e
               SLOT(updateParamViewer()));
Shinya Kitaoka 120a6e
    disconnect(m_fxHandle, SIGNAL(fxSettingsShouldBeSwitched()), this,
Shinya Kitaoka 120a6e
               SLOT(setCurrentFx()));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (m_sceneHandle) {
Shinya Kitaoka 120a6e
    disconnect(m_sceneHandle, SIGNAL(sceneChanged()), this,
Shinya Kitaoka 120a6e
               SLOT(notifySceneChanged()));
Shinya Kitaoka 120a6e
    disconnect(m_sceneHandle, SIGNAL(sceneSwitched()), this,
Shinya Kitaoka 120a6e
               SLOT(setCurrentScene()));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (m_xsheetHandle)
Shinya Kitaoka 120a6e
    disconnect(m_xsheetHandle, SIGNAL(xsheetChanged()), this,
Shinya Kitaoka 120a6e
               SLOT(setCurrentFx()));
Shinya Kitaoka 120a6e
  if (m_levelHandle)
Shinya Kitaoka 120a6e
    disconnect(m_levelHandle, SIGNAL(xshLevelChanged()), this,
Shinya Kitaoka 120a6e
               SLOT(setCurrentFx()));
Shinya Kitaoka 120a6e
  if (m_objectHandle)
Shinya Kitaoka 120a6e
    disconnect(m_objectHandle, SIGNAL(objectChanged(bool)), this,
Shinya Kitaoka 120a6e
               SLOT(setCurrentFx()));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::setCheckboardColors(const TPixel32 &col1,
Shinya Kitaoka 120a6e
                                     const TPixel32 &col2) {
Shinya Kitaoka 120a6e
  m_checkCol1 = col1;
Shinya Kitaoka 120a6e
  m_checkCol2 = col2;
Shinya Kitaoka 120a6e
  if (m_checkboardBg->isChecked())
Shinya Kitaoka 120a6e
    m_viewer->setBgPainter(m_checkCol1, m_checkCol2);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::setWhiteBg() { m_viewer->setBgPainter(TPixel32::White); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::setBlackBg() { m_viewer->setBgPainter(TPixel32::Black); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::setCheckboardBg() {
Shinya Kitaoka 120a6e
  m_viewer->setBgPainter(m_checkCol1, m_checkCol2);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::updateViewer() {
Shinya Kitaoka 120a6e
  if (m_viewer->isEnabled())
Shinya Kitaoka 120a6e
    m_viewer->updateFrame(m_frameHandle->getFrameIndex());
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::updateParamViewer() {
Shinya Kitaoka 120a6e
  if (!m_paramViewer || !m_frameHandle) return;
Shinya Kitaoka 120a6e
  m_paramViewer->update(m_frameHandle->getFrameIndex(), true);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::onPointChanged(int index, const TPointD &p) {
Shinya Kitaoka 120a6e
  m_paramViewer->setPointValue(index, p);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::onViewModeChanged(QAction *triggeredAct) {
Shinya Kitaoka 120a6e
  setFocus();
Shinya Kitaoka 120a6e
  QString name             = triggeredAct->text();
Shinya Kitaoka 120a6e
  bool actIsChecked        = triggeredAct->isChecked();
Shinya Kitaoka 120a6e
  QList<qaction *=""> actions = m_toolBar->actions();</qaction>
Shinya Kitaoka 120a6e
  QAction *cameraAct       = actions[0];
Shinya Kitaoka 120a6e
  QAction *previewAct      = actions[1];
Shinya Kitaoka 120a6e
  if (name == previewAct->text()) {
Shinya Kitaoka 120a6e
    if (cameraAct->isChecked()) cameraAct->setChecked(false);
Shinya Kitaoka 120a6e
    if (actIsChecked) {
Shinya Kitaoka 120a6e
      m_isCameraModeView = false;
Shinya Kitaoka 120a6e
      m_paramViewer->setIsCameraViewMode(false);
Shinya Kitaoka 120a6e
      setCurrentFx();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    m_viewer->setEnable(actIsChecked);
Shinya Kitaoka 120a6e
  } else if (name == cameraAct->text()) {
Shinya Kitaoka 120a6e
    if (previewAct->isChecked()) previewAct->setChecked(false);
Shinya Kitaoka 120a6e
    if (actIsChecked) {
Shinya Kitaoka 120a6e
      m_isCameraModeView = true;
Shinya Kitaoka 120a6e
      m_paramViewer->setIsCameraViewMode(true);
Shinya Kitaoka 120a6e
      setCurrentFx();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    m_viewer->setEnable(actIsChecked);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
shun-iwasawa 0ed559
void FxSettings::onPreferredSizeChanged(QSize pvBestSize) {
Shinya Kitaoka 120a6e
  QSize popupBestSize = pvBestSize;
manongjohn b13816
manongjohn b13816
  // Set minimum size, just in case
manongjohn b13816
  popupBestSize.setHeight(std::max(popupBestSize.height(), 85));
manongjohn b13816
  popupBestSize.setWidth(std::max(popupBestSize.width(), 390));
manongjohn b13816
Shinya Kitaoka 120a6e
  if (m_toolBar->isVisible()) {
manongjohn b13816
    popupBestSize += QSize(0, m_viewer->height() + m_toolBar->height() + 4);
manongjohn b13816
    popupBestSize.setWidth(
manongjohn b13816
        std::max(popupBestSize.width(), m_viewer->width() + 13));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
manongjohn b13816
  DockWidget *popup = dynamic_cast<dockwidget *="">(parentWidget());</dockwidget>
manongjohn b13816
  if (popup && popup->isFloating()) {
Shinya Kitaoka 120a6e
    QRect geom = popup->geometry();
Shinya Kitaoka 120a6e
    geom.setSize(popupBestSize);
Shinya Kitaoka 120a6e
    popup->setGeometry(geom);
Shinya Kitaoka 120a6e
    popup->update();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FxSettings::onShowSwatchButtonToggled(bool on) {
Shinya Kitaoka 120a6e
  QWidget *bottomContainer = widget(1);
Toshihiro Shimizu 890ddd
manongjohn b13816
  if (!on) {
Shinya Kitaoka 120a6e
    m_container_height =
Shinya Kitaoka 120a6e
        bottomContainer->height() + handleWidth() /* ハンドル幅 */;
manongjohn b13816
    m_container_width = m_viewer->width() + 13;
manongjohn b13816
  }
Shinya Kitaoka 120a6e
  bottomContainer->setVisible(on);
Toshihiro Shimizu 890ddd
manongjohn b13816
  DockWidget *popup = dynamic_cast<dockwidget *="">(parentWidget());</dockwidget>
manongjohn b13816
  if (popup && popup->isFloating()) {
Shinya Kitaoka 120a6e
    QRect geom = popup->geometry();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    int height_change = (on) ? m_container_height : -m_container_height;
manongjohn b13816
    int width_change  = 0;
manongjohn b13816
manongjohn b13816
    if (on && m_container_width > geom.width())
manongjohn b13816
      width_change = m_container_width - geom.width();
Toshihiro Shimizu 890ddd
manongjohn b13816
    geom.setSize(geom.size() + QSize(width_change, height_change));
Shinya Kitaoka 120a6e
    popup->setGeometry(geom);
Shinya Kitaoka 120a6e
    popup->update();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------