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
manongjohn 19dec5
#include "edittool.h"
Toshihiro Shimizu 890ddd
#include "selectiontool.h"
Toshihiro Shimizu 890ddd
#include "vectorselectiontool.h"
Toshihiro Shimizu 890ddd
#include "rasterselectiontool.h"
shun-iwasawa 98926d
#include "toonzrasterbrushtool.h"
Toshihiro Shimizu 890ddd
#include "fullcolorbrushtool.h"
shun-iwasawa 98926d
#include "toonzvectorbrushtool.h"
Toshihiro Shimizu 890ddd
#include "tooloptionscontrols.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//#include "rgbpickertool.h"
Toshihiro Shimizu 890ddd
#include "rulertool.h"
shun-iwasawa 1d5937
#include "shifttracetool.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"
shun-iwasawa ad7711
#include "toonzqt/lutcalibrator.h"
manongjohn 4f0f61
#include "toonzqt/viewcommandids.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"
bf1d82
#include "toonz/tpalettehandle.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"
bf1d82
#include "toonz/mypaintbrushstyle.h"
shun-iwasawa 2b24e8
#include "toonz/tonionskinmaskhandle.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 <qpropertyanimation></qpropertyanimation>
Toshihiro Shimizu 890ddd
#include <qeasingcurve></qeasingcurve>
Toshihiro Shimizu 890ddd
#include <qstackedwidget></qstackedwidget>
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
shun-iwasawa 59484b
ToolOptionsBox::ToolOptionsBox(QWidget *parent, bool isScrollable)
shun-iwasawa 59484b
    : 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);
shun-iwasawa 59484b
shun-iwasawa 59484b
  if (isScrollable) {
shun-iwasawa 59484b
    QHBoxLayout *hLayout = new QHBoxLayout;
shun-iwasawa 59484b
    hLayout->setMargin(0);
shun-iwasawa 59484b
    hLayout->setSpacing(0);
shun-iwasawa 59484b
    setLayout(hLayout);
shun-iwasawa 59484b
shun-iwasawa 59484b
    // Build the scroll widget vin which the toolbar will be placed
shun-iwasawa 59484b
    DvScrollWidget *scrollWidget = new DvScrollWidget;
shun-iwasawa 59484b
    hLayout->addWidget(scrollWidget);
shun-iwasawa 59484b
shun-iwasawa 59484b
    // In the scrollable layout we add a widget of 24 height
shun-iwasawa 59484b
    // which contains the tooloptionBar. This is necessary
shun-iwasawa 59484b
    // to make the hboxlayout adjust the bar's vertical position.
shun-iwasawa 59484b
    QWidget *toolContainer = new QWidget;
shun-iwasawa 59484b
    scrollWidget->setWidget(toolContainer);
shun-iwasawa 59484b
shun-iwasawa 59484b
    toolContainer->setSizePolicy(QSizePolicy::MinimumExpanding,
shun-iwasawa 59484b
                                 QSizePolicy::Fixed);
shun-iwasawa 59484b
    toolContainer->setFixedHeight(24);
Jeremy Bullock ed3888
    toolContainer->setObjectName("toolOptionsPanel");
shun-iwasawa 59484b
    toolContainer->setLayout(m_layout);
shun-iwasawa 59484b
  } else
shun-iwasawa 59484b
    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(),
otakuto 675691
                std::default_delete<tooloptioncontrol>());</tooloptioncontrol>
John Dancel c323ac
  std::for_each(m_labels.begin(), m_labels.end(),
John Dancel c323ac
                std::default_delete<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
  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
  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
  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
  hLayout()->addWidget(control, 100);
Shinya Kitaoka 120a6e
  m_panel->addControl(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(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
  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
manongjohn b66bc4
  case FONTCOMBOBOX: {
manongjohn b66bc4
    if (p->getQStringName() != "") {
manongjohn b66bc4
      QLabel *label = addLabel(p);
manongjohn b66bc4
      m_panel->addLabel(p->getName(), label);
manongjohn b66bc4
    }
manongjohn b66bc4
    ToolOptionFontCombo *obj = new ToolOptionFontCombo(m_tool, p, m_toolHandle);
manongjohn b66bc4
    control                  = obj;
manongjohn b66bc4
    widget                   = obj;
manongjohn b66bc4
    break;
manongjohn b66bc4
  }
manongjohn b66bc4
Shinya Kitaoka 120a6e
  case COMBOBOX:
Shinya Kitaoka 120a6e
  default: {
Jeremy Bullock cd00fd
    if (p->getQStringName() != "") {
Jeremy Bullock cd00fd
      QLabel *label = addLabel(p);
Jeremy Bullock cd00fd
      m_panel->addLabel(p->getName(), label);
Jeremy Bullock cd00fd
    }
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
}
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,
Jeremy Bullock ed3888
                                             ToolHandle *toolHandle,
Jeremy Bullock ed3888
                                             bool scrollable)
Jeremy Bullock ed3888
    : ToolOptionsBox(parent, scrollable) {
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
shun-iwasawa 59484b
// show 17x17 icon without style dependency
shun-iwasawa 25d3db
class SimpleIconViewField : public DraggableIconView {
shun-iwasawa 59484b
  QIcon m_icon;
shun-iwasawa 59484b
shun-iwasawa 59484b
public:
shun-iwasawa 59484b
  SimpleIconViewField(const QString &iconName, const QString &toolTipStr = "",
shun-iwasawa 59484b
                      QWidget *parent = 0)
shun-iwasawa 25d3db
      : DraggableIconView(parent), m_icon(createQIcon(iconName.toUtf8())) {
Kite 521c84
    setMinimumSize(18, 18);
shun-iwasawa 59484b
    setToolTip(toolTipStr);
shun-iwasawa 59484b
  }
shun-iwasawa 59484b
shun-iwasawa 59484b
protected:
shun-iwasawa 59484b
  void paintEvent(QPaintEvent *e) {
shun-iwasawa 59484b
    QPainter p(this);
Kite 521c84
    p.drawPixmap(QRect(0, 2, 18, 18), m_icon.pixmap(18, 18));
shun-iwasawa 59484b
  }
shun-iwasawa 59484b
};
shun-iwasawa 59484b
shun-iwasawa 59484b
//-----------------------------------------------------------------------------
shun-iwasawa 59484b
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)
shun-iwasawa 59484b
    : ToolOptionsBox(parent, true)
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
manongjohn 19dec5
  EditTool *editTool = dynamic_cast<edittool *="">(tool);</edittool>
manongjohn 19dec5
shun-iwasawa 59484b
  m_axisOptionWidgets = new QWidget *[AllAxis];
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
shun-iwasawa 59484b
  m_pickWidget = new QWidget(this);
shun-iwasawa 59484b
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);
shun-iwasawa 80c2e7
  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");
Jeremy Bullock 771290
Jeremy Bullock 771290
  m_zLabel             = new ClickableLabel(tr("Z:"), this);
Jeremy Bullock 771290
  m_motionPathPosLabel = new ClickableLabel(tr("Position:"), this);
c7649c
  m_ewPosLabel         = new ClickableLabel(tr("X:"), this);
c7649c
  m_nsPosLabel         = new ClickableLabel(tr("Y:"), this);
Jeremy Bullock 771290
c7649c
  // Lock X
Shinya Kitaoka 120a6e
  TBoolProperty *lockProp =
c7649c
      dynamic_cast<tboolproperty *="">(m_pg->getProperty("Lock Position X"));</tboolproperty>
Shinya Kitaoka 120a6e
  if (lockProp)
Shinya Kitaoka 120a6e
    m_lockEWPosCheckbox =
Shinya Kitaoka 120a6e
        new ToolOptionCheckbox(m_tool, lockProp, toolHandle, this);
c7649c
  // Lock Y
Shinya Kitaoka 120a6e
  lockProp =
c7649c
      dynamic_cast<tboolproperty *="">(m_pg->getProperty("Lock Position Y"));</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
Jeremy Bullock 771290
  m_soLabel = new ClickableLabel(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 --- */
Jeremy Bullock 771290
  m_rotationLabel = new ClickableLabel(tr("Rotation:"), this);
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);
Jeremy Bullock 771290
Jeremy Bullock 771290
  m_globalScaleLabel = new ClickableLabel(tr("Global:"), this);
Jeremy Bullock 771290
  m_scaleHLabel      = new ClickableLabel(tr("H:"), this);
Jeremy Bullock 771290
  m_scaleVLabel      = new ClickableLabel(tr("V:"), this);
Jeremy Bullock 771290
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);
Jeremy Bullock 771290
  m_shearHLabel = new ClickableLabel(tr("H:"), this);
Jeremy Bullock 771290
  m_shearVLabel = new ClickableLabel(tr("V:"), this);
Jeremy Bullock 771290
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);
c7649c
  m_ewCenterLabel = new ClickableLabel(tr("X:"), this);
c7649c
  m_nsCenterLabel = new ClickableLabel(tr("Y:"), this);
Jeremy Bullock 771290
c7649c
  // Lock X Center
shun-iwasawa 80c2e7
  lockProp = dynamic_cast<tboolproperty *="">(m_pg->getProperty("Lock Center X"));</tboolproperty>
Shinya Kitaoka 120a6e
  if (lockProp)
Shinya Kitaoka 120a6e
    m_lockEWCenterCheckbox =
Shinya Kitaoka 120a6e
        new ToolOptionCheckbox(m_tool, lockProp, toolHandle, this);
c7649c
  // Lock Y Center
shun-iwasawa 80c2e7
  lockProp = dynamic_cast<tboolproperty *="">(m_pg->getProperty("Lock Center Y"));</tboolproperty>
Shinya Kitaoka 120a6e
  if (lockProp)
Shinya Kitaoka 120a6e
    m_lockNSCenterCheckbox =
Shinya Kitaoka 120a6e
        new ToolOptionCheckbox(m_tool, lockProp, toolHandle, this);
Shinya Kitaoka 120a6e
shun_iwasawa b366ef
  TBoolProperty *globalKeyProp =
Shinya Kitaoka 120a6e
      dynamic_cast<tboolproperty *="">(m_pg->getProperty("Global Key"));</tboolproperty>
shun_iwasawa b366ef
  if (globalKeyProp)
shun_iwasawa b366ef
    m_globalKey =
