Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tools/tooloptions.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzTools includes
Toshihiro Shimizu 890ddd
#include "tools/tool.h"
Toshihiro Shimizu 890ddd
#include "tools/toolhandle.h"
Toshihiro Shimizu 890ddd
#include "tools/toolcommandids.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "selectiontool.h"
Toshihiro Shimizu 890ddd
#include "vectorselectiontool.h"
Toshihiro Shimizu 890ddd
#include "rasterselectiontool.h"
Toshihiro Shimizu 890ddd
#include "brushtool.h"
Toshihiro Shimizu 890ddd
#include "fullcolorbrushtool.h"
Toshihiro Shimizu 890ddd
#include "tooloptionscontrols.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//#include "rgbpickertool.h"
Toshihiro Shimizu 890ddd
#include "rulertool.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzQt includes
Toshihiro Shimizu 890ddd
#include "toonzqt/dvdialog.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/menubarcommand.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/gutil.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/dvscrollwidget.h"
Shinya Kitaoka 120a6e
// iwsw commented out temporarily
Toshihiro Shimizu 890ddd
//#include "toonzqt/ghibli_3dlut_converter.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzLib includes
Toshihiro Shimizu 890ddd
#include "toonz/tobjecthandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/tstageobject.h"
Toshihiro Shimizu 890ddd
#include "toonz/txsheethandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/tstageobjectspline.h"
Toshihiro Shimizu 890ddd
#include "toonz/tframehandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/palettecontroller.h"
Toshihiro Shimizu 890ddd
#include "toonz/txshlevelhandle.h"
Toshihiro Shimizu 890ddd
#include "toonz/preferences.h"
Toshihiro Shimizu 890ddd
#include "toonz/tstageobjecttree.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tproperty.h"
Toshihiro Shimizu 890ddd
#include "tenv.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// Qt includes
Toshihiro Shimizu 890ddd
#include <qpainter></qpainter>
Toshihiro Shimizu 890ddd
#include <qtoolbar></qtoolbar>
Toshihiro Shimizu 890ddd
#include <qdockwidget></qdockwidget>
Toshihiro Shimizu 890ddd
#include <qhboxlayout></qhboxlayout>
Toshihiro Shimizu 890ddd
#include <qcombobox></qcombobox>
Toshihiro Shimizu 890ddd
#include <qlabel></qlabel>
Toshihiro Shimizu 890ddd
#include <qpushbutton></qpushbutton>
Toshihiro Shimizu 890ddd
#include <qtoolbutton></qtoolbutton>
Toshihiro Shimizu 890ddd
#include <qresizeevent></qresizeevent>
Toshihiro Shimizu 890ddd
#include <qlist></qlist>
Toshihiro Shimizu 890ddd
#include <qsignalmapper></qsignalmapper>
Toshihiro Shimizu 890ddd
#include <qpushbutton></qpushbutton>
Toshihiro Shimizu 890ddd
#include <qpropertyanimation></qpropertyanimation>
Toshihiro Shimizu 890ddd
#include <qeasingcurve></qeasingcurve>
Toshihiro Shimizu 890ddd
#include <qstackedwidget></qstackedwidget>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// tcg includes
Toshihiro Shimizu 890ddd
#include "tcg/tcg_deleter_types.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
TEnv::IntVar ArrowGlobalKeyFrame("EditToolGlobalKeyFrame", 0);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// ToolOptionToolBar
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ToolOptionToolBar::ToolOptionToolBar(QWidget *parent) : QToolBar(parent) {
Shinya Kitaoka 120a6e
  setObjectName("toolOptionsPanel");
Shinya Kitaoka 120a6e
  setMaximumHeight(25);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ToolOptionToolBar::addSpacing(int width) {
Shinya Kitaoka 120a6e
  QWidget *spaceW = new QWidget(this);
Shinya Kitaoka 120a6e
  spaceW->setFixedWidth(width);
Shinya Kitaoka 120a6e
  addWidget(spaceW);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// ToolOptionsBox
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ToolOptionsBox::ToolOptionsBox(QWidget *parent) : QFrame(parent) {
Shinya Kitaoka 120a6e
  setObjectName("toolOptionsPanel");
Shinya Kitaoka 120a6e
  setStyleSheet("#toolOptionsPanel {border: 0px; margin: 1px;}");
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  setFrameStyle(QFrame::StyledPanel);
Shinya Kitaoka 120a6e
  setFixedHeight(26);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_layout = new QHBoxLayout;
Shinya Kitaoka 120a6e
  m_layout->setMargin(0);
shun-iwasawa c86c5d
  m_layout->setSpacing(5);
Shinya Kitaoka 120a6e
  m_layout->addSpacing(5);
Shinya Kitaoka 120a6e
  setLayout(m_layout);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ToolOptionsBox::~ToolOptionsBox() {
Shinya Kitaoka 120a6e
  std::for_each(m_controls.begin(), m_controls.end(),
Shinya Kitaoka 120a6e
                tcg::deleter<tooloptioncontrol>());</tooloptioncontrol>
Shinya Kitaoka 120a6e
  std::for_each(m_labels.begin(), m_labels.end(), tcg::deleter<qlabel>());</qlabel>
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
QLabel *ToolOptionsBox::addLabel(QString name) {
Shinya Kitaoka 120a6e
  QLabel *label = new QLabel(name);
Shinya Kitaoka 120a6e
  label->setFixedHeight(20);
Shinya Kitaoka 120a6e
  m_layout->addWidget(label);
Shinya Kitaoka 120a6e
  m_labels[name.toStdString()] = label;
Shinya Kitaoka 120a6e
  return label;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ToolOptionsBox::addLabel(std::string propName, QLabel *label) {
Shinya Kitaoka 120a6e
  m_labels[propName] = label;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ToolOptionsBox::addSeparator() {
Shinya Kitaoka 120a6e
  DVGui::Separator *separator = new DVGui::Separator();
Shinya Kitaoka 120a6e
  separator->setOrientation(false);
Shinya Kitaoka 120a6e
  separator->setFixedWidth(17);
Shinya Kitaoka 120a6e
  m_layout->addWidget(separator, 0);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ToolOptionsBox::addControl(ToolOptionControl *control) {
Shinya Kitaoka 120a6e
  m_controls[control->propertyName()] = control;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ToolOptionControl *ToolOptionsBox::control(
Shinya Kitaoka 120a6e
    const std::string &controlName) const {
Shinya Kitaoka 120a6e
  QMap<std::string, *="" tooloptioncontrol="">::const_iterator ct =</std::string,>
Shinya Kitaoka 120a6e
      m_controls.find(controlName);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  return (ct == m_controls.end()) ? 0 : ct.value();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ToolOptionsBox::updateStatus() {
Shinya Kitaoka 120a6e
  QMap<std::string, *="" tooloptioncontrol="">::iterator it;</std::string,>
Shinya Kitaoka 120a6e
  for (it = m_controls.begin(); it != m_controls.end(); it++)
Shinya Kitaoka 120a6e
    it.value()->updateStatus();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// ToolOptionControlBuilder
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ToolOptionControlBuilder::ToolOptionControlBuilder(ToolOptionsBox *panel,
Shinya Kitaoka 120a6e
                                                   TTool *tool,
Shinya Kitaoka 120a6e
                                                   TPaletteHandle *pltHandle,
Shinya Kitaoka 120a6e
                                                   ToolHandle *toolHandle)
Shinya Kitaoka 120a6e
    : m_panel(panel)
Shinya Kitaoka 120a6e
    , m_tool(tool)
Shinya Kitaoka 120a6e
    , m_pltHandle(pltHandle)
Shinya Kitaoka 120a6e
    , m_toolHandle(toolHandle)
Shinya Kitaoka 120a6e
    , m_singleValueWidgetType(SLIDER)
Shinya Kitaoka 120a6e
    , m_enumWidgetType(COMBOBOX) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
QLabel *ToolOptionControlBuilder::addLabel(TProperty *p) {
Shinya Kitaoka 120a6e
  QLabel *label = new QLabel(p->getQStringName());
Shinya Kitaoka 120a6e
  hLayout()->addWidget(label, 0);
Shinya Kitaoka 120a6e
  return label;
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void ToolOptionControlBuilder::visit(TDoubleProperty *p) {
Shinya Kitaoka 120a6e
  QLabel *label = addLabel(p);
Shinya Kitaoka 120a6e
  m_panel->addLabel(p->getName(), label);
Shinya Kitaoka 120a6e
  ToolOptionSlider *control = new ToolOptionSlider(m_tool, p, m_toolHandle);
Shinya Kitaoka 120a6e
  hLayout()->addWidget(control, 100);
Shinya Kitaoka 120a6e
  // storing the control in the map for updating values later
Shinya Kitaoka 120a6e
  m_panel->addControl(control);
Shinya Kitaoka 120a6e
  CommandManager *cm = CommandManager::instance();
Shinya Kitaoka 120a6e
  if (p->getName() == "Size:") {
Shinya Kitaoka 120a6e
    QAction *a;
Shinya Kitaoka 120a6e
    a = cm->getAction("A_IncreaseMaxBrushThickness");
Shinya Kitaoka 120a6e
    control->addAction(a);
Shinya Kitaoka 120a6e
    QObject::connect(a, SIGNAL(triggered()), control, SLOT(increase()));
Shinya Kitaoka 120a6e
    a = cm->getAction("A_DecreaseMaxBrushThickness");
Shinya Kitaoka 120a6e
    control->addAction(a);
Shinya Kitaoka 120a6e
    QObject::connect(a, SIGNAL(triggered()), control, SLOT(decrease()));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (p->getName() == "Hardness:") {
Shinya Kitaoka 120a6e
    QAction *a;
Shinya Kitaoka 120a6e
    a = cm->getAction("A_IncreaseBrushHardness");
Shinya Kitaoka 120a6e
    control->addAction(a);
Shinya Kitaoka 120a6e
    QObject::connect(a, SIGNAL(triggered()), control, SLOT(increase()));
Shinya Kitaoka 120a6e
    a = cm->getAction("A_DecreaseBrushHardness");
Shinya Kitaoka 120a6e
    control->addAction(a);
Shinya Kitaoka 120a6e
    QObject::connect(a, SIGNAL(triggered()), control, SLOT(decrease()));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  hLayout()->addSpacing(5);
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void ToolOptionControlBuilder::visit(TDoublePairProperty *p) {
Shinya Kitaoka 120a6e
  QLabel *label = addLabel(p);
Shinya Kitaoka 120a6e
  m_panel->addLabel(p->getName(), label);
Shinya Kitaoka 120a6e
  ToolOptionPairSlider *control = new ToolOptionPairSlider(
Shinya Kitaoka 120a6e
      m_tool, p, QObject::tr("Min:"), QObject::tr("Max:"), m_toolHandle);
shun-iwasawa c86c5d
  hLayout()->addWidget(control, 150);
Shinya Kitaoka 120a6e
  m_panel->addControl(control);
Shinya Kitaoka 120a6e
shun_iwasawa d2802f
  if (p->getName() == "Size:" || p->getName() == "Size") {
Shinya Kitaoka 120a6e
    CommandManager *cm = CommandManager::instance();
Shinya Kitaoka 120a6e
    QAction *a;
Shinya Kitaoka 120a6e
    a = cm->getAction("A_IncreaseMaxBrushThickness");
Shinya Kitaoka 120a6e
    control->addAction(a);
Shinya Kitaoka 120a6e
    QObject::connect(a, SIGNAL(triggered()), control, SLOT(increaseMaxValue()));
Shinya Kitaoka 120a6e
    a = cm->getAction("A_DecreaseMaxBrushThickness");
Shinya Kitaoka 120a6e
    control->addAction(a);
Shinya Kitaoka 120a6e
    QObject::connect(a, SIGNAL(triggered()), control, SLOT(decreaseMaxValue()));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    a = cm->getAction("A_IncreaseMinBrushThickness");
Shinya Kitaoka 120a6e
    control->addAction(a);
Shinya Kitaoka 120a6e
    QObject::connect(a, SIGNAL(triggered()), control, SLOT(increaseMinValue()));
Shinya Kitaoka 120a6e
    a = cm->getAction("A_DecreaseMinBrushThickness");
Shinya Kitaoka 120a6e
    control->addAction(a);
Shinya Kitaoka 120a6e
    QObject::connect(a, SIGNAL(triggered()), control, SLOT(decreaseMinValue()));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  hLayout()->addSpacing(5);
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void ToolOptionControlBuilder::visit(TIntPairProperty *p) {
Shinya Kitaoka 120a6e
  QLabel *label = addLabel(p);
Shinya Kitaoka 120a6e
  m_panel->addLabel(p->getName(), label);
Shinya Kitaoka 120a6e
  ToolOptionIntPairSlider *control = new ToolOptionIntPairSlider(
Shinya Kitaoka 120a6e
      m_tool, p, QObject::tr("Min:"), QObject::tr("Max:"), m_toolHandle);
Shinya Kitaoka 120a6e
  hLayout()->addWidget(control, 100);
Shinya Kitaoka 120a6e
  m_panel->addControl(control);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (p->getName() == "Size:") {
Shinya Kitaoka 120a6e
    CommandManager *cm = CommandManager::instance();
Shinya Kitaoka 120a6e
    QAction *a;
Shinya Kitaoka 120a6e
    a = cm->getAction("A_IncreaseMaxBrushThickness");
Shinya Kitaoka 120a6e
    control->addAction(a);
Shinya Kitaoka 120a6e
    QObject::connect(a, SIGNAL(triggered()), control, SLOT(increaseMaxValue()));
Shinya Kitaoka 120a6e
    a = cm->getAction("A_DecreaseMaxBrushThickness");
Shinya Kitaoka 120a6e
    control->addAction(a);
Shinya Kitaoka 120a6e
    QObject::connect(a, SIGNAL(triggered()), control, SLOT(decreaseMaxValue()));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    a = cm->getAction("A_IncreaseMinBrushThickness");
Shinya Kitaoka 120a6e
    control->addAction(a);
Shinya Kitaoka 120a6e
    QObject::connect(a, SIGNAL(triggered()), control, SLOT(increaseMinValue()));
Shinya Kitaoka 120a6e
    a = cm->getAction("A_DecreaseMinBrushThickness");
Shinya Kitaoka 120a6e
    control->addAction(a);
Shinya Kitaoka 120a6e
    QObject::connect(a, SIGNAL(triggered()), control, SLOT(decreaseMinValue()));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  hLayout()->addSpacing(5);
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void ToolOptionControlBuilder::visit(TIntProperty *p) {
Shinya Kitaoka 120a6e
  QLabel *label = addLabel(p);
Shinya Kitaoka 120a6e
  m_panel->addLabel(p->getName(), label);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ToolOptionIntSlider *control =
Shinya Kitaoka 120a6e
      new ToolOptionIntSlider(m_tool, p, m_toolHandle);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (m_singleValueWidgetType == FIELD) {
Shinya Kitaoka 120a6e
    control->enableSlider(false);
Shinya Kitaoka 120a6e
    control->setFixedWidth(45);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  hLayout()->addWidget(control, 100);
Shinya Kitaoka 120a6e
  m_panel->addControl(control);
Shinya Kitaoka 120a6e
  if (p->getName() == "Size:") {
Shinya Kitaoka 120a6e
    CommandManager *cm = CommandManager::instance();
Shinya Kitaoka 120a6e
    QAction *a;
Shinya Kitaoka 120a6e
    a = cm->getAction("A_IncreaseMaxBrushThickness");
Shinya Kitaoka 120a6e
    control->addAction(a);
Shinya Kitaoka 120a6e
    QObject::connect(a, SIGNAL(triggered()), control, SLOT(increase()));
Shinya Kitaoka 120a6e
    a = cm->getAction("A_DecreaseMaxBrushThickness");
Shinya Kitaoka 120a6e
    control->addAction(a);
Shinya Kitaoka 120a6e
    QObject::connect(a, SIGNAL(triggered()), control, SLOT(decrease()));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  hLayout()->addSpacing(5);
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void ToolOptionControlBuilder::visit(TBoolProperty *p) {
Shinya Kitaoka 120a6e
  ToolOptionCheckbox *control = new ToolOptionCheckbox(m_tool, p, m_toolHandle);
Shinya Kitaoka 120a6e
  hLayout()->addWidget(control, 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_panel->addControl(control);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (p->getId() != "") {
Shinya Kitaoka 120a6e
    std::string actionName = "A_ToolOption_" + p->getId();
Shinya Kitaoka 120a6e
    QAction *a = CommandManager::instance()->getAction(actionName.c_str());
Shinya Kitaoka 120a6e
    if (a) {
Shinya Kitaoka 120a6e
      control->addAction(a);
Shinya Kitaoka 120a6e
      QObject::connect(a, SIGNAL(triggered()), control, SLOT(doClick()));
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  hLayout()->addSpacing(5);
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void ToolOptionControlBuilder::visit(TStringProperty *p) {
Shinya Kitaoka 120a6e
  QLabel *label = addLabel(p);
Shinya Kitaoka 120a6e
  m_panel->addLabel(p->getName(), label);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ToolOptionTextField *control = new ToolOptionTextField(m_tool, p);
Shinya Kitaoka 120a6e
  m_panel->addControl(control);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  hLayout()->addWidget(control);
Shinya Kitaoka 120a6e
  hLayout()->addSpacing(5);
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void ToolOptionControlBuilder::visit(TEnumProperty *p) {
Shinya Kitaoka 120a6e
  QWidget *widget;
Shinya Kitaoka 120a6e
  ToolOptionControl *control;
Shinya Kitaoka 120a6e
  switch (m_enumWidgetType) {
Shinya Kitaoka 120a6e
  case POPUPBUTTON: {
Shinya Kitaoka 120a6e
    ToolOptionPopupButton *obj = new ToolOptionPopupButton(m_tool, p);
Shinya Kitaoka 120a6e
    obj->setToolTip(p->getQStringName());
Shinya Kitaoka 120a6e
    control = obj;
Shinya Kitaoka 120a6e
    widget  = obj;
Shinya Kitaoka 120a6e
    break;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  case COMBOBOX:
Shinya Kitaoka 120a6e
  default: {
Shinya Kitaoka 120a6e
    QLabel *label = addLabel(p);
Shinya Kitaoka 120a6e
    m_panel->addLabel(p->getName(), label);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    ToolOptionCombo *obj = new ToolOptionCombo(m_tool, p, m_toolHandle);
Shinya Kitaoka 120a6e
    control              = obj;
Shinya Kitaoka 120a6e
    widget               = obj;
Shinya Kitaoka 120a6e
    break;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
shun-iwasawa c86c5d
  hLayout()->addWidget(widget, 100);
Shinya Kitaoka 120a6e
  m_panel->addControl(control);
Shinya Kitaoka 120a6e
  hLayout()->addSpacing(5);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (p->getId() != "") {
Shinya Kitaoka 120a6e
    std::string actionName = "A_ToolOption_" + p->getId();
Shinya Kitaoka 120a6e
    QAction *a = CommandManager::instance()->getAction(actionName.c_str());
Shinya Kitaoka 120a6e
    if (a) {
Shinya Kitaoka 120a6e
      widget->addAction(a);
Shinya Kitaoka 120a6e
      QObject::connect(a, SIGNAL(triggered()), widget, SLOT(doShowPopup()));
Shinya Kitaoka 120a6e
    }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    TEnumProperty::Range range = p->getRange();
Shinya Kitaoka 120a6e
    TEnumProperty::Range::iterator it;
Shinya Kitaoka 120a6e
    QSignalMapper *signalMapper = 0;
Shinya Kitaoka 120a6e
    int index                   = 0;
Shinya Kitaoka 120a6e
    for (it = range.begin(); it != range.end(); ++it, ++index) {
Shinya Kitaoka 120a6e
      std::string item           = ::to_string(*it);
Shinya Kitaoka 120a6e
      std::string itemActionName = actionName + ":" + item;
Shinya Kitaoka 120a6e
      a = CommandManager::instance()->getAction(itemActionName.c_str());
Shinya Kitaoka 120a6e
      if (a) {
Shinya Kitaoka 120a6e
        widget->addAction(a);
Shinya Kitaoka 120a6e
        if (signalMapper == 0) {
Shinya Kitaoka 120a6e
          signalMapper = new QSignalMapper(widget);
Shinya Kitaoka 120a6e
          QObject::connect(signalMapper, SIGNAL(mapped(int)), widget,
Shinya Kitaoka 120a6e
                           SLOT(doOnActivated(int)));
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
        QObject::connect(a, SIGNAL(triggered()), signalMapper, SLOT(map()));
Shinya Kitaoka 120a6e
        signalMapper->setMapping(a, index);
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ToolOptionControlBuilder::visit(TStyleIndexProperty *p) {
Shinya Kitaoka 120a6e
  QLabel *label = addLabel(p);
Shinya Kitaoka 120a6e
  m_panel->addLabel(p->getName(), label);
Shinya Kitaoka 120a6e
  StyleIndexFieldAndChip *chip =
Shinya Kitaoka 120a6e
      new StyleIndexFieldAndChip(m_tool, p, m_pltHandle, m_toolHandle);
Shinya Kitaoka 120a6e
  hLayout()->addWidget(chip, 0);
Shinya Kitaoka 120a6e
  m_panel->addControl(chip);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//----------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ToolOptionControlBuilder::visit(TPointerProperty *p) {
Shinya Kitaoka 120a6e
  assert(!"not implemented");
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// GenericToolOptionsBox
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
GenericToolOptionsBox::GenericToolOptionsBox(QWidget *parent, TTool *tool,
Shinya Kitaoka 120a6e
                                             TPaletteHandle *pltHandle,
Shinya Kitaoka 120a6e
                                             int propertyGroupIdx,
Shinya Kitaoka 120a6e
                                             ToolHandle *toolHandle)
Shinya Kitaoka 120a6e
    : ToolOptionsBox(parent) {
Shinya Kitaoka 120a6e
  setObjectName("toolOptionsPanel");
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToolOptionControlBuilder builder(this, tool, pltHandle, toolHandle);
Shinya Kitaoka 120a6e
  if (tool && tool->getProperties(propertyGroupIdx))
Shinya Kitaoka 120a6e
    tool->getProperties(propertyGroupIdx)->accept(builder);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_layout->addStretch(1);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ArrowToolOptionsBox::ArrowToolOptionsBox(
Shinya Kitaoka 120a6e
    QWidget *parent, TTool *tool, TPropertyGroup *pg, TFrameHandle *frameHandle,
Shinya Kitaoka 120a6e
    TObjectHandle *objHandle, TXsheetHandle *xshHandle, ToolHandle *toolHandle)
Shinya Kitaoka 120a6e
    : ToolOptionsBox(parent)
Shinya Kitaoka 120a6e
    , m_pg(pg)
Campbell Barton 9b2bfd
    , m_splined(false)
Shinya Kitaoka 120a6e
    , m_tool(tool)
Shinya Kitaoka 120a6e
    , m_frameHandle(frameHandle)
Shinya Kitaoka 120a6e
    , m_objHandle(objHandle)
Shinya Kitaoka 120a6e
    , m_xshHandle(xshHandle) {
Shinya Kitaoka 120a6e
  setFrameStyle(QFrame::StyledPanel);
Shinya Kitaoka 120a6e
  setObjectName("toolOptionsPanel");
Shinya Kitaoka 120a6e
  setFixedHeight(26);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_mainStackedWidget = new QStackedWidget(this);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /* --- General Parts --- */
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // enable to choose target pegbar with combobox
Shinya Kitaoka 120a6e
  m_currentStageObjectCombo = new QComboBox(this);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TEnumProperty *activeAxisProp =
Shinya Kitaoka 120a6e
      dynamic_cast<tenumproperty *="">(m_pg->getProperty("Active Axis"));</tenumproperty>
Shinya Kitaoka 120a6e
  if (activeAxisProp)
Shinya Kitaoka 120a6e
    m_chooseActiveAxisCombo =
Shinya Kitaoka 120a6e
        new ToolOptionCombo(m_tool, activeAxisProp, toolHandle);
Shinya Kitaoka 120a6e
  TEnumProperty *autoSelectProp =
Shinya Kitaoka 120a6e
      dynamic_cast<tenumproperty *="">(m_pg->getProperty("Auto Select Column"));</tenumproperty>
Shinya Kitaoka 120a6e
  if (autoSelectProp)
Shinya Kitaoka 120a6e
    m_pickCombo = new ToolOptionCombo(m_tool, autoSelectProp, toolHandle);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /* --- Position --- */
Shinya Kitaoka 120a6e
  m_motionPathPosField =
Shinya Kitaoka 120a6e
      new PegbarChannelField(m_tool, TStageObject::T_Path, "field", frameHandle,
Shinya Kitaoka 120a6e
                             objHandle, xshHandle, this);
Shinya Kitaoka 120a6e
  m_ewPosField =
Shinya Kitaoka 120a6e
      new PegbarChannelField(m_tool, TStageObject::T_X, "field", frameHandle,
Shinya Kitaoka 120a6e
                             objHandle, xshHandle, this);
Shinya Kitaoka 120a6e
  m_nsPosField =
Shinya Kitaoka 120a6e
      new PegbarChannelField(m_tool, TStageObject::T_Y, "field", frameHandle,
Shinya Kitaoka 120a6e
                             objHandle, xshHandle, this);
Shinya Kitaoka 120a6e
  m_zField = new PegbarChannelField(m_tool, TStageObject::T_Z, "field",
Shinya Kitaoka 120a6e
                                    frameHandle, objHandle, xshHandle, this);
Shinya Kitaoka 120a6e
  m_noScaleZField = new NoScaleField(m_tool, "field");
Shinya Kitaoka 120a6e
  m_ewPosLabel    = new QLabel(tr("E/W:"), this);
Shinya Kitaoka 120a6e
  m_nsPosLabel    = new QLabel(tr("N/S:"), this);
Shinya Kitaoka 120a6e
  // Lock E/W
Shinya Kitaoka 120a6e
  TBoolProperty *lockProp =
Shinya Kitaoka 120a6e
      dynamic_cast<tboolproperty *="">(m_pg->getProperty("Lock Position E/W"));</tboolproperty>
Shinya Kitaoka 120a6e
  if (lockProp)
Shinya Kitaoka 120a6e
    m_lockEWPosCheckbox =
Shinya Kitaoka 120a6e
        new ToolOptionCheckbox(m_tool, lockProp, toolHandle, this);
Shinya Kitaoka 120a6e
  // Lock N/S
Shinya Kitaoka 120a6e
  lockProp =
Shinya Kitaoka 120a6e
      dynamic_cast<tboolproperty *="">(m_pg->getProperty("Lock Position N/S"));</tboolproperty>
Shinya Kitaoka 120a6e
  if (lockProp)
Shinya Kitaoka 120a6e
    m_lockNSPosCheckbox =
Shinya Kitaoka 120a6e
        new ToolOptionCheckbox(m_tool, lockProp, toolHandle, this);
Shinya Kitaoka 120a6e
  // stacking order
Shinya Kitaoka 120a6e
  m_soLabel = new QLabel(tr("SO:"), this);
Shinya Kitaoka 120a6e
  m_soField = new PegbarChannelField(m_tool, TStageObject::T_SO, "field",
Shinya Kitaoka 120a6e
                                     frameHandle, objHandle, xshHandle, this);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /* --- Rotation --- */
Shinya Kitaoka 120a6e
  m_rotationField =
Shinya Kitaoka 120a6e
      new PegbarChannelField(m_tool, TStageObject::T_Angle, "field",
Shinya Kitaoka 120a6e
                             frameHandle, objHandle, xshHandle, this);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /* --- Scale --- */
Shinya Kitaoka 120a6e
  m_globalScaleField =
Shinya Kitaoka 120a6e
      new PegbarChannelField(m_tool, TStageObject::T_Scale, "field",
Shinya Kitaoka 120a6e
                             frameHandle, objHandle, xshHandle, this);
Shinya Kitaoka 120a6e
  m_scaleHField =
Shinya Kitaoka 120a6e
      new PegbarChannelField(m_tool, TStageObject::T_ScaleX, "field",
Shinya Kitaoka 120a6e
                             frameHandle, objHandle, xshHandle, this);
Shinya Kitaoka 120a6e
  m_scaleVField =
Shinya Kitaoka 120a6e
      new PegbarChannelField(m_tool, TStageObject::T_ScaleY, "field",
Shinya Kitaoka 120a6e
                             frameHandle, objHandle, xshHandle, this);
Shinya Kitaoka 120a6e
  TEnumProperty *scaleConstraintProp =
Shinya Kitaoka 120a6e
      dynamic_cast<tenumproperty *="">(m_pg->getProperty("Scale Constraint:"));</tenumproperty>
Shinya Kitaoka 120a6e
  if (scaleConstraintProp)
Shinya Kitaoka 120a6e
    m_maintainCombo =
Shinya Kitaoka 120a6e
        new ToolOptionCombo(m_tool, scaleConstraintProp, toolHandle);
Shinya Kitaoka 120a6e
  // Lock Scale H
Shinya Kitaoka 120a6e
  lockProp = dynamic_cast<tboolproperty *="">(m_pg->getProperty("Lock Scale H"));</tboolproperty>
Shinya Kitaoka 120a6e
  if (lockProp)
Shinya Kitaoka 120a6e
    m_lockScaleHCheckbox =
Shinya Kitaoka 120a6e
        new ToolOptionCheckbox(m_tool, lockProp, toolHandle, this);
Shinya Kitaoka 120a6e
  // Lock Scale V
Shinya Kitaoka 120a6e
  lockProp = dynamic_cast<tboolproperty *="">(m_pg->getProperty("Lock Scale V"));</tboolproperty>
Shinya Kitaoka 120a6e
  if (lockProp)
Shinya Kitaoka 120a6e
    m_lockScaleVCheckbox =
Shinya Kitaoka 120a6e
        new ToolOptionCheckbox(m_tool, lockProp, toolHandle, this);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /* --- Shear --- */
Shinya Kitaoka 120a6e
  m_shearHField =
Shinya Kitaoka 120a6e
      new PegbarChannelField(m_tool, TStageObject::T_ShearX, "field",
Shinya Kitaoka 120a6e
                             frameHandle, objHandle, xshHandle, this);
Shinya Kitaoka 120a6e
  m_shearVField =
Shinya Kitaoka 120a6e
      new PegbarChannelField(m_tool, TStageObject::T_ShearY, "field",
Shinya Kitaoka 120a6e
                             frameHandle, objHandle, xshHandle, this);
Shinya Kitaoka 120a6e
  // Lock Shear H
Shinya Kitaoka 120a6e
  lockProp = dynamic_cast<tboolproperty *="">(m_pg->getProperty("Lock Shear H"));</tboolproperty>
Shinya Kitaoka 120a6e
  if (lockProp)
Shinya Kitaoka 120a6e
    m_lockShearHCheckbox =
Shinya Kitaoka 120a6e
        new ToolOptionCheckbox(m_tool, lockProp, toolHandle, this);
Shinya Kitaoka 120a6e
  // Lock Scale V
Shinya Kitaoka 120a6e
  lockProp = dynamic_cast<tboolproperty *="">(m_pg->getProperty("Lock Shear V"));</tboolproperty>
Shinya Kitaoka 120a6e
  if (lockProp)
Shinya Kitaoka 120a6e
    m_lockShearVCheckbox =
Shinya Kitaoka 120a6e
        new ToolOptionCheckbox(m_tool, lockProp, toolHandle, this);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /* --- Center Position --- */
Shinya Kitaoka 120a6e
  m_ewCenterField =
Shinya Kitaoka 120a6e
      new PegbarCenterField(m_tool, 0, "field", objHandle, xshHandle, this);
Shinya Kitaoka 120a6e
  m_nsCenterField =
Shinya Kitaoka 120a6e
      new PegbarCenterField(m_tool, 1, "field", objHandle, xshHandle, this);
Shinya Kitaoka 120a6e
  // Lock E/W Center
Shinya Kitaoka 120a6e
  lockProp =
Shinya Kitaoka 120a6e
      dynamic_cast<tboolproperty *="">(m_pg->getProperty("Lock Center E/W"));</tboolproperty>
Shinya Kitaoka 120a6e
  if (lockProp)
Shinya Kitaoka 120a6e
    m_lockEWCenterCheckbox =
Shinya Kitaoka 120a6e
        new ToolOptionCheckbox(m_tool, lockProp, toolHandle, this);
Shinya Kitaoka 120a6e
  // Lock N/S Center
Shinya Kitaoka 120a6e
  lockProp =
Shinya Kitaoka 120a6e
      dynamic_cast<tboolproperty *="">(m_pg->getProperty("Lock Center N/S"));</tboolproperty>
Shinya Kitaoka 120a6e
  if (lockProp)
Shinya Kitaoka 120a6e
    m_lockNSCenterCheckbox =
Shinya Kitaoka 120a6e
        new ToolOptionCheckbox(m_tool, lockProp, toolHandle, this);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TBoolProperty *prop =
Shinya Kitaoka 120a6e
      dynamic_cast<tboolproperty *="">(m_pg->getProperty("Global Key"));</tboolproperty>
Shinya Kitaoka 120a6e
  if (prop)
Shinya Kitaoka 120a6e
    m_globalKey = new ToolOptionCheckbox(m_tool, prop, toolHandle, this);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_lockEWPosCheckbox->setObjectName("EditToolLockButton");
Shinya Kitaoka 120a6e
  m_lockNSPosCheckbox->setObjectName("EditToolLockButton");
Shinya Kitaoka 120a6e
  m_lockEWCenterCheckbox->setObjectName("EditToolLockButton");
Shinya Kitaoka 120a6e
  m_lockNSCenterCheckbox->setObjectName("EditToolLockButton");
Shinya Kitaoka 120a6e
  m_lockScaleHCheckbox->setObjectName("EditToolLockButton");
Shinya Kitaoka 120a6e
  m_lockScaleVCheckbox->setObjectName("EditToolLockButton");
Shinya Kitaoka 120a6e
  m_lockShearHCheckbox->setObjectName("EditToolLockButton");
Shinya Kitaoka 120a6e
  m_lockShearVCheckbox->setObjectName("EditToolLockButton");
Shinya Kitaoka 120a6e
  m_lockEWPosCheckbox->setText("");
Shinya Kitaoka 120a6e
  m_lockNSPosCheckbox->setText("");
Shinya Kitaoka 120a6e
  m_lockEWCenterCheckbox->setText("");
Shinya Kitaoka 120a6e
  m_lockNSCenterCheckbox->setText("");
Shinya Kitaoka 120a6e
  m_lockScaleHCheckbox->setText("");
Shinya Kitaoka 120a6e
  m_lockScaleVCheckbox->setText("");
Shinya Kitaoka 120a6e
  m_lockShearHCheckbox->setText("");
Shinya Kitaoka 120a6e
  m_lockShearVCheckbox->setText("");
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_zField->setPrecision(4);
Shinya Kitaoka 120a6e
  m_noScaleZField->setPrecision(4);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool splined                        = isCurrentObjectSplined();
Shinya Kitaoka 120a6e
  if (splined != m_splined) m_splined = splined;
Shinya Kitaoka 120a6e
  setSplined(m_splined);
Shinya Kitaoka 120a6e
Shinya Kitaoka d1f6c4
  const int ITEM_SPACING  = 10;
shun-iwasawa c86c5d
  const int LABEL_SPACING = 3;
Shinya Kitaoka d1f6c4
  /* --- Layout --- */
Shinya Kitaoka 120a6e
  /* --- Layout --- */
Shinya Kitaoka 120a6e
  QHBoxLayout *mainLay = m_layout;
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    mainLay->addWidget(m_currentStageObjectCombo, 0);
Shinya Kitaoka 120a6e
    mainLay->addWidget(m_chooseActiveAxisCombo, 0);
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
    addSeparator();
shun-iwasawa c86c5d
shun-iwasawa c86c5d
    mainLay->addWidget(m_mainStackedWidget, 1);
Shinya Kitaoka 120a6e
    {
Shinya Kitaoka d1f6c4
      // Position
Shinya Kitaoka d1f6c4
      QFrame *posFrame    = new QFrame(this);
Shinya Kitaoka 120a6e
      QHBoxLayout *posLay = new QHBoxLayout();
Shinya Kitaoka 120a6e
      posLay->setMargin(0);
shun-iwasawa c86c5d
      posLay->setSpacing(0);
Shinya Kitaoka 120a6e
      posFrame->setLayout(posLay);
Shinya Kitaoka 120a6e
      m_mainStackedWidget->addWidget(posFrame);
Shinya Kitaoka 120a6e
      {
Shinya Kitaoka 120a6e
        posLay->addWidget(new QLabel(tr("Position"), this), 0);
shun-iwasawa c86c5d
        posLay->addSpacing(ITEM_SPACING);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        posLay->addWidget(m_motionPathPosField, 0);
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
        posLay->addWidget(m_ewPosLabel, 0);
shun-iwasawa c86c5d
        posLay->addSpacing(LABEL_SPACING);
shun-iwasawa c86c5d
        posLay->addWidget(m_ewPosField, 10);
shun-iwasawa c86c5d
        posLay->addWidget(m_lockEWPosCheckbox, 0);
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
        posLay->addSpacing(ITEM_SPACING);
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
        posLay->addWidget(m_nsPosLabel, 0);
shun-iwasawa c86c5d
        posLay->addSpacing(LABEL_SPACING);
shun-iwasawa c86c5d
        posLay->addWidget(m_nsPosField, 10);
shun-iwasawa c86c5d
        posLay->addWidget(m_lockNSPosCheckbox, 0);
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
        posLay->addSpacing(ITEM_SPACING);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        posLay->addWidget(new QLabel(tr("Z:"), this), 0);
shun-iwasawa c86c5d
        posLay->addSpacing(LABEL_SPACING);
shun-iwasawa c86c5d
        posLay->addWidget(m_zField, 10);
shun-iwasawa c86c5d
        posLay->addSpacing(LABEL_SPACING);
Shinya Kitaoka 120a6e
        posLay->addWidget(new QLabel(tr("("), this), 0);
shun-iwasawa c86c5d
        posLay->addWidget(m_noScaleZField, 10);
Shinya Kitaoka 120a6e
        posLay->addWidget(new QLabel(tr(")"), this), 0);
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
        posLay->addSpacing(ITEM_SPACING);
shun-iwasawa c86c5d
shun-iwasawa c86c5d
        posLay->addWidget(m_soLabel, 0);
shun-iwasawa c86c5d
        posLay->addWidget(m_soField, 10);
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
        posLay->addStretch(1);
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
Shinya Kitaoka d1f6c4
      // Rotation
Shinya Kitaoka d1f6c4
      QFrame *rotFrame    = new QFrame(this);
Shinya Kitaoka 120a6e
      QHBoxLayout *rotLay = new QHBoxLayout();
Shinya Kitaoka 120a6e
      rotLay->setMargin(0);
shun-iwasawa c86c5d
      rotLay->setSpacing(0);
Shinya Kitaoka 120a6e
      rotFrame->setLayout(rotLay);
Shinya Kitaoka 120a6e
      m_mainStackedWidget->addWidget(rotFrame);
Shinya Kitaoka 120a6e
      {
Shinya Kitaoka 120a6e
        rotLay->addWidget(new QLabel(tr("Rotation"), this), 0);
shun-iwasawa c86c5d
        rotLay->addSpacing(ITEM_SPACING);
shun-iwasawa c86c5d
shun-iwasawa c86c5d
        rotLay->addWidget(m_rotationField, 10);
shun-iwasawa c86c5d
Shinya Kitaoka 120a6e
        rotLay->addStretch(1);
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
Shinya Kitaoka d1f6c4
      // Scale
Shinya Kitaoka d1f6c4
      QFrame *scaleFrame    = new QFrame(this);
Shinya Kitaoka 120a6e
      QHBoxLayout *scaleLay = new QHBoxLayout();
Shinya Kitaoka 120a6e
      scaleLay->setMargin(0);
shun-iwasawa c86c5d
      scaleLay->setSpacing(0);
Shinya Kitaoka 120a6e
      scaleFrame->setLayout(scaleLay);
Shinya Kitaoka 120a6e
      m_mainStackedWidget->addWidget(scaleFrame);
Shinya Kitaoka 120a6e
      {
Shinya Kitaoka 120a6e
        scaleLay->addWidget(new QLabel(tr("Scale"), this), 0);
shun-iwasawa c86c5d
        scaleLay->addSpacing(ITEM_SPACING);
shun-iwasawa c86c5d
Shinya Kitaoka 120a6e
        scaleLay->addWidget(new QLabel(tr("Global:"), this), 0);
shun-iwasawa c86c5d
        scaleLay->addSpacing(LABEL_SPACING);
shun-iwasawa c86c5d
        scaleLay->addWidget(m_globalScaleField, 10);
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
        scaleLay->addSpacing(ITEM_SPACING);
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
        scaleLay->addWidget(new QLabel(tr("H:"), this), 0);
shun-iwasawa c86c5d
        scaleLay->addSpacing(LABEL_SPACING);
shun-iwasawa c86c5d
        scaleLay->addWidget(m_scaleHField, 10);
shun-iwasawa c86c5d
        scaleLay->addWidget(m_lockScaleHCheckbox, 0);
shun-iwasawa c86c5d
shun-iwasawa c86c5d
        scaleLay->addSpacing(ITEM_SPACING);
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
        scaleLay->addWidget(new QLabel(tr("V:"), this), 0);
shun-iwasawa c86c5d
        scaleLay->addSpacing(LABEL_SPACING);
shun-iwasawa c86c5d
        scaleLay->addWidget(m_scaleVField, 10);
shun-iwasawa c86c5d
        scaleLay->addWidget(m_lockScaleVCheckbox, 0);
shun-iwasawa c86c5d
shun-iwasawa c86c5d
        scaleLay->addSpacing(ITEM_SPACING);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        scaleLay->addWidget(new QLabel(tr("Maintain:"), this), 0);
shun-iwasawa c86c5d
        scaleLay->addSpacing(LABEL_SPACING);
Shinya Kitaoka 120a6e
        scaleLay->addWidget(m_maintainCombo, 0);
shun-iwasawa c86c5d
Shinya Kitaoka 120a6e
        scaleLay->addStretch(1);
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
Shinya Kitaoka d1f6c4
      // Shear
Shinya Kitaoka d1f6c4
      QFrame *shearFrame    = new QFrame(this);
Shinya Kitaoka 120a6e
      QHBoxLayout *shearLay = new QHBoxLayout();
Shinya Kitaoka 120a6e
      shearLay->setMargin(0);
shun-iwasawa c86c5d
      shearLay->setSpacing(0);
Shinya Kitaoka 120a6e
      shearFrame->setLayout(shearLay);
Shinya Kitaoka 120a6e
      m_mainStackedWidget->addWidget(shearFrame);
Shinya Kitaoka 120a6e
      {
Shinya Kitaoka 120a6e
        shearLay->addWidget(new QLabel(tr("Shear"), this), 0);
shun-iwasawa c86c5d
        shearLay->addSpacing(ITEM_SPACING);
shun-iwasawa c86c5d
shun-iwasawa c86c5d
        shearLay->addWidget(new QLabel(tr("H:"), this), 0);
shun-iwasawa c86c5d
        shearLay->addSpacing(LABEL_SPACING);
shun-iwasawa c86c5d
        shearLay->addWidget(m_shearHField, 10);
shun-iwasawa c86c5d
        shearLay->addWidget(m_lockShearHCheckbox, 0);
shun-iwasawa c86c5d
shun-iwasawa c86c5d
        shearLay->addSpacing(ITEM_SPACING);
shun-iwasawa c86c5d
shun-iwasawa c86c5d
        shearLay->addWidget(new QLabel(tr("V:"), this), 0);
shun-iwasawa c86c5d
        shearLay->addSpacing(LABEL_SPACING);
shun-iwasawa c86c5d
        shearLay->addWidget(m_shearVField, 10);
shun-iwasawa c86c5d
        shearLay->addWidget(m_lockShearVCheckbox, 0);
shun-iwasawa c86c5d
shun-iwasawa c86c5d
        shearLay->addSpacing(ITEM_SPACING);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        shearLay->addStretch(1);
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
Shinya Kitaoka d1f6c4
      // Center Position
Shinya Kitaoka d1f6c4
      QFrame *centerPosFrame    = new QFrame(this);
Shinya Kitaoka 120a6e
      QHBoxLayout *centerPosLay = new QHBoxLayout();
Shinya Kitaoka 120a6e
      centerPosLay->setMargin(0);
shun-iwasawa c86c5d
      centerPosLay->setSpacing(0);
Shinya Kitaoka 120a6e
      centerPosFrame->setLayout(centerPosLay);
Shinya Kitaoka 120a6e
      m_mainStackedWidget->addWidget(centerPosFrame);
Shinya Kitaoka 120a6e
      {
Shinya Kitaoka 120a6e
        centerPosLay->addWidget(new QLabel(tr("Center Position"), this), 0);
shun-iwasawa c86c5d
        centerPosLay->addSpacing(ITEM_SPACING);
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
        centerPosLay->addWidget(new QLabel(tr("E/W:"), this), 0);
shun-iwasawa c86c5d
        centerPosLay->addSpacing(LABEL_SPACING);
shun-iwasawa c86c5d
        centerPosLay->addWidget(m_ewCenterField, 10);
shun-iwasawa c86c5d
        centerPosLay->addWidget(m_lockEWCenterCheckbox, 0);
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
        centerPosLay->addSpacing(ITEM_SPACING);
shun-iwasawa c86c5d
shun-iwasawa c86c5d
        centerPosLay->addWidget(new QLabel(tr("N/S:"), this), 0);
shun-iwasawa c86c5d
        centerPosLay->addSpacing(LABEL_SPACING);
shun-iwasawa c86c5d
        centerPosLay->addWidget(m_nsCenterField, 10);
shun-iwasawa c86c5d
        centerPosLay->addWidget(m_lockNSCenterCheckbox, 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
        centerPosLay->addStretch(1);
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
    addSeparator();
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
    mainLay->addWidget(m_globalKey, 0);
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
    mainLay->addSpacing(5);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    QHBoxLayout *pickLay = new QHBoxLayout();
Shinya Kitaoka 120a6e
    pickLay->setMargin(0);
Shinya Kitaoka 120a6e
    pickLay->setSpacing(0);
Shinya Kitaoka 120a6e
    mainLay->addLayout(pickLay, 0);
Shinya Kitaoka 120a6e
    {
Shinya Kitaoka 120a6e
      pickLay->addWidget(new QLabel(tr("Pick:"), this), 0);
Shinya Kitaoka 120a6e
      pickLay->addWidget(m_pickCombo, 0);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /* --- signal-slot connections --- */
Shinya Kitaoka 120a6e
  // swap page when the active axis is changed
Shinya Kitaoka 120a6e
  connect(m_chooseActiveAxisCombo, SIGNAL(currentIndexChanged(int)),
Shinya Kitaoka 120a6e
          m_mainStackedWidget, SLOT(setCurrentIndex(int)));
Shinya Kitaoka 120a6e
  // when the current stage object is changed via combo box, then switch the
Shinya Kitaoka 120a6e
  // current stage object in the scene
Shinya Kitaoka 120a6e
  connect(m_currentStageObjectCombo, SIGNAL(activated(int)), this,
Shinya Kitaoka 120a6e
          SLOT(onCurrentStageObjectComboActivated(int)));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /* --- Assigning shortcut keys --- */
Shinya Kitaoka 120a6e
  if (activeAxisProp->getId() != "") {
Shinya Kitaoka 120a6e
    std::string actionName = "A_ToolOption_" + activeAxisProp->getId();
Shinya Kitaoka 120a6e
    QAction *a = CommandManager::instance()->getAction(actionName.c_str());
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    if (a) {
Shinya Kitaoka 120a6e
      m_chooseActiveAxisCombo->addAction(a);
Shinya Kitaoka 120a6e
      QObject::connect(a, SIGNAL(triggered()), m_chooseActiveAxisCombo,
Shinya Kitaoka 120a6e
                       SLOT(doShowPopup()));
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    TEnumProperty::Range range = activeAxisProp->getRange();
Shinya Kitaoka 120a6e
    TEnumProperty::Range::iterator it;
Shinya Kitaoka 120a6e
    QSignalMapper *signalMapper = 0;
Shinya Kitaoka 120a6e
    int index                   = 0;
Shinya Kitaoka 120a6e
    for (it = range.begin(); it != range.end(); ++it, ++index) {
Shinya Kitaoka 120a6e
      std::string item           = ::to_string(*it);
Shinya Kitaoka 120a6e
      std::string itemActionName = actionName + ":" + item;
Shinya Kitaoka 120a6e
      a = CommandManager::instance()->getAction(itemActionName.c_str());
Shinya Kitaoka 120a6e
      if (a) {
Shinya Kitaoka 120a6e
        m_chooseActiveAxisCombo->addAction(a);
Shinya Kitaoka 120a6e
        if (signalMapper == 0) {
Shinya Kitaoka 120a6e
          signalMapper = new QSignalMapper(m_chooseActiveAxisCombo);
Shinya Kitaoka 120a6e
          QObject::connect(signalMapper, SIGNAL(mapped(int)),
Shinya Kitaoka 120a6e
                           m_chooseActiveAxisCombo, SLOT(doOnActivated(int)));
Shinya Kitaoka 120a6e
        }
Shinya Kitaoka 120a6e
        QObject::connect(a, SIGNAL(triggered()), signalMapper, SLOT(map()));
Shinya Kitaoka 120a6e
        signalMapper->setMapping(a, index);
Shinya Kitaoka 120a6e
      }
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (scaleConstraintProp) {
Shinya Kitaoka 120a6e
    m_scaleHField->onScaleTypeChanged(m_maintainCombo->currentIndex());
Shinya Kitaoka 120a6e
    m_scaleVField->onScaleTypeChanged(m_maintainCombo->currentIndex());
Shinya Kitaoka 120a6e
    connect(m_maintainCombo, SIGNAL(currentIndexChanged(int)), m_scaleHField,
Shinya Kitaoka 120a6e
            SLOT(onScaleTypeChanged(int)));
Shinya Kitaoka 120a6e
    connect(m_maintainCombo, SIGNAL(currentIndexChanged(int)), m_scaleVField,
Shinya Kitaoka 120a6e
            SLOT(onScaleTypeChanged(int)));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void ArrowToolOptionsBox::showEvent(QShowEvent *) {
Shinya Kitaoka 120a6e
  connect(m_frameHandle, SIGNAL(frameSwitched()), SLOT(onFrameSwitched()));
Shinya Kitaoka 120a6e
  // if some stage object is added/removed, then reflect it to the combobox
Shinya Kitaoka 120a6e
  connect(m_xshHandle, SIGNAL(xsheetSwitched()), this,
Shinya Kitaoka 120a6e
          SLOT(updateStageObjectComboItems()));
Shinya Kitaoka 120a6e
  connect(m_xshHandle, SIGNAL(xsheetChanged()), this,
Shinya Kitaoka 120a6e
          SLOT(updateStageObjectComboItems()));
Shinya Kitaoka 120a6e
  // If the current stage object is switched, then synchronize it to the
Shinya Kitaoka 120a6e
  // combobox
Shinya Kitaoka 120a6e
  connect(m_objHandle, SIGNAL(objectSwitched()), this,
Shinya Kitaoka 120a6e
          SLOT(syncCurrentStageObjectComboItem()));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // update the item list in m_currentStageObjectCombo
Shinya Kitaoka 120a6e
  updateStageObjectComboItems();
Shinya Kitaoka 120a6e
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ArrowToolOptionsBox::hideEvent(QShowEvent *) {
Shinya Kitaoka 120a6e
  disconnect(m_frameHandle, SIGNAL(frameSwitched()), this,
Shinya Kitaoka 120a6e
             SLOT(onFrameSwitched()));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  disconnect(m_xshHandle, SIGNAL(xsheetSwitched()), this,
Shinya Kitaoka 120a6e
             SLOT(updateStageObjectComboItems()));
Shinya Kitaoka 120a6e
  disconnect(m_xshHandle, SIGNAL(xsheetChanged()), this,
Shinya Kitaoka 120a6e
             SLOT(updateStageObjectComboItems()));
Shinya Kitaoka 120a6e
  disconnect(m_objHandle, SIGNAL(objectSwitched()), this,
Shinya Kitaoka 120a6e
             SLOT(syncCurrentStageObjectComboItem()));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ArrowToolOptionsBox::setSplined(bool on) {
Shinya Kitaoka 120a6e
  m_splined = on;
Shinya Kitaoka 120a6e
  // Activate on selecting spline
Shinya Kitaoka 120a6e
  m_motionPathPosField->setVisible(on);
Shinya Kitaoka 120a6e
  // DEactivate on selecting spline
Shinya Kitaoka 120a6e
  m_ewPosField->setVisible(!on);
Shinya Kitaoka 120a6e
  m_nsPosField->setVisible(!on);
Shinya Kitaoka 120a6e
  m_ewPosLabel->setVisible(!on);
Shinya Kitaoka 120a6e
  m_nsPosLabel->setVisible(!on);
Shinya Kitaoka 120a6e
  m_lockEWPosCheckbox->setVisible(!on);
Shinya Kitaoka 120a6e
  m_lockNSPosCheckbox->setVisible(!on);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
bool ArrowToolOptionsBox::isCurrentObjectSplined() const {
Shinya Kitaoka 120a6e
  TStageObjectId objId = m_objHandle->getObjectId();
Shinya Kitaoka 120a6e
  return m_xshHandle->getXsheet()->getStageObject(objId)->getSpline() != 0;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ArrowToolOptionsBox::updateStatus() {
Shinya Kitaoka 120a6e
  // General
Shinya Kitaoka 120a6e
  m_chooseActiveAxisCombo->updateStatus();
Shinya Kitaoka 120a6e
  m_pickCombo->updateStatus();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Position
Shinya Kitaoka 120a6e
  m_motionPathPosField->updateStatus();
Shinya Kitaoka 120a6e
  m_ewPosField->updateStatus();
Shinya Kitaoka 120a6e
  m_nsPosField->updateStatus();
Shinya Kitaoka 120a6e
  m_zField->updateStatus();
Shinya Kitaoka 120a6e
  m_noScaleZField->updateStatus();
Shinya Kitaoka 120a6e
  m_soField->updateStatus();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Rotation
Shinya Kitaoka 120a6e
  m_rotationField->updateStatus();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Scale
Shinya Kitaoka 120a6e
  m_globalScaleField->updateStatus();
Shinya Kitaoka 120a6e
  m_scaleHField->updateStatus();
Shinya Kitaoka 120a6e
  m_scaleVField->updateStatus();
Shinya Kitaoka 120a6e
  m_maintainCombo->updateStatus();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Shear
Shinya Kitaoka 120a6e
  m_shearHField->updateStatus();
Shinya Kitaoka 120a6e
  m_shearVField->updateStatus();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Center Position
Shinya Kitaoka 120a6e
  m_ewCenterField->updateStatus();
Shinya Kitaoka 120a6e
  m_nsCenterField->updateStatus();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool splined = isCurrentObjectSplined();
Shinya Kitaoka 120a6e
  if (splined != m_splined) setSplined(splined);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void ArrowToolOptionsBox::onStageObjectChange() { updateStatus(); }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
/*! update the object list in combobox
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka 120a6e
void ArrowToolOptionsBox::updateStageObjectComboItems() {
Shinya Kitaoka 120a6e
  // clear items
Shinya Kitaoka 120a6e
  m_currentStageObjectCombo->clear();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TXsheet *xsh = m_xshHandle->getXsheet();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TStageObjectId id;
Shinya Kitaoka 120a6e
  for (int i = 0; i < xsh->getStageObjectTree()->getStageObjectCount(); i++) {
Shinya Kitaoka 120a6e
    id = xsh->getStageObjectTree()->getStageObject(i)->getId();
Shinya Kitaoka 120a6e
    if (id.isColumn()) {
Shinya Kitaoka 120a6e
      int columnIndex = id.getIndex();
Shinya Kitaoka 120a6e
      if (xsh->isColumnEmpty(columnIndex)) continue;
Shinya Kitaoka 120a6e
    }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    TStageObject *pegbar = xsh->getStageObject(id);
Shinya Kitaoka 120a6e
    QString itemName     = QString::fromStdString(pegbar->getName());
Shinya Kitaoka 120a6e
    // store the item with ObjectId data
Shinya Kitaoka 120a6e
    m_currentStageObjectCombo->addItem(itemName, (int)id.getCode());
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // synchronize
Shinya Kitaoka 120a6e
  syncCurrentStageObjectComboItem();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
/*! syncronize the current item in the combobox to the selected stage object
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka 120a6e
void ArrowToolOptionsBox::syncCurrentStageObjectComboItem() {
Shinya Kitaoka 120a6e
  TStageObjectId curObjId = m_objHandle->getObjectId();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int index = m_currentStageObjectCombo->findData((int)curObjId.getCode());
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // if the item is found
Shinya Kitaoka 120a6e
  if (index >= 0) m_currentStageObjectCombo->setCurrentIndex(index);
Shinya Kitaoka 120a6e
  // if not found, add a new item. (This may happens when selecting the empty
Shinya Kitaoka 120a6e
  // column.)
Shinya Kitaoka 120a6e
  else {
Shinya Kitaoka 120a6e
    TStageObject *pegbar = m_xshHandle->getXsheet()->getStageObject(curObjId);
Shinya Kitaoka 120a6e
    QString itemName     = QString::fromStdString(pegbar->getName());
Shinya Kitaoka 120a6e
    // store the item with ObjectId data
Shinya Kitaoka 120a6e
    m_currentStageObjectCombo->addItem(itemName, (int)curObjId.getCode());
Shinya Kitaoka 120a6e
    // move the current index to it
Shinya Kitaoka 120a6e
    m_currentStageObjectCombo->setCurrentIndex(
Shinya Kitaoka 120a6e
        m_currentStageObjectCombo->findText(itemName));
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
/*!change the current stage object when user changes it via combobox by hand
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka 120a6e
void ArrowToolOptionsBox::onCurrentStageObjectComboActivated(int index) {
Shinya Kitaoka 120a6e
  int code = m_currentStageObjectCombo->itemData(index).toInt();
Shinya Kitaoka 120a6e
  TStageObjectId id;
Shinya Kitaoka 120a6e
  id.setCode(code);
Shinya Kitaoka 120a6e
  if (id == TStageObjectId::NoneId) {
Shinya Kitaoka 120a6e
    std::cout << "Warning: "
Shinya Kitaoka 120a6e
                 "ArrowToolOptionsBox::onCurrentStageObjectComboActivated \nNo "
Shinya Kitaoka 120a6e
                 "stage object linked to the selected item found in the scene."
Shinya Kitaoka 120a6e
              << std::endl;
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  // switch the current object
Shinya Kitaoka 120a6e
  m_objHandle->setObjectId(id);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// SelectionToolOptionsBox
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
shun-iwasawa c86c5d
IconViewField::IconViewField(QWidget *parent, IconType iconType)
Shinya Kitaoka d1f6c4
    : QWidget(parent), m_iconType(iconType) {
shun-iwasawa c86c5d
  setMinimumSize(21, 25);
shun-iwasawa c86c5d
}
shun-iwasawa c86c5d
Shinya Kitaoka d1f6c4
void IconViewField::paintEvent(QPaintEvent *e) {
shun-iwasawa c86c5d
  QPainter p(this);
shun-iwasawa c86c5d
  // La pixmap e' alta 17 px, il widget 23. Per centrarla faccio il draw a 3 px.
shun-iwasawa c86c5d
  p.drawPixmap(QRect(0, 3, 21, 17), m_pm[m_iconType]);
shun-iwasawa c86c5d
}
shun-iwasawa c86c5d
shun-iwasawa c86c5d
//-----------------------------------------------------------------------------
shun-iwasawa c86c5d
Shinya Kitaoka 120a6e
SelectionToolOptionsBox::SelectionToolOptionsBox(QWidget *parent, TTool *tool,
Shinya Kitaoka 120a6e
                                                 TPaletteHandle *pltHandle,
Shinya Kitaoka 120a6e
                                                 ToolHandle *toolHandle)
Shinya Kitaoka 120a6e
    : ToolOptionsBox(parent)
Shinya Kitaoka 120a6e
    , m_tool(tool)
Shinya Kitaoka 120a6e
    , m_isVectorSelction(false)
Shinya Kitaoka 120a6e
    , m_setSaveboxCheckbox(0) {
Shinya Kitaoka 120a6e
  TPropertyGroup *props = tool->getProperties(0);
Shinya Kitaoka 120a6e
  assert(props->getPropertyCount() > 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka d1f6c4
  RasterSelectionTool *rasterSelectionTool =
Shinya Kitaoka d1f6c4
      dynamic_cast<rasterselectiontool *="">(tool);</rasterselectiontool>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  SelectionTool *selectionTool = dynamic_cast<selectiontool *="">(tool);</selectiontool>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ToolOptionControlBuilder builder(this, tool, pltHandle, toolHandle);
Shinya Kitaoka d1f6c4
  if (tool && tool->getProperties(0)) tool->getProperties(0)->accept(builder);
Shinya Kitaoka 120a6e
Shinya Kitaoka d1f6c4
  IconViewField *iconView =
Shinya Kitaoka d1f6c4
      new IconViewField(this, IconViewField::Icon_ScalePeg);
shun-iwasawa c86c5d
  m_scaleXLabel = new QLabel(tr("H:"), this);
shun-iwasawa c86c5d
  m_scaleXField = new SelectionScaleField(selectionTool, 0, "Scale X");
shun-iwasawa c86c5d
  m_scaleYLabel = new QLabel(tr("V:"), this);
shun-iwasawa c86c5d
  m_scaleYField = new SelectionScaleField(selectionTool, 1, "Scale Y");
Shinya Kitaoka d1f6c4
  m_scaleLink   = new DVGui::CheckBox(tr("Link"), this);
shun-iwasawa c86c5d
Shinya Kitaoka d1f6c4
  IconViewField *rotIconView =
Shinya Kitaoka d1f6c4
      new IconViewField(this, IconViewField::Icon_Rotation);
shun-iwasawa c86c5d
  m_rotationField = new SelectionRotationField(selectionTool, tr("Rotation"));
shun-iwasawa c86c5d
Shinya Kitaoka d1f6c4
  IconViewField *moveIconView =
Shinya Kitaoka d1f6c4
      new IconViewField(this, IconViewField::Icon_Position);
shun-iwasawa c86c5d
  m_moveXLabel = new QLabel(tr("E/W:"), this);
shun-iwasawa c86c5d
  m_moveXField = new SelectionMoveField(selectionTool, 0, "Move X");
shun-iwasawa c86c5d
  m_moveYLabel = addLabel(tr("N/S:"));
shun-iwasawa c86c5d
  m_moveYField = new SelectionMoveField(selectionTool, 1, "Move Y");
shun-iwasawa c86c5d
shun-iwasawa c86c5d
  if (rasterSelectionTool) {
Shinya Kitaoka d1f6c4
    TBoolProperty *modifySetSaveboxProp =
Shinya Kitaoka d1f6c4
        rasterSelectionTool->getModifySaveboxProperty();
shun-iwasawa c86c5d
    if (modifySetSaveboxProp)
Shinya Kitaoka d1f6c4
      m_setSaveboxCheckbox =
Shinya Kitaoka d1f6c4
          new ToolOptionCheckbox(rasterSelectionTool, modifySetSaveboxProp);
shun-iwasawa c86c5d
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_scaleXLabel->setEnabled(false);
Shinya Kitaoka 120a6e
  m_scaleYLabel->setEnabled(false);
shun-iwasawa c86c5d
  m_moveXLabel->setEnabled(false);
shun-iwasawa c86c5d
  m_moveYLabel->setEnabled(false);
shun-iwasawa c86c5d
Shinya Kitaoka d1f6c4
  //--- layout ----
shun-iwasawa c86c5d
shun-iwasawa c86c5d
  addSeparator();
shun-iwasawa c86c5d
shun-iwasawa c86c5d
  hLayout()->addWidget(iconView, 0);
shun-iwasawa c86c5d
  hLayout()->addWidget(m_scaleXLabel, 0);
shun-iwasawa c86c5d
  hLayout()->addWidget(m_scaleXField, 10);
shun-iwasawa c86c5d
  hLayout()->addWidget(m_scaleYLabel, 0);
shun-iwasawa c86c5d
  hLayout()->addWidget(m_scaleYField, 10);
Shinya Kitaoka 120a6e
  hLayout()->addSpacing(4);
shun-iwasawa c86c5d
  hLayout()->addWidget(m_scaleLink, 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  addSeparator();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  hLayout()->addWidget(rotIconView, 0);
shun-iwasawa c86c5d
  hLayout()->addWidget(m_rotationField, 10);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  addSeparator();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  hLayout()->addWidget(moveIconView, 0);
shun-iwasawa c86c5d
  hLayout()->addWidget(m_moveXLabel, 0);
shun-iwasawa c86c5d
  hLayout()->addWidget(m_moveXField, 10);
shun-iwasawa c86c5d
  hLayout()->addWidget(m_moveYLabel, 0);
shun-iwasawa c86c5d
  hLayout()->addWidget(m_moveYField, 10);
Shinya Kitaoka d1f6c4
  if (m_setSaveboxCheckbox) {
shun-iwasawa c86c5d
    addSeparator();
shun-iwasawa c86c5d
    hLayout()->addWidget(m_setSaveboxCheckbox, 0);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
  VectorSelectionTool *vectorSelectionTool =
Shinya Kitaoka d1f6c4
      dynamic_cast<vectorselectiontool *="">(tool);</vectorselectiontool>
Shinya Kitaoka 120a6e
  if (vectorSelectionTool) {
Shinya Kitaoka 120a6e
    m_isVectorSelction = true;
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
    // change Thick
Shinya Kitaoka d1f6c4
    IconViewField *thicknessIconView =
Shinya Kitaoka d1f6c4
        new IconViewField(this, IconViewField::Icon_Thickness);
Shinya Kitaoka 120a6e
    m_thickChangeField = new ThickChangeField(selectionTool, tr("Thickness"));
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
    addSeparator();
shun-iwasawa c86c5d
    hLayout()->addWidget(thicknessIconView, 0);
shun-iwasawa c86c5d
    hLayout()->addWidget(m_thickChangeField, 10);
Shinya Kitaoka d1f6c4
    // Outline options
Shinya Kitaoka 120a6e
    // Outline options
Shinya Kitaoka 120a6e
    ToolOptionControlBuilder builder(this, tool, pltHandle, toolHandle);
Shinya Kitaoka 120a6e
    builder.setEnumWidgetType(ToolOptionControlBuilder::POPUPBUTTON);
Shinya Kitaoka 120a6e
    builder.setSingleValueWidgetType(ToolOptionControlBuilder::FIELD);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    addSeparator();
Shinya Kitaoka 120a6e
    if (tool && tool->getProperties(1)) tool->getProperties(1)->accept(builder);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    m_capStyle = dynamic_cast<tooloptionpopupbutton *="">(m_controls.value("Cap"));</tooloptionpopupbutton>
Shinya Kitaoka 120a6e
    m_joinStyle =
Shinya Kitaoka 120a6e
        dynamic_cast<tooloptionpopupbutton *="">(m_controls.value("Join"));</tooloptionpopupbutton>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    m_miterField =
Shinya Kitaoka 120a6e
        dynamic_cast<tooloptionintslider *="">(m_controls.value("Miter:"));</tooloptionintslider>
Shinya Kitaoka 120a6e
    m_miterField->setEnabled(m_joinStyle->currentIndex() ==
Shinya Kitaoka 120a6e
                             TStroke::OutlineOptions::MITER_JOIN);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    onPropertyChanged();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
  hLayout()->addStretch(1);
Shinya Kitaoka d1f6c4
  // assert(ret);
Shinya Kitaoka d1f6c4
  bool ret = connect(m_scaleXField, SIGNAL(valueChange()),
Shinya Kitaoka d1f6c4
                     SLOT(onScaleXValueChanged()));
Shinya Kitaoka d1f6c4
  ret = ret && connect(m_scaleYField, SIGNAL(valueChange()),
Shinya Kitaoka d1f6c4
                       SLOT(onScaleYValueChanged()));
Shinya Kitaoka d1f6c4
  if (m_setSaveboxCheckbox)
Shinya Kitaoka d1f6c4
    ret = ret && connect(m_setSaveboxCheckbox, SIGNAL(toggled(bool)),
Shinya Kitaoka d1f6c4
                         SLOT(onSetSaveboxCheckboxChanged(bool)));
shun-iwasawa c86c5d
Shinya Kitaoka d1f6c4
  // assert(ret);
shun-iwasawa c86c5d
Shinya Kitaoka d1f6c4
  updateStatus();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void SelectionToolOptionsBox::updateStatus() {
Shinya Kitaoka 120a6e
  QMap<std::string, *="" tooloptioncontrol="">::iterator it;</std::string,>
Shinya Kitaoka 120a6e
  for (it = m_controls.begin(); it != m_controls.end(); it++)
Shinya Kitaoka 120a6e
    it.value()->updateStatus();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_setSaveboxCheckbox) {
Shinya Kitaoka 120a6e
    bool disable = m_setSaveboxCheckbox->checkState() == Qt::Checked;
Shinya Kitaoka 120a6e
    for (int i = 0; i < hLayout()->count(); i++) {
Shinya Kitaoka 120a6e
      QWidget *w = hLayout()->itemAt(i)->widget();
Shinya Kitaoka 120a6e
      if (w && w != m_setSaveboxCheckbox) w->setEnabled(!disable);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    if (disable) return;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_scaleXField->updateStatus();
Shinya Kitaoka 120a6e
  m_scaleXLabel->setEnabled(m_scaleXField->isEnabled());
Shinya Kitaoka 120a6e
  m_scaleYField->updateStatus();
Shinya Kitaoka 120a6e
  m_scaleYLabel->setEnabled(m_scaleXField->isEnabled());
Shinya Kitaoka 120a6e
  m_rotationField->updateStatus();
Shinya Kitaoka 120a6e
  m_moveXField->updateStatus();
Shinya Kitaoka 120a6e
  m_moveXLabel->setEnabled(m_moveXField->isEnabled());
Shinya Kitaoka 120a6e
  m_moveYField->updateStatus();
Shinya Kitaoka 120a6e
  m_moveYLabel->setEnabled(m_moveYField->isEnabled());
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_isVectorSelction) {
Shinya Kitaoka 120a6e
    m_thickChangeField->updateStatus();
Shinya Kitaoka 120a6e
    onPropertyChanged();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void SelectionToolOptionsBox::onScaleXValueChanged() {
Shinya Kitaoka 120a6e
  if (!m_scaleLink->isChecked() ||
Shinya Kitaoka 120a6e
      m_scaleXField->getValue() == m_scaleYField->getValue())
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  m_scaleYField->setValue(m_scaleXField->getValue());
Shinya Kitaoka 120a6e
  m_scaleYField->applyChange();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void SelectionToolOptionsBox::onScaleYValueChanged() {
Shinya Kitaoka 120a6e
  if (!m_scaleLink->isChecked() ||
Shinya Kitaoka 120a6e
      m_scaleXField->getValue() == m_scaleYField->getValue())
Shinya Kitaoka 120a6e
    return;
Shinya Kitaoka 120a6e
  m_scaleXField->setValue(m_scaleYField->getValue());
Shinya Kitaoka 120a6e
  m_scaleXField->applyChange();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void SelectionToolOptionsBox::onSetSaveboxCheckboxChanged(bool) {
Shinya Kitaoka 120a6e
  updateStatus();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void SelectionToolOptionsBox::onPropertyChanged() {
Shinya Kitaoka 120a6e
  // Check the selection's outline styles group.
Shinya Kitaoka 120a6e
  VectorSelectionTool *tool = (VectorSelectionTool *)m_tool;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int capStyle, joinStyle;
Shinya Kitaoka 120a6e
  tool->selectionOutlineStyle(capStyle, joinStyle);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Show a void icon when no homogeneous style is found
Shinya Kitaoka 120a6e
  if (capStyle < 0)
Shinya Kitaoka 120a6e
    m_capStyle->setIcon(QPixmap());
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    // m_capStyle->setIcon(m_capStyle->currentItem()->icon());
Shinya Kitaoka 120a6e
    m_capStyle->setCurrentIndex(capStyle);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (joinStyle < 0)
Shinya Kitaoka 120a6e
    m_joinStyle->setIcon(QPixmap());
Shinya Kitaoka 120a6e
  else
Shinya Kitaoka 120a6e
    m_joinStyle->setCurrentIndex(joinStyle);
Shinya Kitaoka 120a6e
  // m_joinStyle->setIcon(m_joinStyle->currentItem()->icon());
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Enable the miter field only in case the join is of type miter
Shinya Kitaoka 120a6e
  m_miterField->setEnabled(joinStyle == TStroke::OutlineOptions::MITER_JOIN);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// GeometricToolOptionsBox
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
GeometricToolOptionsBox::GeometricToolOptionsBox(QWidget *parent, TTool *tool,
Shinya Kitaoka 120a6e
                                                 TPaletteHandle *pltHandle,
Shinya Kitaoka 120a6e
                                                 ToolHandle *toolHandle)
Shinya Kitaoka 120a6e
    : ToolOptionsBox(parent)
Shinya Kitaoka 120a6e
    , m_targetType(tool->getTargetType())
Shinya Kitaoka 120a6e
    , m_poligonSideLabel(0)
Shinya Kitaoka 120a6e
    , m_hardnessLabel(0)
Shinya Kitaoka 120a6e
    , m_hardnessField(0)
Shinya Kitaoka 120a6e
    , m_poligonSideField(0)
Shinya Kitaoka 120a6e
    , m_shapeField(0)
Shinya Kitaoka 120a6e
    , m_pencilMode(0) {
Shinya Kitaoka 120a6e
  setFrameStyle(QFrame::StyledPanel);
Shinya Kitaoka 120a6e
  setFixedHeight(26);
Shinya Kitaoka 120a6e
  TPropertyGroup *props = tool->getProperties(0);
Shinya Kitaoka 120a6e
  assert(props->getPropertyCount() > 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToolOptionControlBuilder builder(this, tool, pltHandle, toolHandle);
Shinya Kitaoka 120a6e
  if (tool && tool->getProperties(0)) tool->getProperties(0)->accept(builder);
Shinya Kitaoka 120a6e
  builder.setEnumWidgetType(ToolOptionControlBuilder::POPUPBUTTON);
Shinya Kitaoka 120a6e
  builder.setSingleValueWidgetType(ToolOptionControlBuilder::FIELD);
Shinya Kitaoka 120a6e
  addSeparator();
Shinya Kitaoka 120a6e
  if (tool && tool->getProperties(1)) tool->getProperties(1)->accept(builder);
Toshihiro Shimizu 890ddd
shun-iwasawa c86c5d
  hLayout()->addStretch(1);
Shinya Kitaoka 120a6e
  m_hardnessField =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptionslider *="">(m_controls.value("Hardness:"));</tooloptionslider>
Shinya Kitaoka 120a6e
  if (m_hardnessField)
Shinya Kitaoka 120a6e
    m_hardnessLabel = m_labels.value(m_hardnessField->propertyName());
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_shapeField = dynamic_cast<tooloptioncombo *="">(m_controls.value("Shape:"));</tooloptioncombo>
Shinya Kitaoka 120a6e
  m_poligonSideField =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptionintslider *="">(m_controls.value("Polygon Sides:"));</tooloptionintslider>
Shinya Kitaoka 120a6e
  if (m_poligonSideField)
Shinya Kitaoka 120a6e
    m_poligonSideLabel = m_labels.value(m_poligonSideField->propertyName());
Shinya Kitaoka 120a6e
  m_pencilMode =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Pencil Mode"));</tooloptioncheckbox>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_shapeField->currentText().toStdWString() != L"Polygon") {
Shinya Kitaoka 120a6e
    m_poligonSideLabel->setEnabled(false);
Shinya Kitaoka 120a6e
    m_poligonSideField->setEnabled(false);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  bool ret = connect(m_shapeField, SIGNAL(currentIndexChanged(int)), this,
Shinya Kitaoka 120a6e
                     SLOT(onShapeValueChanged()));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_pencilMode) {
Shinya Kitaoka 120a6e
    if (m_pencilMode->isChecked()) {
Shinya Kitaoka 120a6e
      m_hardnessLabel->setEnabled(false);
Shinya Kitaoka 120a6e
      m_hardnessField->setEnabled(false);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    ret = ret && connect(m_pencilMode, SIGNAL(toggled(bool)), this,
Shinya Kitaoka 120a6e
                         SLOT(onPencilModeToggled(bool)));
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToolOptionPopupButton *m_joinStyle =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptionpopupbutton *="">(m_controls.value("Join"));</tooloptionpopupbutton>
Shinya Kitaoka 120a6e
  m_miterField =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptionintslider *="">(m_controls.value("Miter:"));</tooloptionintslider>
Shinya Kitaoka 120a6e
  m_miterField->setEnabled(m_joinStyle->currentIndex() ==
Shinya Kitaoka 120a6e
                           TStroke::OutlineOptions::MITER_JOIN);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  assert(m_joinStyle && m_miterField);
Shinya Kitaoka 120a6e
  connect(m_joinStyle, SIGNAL(activated(int)), this,
Shinya Kitaoka 120a6e
          SLOT(onJoinStyleChanged(int)));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  assert(ret);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void GeometricToolOptionsBox::updateStatus() {
Shinya Kitaoka 120a6e
  QMap<std::string, *="" tooloptioncontrol="">::iterator it;</std::string,>
Shinya Kitaoka 120a6e
  for (it = m_controls.begin(); it != m_controls.end(); it++)
Shinya Kitaoka 120a6e
    it.value()->updateStatus();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void GeometricToolOptionsBox::onShapeValueChanged() {
Shinya Kitaoka 120a6e
  bool enabled = m_shapeField->currentText() == QString("Polygon");
Shinya Kitaoka 120a6e
  m_poligonSideLabel->setEnabled(enabled);
Shinya Kitaoka 120a6e
  m_poligonSideField->setEnabled(enabled);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void GeometricToolOptionsBox::onPencilModeToggled(bool value) {
Shinya Kitaoka 120a6e
  m_hardnessLabel->setEnabled(!value);
Shinya Kitaoka 120a6e
  m_hardnessField->setEnabled(!value);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void GeometricToolOptionsBox::onJoinStyleChanged(int joinStyle) {
Shinya Kitaoka 120a6e
  m_miterField->setEnabled(joinStyle == TStroke::OutlineOptions::MITER_JOIN);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// TypeToolOptionsBox
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TypeToolOptionsBox::TypeToolOptionsBox(QWidget *parent, TTool *tool,
Shinya Kitaoka 120a6e
                                       TPaletteHandle *pltHandle,
Shinya Kitaoka 120a6e
                                       ToolHandle *toolHandle)
Shinya Kitaoka 120a6e
    : ToolOptionsBox(parent), m_tool(tool) {
Shinya Kitaoka 120a6e
  TPropertyGroup *props = tool->getProperties(0);
Shinya Kitaoka 120a6e
  assert(props->getPropertyCount() > 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToolOptionControlBuilder builder(this, tool, pltHandle, toolHandle);
Shinya Kitaoka 120a6e
  if (tool && tool->getProperties(0)) tool->getProperties(0)->accept(builder);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_layout->addStretch(0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool ret = true;
Shinya Kitaoka 120a6e
  ToolOptionCombo *fontField =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptioncombo *="">(m_controls.value("Font:"));</tooloptioncombo>
Shinya Kitaoka 120a6e
  ret &&connect(fontField, SIGNAL(currentIndexChanged(int)), this,
Shinya Kitaoka 120a6e
                SLOT(onFieldChanged()));
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef MACOSX
Shinya Kitaoka 120a6e
  ToolOptionCombo *styleField =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptioncombo *="">(m_controls.value("Style:"));</tooloptioncombo>
Shinya Kitaoka 120a6e
  ret &&connect(styleField, SIGNAL(currentIndexChanged(int)), this,
Shinya Kitaoka 120a6e
                SLOT(onFieldChanged()));
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToolOptionCombo *sizeField =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptioncombo *="">(m_controls.value("Size:"));</tooloptioncombo>
Shinya Kitaoka 120a6e
  ret &&connect(sizeField, SIGNAL(currentIndexChanged(int)), this,
Shinya Kitaoka 120a6e
                SLOT(onFieldChanged()));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToolOptionCheckbox *orientationField = dynamic_cast<tooloptioncheckbox *="">(</tooloptioncheckbox>
Shinya Kitaoka 120a6e
      m_controls.value("Vertical Orientation"));
Shinya Kitaoka 120a6e
  ret = ret && connect(orientationField, SIGNAL(stateChanged(int)), this,
Shinya Kitaoka 120a6e
                       SLOT(onFieldChanged()));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  assert(ret);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TypeToolOptionsBox::updateStatus() {
Shinya Kitaoka 120a6e
  QMap<std::string, *="" tooloptioncontrol="">::iterator it;</std::string,>
Shinya Kitaoka 120a6e
  for (it = m_controls.begin(); it != m_controls.end(); it++)
Shinya Kitaoka 120a6e
    it.value()->updateStatus();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TypeToolOptionsBox::onFieldChanged() {
Shinya Kitaoka 120a6e
  assert(m_tool);
Shinya Kitaoka 120a6e
  m_tool->getViewer()->setFocus();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// PaintbrushToolOptionsBox
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
PaintbrushToolOptionsBox::PaintbrushToolOptionsBox(QWidget *parent, TTool *tool,
Shinya Kitaoka 120a6e
                                                   TPaletteHandle *pltHandle,
Shinya Kitaoka 120a6e
                                                   ToolHandle *toolHandle)
Shinya Kitaoka 120a6e
    : ToolOptionsBox(parent) {
Shinya Kitaoka 120a6e
  TPropertyGroup *props = tool->getProperties(0);
Shinya Kitaoka 120a6e
  assert(props->getPropertyCount() > 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToolOptionControlBuilder builder(this, tool, pltHandle, toolHandle);
Shinya Kitaoka 120a6e
  if (tool && tool->getProperties(0)) tool->getProperties(0)->accept(builder);
shun-iwasawa c86c5d
  hLayout()->addStretch(1);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_colorMode = dynamic_cast<tooloptioncombo *="">(m_controls.value("Mode:"));</tooloptioncombo>
Shinya Kitaoka 120a6e
  m_selectiveMode =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Selective"));</tooloptioncheckbox>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_colorMode->currentText().toStdWString() == L"Lines")
Shinya Kitaoka 120a6e
    m_selectiveMode->setEnabled(false);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool ret = connect(m_colorMode, SIGNAL(currentIndexChanged(int)), this,
Shinya Kitaoka 120a6e
                     SLOT(onColorModeChanged()));
Shinya Kitaoka 120a6e
  assert(ret);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void PaintbrushToolOptionsBox::updateStatus() {
Shinya Kitaoka 120a6e
  QMap<std::string, *="" tooloptioncontrol="">::iterator it;</std::string,>
Shinya Kitaoka 120a6e
  for (it = m_controls.begin(); it != m_controls.end(); it++)
Shinya Kitaoka 120a6e
    it.value()->updateStatus();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void PaintbrushToolOptionsBox::onColorModeChanged() {
Shinya Kitaoka 120a6e
  bool enabled = m_colorMode->currentText() != QString("Lines");
Shinya Kitaoka 120a6e
  m_selectiveMode->setEnabled(enabled);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// FillToolOptionsBox
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
FillToolOptionsBox::FillToolOptionsBox(QWidget *parent, TTool *tool,
Shinya Kitaoka 120a6e
                                       TPaletteHandle *pltHandle,
Shinya Kitaoka 120a6e
                                       ToolHandle *toolHandle)
Shinya Kitaoka 120a6e
    : ToolOptionsBox(parent)
Shinya Kitaoka 120a6e
    , m_targetType(tool->getTargetType())
Shinya Kitaoka 120a6e
    , m_fillDepthLabel(0)
Shinya Kitaoka 120a6e
    , m_fillDepthField(0)
Shinya Kitaoka 120a6e
    , m_segmentMode(0) {
Shinya Kitaoka 120a6e
  TPropertyGroup *props = tool->getProperties(0);
Shinya Kitaoka 120a6e
  assert(props->getPropertyCount() > 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToolOptionControlBuilder builder(this, tool, pltHandle, toolHandle);
Shinya Kitaoka 120a6e
  if (tool && tool->getProperties(0)) tool->getProperties(0)->accept(builder);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_layout->addStretch(0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_toolType  = dynamic_cast<tooloptioncombo *="">(m_controls.value("Type:"));</tooloptioncombo>
Shinya Kitaoka 120a6e
  m_colorMode = dynamic_cast<tooloptioncombo *="">(m_controls.value("Mode:"));</tooloptioncombo>
Shinya Kitaoka 120a6e
  m_selectiveMode =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Selective"));</tooloptioncheckbox>
Shinya Kitaoka 120a6e
  m_fillDepthField =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptionpairslider *="">(m_controls.value("Fill Depth"));</tooloptionpairslider>
Shinya Kitaoka 120a6e
  if (m_fillDepthField)
Shinya Kitaoka 120a6e
    m_fillDepthLabel = m_labels.value(m_fillDepthField->propertyName());
Shinya Kitaoka 120a6e
  m_segmentMode =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Segment"));</tooloptioncheckbox>
Shinya Kitaoka 120a6e
  m_onionMode =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Onion Skin"));</tooloptioncheckbox>
Shinya Kitaoka 120a6e
  m_multiFrameMode =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Frame Range"));</tooloptioncheckbox>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool ret = connect(m_colorMode, SIGNAL(currentIndexChanged(int)), this,
Shinya Kitaoka 120a6e
                     SLOT(onColorModeChanged()));
Shinya Kitaoka 120a6e
  ret = ret && connect(m_toolType, SIGNAL(currentIndexChanged(int)), this,
Shinya Kitaoka 120a6e
                       SLOT(onToolTypeChanged()));
Shinya Kitaoka 120a6e
  ret = ret && connect(m_onionMode, SIGNAL(toggled(bool)), this,
Shinya Kitaoka 120a6e
                       SLOT(onOnionModeToggled(bool)));
Shinya Kitaoka 120a6e
  ret = ret && connect(m_multiFrameMode, SIGNAL(toggled(bool)), this,
Shinya Kitaoka 120a6e
                       SLOT(onMultiFrameModeToggled(bool)));
Shinya Kitaoka 120a6e
  assert(ret);
Shinya Kitaoka 120a6e
  if (m_colorMode->currentText().toStdWString() == L"Lines") {
Shinya Kitaoka 120a6e
    m_selectiveMode->setEnabled(false);
Shinya Kitaoka 120a6e
    if (m_fillDepthLabel && m_fillDepthField) {
Shinya Kitaoka 120a6e
      m_fillDepthLabel->setEnabled(false);
Shinya Kitaoka 120a6e
      m_fillDepthField->setEnabled(false);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    if (m_toolType->currentText() == QString("Normal") ||
Shinya Kitaoka 120a6e
        m_multiFrameMode->isChecked())
Shinya Kitaoka 120a6e
      m_onionMode->setEnabled(false);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (m_toolType->currentText().toStdWString() != L"Normal") {
Shinya Kitaoka 120a6e
    if (m_segmentMode) m_segmentMode->setEnabled(false);
Shinya Kitaoka 120a6e
    if (m_colorMode->currentText() == QString("Lines") ||
Shinya Kitaoka 120a6e
        m_multiFrameMode->isChecked())
Shinya Kitaoka 120a6e
      m_onionMode->setEnabled(false);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (m_onionMode->isChecked()) m_multiFrameMode->setEnabled(false);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FillToolOptionsBox::updateStatus() {
Shinya Kitaoka 120a6e
  QMap<std::string, *="" tooloptioncontrol="">::iterator it;</std::string,>
Shinya Kitaoka 120a6e
  for (it = m_controls.begin(); it != m_controls.end(); it++)
Shinya Kitaoka 120a6e
    it.value()->updateStatus();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FillToolOptionsBox::onColorModeChanged() {
Shinya Kitaoka 120a6e
  bool enabled = m_colorMode->currentText() != QString("Lines");
Shinya Kitaoka 120a6e
  m_selectiveMode->setEnabled(enabled);
Shinya Kitaoka 120a6e
  if (m_fillDepthLabel && m_fillDepthField) {
Shinya Kitaoka 120a6e
    m_fillDepthLabel->setEnabled(enabled);
Shinya Kitaoka 120a6e
    m_fillDepthField->setEnabled(enabled);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  if (m_segmentMode) {
Shinya Kitaoka 120a6e
    enabled = m_colorMode->currentText() != QString("Areas");
Shinya Kitaoka 120a6e
    m_segmentMode->setEnabled(
Shinya Kitaoka 120a6e
        enabled ? m_toolType->currentText() == QString("Normal") : false);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  enabled = m_colorMode->currentText() != QString("Lines") &&
Shinya Kitaoka 120a6e
            !m_multiFrameMode->isChecked();
Shinya Kitaoka 120a6e
  m_onionMode->setEnabled(enabled);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FillToolOptionsBox::onToolTypeChanged() {
Shinya Kitaoka 120a6e
  bool enabled = m_toolType->currentText() == QString("Normal");
Shinya Kitaoka 120a6e
  if (m_segmentMode)
Shinya Kitaoka 120a6e
    m_segmentMode->setEnabled(
Shinya Kitaoka 120a6e
        enabled ? m_colorMode->currentText() != QString("Areas") : false);
Shinya Kitaoka 120a6e
  enabled = enabled || (m_colorMode->currentText() != QString("Lines") &&
Shinya Kitaoka 120a6e
                        !m_multiFrameMode->isChecked());
Shinya Kitaoka 120a6e
  m_onionMode->setEnabled(enabled);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FillToolOptionsBox::onOnionModeToggled(bool value) {
Shinya Kitaoka 120a6e
  m_multiFrameMode->setEnabled(!value);
Shinya Kitaoka 120a6e
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void FillToolOptionsBox::onMultiFrameModeToggled(bool value) {
Shinya Kitaoka 120a6e
  m_onionMode->setEnabled(!value);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// BrushToolOptionsBox classes
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class BrushToolOptionsBox::PresetNamePopup final : public DVGui::Dialog {
Shinya Kitaoka 120a6e
  DVGui::LineEdit *m_nameFld;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  PresetNamePopup() : Dialog(0, true) {
Shinya Kitaoka 120a6e
    setWindowTitle(tr("Preset Name"));
Shinya Kitaoka 120a6e
    m_nameFld = new DVGui::LineEdit();
Shinya Kitaoka 120a6e
    addWidget(m_nameFld);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    QPushButton *okBtn = new QPushButton(tr("OK"), this);
Shinya Kitaoka 120a6e
    okBtn->setDefault(true);
Shinya Kitaoka 120a6e
    QPushButton *cancelBtn = new QPushButton(tr("Cancel"), this);
Shinya Kitaoka 120a6e
    connect(okBtn, SIGNAL(clicked()), this, SLOT(accept()));
Shinya Kitaoka 120a6e
    connect(cancelBtn, SIGNAL(clicked()), this, SLOT(reject()));
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    addButtonBarWidget(okBtn, cancelBtn);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  QString getName() { return m_nameFld->text(); }
Shinya Kitaoka 120a6e
  void removeName() { m_nameFld->setText(QString("")); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// BrushToolOptionsBox
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
BrushToolOptionsBox::BrushToolOptionsBox(QWidget *parent, TTool *tool,
Shinya Kitaoka 120a6e
                                         TPaletteHandle *pltHandle,
Shinya Kitaoka 120a6e
                                         ToolHandle *toolHandle)
Shinya Kitaoka 120a6e
    : ToolOptionsBox(parent)
Shinya Kitaoka 120a6e
    , m_tool(tool)
Shinya Kitaoka 120a6e
    , m_presetNamePopup(0)
Shinya Kitaoka 120a6e
    , m_pencilMode(0)
Shinya Kitaoka 120a6e
    , m_hardnessLabel(0)
Shinya Kitaoka 120a6e
    , m_joinStyleCombo(0)
Shinya Kitaoka 120a6e
    , m_miterField(0) {
Shinya Kitaoka 120a6e
  TPropertyGroup *props = tool->getProperties(0);
Shinya Kitaoka 120a6e
  assert(props->getPropertyCount() > 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToolOptionControlBuilder builder(this, tool, pltHandle, toolHandle);
Shinya Kitaoka 120a6e
  if (tool && tool->getProperties(0)) tool->getProperties(0)->accept(builder);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_hardnessField =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptionslider *="">(m_controls.value("Hardness:"));</tooloptionslider>
Shinya Kitaoka 120a6e
  if (m_hardnessField)
Shinya Kitaoka 120a6e
    m_hardnessLabel = m_labels.value(m_hardnessField->propertyName());
Shinya Kitaoka 120a6e
  m_pencilMode = dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Pencil"));</tooloptioncheckbox>
Shinya Kitaoka 120a6e
  m_presetCombo = dynamic_cast<tooloptioncombo *="">(m_controls.value("Preset:"));</tooloptioncombo>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Preset +/- buttons
Shinya Kitaoka 120a6e
  m_addPresetButton    = new QPushButton(QString("+"));
Shinya Kitaoka 120a6e
  m_removePresetButton = new QPushButton(QString("-"));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_addPresetButton->setFixedSize(QSize(20, 20));
Shinya Kitaoka 120a6e
  m_removePresetButton->setFixedSize(QSize(20, 20));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  hLayout()->addWidget(m_addPresetButton);
Shinya Kitaoka 120a6e
  hLayout()->addWidget(m_removePresetButton);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  connect(m_addPresetButton, SIGNAL(clicked()), this, SLOT(onAddPreset()));
Shinya Kitaoka 120a6e
  connect(m_removePresetButton, SIGNAL(clicked()), this,
Shinya Kitaoka 120a6e
          SLOT(onRemovePreset()));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (tool->getTargetType() & TTool::ToonzImage) {
Shinya Kitaoka 120a6e
    assert(m_pencilMode);
Shinya Kitaoka 120a6e
    bool ret = connect(m_pencilMode, SIGNAL(toggled(bool)), this,
Shinya Kitaoka 120a6e
                       SLOT(onPencilModeToggled(bool)));
Shinya Kitaoka 120a6e
    assert(ret);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    if (m_pencilMode->isChecked()) {
Shinya Kitaoka 120a6e
      m_hardnessLabel->setEnabled(false);
Shinya Kitaoka 120a6e
      m_hardnessField->setEnabled(false);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
  } else if (tool->getTargetType() & TTool::Vectors) {
Shinya Kitaoka 120a6e
    // Further vector options
Shinya Kitaoka 120a6e
    builder.setEnumWidgetType(ToolOptionControlBuilder::POPUPBUTTON);
Shinya Kitaoka 120a6e
    builder.setSingleValueWidgetType(ToolOptionControlBuilder::FIELD);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    addSeparator();
Shinya Kitaoka 120a6e
    if (tool && tool->getProperties(1)) tool->getProperties(1)->accept(builder);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    m_joinStyleCombo =
Shinya Kitaoka 120a6e
        dynamic_cast<tooloptionpopupbutton *="">(m_controls.value("Join"));</tooloptionpopupbutton>
Shinya Kitaoka 120a6e
    m_miterField =
Shinya Kitaoka 120a6e
        dynamic_cast<tooloptionintslider *="">(m_controls.value("Miter:"));</tooloptionintslider>
Shinya Kitaoka 120a6e
    m_miterField->setEnabled(m_joinStyleCombo->currentIndex() ==
Shinya Kitaoka 120a6e
                             TStroke::OutlineOptions::MITER_JOIN);
Shinya Kitaoka 120a6e
  }
shun-iwasawa c86c5d
  hLayout()->addStretch(1);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void BrushToolOptionsBox::updateStatus() {
Shinya Kitaoka 120a6e
  QMap<std::string, *="" tooloptioncontrol="">::iterator it;</std::string,>
Shinya Kitaoka 120a6e
  for (it = m_controls.begin(); it != m_controls.end(); it++)
Shinya Kitaoka 120a6e
    it.value()->updateStatus();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_miterField)
Shinya Kitaoka 120a6e
    m_miterField->setEnabled(m_joinStyleCombo->currentIndex() ==
Shinya Kitaoka 120a6e
                             TStroke::OutlineOptions::MITER_JOIN);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void BrushToolOptionsBox::onPencilModeToggled(bool value) {
Shinya Kitaoka 120a6e
  m_hardnessLabel->setEnabled(!value);
Shinya Kitaoka 120a6e
  m_hardnessField->setEnabled(!value);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void BrushToolOptionsBox::onAddPreset() {
Shinya Kitaoka 120a6e
  // Initialize preset name popup
Shinya Kitaoka 120a6e
  if (!m_presetNamePopup) m_presetNamePopup = new PresetNamePopup;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (!m_presetNamePopup->getName().isEmpty()) m_presetNamePopup->removeName();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Retrieve the preset name
Shinya Kitaoka 120a6e
  bool ret = m_presetNamePopup->exec();
Shinya Kitaoka 120a6e
  if (!ret) return;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QString name(m_presetNamePopup->getName());
Shinya Kitaoka 120a6e
  m_presetNamePopup->removeName();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  switch (m_tool->getTargetType() & TTool::CommonImages) {
Shinya Kitaoka 120a6e
  case TTool::VectorImage:
Shinya Kitaoka 120a6e
  case TTool::ToonzImage: {
Shinya Kitaoka 120a6e
    static_cast<brushtool *="">(m_tool)->addPreset(name);</brushtool>
Shinya Kitaoka 120a6e
    break;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  case TTool::RasterImage: {
Shinya Kitaoka 120a6e
    static_cast<fullcolorbrushtool *="">(m_tool)->addPreset(name);</fullcolorbrushtool>
Shinya Kitaoka 120a6e
    break;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_presetCombo->loadEntries();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void BrushToolOptionsBox::onRemovePreset() {
Shinya Kitaoka 120a6e
  switch (m_tool->getTargetType() & TTool::CommonImages) {
Shinya Kitaoka 120a6e
  case TTool::VectorImage:
Shinya Kitaoka 120a6e
  case TTool::ToonzImage: {
Shinya Kitaoka 120a6e
    static_cast<brushtool *="">(m_tool)->removePreset();</brushtool>
Shinya Kitaoka 120a6e
    break;
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  case TTool::RasterImage: {
Shinya Kitaoka 120a6e
    static_cast<fullcolorbrushtool *="">(m_tool)->removePreset();</fullcolorbrushtool>
Shinya Kitaoka 120a6e
    break;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_presetCombo->loadEntries();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// EraserToolOptionsBox
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
EraserToolOptionsBox::EraserToolOptionsBox(QWidget *parent, TTool *tool,
Shinya Kitaoka 120a6e
                                           TPaletteHandle *pltHandle,
Shinya Kitaoka 120a6e
                                           ToolHandle *toolHandle)
Shinya Kitaoka 120a6e
    : ToolOptionsBox(parent), m_pencilMode(0), m_colorMode(0) {
Shinya Kitaoka 120a6e
  TPropertyGroup *props = tool->getProperties(0);
Shinya Kitaoka 120a6e
  assert(props->getPropertyCount() > 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToolOptionControlBuilder builder(this, tool, pltHandle, toolHandle);
Shinya Kitaoka 120a6e
  if (tool && tool->getProperties(0)) tool->getProperties(0)->accept(builder);
Toshihiro Shimizu 890ddd
shun-iwasawa c86c5d
  hLayout()->addStretch(1);
shun-iwasawa c86c5d
Shinya Kitaoka 120a6e
  m_toolType = dynamic_cast<tooloptioncombo *="">(m_controls.value("Type:"));</tooloptioncombo>
Shinya Kitaoka 120a6e
  m_hardnessField =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptionslider *="">(m_controls.value("Hardness:"));</tooloptionslider>
Shinya Kitaoka 120a6e
  if (m_hardnessField)
Shinya Kitaoka 120a6e
    m_hardnessLabel = m_labels.value(m_hardnessField->propertyName());
Shinya Kitaoka 120a6e
  m_colorMode  = dynamic_cast<tooloptioncombo *="">(m_controls.value("Mode:"));</tooloptioncombo>
Shinya Kitaoka 120a6e
  m_invertMode = dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Invert"));</tooloptioncheckbox>
Shinya Kitaoka 120a6e
  m_multiFrameMode =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Frame Range"));</tooloptioncheckbox>
Shinya Kitaoka 120a6e
  m_pencilMode =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Pencil Mode"));</tooloptioncheckbox>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool ret = true;
Shinya Kitaoka 120a6e
  if (m_pencilMode) {
Shinya Kitaoka 120a6e
    ret = ret && connect(m_pencilMode, SIGNAL(toggled(bool)), this,
Shinya Kitaoka 120a6e
                         SLOT(onPencilModeToggled(bool)));
Shinya Kitaoka 120a6e
    ret = ret && connect(m_colorMode, SIGNAL(currentIndexChanged(int)), this,
Shinya Kitaoka 120a6e
                         SLOT(onColorModeChanged()));
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ret = ret && connect(m_toolType, SIGNAL(currentIndexChanged(int)), this,
Shinya Kitaoka 120a6e
                       SLOT(onToolTypeChanged()));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_pencilMode && m_pencilMode->isChecked()) {
Shinya Kitaoka 120a6e
    assert(m_hardnessField && m_hardnessLabel);
Shinya Kitaoka 120a6e
    m_hardnessField->setEnabled(false);
Shinya Kitaoka 120a6e
    m_hardnessLabel->setEnabled(false);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_toolType && m_toolType->currentText() == QString("Normal")) {
Shinya Kitaoka 120a6e
    m_invertMode->setEnabled(false);
Shinya Kitaoka 120a6e
    m_multiFrameMode->setEnabled(false);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_colorMode && m_colorMode->currentText() == QString("Areas")) {
Shinya Kitaoka 120a6e
    assert(m_hardnessField && m_hardnessLabel && m_pencilMode);
Shinya Kitaoka 120a6e
    m_pencilMode->setEnabled(false);
Shinya Kitaoka 120a6e
    m_hardnessField->setEnabled(false);
Shinya Kitaoka 120a6e
    m_hardnessLabel->setEnabled(false);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void EraserToolOptionsBox::updateStatus() {
Shinya Kitaoka 120a6e
  QMap<std::string, *="" tooloptioncontrol="">::iterator it;</std::string,>
Shinya Kitaoka 120a6e
  for (it = m_controls.begin(); it != m_controls.end(); it++)
Shinya Kitaoka 120a6e
    it.value()->updateStatus();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void EraserToolOptionsBox::onPencilModeToggled(bool value) {
Shinya Kitaoka 120a6e
  if (m_hardnessField && m_hardnessLabel) {
Shinya Kitaoka 120a6e
    m_hardnessField->setEnabled(!value);
Shinya Kitaoka 120a6e
    m_hardnessLabel->setEnabled(!value);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void EraserToolOptionsBox::onToolTypeChanged() {
Shinya Kitaoka 120a6e
  bool value = m_toolType && m_toolType->currentText() != QString("Normal");
Shinya Kitaoka 120a6e
  m_invertMode->setEnabled(value);
Shinya Kitaoka 120a6e
  m_multiFrameMode->setEnabled(value);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void EraserToolOptionsBox::onColorModeChanged() {
Shinya Kitaoka 120a6e
  bool enabled = m_colorMode->currentText() != QString("Areas");
Shinya Kitaoka 120a6e
  if (m_pencilMode && m_hardnessField && m_hardnessLabel) {
Shinya Kitaoka 120a6e
    m_pencilMode->setEnabled(enabled);
Shinya Kitaoka 120a6e
    m_hardnessField->setEnabled(enabled ? !m_pencilMode->isChecked() : false);
Shinya Kitaoka 120a6e
    m_hardnessLabel->setEnabled(enabled ? !m_pencilMode->isChecked() : false);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// RulerToolOptionsBox
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//=============================================================================
Shinya Kitaoka d1f6c4
class ToolOptionsBarSeparator final : public QWidget {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ToolOptionsBarSeparator(QWidget *parent) : QWidget(parent) {
Shinya Kitaoka 120a6e
    setFixedSize(2, 26);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void paintEvent(QPaintEvent *) {
Shinya Kitaoka 120a6e
    QPainter p(this);
Shinya Kitaoka 120a6e
    p.setPen(QColor(64, 64, 64));
Shinya Kitaoka 120a6e
    p.drawLine(0, 0, 0, 25);
Shinya Kitaoka 120a6e
    p.setPen(Qt::white);
Shinya Kitaoka 120a6e
    p.drawLine(1, 0, 1, 25);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
RulerToolOptionsBox::RulerToolOptionsBox(QWidget *parent, TTool *tool)
Shinya Kitaoka 120a6e
    : ToolOptionsBox(parent), m_tool(tool) {
Shinya Kitaoka 120a6e
  setFrameStyle(QFrame::StyledPanel);
Shinya Kitaoka 120a6e
  setFixedHeight(26);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_Xfld = new MeasuredValueField(this);
Shinya Kitaoka 120a6e
  m_Yfld = new MeasuredValueField(this);
Shinya Kitaoka 120a6e
  m_Wfld = new MeasuredValueField(this);
Shinya Kitaoka 120a6e
  m_Hfld = new MeasuredValueField(this);
Shinya Kitaoka 120a6e
  m_Afld = new MeasuredValueField(this);
Shinya Kitaoka 120a6e
  m_Lfld = new MeasuredValueField(this);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_XpixelFld = new QLabel(this);
Shinya Kitaoka 120a6e
  m_YpixelFld = new QLabel(this);
Shinya Kitaoka 120a6e
  m_WpixelFld = new QLabel(this);
Shinya Kitaoka 120a6e
  m_HpixelFld = new QLabel(this);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_Afld->setMeasure("angle");
Shinya Kitaoka 120a6e
Jeremy Bullock 59dbbf
  if (Preferences::instance()->getUnits() == "pixel") {
Jeremy Bullock 59dbbf
    m_Xfld->setMeasure("length.x");
Jeremy Bullock 59dbbf
    m_Yfld->setMeasure("length.y");
Jeremy Bullock 59dbbf
    m_Wfld->setMeasure("length.x");
Jeremy Bullock 59dbbf
    m_Hfld->setMeasure("length.y");
Jeremy Bullock 59dbbf
    m_Lfld->setMeasure("length.x");
Jeremy Bullock 59dbbf
  }
Jeremy Bullock 99ca93
Shinya Kitaoka 120a6e
  m_Xfld->setObjectName("RulerToolOptionValues");
Shinya Kitaoka 120a6e
  m_Yfld->setObjectName("RulerToolOptionValues");
Shinya Kitaoka 120a6e
  m_Wfld->setObjectName("RulerToolOptionValues");
Shinya Kitaoka 120a6e
  m_Hfld->setObjectName("RulerToolOptionValues");
Shinya Kitaoka 120a6e
  m_Afld->setObjectName("RulerToolOptionValues");
Shinya Kitaoka 120a6e
  m_Lfld->setObjectName("RulerToolOptionValues");
Shinya Kitaoka 120a6e
  setStyleSheet(
Shinya Kitaoka 120a6e
      "#RulerToolOptionValues {border:0px; background: rgb(196,196,196);}");
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_Xfld->setMaximumWidth(70);
Shinya Kitaoka 120a6e
  m_Yfld->setMaximumWidth(70);
Shinya Kitaoka 120a6e
  m_Wfld->setMaximumWidth(70);
Shinya Kitaoka 120a6e
  m_Hfld->setMaximumWidth(70);
Shinya Kitaoka 120a6e
  m_Afld->setMaximumWidth(70);
Shinya Kitaoka 120a6e
  m_Lfld->setMaximumWidth(70);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_Xfld->setReadOnly(true);
Shinya Kitaoka 120a6e
  m_Yfld->setReadOnly(true);
Shinya Kitaoka 120a6e
  m_Wfld->setReadOnly(true);
Shinya Kitaoka 120a6e
  m_Hfld->setReadOnly(true);
Shinya Kitaoka 120a6e
  m_Afld->setReadOnly(true);
Shinya Kitaoka 120a6e
  m_Lfld->setReadOnly(true);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // layout
Shinya Kitaoka 120a6e
  QHBoxLayout *lay = new QHBoxLayout();
Shinya Kitaoka 120a6e
  lay->setMargin(0);
Shinya Kitaoka 120a6e
  lay->setSpacing(3);
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    lay->addWidget(new QLabel("X:", this), 0);
Shinya Kitaoka 120a6e
    lay->addWidget(m_Xfld, 0);
Shinya Kitaoka 120a6e
    lay->addWidget(m_XpixelFld, 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    lay->addSpacing(3);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    lay->addWidget(new QLabel("Y:", this), 0);
Shinya Kitaoka 120a6e
    lay->addWidget(m_Yfld, 0);
Shinya Kitaoka 120a6e
    lay->addWidget(m_YpixelFld, 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    lay->addSpacing(3);
Shinya Kitaoka 120a6e
    lay->addWidget(new ToolOptionsBarSeparator(this), 0);
Shinya Kitaoka 120a6e
    lay->addSpacing(3);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    lay->addWidget(new QLabel("W:", this), 0);
Shinya Kitaoka 120a6e
    lay->addWidget(m_Wfld, 0);
Shinya Kitaoka 120a6e
    lay->addWidget(m_WpixelFld, 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    lay->addSpacing(3);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    lay->addWidget(new QLabel("H:", this), 0);
Shinya Kitaoka 120a6e
    lay->addWidget(m_Hfld, 0);
Shinya Kitaoka 120a6e
    lay->addWidget(m_HpixelFld, 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    lay->addSpacing(3);
Shinya Kitaoka 120a6e
    lay->addWidget(new ToolOptionsBarSeparator(this), 0);
Shinya Kitaoka 120a6e
    lay->addSpacing(3);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    lay->addWidget(new QLabel("A:", this), 0);
Shinya Kitaoka 120a6e
    lay->addWidget(m_Afld, 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    lay->addSpacing(3);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    lay->addWidget(new QLabel("L:", this), 0);
Shinya Kitaoka 120a6e
    lay->addWidget(m_Lfld, 0);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  m_layout->addLayout(lay, 0);
Shinya Kitaoka 120a6e
  m_layout->addStretch(1);
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void RulerToolOptionsBox::updateValues(bool isRasterLevelEditing, double X,
Shinya Kitaoka 120a6e
                                       double Y, double W, double H, double A,
Shinya Kitaoka 120a6e
                                       double L, int Xpix, int Ypix, int Wpix,
Shinya Kitaoka 120a6e
                                       int Hpix) {
Shinya Kitaoka 120a6e
  m_Xfld->setValue(X);
Shinya Kitaoka 120a6e
  m_Yfld->setValue(Y);
Shinya Kitaoka 120a6e
  m_Wfld->setValue(W);
Shinya Kitaoka 120a6e
  m_Hfld->setValue(H);
Shinya Kitaoka 120a6e
  m_Afld->setValue(A);
Shinya Kitaoka 120a6e
  m_Lfld->setValue(L);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_XpixelFld->setVisible(isRasterLevelEditing);
Shinya Kitaoka 120a6e
  m_YpixelFld->setVisible(isRasterLevelEditing);
Shinya Kitaoka 120a6e
  m_WpixelFld->setVisible(isRasterLevelEditing);
Shinya Kitaoka 120a6e
  m_HpixelFld->setVisible(isRasterLevelEditing);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (isRasterLevelEditing) {
Shinya Kitaoka 120a6e
    m_XpixelFld->setText(QString("(%1)").arg(Xpix));
Shinya Kitaoka 120a6e
    m_YpixelFld->setText(QString("(%1)").arg(Ypix));
Shinya Kitaoka 120a6e
    m_WpixelFld->setText(QString("(%1)").arg(Wpix));
Shinya Kitaoka 120a6e
    m_HpixelFld->setText(QString("(%1)").arg(Hpix));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  repaint();
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void RulerToolOptionsBox::resetValues() {
Shinya Kitaoka 120a6e
  m_Xfld->setValue(0);
Shinya Kitaoka 120a6e
  m_Yfld->setValue(0);
Shinya Kitaoka 120a6e
  m_Wfld->setValue(0);
Shinya Kitaoka 120a6e
  m_Hfld->setValue(0);
Shinya Kitaoka 120a6e
  m_Afld->setValue(0);
Shinya Kitaoka 120a6e
  m_Lfld->setValue(0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  m_XpixelFld->setVisible(false);
Shinya Kitaoka 120a6e
  m_YpixelFld->setVisible(false);
Shinya Kitaoka 120a6e
  m_WpixelFld->setVisible(false);
Shinya Kitaoka 120a6e
  m_HpixelFld->setVisible(false);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  update();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
// TapeToolOptionsBox
Toshihiro Shimizu 890ddd
//
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TapeToolOptionsBox::TapeToolOptionsBox(QWidget *parent, TTool *tool,
Shinya Kitaoka 120a6e
                                       TPaletteHandle *pltHandle,
Shinya Kitaoka 120a6e
                                       ToolHandle *toolHandle)
Shinya Kitaoka 120a6e
    : ToolOptionsBox(parent)
Shinya Kitaoka 120a6e
    , m_smoothMode(0)
Shinya Kitaoka 120a6e
    , m_joinStrokesMode(0)
Shinya Kitaoka 120a6e
    , m_toolMode(0)
Shinya Kitaoka 120a6e
    , m_autocloseLabel(0)
Shinya Kitaoka 120a6e
    , m_autocloseField(0) {
Shinya Kitaoka 120a6e
  TPropertyGroup *props = tool->getProperties(0);
Shinya Kitaoka 120a6e
  assert(props->getPropertyCount() > 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToolOptionControlBuilder builder(this, tool, pltHandle, toolHandle);
Shinya Kitaoka 120a6e
  if (tool && tool->getProperties(0)) tool->getProperties(0)->accept(builder);
Shinya Kitaoka d1f6c4
shun-iwasawa c86c5d
  hLayout()->addStretch(1);
Shinya Kitaoka 120a6e
  if (!(tool->getTargetType() & TTool::Vectors)) return;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_smoothMode = dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Smooth"));</tooloptioncheckbox>
Shinya Kitaoka 120a6e
  m_joinStrokesMode =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptioncheckbox *="">(m_controls.value("JoinStrokes"));</tooloptioncheckbox>
Shinya Kitaoka 120a6e
  m_toolMode = dynamic_cast<tooloptioncombo *="">(m_controls.value("Mode"));</tooloptioncombo>
Shinya Kitaoka 120a6e
  m_typeMode = dynamic_cast<tooloptioncombo *="">(m_controls.value("Type"));</tooloptioncombo>
Shinya Kitaoka 120a6e
  m_autocloseField =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptionslider *="">(m_controls.value("Distance"));</tooloptionslider>
Shinya Kitaoka 120a6e
  if (m_autocloseField)
Shinya Kitaoka 120a6e
    m_autocloseLabel = m_labels.value(m_autocloseField->propertyName());
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool isNormalType = m_typeMode->currentText() == "Normal";
Shinya Kitaoka 120a6e
  m_toolMode->setEnabled(isNormalType);
Shinya Kitaoka 120a6e
  m_autocloseField->setEnabled(!isNormalType);
Shinya Kitaoka 120a6e
  m_autocloseLabel->setEnabled(!isNormalType);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool isLineToLineMode = m_toolMode->currentText() == "Line to Line";
Shinya Kitaoka 120a6e
  m_joinStrokesMode->setEnabled(!isLineToLineMode);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool isJoinStrokes = m_joinStrokesMode->isChecked();
Shinya Kitaoka 120a6e
  m_smoothMode->setEnabled(!isLineToLineMode && isJoinStrokes);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool ret = connect(m_typeMode, SIGNAL(currentIndexChanged(int)), this,
Shinya Kitaoka 120a6e
                     SLOT(onToolTypeChanged()));
Shinya Kitaoka 120a6e
  ret = ret && connect(m_toolMode, SIGNAL(currentIndexChanged(int)), this,
Shinya Kitaoka 120a6e
                       SLOT(onToolModeChanged()));
Shinya Kitaoka 120a6e
  ret = ret && connect(m_joinStrokesMode, SIGNAL(toggled(bool)), this,
Shinya Kitaoka 120a6e
                       SLOT(onJoinStrokesModeChanged()));
Shinya Kitaoka 120a6e
  assert(ret);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TapeToolOptionsBox::updateStatus() {
Shinya Kitaoka 120a6e
  QMap<std::string, *="" tooloptioncontrol="">::iterator it;</std::string,>
Shinya Kitaoka 120a6e
  for (it = m_controls.begin(); it != m_controls.end(); it++)
Shinya Kitaoka 120a6e
    it.value()->updateStatus();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TapeToolOptionsBox::onToolTypeChanged() {
Shinya Kitaoka 120a6e
  bool isNormalType = m_typeMode->currentText() == "Normal";
Shinya Kitaoka 120a6e
  m_toolMode->setEnabled(isNormalType);
Shinya Kitaoka 120a6e
  m_autocloseField->setEnabled(!isNormalType);
Shinya Kitaoka 120a6e
  m_autocloseLabel->setEnabled(!isNormalType);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TapeToolOptionsBox::onToolModeChanged() {
Shinya Kitaoka 120a6e
  bool isLineToLineMode = m_toolMode->currentText() == "Line to Line";
Shinya Kitaoka 120a6e
  m_joinStrokesMode->setEnabled(!isLineToLineMode);
Shinya Kitaoka 120a6e
  bool isJoinStrokes = m_joinStrokesMode->isChecked();
Shinya Kitaoka 120a6e
  m_smoothMode->setEnabled(!isLineToLineMode && isJoinStrokes);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TapeToolOptionsBox::onJoinStrokesModeChanged() {
Shinya Kitaoka 120a6e
  bool isLineToLineMode = m_toolMode->currentText() == "Line to Line";
Shinya Kitaoka 120a6e
  bool isJoinStrokes    = m_joinStrokesMode->isChecked();
Shinya Kitaoka 120a6e
  m_smoothMode->setEnabled(!isLineToLineMode && isJoinStrokes);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// RGBPickerToolOptions
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
/*! Label with background color
Toshihiro Shimizu 890ddd
*/
Shinya Kitaoka d1f6c4
class RGBLabel final : public QWidget {
Shinya Kitaoka 120a6e
  QColor m_color;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  RGBLabel(QColor color, QWidget *parent) : QWidget(parent), m_color(color) {
Shinya Kitaoka 120a6e
    setFixedSize(120, 20);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ~RGBLabel() {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setColorAndUpdate(QColor color) {
Shinya Kitaoka 120a6e
    if (m_color == color) return;
Shinya Kitaoka 120a6e
    m_color = color;
Shinya Kitaoka 120a6e
    update();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  void paintEvent(QPaintEvent *pe) {
Shinya Kitaoka 120a6e
    QPainter p(this);
Shinya Kitaoka 120a6e
    p.setPen(Qt::NoPen);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    // iwsw commented out temporarily
Shinya Kitaoka 120a6e
    /*
Shinya Kitaoka 120a6e
    if (Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled())
Shinya Kitaoka 120a6e
    {
Shinya Kitaoka 120a6e
            QColor convertedColor(m_color);
Shinya Kitaoka 120a6e
            Ghibli3DLutConverter::instance()->convert(convertedColor);
Shinya Kitaoka 120a6e
            p.setBrush(convertedColor);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
    */
Shinya Kitaoka 120a6e
    p.setBrush(m_color);
Shinya Kitaoka 120a6e
    p.setBrush(m_color);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    p.drawRect(rect());
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    // white text on dark color. black text on light color.
Shinya Kitaoka 120a6e
    int val = m_color.red() * 30 + m_color.green() * 59 + m_color.blue() * 11;
Shinya Kitaoka 120a6e
    if (val < 12800)
Shinya Kitaoka 120a6e
      p.setPen(Qt::white);
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
      p.setPen(Qt::black);
Shinya Kitaoka 120a6e
    p.setBrush(Qt::NoBrush);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    p.drawText(rect(), Qt::AlignCenter, QString("R:%1 G:%2 B:%3")
Shinya Kitaoka 120a6e
                                            .arg(m_color.red())
Shinya Kitaoka 120a6e
                                            .arg(m_color.green())
Shinya Kitaoka 120a6e
                                            .arg(m_color.blue()));
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
RGBPickerToolOptionsBox::RGBPickerToolOptionsBox(
Shinya Kitaoka 120a6e
    QWidget *parent, TTool *tool, TPaletteHandle *pltHandle,
Shinya Kitaoka 120a6e
    ToolHandle *toolHandle, PaletteController *paletteController)
Shinya Kitaoka 120a6e
    : ToolOptionsBox(parent) {
Shinya Kitaoka 120a6e
  setFrameStyle(QFrame::StyledPanel);
Shinya Kitaoka 120a6e
  setFixedHeight(26);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_currentRGBLabel = new RGBLabel(QColor(128, 128, 128), this);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QAction *pickScreenAction =
Shinya Kitaoka 120a6e
      CommandManager::instance()->getAction("A_ToolOption_PickScreen");
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QPushButton *button = new QPushButton(tr("Pick Screen"));
Shinya Kitaoka 120a6e
  button->setFixedHeight(20);
Shinya Kitaoka 120a6e
  button->addAction(pickScreenAction);
Shinya Kitaoka 120a6e
  connect(button, SIGNAL(clicked()), pickScreenAction, SLOT(trigger()));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TPropertyGroup *props = tool->getProperties(0);
Shinya Kitaoka 120a6e
  assert(props->getPropertyCount() > 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToolOptionControlBuilder builder(this, tool, pltHandle, toolHandle);
Shinya Kitaoka 120a6e
  if (tool && tool->getProperties(0)) tool->getProperties(0)->accept(builder);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_realTimePickMode =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Passive Pick"));</tooloptioncheckbox>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_layout->addWidget(m_currentRGBLabel, 0);
Shinya Kitaoka 120a6e
  m_layout->addStretch(1);
Shinya Kitaoka 120a6e
  m_layout->addWidget(button, 0);  // new in 6.4
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  if (m_realTimePickMode) {
Shinya Kitaoka 120a6e
    connect(m_realTimePickMode, SIGNAL(toggled(bool)), m_currentRGBLabel,
Shinya Kitaoka 120a6e
            SLOT(setVisible(bool)));
Shinya Kitaoka 120a6e
    m_currentRGBLabel->setVisible(m_realTimePickMode->isChecked());
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // for passive pick
Shinya Kitaoka 120a6e
  connect(paletteController, SIGNAL(colorPassivePicked(const QColor &)), this,
Shinya Kitaoka 120a6e
          SLOT(updateRealTimePickLabel(const QColor &)));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void RGBPickerToolOptionsBox::updateStatus() {
Shinya Kitaoka 120a6e
  QMap<std::string, *="" tooloptioncontrol="">::iterator it;</std::string,>
Shinya Kitaoka 120a6e
  for (it = m_controls.begin(); it != m_controls.end(); it++)
Shinya Kitaoka 120a6e
    it.value()->updateStatus();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void RGBPickerToolOptionsBox::updateRealTimePickLabel(const QColor &pix) {
Shinya Kitaoka 120a6e
  if (isVisible()) m_currentRGBLabel->setColorAndUpdate(pix);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// StylePickerToolOptions
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
StylePickerToolOptionsBox::StylePickerToolOptionsBox(
Shinya Kitaoka 120a6e
    QWidget *parent, TTool *tool, TPaletteHandle *pltHandle,
Shinya Kitaoka 120a6e
    ToolHandle *toolHandle, PaletteController *paletteController)
Shinya Kitaoka 120a6e
    : ToolOptionsBox(parent) {
Shinya Kitaoka 120a6e
  setFrameStyle(QFrame::StyledPanel);
Shinya Kitaoka 120a6e
  setFixedHeight(26);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_currentStyleLabel = new QLabel(" - - - ", this);
Shinya Kitaoka 120a6e
  m_currentStyleLabel->setObjectName("SytlePickerValue");
Shinya Kitaoka 120a6e
  setStyleSheet(
Shinya Kitaoka 120a6e
      "#SytlePickerValue {color: black; border:0px; background: "
Shinya Kitaoka 120a6e
      "rgb(196,196,196);}");
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_currentStyleLabel->setFixedSize(200, 20);
Shinya Kitaoka 120a6e
  m_currentStyleLabel->setAlignment(Qt::AlignCenter);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TPropertyGroup *props = tool->getProperties(0);
Shinya Kitaoka 120a6e
  assert(props->getPropertyCount() > 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ToolOptionControlBuilder builder(this, tool, pltHandle, toolHandle);
Shinya Kitaoka 120a6e
  if (tool && tool->getProperties(0)) tool->getProperties(0)->accept(builder);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_realTimePickMode =
Shinya Kitaoka 120a6e
      dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Passive Pick"));</tooloptioncheckbox>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_layout->addWidget(m_currentStyleLabel, 0);
Shinya Kitaoka 120a6e
  m_layout->addStretch(1);
Toshihiro Shimizu 890ddd
shun_iwasawa e897af
  // retrieve the "organize palette" checkbox from the layout and insert
shun_iwasawa 06bcc2
  // into rightmost of the tool option bar
shun_iwasawa e897af
  ToolOptionCheckbox *organizePaletteCB =
shun_iwasawa e897af
      dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Organize Palette"));</tooloptioncheckbox>
shun_iwasawa 06bcc2
  m_layout->removeWidget(organizePaletteCB);
shun_iwasawa 06bcc2
  m_layout->addWidget(new ToolOptionsBarSeparator(this), 0);
shun_iwasawa 06bcc2
  m_layout->addWidget(organizePaletteCB);
shun_iwasawa e897af
  organizePaletteCB->setToolTip(
shun_iwasawa e897af
      tr("With this option being activated, the picked style will be\nmoved to "
shun_iwasawa e897af
         "the end of the first page of the palette."));
shun_iwasawa 06bcc2
Shinya Kitaoka 120a6e
  if (m_realTimePickMode) {
Shinya Kitaoka 120a6e
    connect(m_realTimePickMode, SIGNAL(toggled(bool)), m_currentStyleLabel,
Shinya Kitaoka 120a6e
            SLOT(setVisible(bool)));
Shinya Kitaoka 120a6e
    m_currentStyleLabel->setVisible(m_realTimePickMode->isChecked());
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // for passive pick
Shinya Kitaoka 120a6e
  connect(paletteController,
Shinya Kitaoka 120a6e
          SIGNAL(stylePassivePicked(const int, const int, const int)), this,
Shinya Kitaoka 120a6e
          SLOT(updateRealTimePickLabel(const int, const int, const int)));
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void StylePickerToolOptionsBox::updateStatus() {
Shinya Kitaoka 120a6e
  QMap<std::string, *="" tooloptioncontrol="">::iterator it;</std::string,>
Shinya Kitaoka 120a6e
  for (it = m_controls.begin(); it != m_controls.end(); it++)
Shinya Kitaoka 120a6e
    it.value()->updateStatus();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void StylePickerToolOptionsBox::updateRealTimePickLabel(const int ink,
Shinya Kitaoka 120a6e
                                                        const int paint,
Shinya Kitaoka 120a6e
                                                        const int tone) {
Shinya Kitaoka 120a6e
  if (isVisible()) {
Shinya Kitaoka 120a6e
    if (ink < 0)
Shinya Kitaoka 120a6e
      m_currentStyleLabel->setText(" - - - ");
Shinya Kitaoka 120a6e
    else
Shinya Kitaoka 120a6e
      m_currentStyleLabel->setText(QString("INK: #%1  PAINT: #%2  TONE: %3")
Shinya Kitaoka 120a6e
                                       .arg(ink)
Shinya Kitaoka 120a6e
                                       .arg(paint)
Shinya Kitaoka 120a6e
                                       .arg(tone));
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// ToolOptions
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
ToolOptions::ToolOptions() : m_panel(0) {
Shinya Kitaoka 120a6e
  QHBoxLayout *mainLayout = new QHBoxLayout();
Shinya Kitaoka 120a6e
  mainLayout->setMargin(0);
Shinya Kitaoka 120a6e
  mainLayout->setSpacing(0);
Shinya Kitaoka 120a6e
  setLayout(mainLayout);
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
ToolOptions::~ToolOptions() {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void ToolOptions::showEvent(QShowEvent *) {
Shinya Kitaoka 120a6e
  TTool::Application *app = TTool::getApplication();
Shinya Kitaoka 120a6e
  ToolHandle *currTool    = app->getCurrentTool();
Shinya Kitaoka 120a6e
  if (currTool) {
Shinya Kitaoka 120a6e
    onToolSwitched();
Shinya Kitaoka 120a6e
    connect(currTool, SIGNAL(toolSwitched()), SLOT(onToolSwitched()));
Shinya Kitaoka 120a6e
    connect(currTool, SIGNAL(toolChanged()), SLOT(onToolChanged()));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TObjectHandle *currObject = app->getCurrentObject();
Shinya Kitaoka 120a6e
  if (currObject) {
Shinya Kitaoka 120a6e
    onStageObjectChange();
Shinya Kitaoka 120a6e
    connect(currObject, SIGNAL(objectSwitched()), SLOT(onStageObjectChange()));
Shinya Kitaoka 120a6e
    connect(currObject, SIGNAL(objectChanged(bool)),
Shinya Kitaoka 120a6e
            SLOT(onStageObjectChange()));
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TXshLevelHandle *currLevel = app->getCurrentLevel();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  if (currLevel)
Shinya Kitaoka 120a6e
    connect(currLevel, SIGNAL(xshLevelSwitched(TXshLevel *)), this,
Shinya Kitaoka 120a6e
            SLOT(onStageObjectChange()));
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void ToolOptions::hideEvent(QShowEvent *) {
Shinya Kitaoka 120a6e
  TTool::Application *app = TTool::getApplication();
Shinya Kitaoka 120a6e
  ToolHandle *currTool    = app->getCurrentTool();
Shinya Kitaoka 120a6e
  if (currTool) currTool->disconnect(this);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TObjectHandle *currObject = app->getCurrentObject();
Shinya Kitaoka 120a6e
  if (currObject) currObject->disconnect(this);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TXshLevelHandle *currLevel = app->getCurrentLevel();
Shinya Kitaoka 120a6e
  if (currLevel) currLevel->disconnect(this);
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void ToolOptions::onToolSwitched() {
Shinya Kitaoka 120a6e
  if (m_panel) m_panel->hide();
Shinya Kitaoka 120a6e
  m_panel = 0;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TTool::Application *app = TTool::getApplication();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // Quando i seguenti non serviranno piu', rimuovere gli header corrispondenti
Shinya Kitaoka 120a6e
  // in cima, thx
Shinya Kitaoka 120a6e
  TFrameHandle *currFrame   = app->getCurrentFrame();
Shinya Kitaoka 120a6e
  TObjectHandle *currObject = app->getCurrentObject();
Shinya Kitaoka 120a6e
  TXsheetHandle *currXsheet = app->getCurrentXsheet();
Shinya Kitaoka 120a6e
  TPaletteHandle *currPalette =
Shinya Kitaoka 120a6e
      app->getPaletteController()->getCurrentLevelPalette();
Shinya Kitaoka 120a6e
  ToolHandle *currTool = app->getCurrentTool();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TTool *tool = app->getCurrentTool()->getTool();
Shinya Kitaoka 120a6e
  if (tool) {
Shinya Kitaoka 120a6e
    // c'e' un tool corrente
Shinya Kitaoka 120a6e
    ToolOptionsBox *panel = 0;
Shinya Kitaoka 120a6e
    std::map<ttool *="" *,="" tooloptionsbox="">::iterator it = m_panels.find(tool);</ttool>
Shinya Kitaoka 120a6e
    if (it == m_panels.end()) {
Shinya Kitaoka 120a6e
      // ... senza panel associato
Shinya Kitaoka 120a6e
      if (tool->getName() == T_Edit) {
Shinya Kitaoka 120a6e
        TPropertyGroup *pg = tool->getProperties(0);
Shinya Kitaoka 120a6e
        panel = new ArrowToolOptionsBox(0, tool, pg, currFrame, currObject,
Shinya Kitaoka 120a6e
                                        currXsheet, currTool);
Shinya Kitaoka 120a6e
      } else if (tool->getName() == T_Selection)
Shinya Kitaoka 120a6e
        panel = new SelectionToolOptionsBox(0, tool, currPalette, currTool);
Shinya Kitaoka 120a6e
      else if (tool->getName() == T_Geometric)
Shinya Kitaoka 120a6e
        panel = new GeometricToolOptionsBox(0, tool, currPalette, currTool);
Shinya Kitaoka 120a6e
      else if (tool->getName() == T_Type)
Shinya Kitaoka 120a6e
        panel = new TypeToolOptionsBox(0, tool, currPalette, currTool);
Shinya Kitaoka 120a6e
      else if (tool->getName() == T_PaintBrush)
Shinya Kitaoka 120a6e
        panel = new PaintbrushToolOptionsBox(0, tool, currPalette, currTool);
Shinya Kitaoka 120a6e
      else if (tool->getName() == T_Fill)
Shinya Kitaoka 120a6e
        panel = new FillToolOptionsBox(0, tool, currPalette, currTool);
Shinya Kitaoka 120a6e
      else if (tool->getName() == T_Eraser)
Shinya Kitaoka 120a6e
        panel = new EraserToolOptionsBox(0, tool, currPalette, currTool);
Shinya Kitaoka 120a6e
      else if (tool->getName() == T_Tape)
Shinya Kitaoka 120a6e
        panel = new TapeToolOptionsBox(0, tool, currPalette, currTool);
Shinya Kitaoka 120a6e
      else if (tool->getName() == T_RGBPicker)
Shinya Kitaoka 120a6e
        panel = new RGBPickerToolOptionsBox(0, tool, currPalette, currTool,
Shinya Kitaoka 120a6e
                                            app->getPaletteController());
Shinya Kitaoka 120a6e
      else if (tool->getName() == T_Ruler) {
Shinya Kitaoka 120a6e
        RulerToolOptionsBox *p = new RulerToolOptionsBox(0, tool);
Shinya Kitaoka 120a6e
        panel                  = p;
Shinya Kitaoka 120a6e
        RulerTool *rt          = dynamic_cast<rulertool *="">(tool);</rulertool>
Shinya Kitaoka 120a6e
        if (rt) rt->setToolOptionsBox(p);
Shinya Kitaoka 120a6e
      } else if (tool->getName() == T_StylePicker)
Shinya Kitaoka 120a6e
        panel = new StylePickerToolOptionsBox(0, tool, currPalette, currTool,
Shinya Kitaoka 120a6e
                                              app->getPaletteController());
Shinya Kitaoka 120a6e
      else
Shinya Kitaoka 120a6e
        panel = tool->createOptionsBox();  // Only this line should remain out
Shinya Kitaoka 120a6e
                                           // of that if/else monstrosity
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      /* DANIELE: Regola per il futuro - NON FARE PIU' COME SOPRA.
Shinya Kitaoka 120a6e
Bisogna cominciare a collegare il metodo virtuale
Shinya Kitaoka 120a6e
createOptionsBox() di ogni tool.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
Chi ha tempo si adoperi un pochino per normalizzare
Shinya Kitaoka 120a6e
la situazione anche per i tool sopra, plz - basta spostare
Shinya Kitaoka 120a6e
un po' di codice... */
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
      m_panels[tool] = panel;
Shinya Kitaoka 120a6e
      layout()->addWidget(panel);
shun_iwasawa 4635d8
      emit newPanelCreated();
Shinya Kitaoka 120a6e
    } else {
Shinya Kitaoka 120a6e
      // il panel c'e' gia'.
Shinya Kitaoka 120a6e
      panel = it->second;
Shinya Kitaoka 120a6e
      panel->updateStatus();
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
    m_panel = panel;
Shinya Kitaoka 120a6e
    m_panel->show();
Shinya Kitaoka 120a6e
  } else {
Shinya Kitaoka 120a6e
    // niente tool
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void ToolOptions::onToolChanged() {
Shinya Kitaoka 120a6e
  assert(m_panel);
Shinya Kitaoka 120a6e
  ToolOptionsBox *optionBox = dynamic_cast<tooloptionsbox *="">(m_panel);</tooloptionsbox>
Shinya Kitaoka 120a6e
  assert(optionBox);
Shinya Kitaoka 120a6e
  optionBox->updateStatus();
Shinya Kitaoka 120a6e
}
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
//-----------------------------------------------------------------------------
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
void ToolOptions::onStageObjectChange() {
Shinya Kitaoka 120a6e
  TTool *tool = TTool::getApplication()->getCurrentTool()->getTool();
Shinya Kitaoka 120a6e
  if (!tool) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  std::map<ttool *="" *,="" tooloptionsbox="">::iterator it = m_panels.find(tool);</ttool>
Shinya Kitaoka 120a6e
  if (it == m_panels.end()) return;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  ToolOptionsBox *panel = it->second;
Shinya Kitaoka 120a6e
  panel->onStageObjectChange();
Toshihiro Shimizu 890ddd
}