diff --git a/toonz/sources/include/tools/tooloptions.h b/toonz/sources/include/tools/tooloptions.h index f393606..a4c8099 100644 --- a/toonz/sources/include/tools/tooloptions.h +++ b/toonz/sources/include/tools/tooloptions.h @@ -378,6 +378,9 @@ class SelectionToolOptionsBox final : public ToolOptionsBox, ToolOptionPopupButton *m_joinStyle; ToolOptionIntSlider *m_miterField; + QPushButton *m_hFlipButton, *m_vFlipButton, *m_leftRotateButton, + *m_rightRotateButton; + public: SelectionToolOptionsBox(QWidget *parent, TTool *tool, TPaletteHandle *pltHandle, ToolHandle *toolHandle); @@ -391,6 +394,10 @@ protected slots: void onScaleXValueChanged(bool addToUndo = true); void onScaleYValueChanged(bool addToUndo = true); void onSetSaveboxCheckboxChanged(bool); + void onFlipHorizontal(); + void onFlipVertical(); + void onRotateLeft(); + void onRotateRight(); }; //============================================================================= diff --git a/toonz/sources/tnztools/tooloptions.cpp b/toonz/sources/tnztools/tooloptions.cpp index dc9d41a..9b4ab8c 100644 --- a/toonz/sources/tnztools/tooloptions.cpp +++ b/toonz/sources/tnztools/tooloptions.cpp @@ -1070,11 +1070,42 @@ SelectionToolOptionsBox::SelectionToolOptionsBox(QWidget *parent, TTool *tool, new ToolOptionCheckbox(rasterSelectionTool, modifySetSaveboxProp); } + m_hFlipButton = new QPushButton(this); + m_vFlipButton = new QPushButton(this); + + m_leftRotateButton = new QPushButton(this); + m_rightRotateButton = new QPushButton(this); + + m_hFlipButton->setFixedSize(QSize(20, 20)); + m_vFlipButton->setFixedSize(QSize(20, 20)); + + m_leftRotateButton->setFixedSize(QSize(20, 20)); + m_rightRotateButton->setFixedSize(QSize(20, 20)); + + m_hFlipButton->setIcon(createQIcon("fliphoriz")); + m_hFlipButton->setIconSize(QSize(20, 20)); + m_vFlipButton->setIcon(createQIcon("flipvert")); + m_vFlipButton->setIconSize(QSize(20, 20)); + m_leftRotateButton->setIcon(createQIcon("rotateleft")); + m_leftRotateButton->setIconSize(QSize(20, 20)); + m_rightRotateButton->setIcon(createQIcon("rotateright")); + m_rightRotateButton->setIconSize(QSize(20, 20)); + + m_hFlipButton->setToolTip(tr("Flip Selection Horizontally")); + m_vFlipButton->setToolTip(tr("Flip Selection Vertically")); + m_leftRotateButton->setToolTip(tr("Rotate Selection Left")); + m_rightRotateButton->setToolTip(tr("Rotate Selection Right")); + m_scaleXLabel->setEnabled(false); m_scaleYLabel->setEnabled(false); m_moveXLabel->setEnabled(false); m_moveYLabel->setEnabled(false); + m_hFlipButton->setEnabled(false); + m_vFlipButton->setEnabled(false); + m_leftRotateButton->setEnabled(false); + m_rightRotateButton->setEnabled(false); + //--- layout ---- addSeparator(); @@ -1083,8 +1114,10 @@ SelectionToolOptionsBox::SelectionToolOptionsBox(QWidget *parent, TTool *tool, 0); hLayout()->addWidget(m_scaleXLabel, 0); hLayout()->addWidget(m_scaleXField, 10); + hLayout()->addWidget(m_hFlipButton); hLayout()->addWidget(m_scaleYLabel, 0); hLayout()->addWidget(m_scaleYField, 10); + hLayout()->addWidget(m_vFlipButton); hLayout()->addSpacing(4); hLayout()->addWidget(m_scaleLink, 0); @@ -1092,6 +1125,8 @@ SelectionToolOptionsBox::SelectionToolOptionsBox(QWidget *parent, TTool *tool, hLayout()->addWidget(rotIconView, 0); hLayout()->addWidget(m_rotationField, 10); + hLayout()->addWidget(m_leftRotateButton); + hLayout()->addWidget(m_rightRotateButton); addSeparator(); @@ -1185,6 +1220,11 @@ SelectionToolOptionsBox::SelectionToolOptionsBox(QWidget *parent, TTool *tool, SLOT(receiveMouseMove(QMouseEvent *))); connect(m_moveYLabel, SIGNAL(onMouseRelease(QMouseEvent *)), m_moveYField, SLOT(receiveMouseRelease(QMouseEvent *))); + connect(m_hFlipButton, SIGNAL(clicked()), SLOT(onFlipHorizontal())); + connect(m_vFlipButton, SIGNAL(clicked()), SLOT(onFlipVertical())); + connect(m_leftRotateButton, SIGNAL(clicked()), SLOT(onRotateLeft())); + connect(m_rightRotateButton, SIGNAL(clicked()), + SLOT(onRotateRight())); // assert(ret); updateStatus(); @@ -1216,6 +1256,11 @@ void SelectionToolOptionsBox::updateStatus() { m_moveYField->updateStatus(); m_moveYLabel->setEnabled(m_moveYField->isEnabled()); + m_hFlipButton->setEnabled(m_scaleXField->isEnabled()); + m_vFlipButton->setEnabled(m_scaleXField->isEnabled()); + m_leftRotateButton->setEnabled(m_rotationField->isEnabled()); + m_rightRotateButton->setEnabled(m_rotationField->isEnabled()); + if (m_isVectorSelction) { m_thickChangeField->updateStatus(); onPropertyChanged(); @@ -1250,6 +1295,38 @@ void SelectionToolOptionsBox::onSetSaveboxCheckboxChanged(bool) { //----------------------------------------------------------------------------- +void SelectionToolOptionsBox::onFlipHorizontal() { + m_scaleXField->setValue(m_scaleXField->getValue() * -1); + m_scaleXField->applyChange(true); + + onScaleXValueChanged(true); +} + +//----------------------------------------------------------------------------- + +void SelectionToolOptionsBox::onFlipVertical() { + m_scaleYField->setValue(m_scaleYField->getValue() * -1); + m_scaleYField->applyChange(true); + + onScaleYValueChanged(true); +} + +//----------------------------------------------------------------------------- + +void SelectionToolOptionsBox::onRotateLeft() { + m_rotationField->setValue(m_rotationField->getValue() + 90); + m_rotationField->applyChange(true); +} + +//----------------------------------------------------------------------------- + +void SelectionToolOptionsBox::onRotateRight() { + m_rotationField->setValue(m_rotationField->getValue() - 90); + m_rotationField->applyChange(true); +} + +//----------------------------------------------------------------------------- + void SelectionToolOptionsBox::onPropertyChanged() { // Check the selection's outline styles group. VectorSelectionTool *tool = (VectorSelectionTool *)m_tool; diff --git a/toonz/sources/tnztools/tooloptionscontrols.cpp b/toonz/sources/tnztools/tooloptionscontrols.cpp index f197f9c..96775c9 100644 --- a/toonz/sources/tnztools/tooloptionscontrols.cpp +++ b/toonz/sources/tnztools/tooloptionscontrols.cpp @@ -1340,10 +1340,10 @@ SelectionRotationField::SelectionRotationField(SelectionTool *tool, //----------------------------------------------------------------------------- -void SelectionRotationField::onChange(TMeasuredValue *fld, bool addToUndo) { +bool SelectionRotationField::applyChange(bool addToUndo) { if (!m_tool || !m_tool->isEnabled() || (m_tool->isSelectionEmpty() && !m_tool->isLevelType())) - return; + return false; DragSelectionTool::DragTool *rotationTool = createNewRotationTool(m_tool); @@ -1359,6 +1359,15 @@ void SelectionRotationField::onChange(TMeasuredValue *fld, bool addToUndo) { if (!m_tool->isLevelType() && addToUndo) rotationTool->addTransformUndo(); setCursorPosition(0); + + return true; +} + +//----------------------------------------------------------------------------- + +void SelectionRotationField::onChange(TMeasuredValue *fld, bool addToUndo) { + if (!m_tool->isEnabled()) return; + if (!applyChange(addToUndo)) return; } //----------------------------------------------------------------------------- diff --git a/toonz/sources/tnztools/tooloptionscontrols.h b/toonz/sources/tnztools/tooloptionscontrols.h index 074d42a..78fad5b 100644 --- a/toonz/sources/tnztools/tooloptionscontrols.h +++ b/toonz/sources/tnztools/tooloptionscontrols.h @@ -519,6 +519,7 @@ public: ~SelectionRotationField() {} void updateStatus(); + bool applyChange(bool addToUndo = true); protected slots: // add to undo is only false if mouse dragging to change the value diff --git a/toonz/sources/toonz/icons/dark/actions/16/rotateleft.svg b/toonz/sources/toonz/icons/dark/actions/16/rotateleft.svg new file mode 100644 index 0000000..94b8d89 --- /dev/null +++ b/toonz/sources/toonz/icons/dark/actions/16/rotateleft.svg @@ -0,0 +1,70 @@ + +image/svg+xml + + \ No newline at end of file diff --git a/toonz/sources/toonz/icons/dark/actions/16/rotateright.svg b/toonz/sources/toonz/icons/dark/actions/16/rotateright.svg new file mode 100644 index 0000000..78d304e --- /dev/null +++ b/toonz/sources/toonz/icons/dark/actions/16/rotateright.svg @@ -0,0 +1,70 @@ + +image/svg+xml + + \ No newline at end of file diff --git a/toonz/sources/toonz/toonz.qrc b/toonz/sources/toonz/toonz.qrc index 8cd89a3..527f116 100644 --- a/toonz/sources/toonz/toonz.qrc +++ b/toonz/sources/toonz/toonz.qrc @@ -50,7 +50,10 @@ icons/dark/actions/16/butt_cap.svg icons/dark/actions/16/miter_join.svg - + icons/dark/actions/16/rotateleft.svg + icons/dark/actions/16/rotateright.svg + + icons/dark/actions/16/menu.svg icons/dark/actions/16/export.svg icons/dark/actions/16/import.svg