shun_iwasawa b366ef
        new ToolOptionCheckbox(m_tool, globalKeyProp, 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
manongjohn edf5e1
  m_hFlipButton = new QPushButton(this);
manongjohn edf5e1
  m_vFlipButton = new QPushButton(this);
manongjohn edf5e1
manongjohn 19dec5
  m_leftRotateButton  = new QPushButton(this);
manongjohn edf5e1
  m_rightRotateButton = new QPushButton(this);
manongjohn edf5e1
manongjohn edf5e1
  m_hFlipButton->setFixedSize(QSize(20, 20));
manongjohn edf5e1
  m_vFlipButton->setFixedSize(QSize(20, 20));
manongjohn edf5e1
manongjohn edf5e1
  m_leftRotateButton->setFixedSize(QSize(20, 20));
manongjohn edf5e1
  m_rightRotateButton->setFixedSize(QSize(20, 20));
manongjohn edf5e1
manongjohn edf5e1
  m_hFlipButton->setIcon(createQIcon("fliphoriz"));
manongjohn edf5e1
  m_hFlipButton->setIconSize(QSize(20, 20));
manongjohn edf5e1
  m_vFlipButton->setIcon(createQIcon("flipvert"));
manongjohn edf5e1
  m_vFlipButton->setIconSize(QSize(20, 20));
manongjohn edf5e1
  m_leftRotateButton->setIcon(createQIcon("rotateleft"));
manongjohn edf5e1
  m_leftRotateButton->setIconSize(QSize(20, 20));
manongjohn edf5e1
  m_rightRotateButton->setIcon(createQIcon("rotateright"));
manongjohn edf5e1
  m_rightRotateButton->setIconSize(QSize(20, 20));
manongjohn edf5e1
manongjohn edf5e1
  m_hFlipButton->setToolTip(tr("Flip Object Horizontally"));
manongjohn edf5e1
  m_vFlipButton->setToolTip(tr("Flip Object Vertically"));
manongjohn edf5e1
  m_leftRotateButton->setToolTip(tr("Rotate Object Left"));
manongjohn edf5e1
  m_rightRotateButton->setToolTip(tr("Rotate Object Right"));
manongjohn edf5e1
shun-iwasawa 80c2e7
  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
  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 59484b
    // Pick combobox only available on "All" axis mode
shun-iwasawa 59484b
    QHBoxLayout *pickLay = new QHBoxLayout();
shun-iwasawa 59484b
    pickLay->setMargin(0);
shun-iwasawa 59484b
    pickLay->setSpacing(0);
shun-iwasawa 59484b
    {
shun-iwasawa 59484b
      pickLay->addSpacing(5);
shun-iwasawa 59484b
      pickLay->addWidget(new QLabel(tr("Pick:"), this), 0);
shun-iwasawa 59484b
      pickLay->addWidget(m_pickCombo, 0);
shun-iwasawa 59484b
    }
shun-iwasawa 59484b
    m_pickWidget->setLayout(pickLay);
shun-iwasawa 59484b
    mainLay->addWidget(m_pickWidget, 0);
shun-iwasawa 59484b
shun-iwasawa c86c5d
    addSeparator();
shun-iwasawa c86c5d
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
      {
shun-iwasawa 59484b
        posLay->addWidget(
shun-iwasawa 59484b
            new SimpleIconViewField("edit_position", tr("Position"), this), 0);
shun-iwasawa 59484b
        posLay->addSpacing(LABEL_SPACING * 2);
Jeremy Bullock 771290
        posLay->addWidget(m_motionPathPosLabel, 0);
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
Jeremy Bullock 771290
        posLay->addWidget(m_zLabel, 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 59484b
        posLay->addSpacing(ITEM_SPACING);
shun-iwasawa 59484b
        posLay->addWidget(new DVGui::Separator("", this, false));
shun-iwasawa 59484b
shun-iwasawa c86c5d
        posLay->addStretch(1);
Shinya Kitaoka 120a6e
      }
shun-iwasawa 59484b
      m_axisOptionWidgets[Position] = posFrame;
shun-iwasawa 59484b
      mainLay->addWidget(m_axisOptionWidgets[Position], 0);
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
      {
shun-iwasawa 59484b
        rotLay->addWidget(
shun-iwasawa 59484b
            new SimpleIconViewField("edit_rotation", tr("Rotation"), this), 0);
shun-iwasawa 59484b
        rotLay->addSpacing(LABEL_SPACING * 2);
Jeremy Bullock 771290
        rotLay->addWidget(m_rotationLabel, 0);
shun-iwasawa 59484b
        rotLay->addSpacing(LABEL_SPACING);
shun-iwasawa c86c5d
        rotLay->addWidget(m_rotationField, 10);
manongjohn edf5e1
        rotLay->addWidget(m_leftRotateButton);
manongjohn edf5e1
        rotLay->addWidget(m_rightRotateButton);
shun-iwasawa c86c5d
shun-iwasawa 59484b
        rotLay->addSpacing(ITEM_SPACING);
shun-iwasawa 59484b
        rotLay->addWidget(new DVGui::Separator("", this, false));
shun-iwasawa 59484b
Shinya Kitaoka 120a6e
        rotLay->addStretch(1);
Shinya Kitaoka 120a6e
      }
shun-iwasawa 59484b
      m_axisOptionWidgets[Rotation] = rotFrame;
shun-iwasawa 59484b
      mainLay->addWidget(m_axisOptionWidgets[Rotation], 0);
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
      {
shun-iwasawa 59484b
        scaleLay->addWidget(
shun-iwasawa 59484b
            new SimpleIconViewField("edit_scale", tr("Scale"), this), 0);
shun-iwasawa 59484b
        scaleLay->addSpacing(LABEL_SPACING * 2);
shun-iwasawa c86c5d
Jeremy Bullock 771290
        scaleLay->addWidget(m_globalScaleLabel, 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
Jeremy Bullock 771290
        scaleLay->addWidget(m_scaleHLabel, 0);
shun-iwasawa c86c5d
        scaleLay->addSpacing(LABEL_SPACING);
shun-iwasawa c86c5d
        scaleLay->addWidget(m_scaleHField, 10);
manongjohn edf5e1
        scaleLay->addWidget(m_hFlipButton);
shun-iwasawa c86c5d
        scaleLay->addWidget(m_lockScaleHCheckbox, 0);
shun-iwasawa c86c5d
shun-iwasawa c86c5d
        scaleLay->addSpacing(ITEM_SPACING);
Shinya Kitaoka 120a6e
Jeremy Bullock 771290
        scaleLay->addWidget(m_scaleVLabel, 0);
shun-iwasawa c86c5d
        scaleLay->addSpacing(LABEL_SPACING);
shun-iwasawa c86c5d
        scaleLay->addWidget(m_scaleVField, 10);
manongjohn edf5e1
        scaleLay->addWidget(m_vFlipButton);
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
shun-iwasawa 59484b
        scaleLay->addSpacing(ITEM_SPACING);
shun-iwasawa 59484b
        scaleLay->addWidget(new DVGui::Separator("", this, false));
shun-iwasawa 59484b
Shinya Kitaoka 120a6e
        scaleLay->addStretch(1);
Shinya Kitaoka 120a6e
      }
shun-iwasawa 59484b
      m_axisOptionWidgets[Scale] = scaleFrame;
shun-iwasawa 59484b
      mainLay->addWidget(m_axisOptionWidgets[Scale], 0);
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
      {
shun-iwasawa 59484b
        shearLay->addWidget(
shun-iwasawa 59484b
            new SimpleIconViewField("edit_shear", tr("Shear"), this), 0);
shun-iwasawa 59484b
        shearLay->addSpacing(LABEL_SPACING * 2);
shun-iwasawa c86c5d
Jeremy Bullock 771290
        shearLay->addWidget(m_shearHLabel, 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
Jeremy Bullock 771290
        shearLay->addWidget(m_shearVLabel, 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
shun-iwasawa 59484b
        shearLay->addWidget(new DVGui::Separator("", this, false));
shun-iwasawa 59484b
Shinya Kitaoka 120a6e
        shearLay->addStretch(1);
Shinya Kitaoka 120a6e
      }
shun-iwasawa 59484b
      m_axisOptionWidgets[Shear] = shearFrame;
shun-iwasawa 59484b
      mainLay->addWidget(m_axisOptionWidgets[Shear], 0);
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
      {
shun-iwasawa 59484b
        centerPosLay->addWidget(
shun-iwasawa 59484b
            new SimpleIconViewField("edit_center", tr("Center Position"), this),
shun-iwasawa 59484b
            0);
shun-iwasawa 59484b
        centerPosLay->addSpacing(LABEL_SPACING * 2);
Shinya Kitaoka 120a6e
Jeremy Bullock 771290
        centerPosLay->addWidget(m_ewCenterLabel, 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
Jeremy Bullock 771290
        centerPosLay->addWidget(m_nsCenterLabel, 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
shun-iwasawa 59484b
        centerPosLay->addSpacing(ITEM_SPACING);
shun-iwasawa 59484b
        centerPosLay->addWidget(new DVGui::Separator("", this, false));
shun-iwasawa 59484b
Shinya Kitaoka 120a6e
        centerPosLay->addStretch(1);
Shinya Kitaoka 120a6e
      }
shun-iwasawa 59484b
      m_axisOptionWidgets[CenterPosition] = centerPosFrame;
shun-iwasawa 59484b
      mainLay->addWidget(m_axisOptionWidgets[CenterPosition], 0);
Shinya Kitaoka 120a6e
    }
Shinya Kitaoka 120a6e
shun-iwasawa c86c5d
    mainLay->addWidget(m_globalKey, 0);
Shinya Kitaoka 120a6e
shun-iwasawa 59484b
    mainLay->addSpacing(ITEM_SPACING);
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /* --- signal-slot connections --- */
Shinya Kitaoka 120a6e
  // swap page when the active axis is changed
shun-iwasawa 59484b
  connect(m_chooseActiveAxisCombo, SIGNAL(currentIndexChanged(int)), this,
shun-iwasawa 59484b
          SLOT(onCurrentAxisChanged(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
  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
  }
shun_iwasawa b366ef
shun-iwasawa 59484b
  // enables adjusting value by dragging on the label
shun-iwasawa 59484b
  connectLabelAndField(m_motionPathPosLabel, m_motionPathPosField);
shun-iwasawa 59484b
  connectLabelAndField(m_ewPosLabel, m_ewPosField);
shun-iwasawa 59484b
  connectLabelAndField(m_nsPosLabel, m_nsPosField);
shun-iwasawa 59484b
  connectLabelAndField(m_zLabel, m_zField);
shun-iwasawa 59484b
  connectLabelAndField(m_soLabel, m_soField);
shun-iwasawa 59484b
  connectLabelAndField(m_rotationLabel, m_rotationField);
shun-iwasawa 59484b
  connectLabelAndField(m_globalScaleLabel, m_globalScaleField);
shun-iwasawa 59484b
  connectLabelAndField(m_scaleHLabel, m_scaleHField);
shun-iwasawa 59484b
  connectLabelAndField(m_scaleVLabel, m_scaleVField);
shun-iwasawa 59484b
  connectLabelAndField(m_shearHLabel, m_shearHField);
shun-iwasawa 59484b
  connectLabelAndField(m_shearVLabel, m_shearVField);
shun-iwasawa 59484b
  connectLabelAndField(m_ewCenterLabel, m_ewCenterField);
shun-iwasawa 59484b
  connectLabelAndField(m_nsCenterLabel, m_nsCenterField);
shun_iwasawa 68d38f
shun-iwasawa 59484b
  onCurrentAxisChanged(activeAxisProp->getIndex());
manongjohn edf5e1
manongjohn edf5e1
  connect(m_hFlipButton, SIGNAL(clicked()), SLOT(onFlipHorizontal()));
manongjohn edf5e1
  connect(m_vFlipButton, SIGNAL(clicked()), SLOT(onFlipVertical()));
manongjohn edf5e1
  connect(m_leftRotateButton, SIGNAL(clicked()), SLOT(onRotateLeft()));
manongjohn edf5e1
  connect(m_rightRotateButton, SIGNAL(clicked()), SLOT(onRotateRight()));
manongjohn 19dec5
manongjohn 19dec5
  connect(editTool, SIGNAL(clickFlipHorizontal()), SLOT(onFlipHorizontal()));
manongjohn 19dec5
  connect(editTool, SIGNAL(clickFlipVertical()), SLOT(onFlipVertical()));
manongjohn 19dec5
  connect(editTool, SIGNAL(clickRotateLeft()), SLOT(onRotateLeft()));
manongjohn 19dec5
  connect(editTool, SIGNAL(clickRotateRight()), SLOT(onRotateRight()));
shun-iwasawa 59484b
}
shun-iwasawa 59484b
shun-iwasawa 59484b
//-----------------------------------------------------------------------------
shun-iwasawa 59484b
// enables adjusting value by dragging on the label
shun-iwasawa 59484b
shun-iwasawa 59484b
void ArrowToolOptionsBox::connectLabelAndField(ClickableLabel *label,
shun-iwasawa 59484b
                                               MeasuredValueField *field) {
shun-iwasawa 59484b
  connect(label, SIGNAL(onMousePress(QMouseEvent *)), field,
shun-iwasawa 59484b
          SLOT(receiveMousePress(QMouseEvent *)));
shun-iwasawa 59484b
  connect(label, SIGNAL(onMouseMove(QMouseEvent *)), field,
shun-iwasawa 59484b
          SLOT(receiveMouseMove(QMouseEvent *)));
shun-iwasawa 59484b
  connect(label, SIGNAL(onMouseRelease(QMouseEvent *)), field,
shun-iwasawa 59484b
          SLOT(receiveMouseRelease(QMouseEvent *)));
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
shun-iwasawa 59484b
  m_motionPathPosLabel->setVisible(on);
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();
shun-iwasawa 390cff
  m_lockEWPosCheckbox->updateStatus();
shun-iwasawa 390cff
  m_lockNSPosCheckbox->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();
shun-iwasawa 390cff
  m_lockScaleHCheckbox->updateStatus();
shun-iwasawa 390cff
  m_lockScaleVCheckbox->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();
shun-iwasawa 390cff
  m_lockShearHCheckbox->updateStatus();
shun-iwasawa 390cff
  m_lockShearVCheckbox->updateStatus();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Center Position
Shinya Kitaoka 120a6e
  m_ewCenterField->updateStatus();
Shinya Kitaoka 120a6e
  m_nsCenterField->updateStatus();
shun-iwasawa 390cff
  m_lockEWCenterCheckbox->updateStatus();
shun-iwasawa 390cff
  m_lockNSCenterCheckbox->updateStatus();
shun-iwasawa 390cff
shun-iwasawa 390cff
  m_globalKey->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
shun-iwasawa e1a8da
 */
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);
shun-iwasawa 86dc52
    QString itemName     = (id.isTable())
shun-iwasawa 86dc52
                           ? tr("Table")
shun-iwasawa 86dc52
                           : 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
//------------------------------------------------------------------------------
luz paz 6454c4
/*! synchronize the current item in the combobox to the selected stage object
shun-iwasawa e1a8da
 */
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
shun-iwasawa e1a8da
 */
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
John Dancel c323ac
  if (id.isCamera()) {
John Dancel c323ac
    TXsheet *xsh = m_xshHandle->getXsheet();
John Dancel c323ac
    if (xsh->getCameraColumnIndex() != id.getIndex())
John Dancel c323ac
      m_xshHandle->changeXsheetCamera(id.getIndex());
John Dancel c323ac
  }
flurick 7916c4
  m_objHandle->setObjectId(id);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
shun-iwasawa 59484b
//------------------------------------------------------------------------------
shun-iwasawa 59484b
shun-iwasawa 59484b
void ArrowToolOptionsBox::onCurrentAxisChanged(int axisId) {
shun-iwasawa 59484b
  // Show the specified axis options, hide all the others
shun-iwasawa 59484b
  for (int a = 0; a != AllAxis; ++a)
shun-iwasawa 59484b
    m_axisOptionWidgets[a]->setVisible(a == axisId || axisId == AllAxis);
shun-iwasawa 59484b
shun-iwasawa 59484b
  m_pickWidget->setVisible(axisId == AllAxis);
shun-iwasawa 59484b
}
shun-iwasawa 59484b
manongjohn edf5e1
//-----------------------------------------------------------------------------
manongjohn edf5e1
manongjohn edf5e1
void ArrowToolOptionsBox::onFlipHorizontal() {
manongjohn edf5e1
  m_scaleHField->setValue(m_scaleHField->getValue() * -1);
manongjohn edf5e1
  emit m_scaleHField->measuredValueChanged(m_scaleHField->getMeasuredValue());
manongjohn edf5e1
}
manongjohn edf5e1
manongjohn edf5e1
//-----------------------------------------------------------------------------
manongjohn edf5e1
manongjohn edf5e1
void ArrowToolOptionsBox::onFlipVertical() {
manongjohn edf5e1
  m_scaleVField->setValue(m_scaleVField->getValue() * -1);
manongjohn edf5e1
  emit m_scaleVField->measuredValueChanged(m_scaleVField->getMeasuredValue());
manongjohn edf5e1
}
manongjohn edf5e1
manongjohn edf5e1
//-----------------------------------------------------------------------------
manongjohn edf5e1
manongjohn edf5e1
void ArrowToolOptionsBox::onRotateLeft() {
manongjohn edf5e1
  m_rotationField->setValue(m_rotationField->getValue() + 90);
manongjohn 19dec5
  emit m_rotationField->measuredValueChanged(
manongjohn 19dec5
      m_rotationField->getMeasuredValue());
manongjohn edf5e1
}
manongjohn edf5e1
manongjohn edf5e1
//-----------------------------------------------------------------------------
manongjohn edf5e1
manongjohn edf5e1
void ArrowToolOptionsBox::onRotateRight() {
manongjohn edf5e1
  m_rotationField->setValue(m_rotationField->getValue() - 90);
manongjohn 19dec5
  emit m_rotationField->measuredValueChanged(
manongjohn 19dec5
      m_rotationField->getMeasuredValue());
manongjohn edf5e1
}
manongjohn edf5e1
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)
shun-iwasawa 25d3db
    : DraggableIconView(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 25d3db
void DraggableIconView::mousePressEvent(QMouseEvent *event) {
Jeremy Bullock 771290
  emit onMousePress(event);
Jeremy Bullock 771290
}
Jeremy Bullock 771290
shun-iwasawa 25d3db
void DraggableIconView::mouseMoveEvent(QMouseEvent *event) {
Jeremy Bullock 771290
  emit onMouseMove(event);
Jeremy Bullock 771290
}
Jeremy Bullock 771290
shun-iwasawa 25d3db
void DraggableIconView::mouseReleaseEvent(QMouseEvent *event) {
Jeremy Bullock 771290
  emit onMouseRelease(event);
Jeremy Bullock 771290
}
Jeremy Bullock 771290
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
Jeremy Bullock 771290
  m_scaleXLabel = new ClickableLabel(tr("H:"), this);
shun-iwasawa c86c5d
  m_scaleXField = new SelectionScaleField(selectionTool, 0, "Scale X");
Jeremy Bullock 771290
  m_scaleYLabel = new ClickableLabel(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
shun-iwasawa 25d3db
  SimpleIconViewField *rotIconView =
shun-iwasawa 25d3db
      new SimpleIconViewField("edit_rotation", tr("Rotation"));
shun-iwasawa c86c5d
  m_rotationField = new SelectionRotationField(selectionTool, tr("Rotation"));
shun-iwasawa c86c5d
c7649c
  m_moveXLabel = new ClickableLabel(tr("X:"), this);
shun-iwasawa c86c5d
  m_moveXField = new SelectionMoveField(selectionTool, 0, "Move X");
c7649c
  m_moveYLabel = new ClickableLabel(tr("Y:"), this);
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
manongjohn f6d1e1
  m_hFlipButton = new QPushButton(this);
manongjohn f6d1e1
  m_vFlipButton = new QPushButton(this);
manongjohn f6d1e1
manongjohn f6d1e1
  m_leftRotateButton  = new QPushButton(this);
manongjohn f6d1e1
  m_rightRotateButton = new QPushButton(this);
manongjohn f6d1e1
manongjohn f6d1e1
  m_hFlipButton->setFixedSize(QSize(20, 20));
manongjohn f6d1e1
  m_vFlipButton->setFixedSize(QSize(20, 20));
manongjohn f6d1e1
manongjohn f6d1e1
  m_leftRotateButton->setFixedSize(QSize(20, 20));
manongjohn f6d1e1
  m_rightRotateButton->setFixedSize(QSize(20, 20));
manongjohn f6d1e1
manongjohn f6d1e1
  m_hFlipButton->setIcon(createQIcon("fliphoriz"));
manongjohn f6d1e1
  m_hFlipButton->setIconSize(QSize(20, 20));
manongjohn f6d1e1
  m_vFlipButton->setIcon(createQIcon("flipvert"));
manongjohn f6d1e1
  m_vFlipButton->setIconSize(QSize(20, 20));
manongjohn f6d1e1
  m_leftRotateButton->setIcon(createQIcon("rotateleft"));
manongjohn f6d1e1
  m_leftRotateButton->setIconSize(QSize(20, 20));
manongjohn f6d1e1
  m_rightRotateButton->setIcon(createQIcon("rotateright"));
manongjohn f6d1e1
  m_rightRotateButton->setIconSize(QSize(20, 20));
manongjohn f6d1e1
manongjohn f6d1e1
  m_hFlipButton->setToolTip(tr("Flip Selection Horizontally"));
manongjohn f6d1e1
  m_vFlipButton->setToolTip(tr("Flip Selection Vertically"));
manongjohn f6d1e1
  m_leftRotateButton->setToolTip(tr("Rotate Selection Left"));
manongjohn f6d1e1
  m_rightRotateButton->setToolTip(tr("Rotate Selection Right"));
manongjohn f6d1e1
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
manongjohn f6d1e1
  m_hFlipButton->setEnabled(false);
manongjohn f6d1e1
  m_vFlipButton->setEnabled(false);
manongjohn f6d1e1
  m_leftRotateButton->setEnabled(false);
manongjohn f6d1e1
  m_rightRotateButton->setEnabled(false);
manongjohn f6d1e1
Shinya Kitaoka d1f6c4
  //--- layout ----
shun-iwasawa c86c5d
shun-iwasawa c86c5d
  addSeparator();
shun-iwasawa c86c5d
shun-iwasawa 25d3db
  hLayout()->addWidget(new SimpleIconViewField("edit_scale", tr("Scale"), this),
shun-iwasawa 25d3db
                       0);
shun-iwasawa c86c5d
  hLayout()->addWidget(m_scaleXLabel, 0);
shun-iwasawa c86c5d
  hLayout()->addWidget(m_scaleXField, 10);
manongjohn f6d1e1
  hLayout()->addWidget(m_hFlipButton);
shun-iwasawa c86c5d
  hLayout()->addWidget(m_scaleYLabel, 0);
shun-iwasawa c86c5d
  hLayout()->addWidget(m_scaleYField, 10);
manongjohn f6d1e1
  hLayout()->addWidget(m_vFlipButton);
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);
manongjohn f6d1e1
  hLayout()->addWidget(m_leftRotateButton);
manongjohn f6d1e1
  hLayout()->addWidget(m_rightRotateButton);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  addSeparator();
Shinya Kitaoka 120a6e
shun-iwasawa 25d3db
  hLayout()->addWidget(
shun-iwasawa 25d3db
      new SimpleIconViewField("edit_position", tr("Position"), this), 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
Kite 521c84
    SimpleIconViewField *thicknessIconView =
Kite 521c84
        new SimpleIconViewField("thickness", tr("Thickness"), this);
Shinya Kitaoka 120a6e
    m_thickChangeField = new ThickChangeField(selectionTool, tr("Thickness"));
Shinya Kitaoka 120a6e
Jeremy Bullock 771290
    connect(thicknessIconView, SIGNAL(onMousePress(QMouseEvent *)),
Jeremy Bullock 771290
            m_thickChangeField, SLOT(receiveMousePress(QMouseEvent *)));
Jeremy Bullock 771290
    connect(thicknessIconView, SIGNAL(onMouseMove(QMouseEvent *)),
Jeremy Bullock 771290
            m_thickChangeField, SLOT(receiveMouseMove(QMouseEvent *)));
Jeremy Bullock 771290
    connect(thicknessIconView, SIGNAL(onMouseRelease(QMouseEvent *)),
Jeremy Bullock 771290
            m_thickChangeField, SLOT(receiveMouseRelease(QMouseEvent *)));
Jeremy Bullock 771290
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
    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);
Jeremy Bullock 771290
  bool ret = connect(m_scaleXField, SIGNAL(valueChange(bool)),
Jeremy Bullock 771290
                     SLOT(onScaleXValueChanged(bool)));
shun-iwasawa 80c2e7
  ret      = ret && connect(m_scaleYField, SIGNAL(valueChange(bool)),
Jeremy Bullock 771290
                       SLOT(onScaleYValueChanged(bool)));
Shinya Kitaoka d1f6c4
  if (m_setSaveboxCheckbox)
Shinya Kitaoka d1f6c4
    ret = ret && connect(m_setSaveboxCheckbox, SIGNAL(toggled(bool)),
Shinya Kitaoka d1f6c4
                         SLOT(onSetSaveboxCheckboxChanged(bool)));
Jeremy Bullock 771290
  connect(m_scaleXLabel, SIGNAL(onMousePress(QMouseEvent *)), m_scaleXField,
Jeremy Bullock 771290
          SLOT(receiveMousePress(QMouseEvent *)));
Jeremy Bullock 771290
  connect(m_scaleXLabel, SIGNAL(onMouseMove(QMouseEvent *)), m_scaleXField,
Jeremy Bullock 771290
          SLOT(receiveMouseMove(QMouseEvent *)));
Jeremy Bullock 771290
  connect(m_scaleXLabel, SIGNAL(onMouseRelease(QMouseEvent *)), m_scaleXField,
Jeremy Bullock 771290
          SLOT(receiveMouseRelease(QMouseEvent *)));
Jeremy Bullock 771290
  connect(m_scaleYLabel, SIGNAL(onMousePress(QMouseEvent *)), m_scaleYField,
Jeremy Bullock 771290
          SLOT(receiveMousePress(QMouseEvent *)));
Jeremy Bullock 771290
  connect(m_scaleYLabel, SIGNAL(onMouseMove(QMouseEvent *)), m_scaleYField,
Jeremy Bullock 771290
          SLOT(receiveMouseMove(QMouseEvent *)));
Jeremy Bullock 771290
  connect(m_scaleYLabel, SIGNAL(onMouseRelease(QMouseEvent *)), m_scaleYField,
Jeremy Bullock 771290
          SLOT(receiveMouseRelease(QMouseEvent *)));
Jeremy Bullock 771290
  connect(rotIconView, SIGNAL(onMousePress(QMouseEvent *)), m_rotationField,
Jeremy Bullock 771290
          SLOT(receiveMousePress(QMouseEvent *)));
Jeremy Bullock 771290
  connect(rotIconView, SIGNAL(onMouseMove(QMouseEvent *)), m_rotationField,
Jeremy Bullock 771290
          SLOT(receiveMouseMove(QMouseEvent *)));
Jeremy Bullock 771290
  connect(rotIconView, SIGNAL(onMouseRelease(QMouseEvent *)), m_rotationField,
Jeremy Bullock 771290
          SLOT(receiveMouseRelease(QMouseEvent *)));
Jeremy Bullock 771290
  connect(m_moveXLabel, SIGNAL(onMousePress(QMouseEvent *)), m_moveXField,
Jeremy Bullock 771290
          SLOT(receiveMousePress(QMouseEvent *)));
Jeremy Bullock 771290
  connect(m_moveXLabel, SIGNAL(onMouseMove(QMouseEvent *)), m_moveXField,
Jeremy Bullock 771290
          SLOT(receiveMouseMove(QMouseEvent *)));
Jeremy Bullock 771290
  connect(m_moveXLabel, SIGNAL(onMouseRelease(QMouseEvent *)), m_moveXField,
Jeremy Bullock 771290
          SLOT(receiveMouseRelease(QMouseEvent *)));
Jeremy Bullock 771290
  connect(m_moveYLabel, SIGNAL(onMousePress(QMouseEvent *)), m_moveYField,
Jeremy Bullock 771290
          SLOT(receiveMousePress(QMouseEvent *)));
Jeremy Bullock 771290
  connect(m_moveYLabel, SIGNAL(onMouseMove(QMouseEvent *)), m_moveYField,
Jeremy Bullock 771290
          SLOT(receiveMouseMove(QMouseEvent *)));
Jeremy Bullock 771290
  connect(m_moveYLabel, SIGNAL(onMouseRelease(QMouseEvent *)), m_moveYField,
Jeremy Bullock 771290
          SLOT(receiveMouseRelease(QMouseEvent *)));
manongjohn f6d1e1
  connect(m_hFlipButton, SIGNAL(clicked()), SLOT(onFlipHorizontal()));
manongjohn f6d1e1
  connect(m_vFlipButton, SIGNAL(clicked()), SLOT(onFlipVertical()));
manongjohn f6d1e1
  connect(m_leftRotateButton, SIGNAL(clicked()), SLOT(onRotateLeft()));
manongjohn f6d1e1
  connect(m_rightRotateButton, SIGNAL(clicked()),
manongjohn f6d1e1
          SLOT(onRotateRight()));
manongjohn 19dec5
manongjohn 19dec5
  connect(selectionTool, SIGNAL(clickFlipHorizontal()),
manongjohn 19dec5
          SLOT(onFlipHorizontal()));
manongjohn 19dec5
  connect(selectionTool, SIGNAL(clickFlipVertical()), SLOT(onFlipVertical()));
manongjohn 19dec5
  connect(selectionTool, SIGNAL(clickRotateLeft()), SLOT(onRotateLeft()));
manongjohn 19dec5
  connect(selectionTool, SIGNAL(clickRotateRight()), SLOT(onRotateRight()));
manongjohn 19dec5
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
manongjohn f6d1e1
  m_hFlipButton->setEnabled(m_scaleXField->isEnabled());
manongjohn f6d1e1
  m_vFlipButton->setEnabled(m_scaleXField->isEnabled());
manongjohn f6d1e1
  m_leftRotateButton->setEnabled(m_rotationField->isEnabled());
manongjohn f6d1e1
  m_rightRotateButton->setEnabled(m_rotationField->isEnabled());
manongjohn f6d1e1
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
Jeremy Bullock 771290
void SelectionToolOptionsBox::onScaleXValueChanged(bool addToUndo) {
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());
Jeremy Bullock 771290
  m_scaleYField->applyChange(addToUndo);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Jeremy Bullock 771290
void SelectionToolOptionsBox::onScaleYValueChanged(bool addToUndo) {
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());
Jeremy Bullock 771290
  m_scaleXField->applyChange(addToUndo);
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
manongjohn f6d1e1
void SelectionToolOptionsBox::onFlipHorizontal() {
manongjohn f6d1e1
  m_scaleXField->setValue(m_scaleXField->getValue() * -1);
manongjohn f6d1e1
  m_scaleXField->applyChange(true);
manongjohn f6d1e1
manongjohn f6d1e1
  onScaleXValueChanged(true);
manongjohn f6d1e1
}
manongjohn f6d1e1
manongjohn f6d1e1
//-----------------------------------------------------------------------------
manongjohn f6d1e1
manongjohn f6d1e1
void SelectionToolOptionsBox::onFlipVertical() {
manongjohn f6d1e1
  m_scaleYField->setValue(m_scaleYField->getValue() * -1);
manongjohn f6d1e1
  m_scaleYField->applyChange(true);
manongjohn f6d1e1
manongjohn f6d1e1
  onScaleYValueChanged(true);
manongjohn f6d1e1
}
manongjohn f6d1e1
manongjohn f6d1e1
//-----------------------------------------------------------------------------
manongjohn f6d1e1
manongjohn f6d1e1
void SelectionToolOptionsBox::onRotateLeft() {
manongjohn f6d1e1
  m_rotationField->setValue(m_rotationField->getValue() + 90);
manongjohn f6d1e1
  m_rotationField->applyChange(true);
manongjohn f6d1e1
}
manongjohn f6d1e1
manongjohn f6d1e1
//-----------------------------------------------------------------------------
manongjohn f6d1e1
manongjohn f6d1e1
void SelectionToolOptionsBox::onRotateRight() {
manongjohn f6d1e1
  m_rotationField->setValue(m_rotationField->getValue() - 90);
manongjohn f6d1e1
  m_rotationField->applyChange(true);
manongjohn f6d1e1
}
manongjohn f6d1e1
manongjohn f6d1e1
//-----------------------------------------------------------------------------
manongjohn f6d1e1
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)
Jeremy Bullock 977232
    , m_snapCheckbox(0)
shun-iwasawa 78ea8c
    , m_smoothCheckbox(0)
Jeremy Bullock 977232
    , m_snapSensitivityCombo(0)
Jeremy Bullock 977232
    , m_tool(tool)
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
shun-iwasawa 48ed93
  if (m_shapeField->getProperty()->getValue() != L"Polygon") {
Shinya Kitaoka 120a6e
    m_poligonSideLabel->setEnabled(false);
Shinya Kitaoka 120a6e
    m_poligonSideField->setEnabled(false);
Shinya Kitaoka 120a6e
  }
shun-iwasawa 78ea8c
shun-iwasawa 78ea8c
  m_smoothCheckbox =
shun-iwasawa 78ea8c
      dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Smooth"));</tooloptioncheckbox>
shun-iwasawa 78ea8c
  if (m_shapeField->getProperty()->getValue() != L"MultiArc") {
shun-iwasawa 78ea8c
    m_smoothCheckbox->setEnabled(false);
shun-iwasawa 78ea8c
  }
shun-iwasawa 78ea8c
Shinya Kitaoka 120a6e
  bool ret = connect(m_shapeField, SIGNAL(currentIndexChanged(int)), this,
shun-iwasawa 48ed93
                     SLOT(onShapeValueChanged(int)));
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
Jeremy Bullock 977232
  if (tool->getTargetType() & TTool::Vectors) {
Jeremy Bullock 977232
    m_snapCheckbox =
Jeremy Bullock 977232
        dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Snap"));</tooloptioncheckbox>
Jeremy Bullock 977232
    m_snapSensitivityCombo =
Jeremy Bullock 977232
        dynamic_cast<tooloptioncombo *="">(m_controls.value("Sensitivity:"));</tooloptioncombo>
Jeremy Bullock 977232
    m_snapSensitivityCombo->setHidden(!m_snapCheckbox->isChecked());
Jeremy Bullock 977232
  }
Jeremy Bullock 977232
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();
Jeremy Bullock 977232
  if (m_tool->getTargetType() & TTool::Vectors) {
Jeremy Bullock 977232
    m_snapSensitivityCombo->setHidden(!m_snapCheckbox->isChecked());
Jeremy Bullock 977232
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
shun-iwasawa 48ed93
void GeometricToolOptionsBox::onShapeValueChanged(int index) {
shun-iwasawa 48ed93
  const TEnumProperty::Range &range = m_shapeField->getProperty()->getRange();
shun-iwasawa 78ea8c
  bool polygonEnabled               = range[index] == L"Polygon";
shun-iwasawa 78ea8c
  m_poligonSideLabel->setEnabled(polygonEnabled);
shun-iwasawa 78ea8c
  m_poligonSideField->setEnabled(polygonEnabled);
shun-iwasawa 78ea8c
shun-iwasawa 78ea8c
  m_smoothCheckbox->setEnabled(range[index] == L"MultiArc");
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);
manongjohn b66bc4
  builder.setEnumWidgetType(ToolOptionControlBuilder::FONTCOMBOBOX);
Shinya Kitaoka 120a6e
  if (tool && tool->getProperties(0)) tool->getProperties(0)->accept(builder);
manongjohn b66bc4
  builder.setEnumWidgetType(ToolOptionControlBuilder::COMBOBOX);
manongjohn b66bc4
  if (tool && tool->getProperties(1)) tool->getProperties(1)->accept(builder);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  m_layout->addStretch(0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool ret = true;
manongjohn b66bc4
manongjohn b66bc4
  ToolOptionFontCombo *fontField =
manongjohn b66bc4
      dynamic_cast<tooloptionfontcombo *="">(m_controls.value("Font:"));</tooloptionfontcombo>
Shinya Kitaoka 120a6e
  ret &&connect(fontField, SIGNAL(currentIndexChanged(int)), this,
Shinya Kitaoka 120a6e
                SLOT(onFieldChanged()));
Toshihiro Shimizu 890ddd
manongjohn b66bc4
  //#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()));
manongjohn b66bc4
  ret &&connect(toolHandle, SIGNAL(toolComboBoxListChanged(std::string)),
manongjohn b66bc4
                styleField, SLOT(reloadComboBoxList(std::string)));
manongjohn b66bc4
  //#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>
manongjohn f027d1
  m_lockAlphaMode =
manongjohn f027d1
      dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Lock Alpha"));</tooloptioncheckbox>
Toshihiro Shimizu 890ddd
manongjohn f027d1
  if (m_colorMode->getProperty()->getValue() == L"Lines") {
shun-iwasawa e1a8da
    m_selectiveMode->setVisible(false);
manongjohn f027d1
    m_lockAlphaMode->setVisible(false);
manongjohn f027d1
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool ret = connect(m_colorMode, SIGNAL(currentIndexChanged(int)), this,
shun-iwasawa 48ed93
                     SLOT(onColorModeChanged(int)));
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
shun-iwasawa 48ed93
void PaintbrushToolOptionsBox::onColorModeChanged(int index) {
shun-iwasawa 48ed93
  const TEnumProperty::Range &range = m_colorMode->getProperty()->getRange();
shun-iwasawa 48ed93
  bool enabled                      = range[index] != L"Lines";
shun-iwasawa e1a8da
  m_selectiveMode->setVisible(enabled);
manongjohn f027d1
  m_lockAlphaMode->setVisible(enabled);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
//
shun-iwasawa 14c787
// FullColorFillToolOptionsBox
shun-iwasawa 14c787
//
shun-iwasawa 14c787
//=============================================================================
shun-iwasawa 14c787
shun-iwasawa 14c787
FullColorFillToolOptionsBox::FullColorFillToolOptionsBox(
shun-iwasawa 14c787
    QWidget *parent, TTool *tool, TPaletteHandle *pltHandle,
shun-iwasawa 14c787
    ToolHandle *toolHandle)
shun-iwasawa 14c787
    : ToolOptionsBox(parent) {
shun-iwasawa 14c787
  TPropertyGroup *props = tool->getProperties(0);
shun-iwasawa 14c787
  assert(props->getPropertyCount() > 0);
shun-iwasawa 14c787
shun-iwasawa 14c787
  ToolOptionControlBuilder builder(this, tool, pltHandle, toolHandle);
shun-iwasawa 14c787
  if (tool && tool->getProperties(0)) tool->getProperties(0)->accept(builder);
shun-iwasawa 14c787
shun-iwasawa 14c787
  m_layout->addStretch(0);
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>
shun-iwasawa 43640b
  m_autopaintMode =
shun-iwasawa 43640b
      dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Autopaint Lines"));</tooloptioncheckbox>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool ret = connect(m_colorMode, SIGNAL(currentIndexChanged(int)), this,
shun-iwasawa 48ed93
                     SLOT(onColorModeChanged(int)));
shun-iwasawa 80c2e7
  ret      = ret && connect(m_toolType, SIGNAL(currentIndexChanged(int)), this,
shun-iwasawa 48ed93
                       SLOT(onToolTypeChanged(int)));
shun-iwasawa 80c2e7
  ret      = ret && connect(m_onionMode, SIGNAL(toggled(bool)), this,
Shinya Kitaoka 120a6e
                       SLOT(onOnionModeToggled(bool)));
shun-iwasawa 80c2e7
  ret      = ret && connect(m_multiFrameMode, SIGNAL(toggled(bool)), this,
Shinya Kitaoka 120a6e
                       SLOT(onMultiFrameModeToggled(bool)));
Shinya Kitaoka 120a6e
  assert(ret);
shun-iwasawa 48ed93
  if (m_colorMode->getProperty()->getValue() == 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
    }
shun-iwasawa 48ed93
    if (m_toolType->getProperty()->getValue() == L"Normal" ||
Shinya Kitaoka 120a6e
        m_multiFrameMode->isChecked())
Shinya Kitaoka 120a6e
      m_onionMode->setEnabled(false);
shun_iwasawa 68d38f
    if (m_autopaintMode) m_autopaintMode->setEnabled(false);
Shinya Kitaoka 120a6e
  }
shun-iwasawa 48ed93
  if (m_toolType->getProperty()->getValue() != L"Normal") {
Shinya Kitaoka 120a6e
    if (m_segmentMode) m_segmentMode->setEnabled(false);
shun-iwasawa 48ed93
    if (m_colorMode->getProperty()->getValue() == L"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
shun-iwasawa 48ed93
void FillToolOptionsBox::onColorModeChanged(int index) {
shun-iwasawa 48ed93
  const TEnumProperty::Range &range = m_colorMode->getProperty()->getRange();
shun-iwasawa 48ed93
  bool enabled                      = range[index] != L"Lines";
Shinya Kitaoka 120a6e
  m_selectiveMode->setEnabled(enabled);
shun_iwasawa 68d38f
  if (m_autopaintMode) m_autopaintMode->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) {
shun-iwasawa 48ed93
    enabled = range[index] != L"Areas";
Shinya Kitaoka 120a6e
    m_segmentMode->setEnabled(
shun-iwasawa 48ed93
        enabled ? m_toolType->getProperty()->getValue() == L"Normal" : false);
Shinya Kitaoka 120a6e
  }
shun-iwasawa 48ed93
  enabled = range[index] != L"Lines" && !m_multiFrameMode->isChecked();
Shinya Kitaoka 120a6e
  m_onionMode->setEnabled(enabled);
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
shun-iwasawa 48ed93
void FillToolOptionsBox::onToolTypeChanged(int index) {
shun-iwasawa 48ed93
  const TEnumProperty::Range &range = m_toolType->getProperty()->getRange();
shun-iwasawa 48ed93
  bool enabled                      = range[index] == L"Normal";
Shinya Kitaoka 120a6e
  if (m_segmentMode)
Shinya Kitaoka 120a6e
    m_segmentMode->setEnabled(
shun-iwasawa 48ed93
        enabled ? m_colorMode->getProperty()->getValue() != L"Areas" : false);
shun-iwasawa 48ed93
  enabled = enabled || (m_colorMode->getProperty()->getValue() != L"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)
Jeremy Bullock cd00fd
    , m_snapCheckbox(0)
Jeremy Bullock cd00fd
    , m_snapSensitivityCombo(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();
Jeremy Bullock cd00fd
    m_snapCheckbox =
Jeremy Bullock cd00fd
        dynamic_cast<tooloptioncheckbox *="">(m_controls.value("Snap"));</tooloptioncheckbox>
Jeremy Bullock cd00fd
    m_snapSensitivityCombo =
Jeremy Bullock cd00fd
        dynamic_cast<tooloptioncombo *="">(m_controls.value("Sensitivity:"));</tooloptioncombo>
manongjohn 0dcb3a
manongjohn 0dcb3a
    if (tool && tool->getProperties(1)) tool->getProperties(1)->accept(builder);
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);
bf1d82
  filterControls();
bf1d82
}
bf1d82
bf1d82
//-----------------------------------------------------------------------------
bf1d82
bf1d82
void BrushToolOptionsBox::filterControls() {
bf1d82
  // show or hide widgets which modify imported brush (mypaint)
bf1d82
bf1d82
  bool showModifiers = false;
shun-iwasawa 98926d
  if (m_tool->getTargetType() & TTool::RasterImage) {
shun-iwasawa 98926d
    FullColorBrushTool *fullColorBrushTool =
shun-iwasawa 98926d
        dynamic_cast<fullcolorbrushtool *="">(m_tool);</fullcolorbrushtool>
bf1d82
    showModifiers = fullColorBrushTool->getBrushStyle();
shun-iwasawa 98926d
  } else if (m_tool->getTargetType() & TTool::ToonzImage) {
shun-iwasawa 98926d
    ToonzRasterBrushTool *toonzRasterBrushTool =
shun-iwasawa 98926d
        dynamic_cast<toonzrasterbrushtool *="">(m_tool);</toonzrasterbrushtool>
shun-iwasawa 98926d
    showModifiers = toonzRasterBrushTool->isMyPaintStyleSelected();
shun-iwasawa 98926d
  } else {  // (m_tool->getTargetType() & TTool::Vectors)
shun-iwasawa 98926d
    m_snapSensitivityCombo->setHidden(!m_snapCheckbox->isChecked());
shun-iwasawa 98926d
    return;
shun-iwasawa 98926d
  }
bf1d82
Jeremy Bullock cd00fd
  for (QMap<std::string, *="" qlabel="">::iterator it = m_labels.begin();</std::string,>
Jeremy Bullock cd00fd
       it != m_labels.end(); it++) {
bf1d82
    bool isModifier = (it.key().substr(0, 8) == "Modifier");
manongjohn 6c9506
    bool isCommon   = (it.key() == "Lock Alpha" || it.key() == "Pressure" ||
manongjohn 6c9506
                     it.key() == "Preset:");
manongjohn 6c9506
    bool visible = isCommon || (isModifier == showModifiers);
bf1d82
    it.value()->setVisible(visible);
bf1d82
  }
bf1d82
Jeremy Bullock cd00fd
  for (QMap<std::string, *="" tooloptioncontrol="">::iterator it = m_controls.begin();</std::string,>
Jeremy Bullock cd00fd
       it != m_controls.end(); it++) {
bf1d82
    bool isModifier = (it.key().substr(0, 8) == "Modifier");
manongjohn 6c9506
    bool isCommon   = (it.key() == "Lock Alpha" || it.key() == "Pressure" ||
manongjohn 6c9506
                     it.key() == "Preset:");
manongjohn 6c9506
    bool visible = isCommon || (isModifier == showModifiers);
Jeremy Bullock cd00fd
    if (QWidget *widget = dynamic_cast<qwidget *="">(it.value()))</qwidget>
bf1d82
      widget->setVisible(visible);
bf1d82
  }
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void BrushToolOptionsBox::updateStatus() {
bf1d82
  filterControls();
bf1d82
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);
Jeremy Bullock cd00fd
  if (m_snapCheckbox)
Jeremy Bullock cd00fd
    m_snapSensitivityCombo->setHidden(!m_snapCheckbox->isChecked());
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) {
shun-iwasawa 98926d
  case TTool::VectorImage: {
shun-iwasawa 98926d
    static_cast<toonzvectorbrushtool *="">(m_tool)->addPreset(name);</toonzvectorbrushtool>
shun-iwasawa 98926d
    break;
shun-iwasawa 98926d
  }
Shinya Kitaoka 120a6e
  case TTool::ToonzImage: {
shun-iwasawa 98926d
    static_cast<toonzrasterbrushtool *="">(m_tool)->addPreset(name);</toonzrasterbrushtool>
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) {
shun-iwasawa 98926d
  case TTool::VectorImage: {
shun-iwasawa 98926d
    static_cast<toonzvectorbrushtool *="">(m_tool)->removePreset();</toonzvectorbrushtool>
shun-iwasawa 98926d
    break;
shun-iwasawa 98926d
  }
Shinya Kitaoka 120a6e
  case TTool::ToonzImage: {
shun-iwasawa 98926d
    static_cast<toonzrasterbrushtool *="">(m_tool)->removePreset();</toonzrasterbrushtool>
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,
shun-iwasawa 48ed93
                         SLOT(onColorModeChanged(int)));
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  ret = ret && connect(m_toolType, SIGNAL(currentIndexChanged(int)), this,
shun-iwasawa 48ed93
                       SLOT(onToolTypeChanged(int)));
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
shun-iwasawa 48ed93
  if (m_toolType && m_toolType->getProperty()->getValue() == L"Normal") {
Shinya Kitaoka 120a6e
    m_invertMode->setEnabled(false);
Shinya Kitaoka 120a6e
    m_multiFrameMode->setEnabled(false);
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
shun-iwasawa 48ed93
  if (m_colorMode && m_colorMode->getProperty()->getValue() == L"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
shun-iwasawa 48ed93
void EraserToolOptionsBox::onToolTypeChanged(int index) {
shun-iwasawa 48ed93
  const TEnumProperty::Range &range = m_toolType->getProperty()->getRange();
shun-iwasawa 48ed93
  bool value                        = range[index] != L"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
shun-iwasawa 48ed93
void EraserToolOptionsBox::onColorModeChanged(int index) {
shun-iwasawa 48ed93
  const TEnumProperty::Range &range = m_colorMode->getProperty()->getRange();
shun-iwasawa 48ed93
  bool enabled                      = range[index] != L"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);
Kite 521c84
    p.setPen(QColor(0, 0, 0, 125));
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
  {
shun-iwasawa 48ed93
    lay->addWidget(new QLabel(tr("X:", "ruler tool option"), 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
shun-iwasawa 48ed93
    lay->addWidget(new QLabel(tr("Y:", "ruler tool option"), 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
shun-iwasawa 48ed93
    lay->addWidget(new QLabel(tr("W:", "ruler tool option"), 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
shun-iwasawa 48ed93
    lay->addWidget(new QLabel(tr("H:", "ruler tool option"), 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
shun-iwasawa 48ed93
    lay->addWidget(new QLabel(tr("A:", "ruler tool option"), this), 0);
Shinya Kitaoka 120a6e
    lay->addWidget(m_Afld, 0);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
    lay->addSpacing(3);
Shinya Kitaoka 120a6e
shun-iwasawa 48ed93
    lay->addWidget(new QLabel(tr("L:", "ruler tool option"), 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
shun-iwasawa 48ed93
  bool isNormalType = m_typeMode->getProperty()->getValue() == L"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
shun-iwasawa 48ed93
  bool isLineToLineMode =
shun-iwasawa 48ed93
      m_toolMode->getProperty()->getValue() == L"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,
shun-iwasawa 48ed93
                     SLOT(onToolTypeChanged(int)));
shun-iwasawa 80c2e7
  ret      = ret && connect(m_toolMode, SIGNAL(currentIndexChanged(int)), this,
shun-iwasawa 48ed93
                       SLOT(onToolModeChanged(int)));
shun-iwasawa 80c2e7
  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
shun-iwasawa 48ed93
void TapeToolOptionsBox::onToolTypeChanged(int index) {
shun-iwasawa 48ed93
  const TEnumProperty::Range &range = m_typeMode->getProperty()->getRange();
shun-iwasawa 48ed93
  bool isNormalType                 = range[index] == L"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
shun-iwasawa 48ed93
void TapeToolOptionsBox::onToolModeChanged(int index) {
shun-iwasawa 48ed93
  const TEnumProperty::Range &range = m_toolMode->getProperty()->getRange();
shun-iwasawa 48ed93
  bool isLineToLineMode             = range[index] == L"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() {
shun-iwasawa 48ed93
  bool isLineToLineMode =
shun-iwasawa 48ed93
      m_toolMode->getProperty()->getValue() == L"Line to Line";
shun-iwasawa 48ed93
  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
shun-iwasawa e1a8da
 */
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
shun-iwasawa 388550
    if (LutManager::instance()->isValid()) {
shun-iwasawa ad7711
      QColor convertedColor(m_color);
shun-iwasawa 388550
      LutManager::instance()->convert(convertedColor);
shun-iwasawa ad7711
      p.setBrush(convertedColor);
shun-iwasawa ad7711
    } else
shun-iwasawa ad7711
      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
shun-iwasawa 80c2e7
    p.drawText(rect(), Qt::AlignCenter,
shun-iwasawa 80c2e7
               QString("R:%1 G:%2 B:%3")
shun-iwasawa 80c2e7
                   .arg(m_color.red())
shun-iwasawa 80c2e7
                   .arg(m_color.green())
shun-iwasawa 80c2e7
                   .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"));
Jeremy Bullock 195eae
  int buttonWidth     = fontMetrics().width(button->text()) + 10;
Jeremy Bullock 195eae
  button->setFixedWidth(buttonWidth);
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);
Jeremy Bullock 195eae
  m_layout->addWidget(button, 0);
Jeremy Bullock 195eae
  m_layout->addSpacing(5);
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);
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);
Jeremy Bullock 195eae
  // m_layout->addWidget(new ToolOptionsBarSeparator(this), 0);
shun_iwasawa 06bcc2
  m_layout->addWidget(organizePaletteCB);
Jeremy Bullock 195eae
  m_layout->addSpacing(5);
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
//=============================================================================
shun-iwasawa 2b24e8
// ShiftTraceToolOptionBox
shun-iwasawa 2b24e8
//-----------------------------------------------------------------------------
shun-iwasawa 2b24e8
shun-iwasawa 1d5937
ShiftTraceToolOptionBox::ShiftTraceToolOptionBox(QWidget *parent, TTool *tool)
shun-iwasawa 1d5937
    : ToolOptionsBox(parent), m_tool(tool) {
shun-iwasawa 2b24e8
  setFrameStyle(QFrame::StyledPanel);
shun-iwasawa 2b24e8
  setFixedHeight(26);
shun-iwasawa 2b24e8
shun-iwasawa 1d5937
  m_prevFrame  = new QFrame(this);
shun-iwasawa 1d5937
  m_afterFrame = new QFrame(this);
shun-iwasawa 1d5937
shun-iwasawa 1d5937
  m_resetPrevGhostBtn  = new QPushButton(tr("Reset Previous"), this);
shun-iwasawa 1d5937
  m_resetAfterGhostBtn = new QPushButton(tr("Reset Following"), this);
shun-iwasawa 1d5937
shun-iwasawa 1d5937
  m_prevRadioBtn  = new QRadioButton(tr("Previous Drawing"), this);
shun-iwasawa 1d5937
  m_afterRadioBtn = new QRadioButton(tr("Following Drawing"), this);
shun-iwasawa 2b24e8
shun-iwasawa 1d5937
  m_prevFrame->setFixedSize(10, 21);
shun-iwasawa 1d5937
  m_afterFrame->setFixedSize(10, 21);
shun-iwasawa 80c2e7
  int buttonWidth = fontMetrics().width(m_resetPrevGhostBtn->text()) + 10;
shun-iwasawa 80c2e7
  m_resetPrevGhostBtn->setFixedWidth(buttonWidth);
shun-iwasawa 80c2e7
  buttonWidth = fontMetrics().width(m_resetAfterGhostBtn->text()) + 10;
shun-iwasawa 80c2e7
  m_resetAfterGhostBtn->setFixedWidth(buttonWidth);
shun-iwasawa 1d5937
shun-iwasawa 1d5937
  m_layout->addWidget(m_prevFrame, 0);
shun-iwasawa 1d5937
  m_layout->addWidget(m_prevRadioBtn, 0);
shun-iwasawa 2b24e8
  m_layout->addWidget(m_resetPrevGhostBtn, 0);
shun-iwasawa 1d5937
shun-iwasawa 1d5937
  m_layout->addWidget(new DVGui::Separator("", this, false));
shun-iwasawa 1d5937
shun-iwasawa 1d5937
  m_layout->addWidget(m_afterFrame, 0);
shun-iwasawa 1d5937
  m_layout->addWidget(m_afterRadioBtn, 0);
shun-iwasawa 2b24e8
  m_layout->addWidget(m_resetAfterGhostBtn, 0);
shun-iwasawa 1d5937
shun-iwasawa 2b24e8
  m_layout->addStretch(1);
shun-iwasawa 2b24e8
shun-iwasawa 1d5937
  connect(m_resetPrevGhostBtn, SIGNAL(clicked(bool)), this,
shun-iwasawa 2b24e8
          SLOT(onResetPrevGhostBtnPressed()));
shun-iwasawa 1d5937
  connect(m_resetAfterGhostBtn, SIGNAL(clicked(bool)), this,
shun-iwasawa 2b24e8
          SLOT(onResetAfterGhostBtnPressed()));
shun-iwasawa 1d5937
  connect(m_prevRadioBtn, SIGNAL(clicked(bool)), this,
shun-iwasawa 1d5937
          SLOT(onPrevRadioBtnClicked()));
shun-iwasawa 1d5937
  connect(m_afterRadioBtn, SIGNAL(clicked(bool)), this,
shun-iwasawa 1d5937
          SLOT(onAfterRadioBtnClicked()));
shun-iwasawa 1d5937
shun-iwasawa 1d5937
  updateStatus();
shun-iwasawa 1d5937
}
shun-iwasawa 1d5937
shun-iwasawa 1d5937
void ShiftTraceToolOptionBox::showEvent(QShowEvent *) {
shun-iwasawa 1d5937
  TTool::Application *app = TTool::getApplication();
shun-iwasawa 1d5937
  connect(app->getCurrentOnionSkin(), SIGNAL(onionSkinMaskChanged()), this,
shun-iwasawa 1d5937
          SLOT(updateColors()));
shun-iwasawa 1d5937
  updateColors();
shun-iwasawa 1d5937
}
shun-iwasawa 1d5937
shun-iwasawa 1d5937
void ShiftTraceToolOptionBox::hideEvent(QShowEvent *) {
shun-iwasawa 1d5937
  TTool::Application *app = TTool::getApplication();
shun-iwasawa 1d5937
  disconnect(app->getCurrentOnionSkin(), SIGNAL(onionSkinMaskChanged()), this,
shun-iwasawa 1d5937
             SLOT(updateColors()));
shun-iwasawa 2b24e8
}
shun-iwasawa 2b24e8
shun-iwasawa 2b24e8
void ShiftTraceToolOptionBox::resetGhost(int index) {
shun-iwasawa 2b24e8
  TTool::Application *app = TTool::getApplication();
shun-iwasawa 2b24e8
  OnionSkinMask osm       = app->getCurrentOnionSkin()->getOnionSkinMask();
shun-iwasawa 2b24e8
  osm.setShiftTraceGhostCenter(index, TPointD());
shun-iwasawa 2b24e8
  osm.setShiftTraceGhostAff(index, TAffine());
shun-iwasawa 2b24e8
  app->getCurrentOnionSkin()->setOnionSkinMask(osm);
shun-iwasawa 2b24e8
  app->getCurrentOnionSkin()->notifyOnionSkinMaskChanged();
shun-iwasawa 2b24e8
  TTool *tool = app->getCurrentTool()->getTool();
shun-iwasawa 2b24e8
  if (tool) tool->reset();
shun-iwasawa 1d5937
shun-iwasawa 1d5937
  if (index == 0)
shun-iwasawa 1d5937
    m_resetPrevGhostBtn->setDisabled(true);
shun-iwasawa 1d5937
  else  // index == 1
shun-iwasawa 1d5937
    m_resetAfterGhostBtn->setDisabled(true);
shun-iwasawa 2b24e8
}
shun-iwasawa 2b24e8
shun-iwasawa 2b24e8
void ShiftTraceToolOptionBox::onResetPrevGhostBtnPressed() { resetGhost(0); }
shun-iwasawa 2b24e8
shun-iwasawa 2b24e8
void ShiftTraceToolOptionBox::onResetAfterGhostBtnPressed() { resetGhost(1); }
shun-iwasawa 2b24e8
shun-iwasawa 1d5937
void ShiftTraceToolOptionBox::updateColors() {
shun-iwasawa 1d5937
  TPixel front, back;
shun-iwasawa 1d5937
  bool ink;
shun-iwasawa 1d5937
  Preferences::instance()->getOnionData(front, back, ink);
shun-iwasawa 1d5937
shun-iwasawa 1d5937
  m_prevFrame->setStyleSheet(QString("background:rgb(%1,%2,%3,255);")
shun-iwasawa 1d5937
                                 .arg((int)back.r)
shun-iwasawa 1d5937
                                 .arg((int)back.g)
shun-iwasawa 1d5937
                                 .arg((int)back.b));
shun-iwasawa 1d5937
  m_afterFrame->setStyleSheet(QString("background:rgb(%1,%2,%3,255);")
shun-iwasawa 1d5937
                                  .arg((int)front.r)
shun-iwasawa 1d5937
                                  .arg((int)front.g)
shun-iwasawa 1d5937
                                  .arg((int)front.b));
shun-iwasawa 1d5937
}
shun-iwasawa 1d5937
shun-iwasawa 1d5937
void ShiftTraceToolOptionBox::updateStatus() {
shun-iwasawa 1d5937
  TTool::Application *app = TTool::getApplication();
shun-iwasawa 1d5937
  OnionSkinMask osm       = app->getCurrentOnionSkin()->getOnionSkinMask();
shun-iwasawa 1d5937
  if (osm.getShiftTraceGhostAff(0).isIdentity() &&
shun-iwasawa 1d5937
      osm.getShiftTraceGhostCenter(0) == TPointD())
shun-iwasawa 1d5937
    m_resetPrevGhostBtn->setDisabled(true);
shun-iwasawa 1d5937
  else
shun-iwasawa 1d5937
    m_resetPrevGhostBtn->setEnabled(true);
shun-iwasawa 1d5937
shun-iwasawa 1d5937
  if (osm.getShiftTraceGhostAff(1).isIdentity() &&
shun-iwasawa 1d5937
      osm.getShiftTraceGhostCenter(1) == TPointD())
shun-iwasawa 1d5937
    m_resetAfterGhostBtn->setDisabled(true);
shun-iwasawa 1d5937
  else
shun-iwasawa 1d5937
    m_resetAfterGhostBtn->setEnabled(true);
shun-iwasawa 1d5937
shun-iwasawa 1d5937
  // Check the ghost index
shun-iwasawa 1d5937
  ShiftTraceTool *stTool = (ShiftTraceTool *)m_tool;
shun-iwasawa 1d5937
  if (!stTool) return;
shun-iwasawa 1d5937
  if (stTool->getCurrentGhostIndex() == 0)
shun-iwasawa 1d5937
    m_prevRadioBtn->setChecked(true);
shun-iwasawa 1d5937
  else  // ghostIndex == 1
shun-iwasawa 1d5937
    m_afterRadioBtn->setChecked(true);
shun-iwasawa 1d5937
}
shun-iwasawa 1d5937
shun-iwasawa 1d5937
void ShiftTraceToolOptionBox::onPrevRadioBtnClicked() {
shun-iwasawa 1d5937
  ShiftTraceTool *stTool = (ShiftTraceTool *)m_tool;
shun-iwasawa 1d5937
  if (!stTool) return;
shun-iwasawa 1d5937
  stTool->setCurrentGhostIndex(0);
shun-iwasawa 1d5937
}
shun-iwasawa 1d5937
shun-iwasawa 1d5937
void ShiftTraceToolOptionBox::onAfterRadioBtnClicked() {
shun-iwasawa 1d5937
  ShiftTraceTool *stTool = (ShiftTraceTool *)m_tool;
shun-iwasawa 1d5937
  if (!stTool) return;
shun-iwasawa 1d5937
  stTool->setCurrentGhostIndex(1);
shun-iwasawa 1d5937
}
shun-iwasawa 1d5937
shun-iwasawa 2b24e8
//=============================================================================
manongjohn 4f0f61
// ZoomToolOptionBox
manongjohn 4f0f61
//-----------------------------------------------------------------------------
manongjohn 4f0f61
manongjohn 4f0f61
ZoomToolOptionsBox::ZoomToolOptionsBox(QWidget *parent, TTool *tool,
manongjohn 4f0f61
                                       TPaletteHandle *pltHandle,
manongjohn 4f0f61
                                       ToolHandle *toolHandle)
manongjohn 4f0f61
    : ToolOptionsBox(parent) {
manongjohn 4f0f61
  setFrameStyle(QFrame::StyledPanel);
manongjohn 4f0f61
  setFixedHeight(26);
manongjohn 4f0f61
Jeremy Bullock 195eae
  QAction *resetZoomAction =
Jeremy Bullock 195eae
      CommandManager::instance()->getAction(VB_ZoomReset);
manongjohn 4f0f61
manongjohn 4f0f61
  QPushButton *button = new QPushButton(tr("Reset Zoom"));
Jeremy Bullock 195eae
  int buttonWidth     = fontMetrics().width(button->text()) + 10;
Jeremy Bullock 195eae
  button->setFixedWidth(buttonWidth);
manongjohn 4f0f61
  button->setFixedHeight(20);
manongjohn 4f0f61
  button->addAction(resetZoomAction);
Jeremy Bullock 195eae
manongjohn 4f0f61
  connect(button, SIGNAL(clicked()), resetZoomAction, SLOT(trigger()));
manongjohn 4f0f61
manongjohn 4f0f61
  m_layout->addStretch(1);
manongjohn 4f0f61
  m_layout->addWidget(button, 0);
Jeremy Bullock 195eae
  m_layout->addSpacing(5);
manongjohn 4f0f61
}
manongjohn 4f0f61
manongjohn 4f0f61
//=============================================================================
manongjohn 4f0f61
// RotateToolOptionBox
manongjohn 4f0f61
//-----------------------------------------------------------------------------
manongjohn 4f0f61
manongjohn 4f0f61
RotateToolOptionsBox::RotateToolOptionsBox(QWidget *parent, TTool *tool,
manongjohn 4f0f61
                                           TPaletteHandle *pltHandle,
manongjohn 4f0f61
                                           ToolHandle *toolHandle)
manongjohn 4f0f61
    : ToolOptionsBox(parent) {
manongjohn 4f0f61
  setFrameStyle(QFrame::StyledPanel);
manongjohn 4f0f61
  setFixedHeight(26);
manongjohn 4f0f61
manongjohn 4f0f61
  QAction *resetRotationAction =
manongjohn ccd524
      CommandManager::instance()->getAction(VB_RotateReset);
manongjohn 4f0f61
manongjohn 4f0f61
  QPushButton *button = new QPushButton(tr("Reset Rotation"));
Jeremy Bullock 195eae
  int buttonWidth     = fontMetrics().width(button->text()) + 10;
Jeremy Bullock 195eae
  button->setFixedWidth(buttonWidth);
manongjohn 4f0f61
  button->setFixedHeight(20);
manongjohn 4f0f61
  button->addAction(resetRotationAction);
Jeremy Bullock 195eae
manongjohn 4f0f61
  connect(button, SIGNAL(clicked()), resetRotationAction, SLOT(trigger()));
manongjohn 4f0f61
manongjohn 4f0f61
  m_layout->addStretch(1);
manongjohn 4f0f61
  m_layout->addWidget(button, 0);
Jeremy Bullock 195eae
  m_layout->addSpacing(5);
manongjohn 4f0f61
}
manongjohn 4f0f61
manongjohn 4f0f61
//=============================================================================
manongjohn 4f0f61
// HandToolOptionBox
manongjohn 4f0f61
//-----------------------------------------------------------------------------
manongjohn 4f0f61
manongjohn 4f0f61
HandToolOptionsBox::HandToolOptionsBox(QWidget *parent, TTool *tool,
manongjohn 4f0f61
                                       TPaletteHandle *pltHandle,
manongjohn 4f0f61
                                       ToolHandle *toolHandle)
manongjohn 4f0f61
    : ToolOptionsBox(parent) {
manongjohn 4f0f61
  setFrameStyle(QFrame::StyledPanel);
manongjohn 4f0f61
  setFixedHeight(26);
manongjohn 4f0f61
manongjohn 4f0f61
  QAction *resetPositionAction =
manongjohn ccd524
      CommandManager::instance()->getAction(VB_PositionReset);
manongjohn 4f0f61
manongjohn 4f0f61
  QPushButton *button = new QPushButton(tr("Reset Position"));
Jeremy Bullock 195eae
  int buttonWidth     = fontMetrics().width(button->text()) + 10;
Jeremy Bullock 195eae
  button->setFixedWidth(buttonWidth);
manongjohn 4f0f61
  button->setFixedHeight(20);
manongjohn 4f0f61
  button->addAction(resetPositionAction);
Jeremy Bullock 195eae
manongjohn 4f0f61
  connect(button, SIGNAL(clicked()), resetPositionAction, SLOT(trigger()));
manongjohn 4f0f61
manongjohn 4f0f61
  m_layout->addStretch(1);
manongjohn 4f0f61
  m_layout->addWidget(button, 0);
Jeremy Bullock 195eae
  m_layout->addSpacing(5);
manongjohn 4f0f61
}
manongjohn 4f0f61
manongjohn 4f0f61
//=============================================================================
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
shun-iwasawa 80c2e7
    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);
shun-iwasawa 14c787
      else if (tool->getName() == T_Fill) {
shun-iwasawa 14c787
        if (tool->getTargetType() & TTool::RasterImage)
shun-iwasawa 14c787
          panel =
shun-iwasawa 14c787
              new FullColorFillToolOptionsBox(0, tool, currPalette, currTool);
shun-iwasawa 14c787
        else
shun-iwasawa 14c787
          panel = new FillToolOptionsBox(0, tool, currPalette, currTool);
shun-iwasawa 14c787
      } 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());
shun-iwasawa 2b24e8
      else if (tool->getName() == "T_ShiftTrace")
shun-iwasawa 1d5937
        panel = new ShiftTraceToolOptionBox(this, tool);
manongjohn 4f0f61
      else if (tool->getName() == T_Zoom)
manongjohn 4f0f61
        panel = new ZoomToolOptionsBox(0, tool, currPalette, currTool);
manongjohn 4f0f61
      else if (tool->getName() == T_Rotate)
manongjohn 4f0f61
        panel = new RotateToolOptionsBox(0, tool, currPalette, currTool);
manongjohn 4f0f61
      else if (tool->getName() == T_Hand)
manongjohn 4f0f61
        panel = new HandToolOptionsBox(0, tool, currPalette, currTool);
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
}
manongjohn 19dec5
manongjohn 19dec5
//***********************************************************************************
manongjohn 19dec5
//    Command instantiation
manongjohn 19dec5
//***********************************************************************************
manongjohn 19dec5
manongjohn 19dec5
class FlipHorizontalCommandHandler final : public MenuItemHandler {
manongjohn 19dec5
public:
manongjohn 19dec5
  FlipHorizontalCommandHandler(CommandId cmdId) : MenuItemHandler(cmdId) {}
manongjohn 19dec5
  void execute() override {
manongjohn 19dec5
    TTool::Application *app = TTool::getApplication();
manongjohn 19dec5
    TTool *tool             = app->getCurrentTool()->getTool();
manongjohn 19dec5
    if (!tool) return;
manongjohn 19dec5
    if (tool->getName() == T_Edit) {
manongjohn 19dec5
      EditTool *editTool = dynamic_cast<edittool *="">(tool);</edittool>
manongjohn 19dec5
      emit editTool->clickFlipHorizontal();
manongjohn 19dec5
    } else if (tool->getName() == T_Selection) {
manongjohn 19dec5
      SelectionTool *selectionTool = dynamic_cast<selectiontool *="">(tool);</selectiontool>
manongjohn 19dec5
      emit selectionTool->clickFlipHorizontal();
manongjohn 19dec5
    }
manongjohn 19dec5
  }
manongjohn 19dec5
} flipHorizontalCHInstance("A_ToolOption_FlipHorizontal");
manongjohn 19dec5
manongjohn 19dec5
class FlipVerticalCommandHandler final : public MenuItemHandler {
manongjohn 19dec5
public:
manongjohn 19dec5
  FlipVerticalCommandHandler(CommandId cmdId) : MenuItemHandler(cmdId) {}
manongjohn 19dec5
  void execute() override {
manongjohn 19dec5
    TTool::Application *app = TTool::getApplication();
manongjohn 19dec5
    TTool *tool             = app->getCurrentTool()->getTool();
manongjohn 19dec5
    if (!tool) return;
manongjohn 19dec5
    if (tool->getName() == T_Edit) {
manongjohn 19dec5
      EditTool *editTool = dynamic_cast<edittool *="">(tool);</edittool>
manongjohn 19dec5
      emit editTool->clickFlipVertical();
manongjohn 19dec5
    } else if (tool->getName() == T_Selection) {
manongjohn 19dec5
      SelectionTool *selectionTool = dynamic_cast<selectiontool *="">(tool);</selectiontool>
manongjohn 19dec5
      emit selectionTool->clickFlipVertical();
manongjohn 19dec5
    }
manongjohn 19dec5
  }
manongjohn 19dec5
} flipVerticalCHInstance("A_ToolOption_FlipVertical");
manongjohn 19dec5
manongjohn 19dec5
class RotateLeftCommandHandler final : public MenuItemHandler {
manongjohn 19dec5
public:
manongjohn 19dec5
  RotateLeftCommandHandler(CommandId cmdId) : MenuItemHandler(cmdId) {}
manongjohn 19dec5
  void execute() override {
manongjohn 19dec5
    TTool::Application *app = TTool::getApplication();
manongjohn 19dec5
    TTool *tool             = app->getCurrentTool()->getTool();
manongjohn 19dec5
    if (!tool) return;
manongjohn 19dec5
    if (tool->getName() == T_Edit) {
manongjohn 19dec5
      EditTool *editTool = dynamic_cast<edittool *="">(tool);</edittool>
manongjohn 19dec5
      emit editTool->clickRotateLeft();
manongjohn 19dec5
    } else if (tool->getName() == T_Selection) {
manongjohn 19dec5
      SelectionTool *selectionTool = dynamic_cast<selectiontool *="">(tool);</selectiontool>
manongjohn 19dec5
      emit selectionTool->clickRotateLeft();
manongjohn 19dec5
    }
manongjohn 19dec5
  }
manongjohn 19dec5
} rotateLeftCHInstance("A_ToolOption_RotateLeft");
manongjohn 19dec5
manongjohn 19dec5
class RotateRightCommandHandler final : public MenuItemHandler {
manongjohn 19dec5
public:
manongjohn 19dec5
  RotateRightCommandHandler(CommandId cmdId) : MenuItemHandler(cmdId) {}
manongjohn 19dec5
  void execute() override {
manongjohn 19dec5
    TTool::Application *app = TTool::getApplication();
manongjohn 19dec5
    TTool *tool             = app->getCurrentTool()->getTool();
manongjohn 19dec5
    if (!tool) return;
manongjohn 19dec5
    if (tool->getName() == T_Edit) {
manongjohn 19dec5
      EditTool *editTool = dynamic_cast<edittool *="">(tool);</edittool>
manongjohn 19dec5
      emit editTool->clickRotateRight();
manongjohn 19dec5
    } else if (tool->getName() == T_Selection) {
manongjohn 19dec5
      SelectionTool *selectionTool = dynamic_cast<selectiontool *="">(tool);</selectiontool>
manongjohn 19dec5
      emit selectionTool->clickRotateRight();
manongjohn 19dec5
    }
manongjohn 19dec5
  }
manongjohn 19dec5
} rotateRightCHInstance("A_ToolOption_RotateRight");