Add Flip and Rotate Selection/Object shortcuts
This commit is contained in:
parent
e3f2292b34
commit
e573048a84
6 changed files with 258 additions and 135 deletions
|
@ -9,6 +9,8 @@ set(MOC_HEADERS
|
|||
tooloptionscontrols.h
|
||||
toonzrasterbrushtool.h
|
||||
viewtools.h
|
||||
selectiontool.h
|
||||
edittool.h
|
||||
../include/tools/imagegrouping.h
|
||||
../include/tools/screenpicker.h
|
||||
../include/tools/toolhandle.h
|
||||
|
@ -24,7 +26,6 @@ set(HEADERS
|
|||
rasterselectiontool.h
|
||||
rgbpickertool.h
|
||||
rulertool.h
|
||||
selectiontool.h
|
||||
setsaveboxtool.h
|
||||
shifttracetool.h
|
||||
stylepickertool.h
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
|
||||
#include "edittool.h"
|
||||
#include "tools/tool.h"
|
||||
#include "tools/cursors.h"
|
||||
#include "tproperty.h"
|
||||
|
@ -633,134 +633,6 @@ bool hasVisibleChildColumn(const TStageObject *obj, const TXsheet *xsh) {
|
|||
} // namespace
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
//=============================================================================
|
||||
// EditTool
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class EditTool final : public TTool {
|
||||
Q_DECLARE_TR_FUNCTIONS(EditTool)
|
||||
|
||||
DragTool *m_dragTool;
|
||||
|
||||
bool m_firstTime;
|
||||
|
||||
enum {
|
||||
None = -1,
|
||||
Translation = 1,
|
||||
Rotation,
|
||||
Scale,
|
||||
ScaleX,
|
||||
ScaleY,
|
||||
ScaleXY,
|
||||
Center,
|
||||
ZTranslation,
|
||||
Shear,
|
||||
};
|
||||
|
||||
// DragInfo m_dragInfo;
|
||||
|
||||
TPointD m_lastPos;
|
||||
TPointD m_curPos;
|
||||
TPointD m_firstPos;
|
||||
TPointD m_curCenter;
|
||||
|
||||
bool m_active;
|
||||
bool m_keyFrameAdded;
|
||||
int m_what;
|
||||
int m_highlightedDevice;
|
||||
|
||||
double m_oldValues[2];
|
||||
|
||||
double m_currentScaleFactor;
|
||||
FxGadgetController *m_fxGadgetController;
|
||||
|
||||
bool m_isAltPressed;
|
||||
|
||||
TEnumProperty m_scaleConstraint;
|
||||
TEnumProperty m_autoSelect;
|
||||
TBoolProperty m_globalKeyframes;
|
||||
|
||||
TBoolProperty m_lockCenterX;
|
||||
TBoolProperty m_lockCenterY;
|
||||
TBoolProperty m_lockPositionX;
|
||||
TBoolProperty m_lockPositionY;
|
||||
TBoolProperty m_lockRotation;
|
||||
TBoolProperty m_lockShearH;
|
||||
TBoolProperty m_lockShearV;
|
||||
TBoolProperty m_lockScaleH;
|
||||
TBoolProperty m_lockScaleV;
|
||||
TBoolProperty m_lockGlobalScale;
|
||||
|
||||
TBoolProperty m_showEWNSposition;
|
||||
TBoolProperty m_showZposition;
|
||||
TBoolProperty m_showSOposition;
|
||||
TBoolProperty m_showRotation;
|
||||
TBoolProperty m_showGlobalScale;
|
||||
TBoolProperty m_showHVscale;
|
||||
TBoolProperty m_showShear;
|
||||
TBoolProperty m_showCenterPosition;
|
||||
|
||||
TEnumProperty m_activeAxis;
|
||||
|
||||
TPropertyGroup m_prop;
|
||||
|
||||
void drawMainHandle();
|
||||
void onEditAllLeftButtonDown(TPointD &pos, const TMouseEvent &e);
|
||||
|
||||
public:
|
||||
EditTool();
|
||||
~EditTool();
|
||||
|
||||
ToolType getToolType() const override { return TTool::ColumnTool; }
|
||||
|
||||
bool doesApply() const; // ritorna vero se posso deformare l'oggetto corrente
|
||||
void saveOldValues();
|
||||
bool transformEnabled() const;
|
||||
|
||||
const TStroke *getSpline() const;
|
||||
|
||||
void rotate();
|
||||
void move();
|
||||
void moveCenter();
|
||||
void scale();
|
||||
void isoScale();
|
||||
void squeeze();
|
||||
void shear(const TPointD &pos, bool single);
|
||||
|
||||
void updateTranslation() override;
|
||||
|
||||
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override;
|
||||
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override;
|
||||
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override;
|
||||
|
||||
void mouseMove(const TPointD &, const TMouseEvent &e) override;
|
||||
|
||||
void draw() override;
|
||||
|
||||
void transform(const TAffine &aff);
|
||||
|
||||
void onActivate() override;
|
||||
void onDeactivate() override;
|
||||
bool onPropertyChanged(std::string propertyName) override;
|
||||
|
||||
void computeBBox();
|
||||
|
||||
int getCursorId() const override;
|
||||
|
||||
TPropertyGroup *getProperties(int targetType) override { return &m_prop; }
|
||||
|
||||
void updateMatrix() override {
|
||||
setMatrix(
|
||||
getCurrentObjectParentMatrix2()); // getCurrentObjectParentMatrix());
|
||||
}
|
||||
|
||||
void drawText(const TPointD &p, double unit, std::string text);
|
||||
|
||||
QString updateEnabled(int rowIndex, int columnIndex) override;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
EditTool::EditTool()
|
||||
: TTool("T_Edit")
|
||||
, m_active(false)
|
||||
|
|
147
toonz/sources/tnztools/edittool.h
Normal file
147
toonz/sources/tnztools/edittool.h
Normal file
|
@ -0,0 +1,147 @@
|
|||
#pragma once
|
||||
|
||||
#ifndef EDITTOOL_INCLUDED
|
||||
#define EDITTOOL_INCLUDED
|
||||
|
||||
#include "tool.h"
|
||||
#include "tproperty.h"
|
||||
#include "edittoolgadgets.h"
|
||||
|
||||
// For Qt translation support
|
||||
#include <QCoreApplication>
|
||||
|
||||
using EditToolGadgets::DragTool;
|
||||
|
||||
//=============================================================================
|
||||
// EditTool
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class EditTool final : public QObject, public TTool {
|
||||
Q_OBJECT
|
||||
|
||||
DragTool* m_dragTool;
|
||||
|
||||
bool m_firstTime;
|
||||
|
||||
enum {
|
||||
None = -1,
|
||||
Translation = 1,
|
||||
Rotation,
|
||||
Scale,
|
||||
ScaleX,
|
||||
ScaleY,
|
||||
ScaleXY,
|
||||
Center,
|
||||
ZTranslation,
|
||||
Shear,
|
||||
};
|
||||
|
||||
// DragInfo m_dragInfo;
|
||||
|
||||
TPointD m_lastPos;
|
||||
TPointD m_curPos;
|
||||
TPointD m_firstPos;
|
||||
TPointD m_curCenter;
|
||||
|
||||
bool m_active;
|
||||
bool m_keyFrameAdded;
|
||||
int m_what;
|
||||
int m_highlightedDevice;
|
||||
|
||||
double m_oldValues[2];
|
||||
|
||||
double m_currentScaleFactor;
|
||||
FxGadgetController* m_fxGadgetController;
|
||||
|
||||
bool m_isAltPressed;
|
||||
|
||||
TEnumProperty m_scaleConstraint;
|
||||
TEnumProperty m_autoSelect;
|
||||
TBoolProperty m_globalKeyframes;
|
||||
|
||||
TBoolProperty m_lockCenterX;
|
||||
TBoolProperty m_lockCenterY;
|
||||
TBoolProperty m_lockPositionX;
|
||||
TBoolProperty m_lockPositionY;
|
||||
TBoolProperty m_lockRotation;
|
||||
TBoolProperty m_lockShearH;
|
||||
TBoolProperty m_lockShearV;
|
||||
TBoolProperty m_lockScaleH;
|
||||
TBoolProperty m_lockScaleV;
|
||||
TBoolProperty m_lockGlobalScale;
|
||||
|
||||
TBoolProperty m_showEWNSposition;
|
||||
TBoolProperty m_showZposition;
|
||||
TBoolProperty m_showSOposition;
|
||||
TBoolProperty m_showRotation;
|
||||
TBoolProperty m_showGlobalScale;
|
||||
TBoolProperty m_showHVscale;
|
||||
TBoolProperty m_showShear;
|
||||
TBoolProperty m_showCenterPosition;
|
||||
|
||||
TEnumProperty m_activeAxis;
|
||||
|
||||
TPropertyGroup m_prop;
|
||||
|
||||
void drawMainHandle();
|
||||
void onEditAllLeftButtonDown(TPointD& pos, const TMouseEvent& e);
|
||||
|
||||
public:
|
||||
EditTool();
|
||||
~EditTool();
|
||||
|
||||
ToolType getToolType() const override { return TTool::ColumnTool; }
|
||||
|
||||
bool doesApply() const; // ritorna vero se posso deformare l'oggetto corrente
|
||||
void saveOldValues();
|
||||
bool transformEnabled() const;
|
||||
|
||||
const TStroke* getSpline() const;
|
||||
|
||||
void rotate();
|
||||
void move();
|
||||
void moveCenter();
|
||||
void scale();
|
||||
void isoScale();
|
||||
void squeeze();
|
||||
void shear(const TPointD& pos, bool single);
|
||||
|
||||
void updateTranslation() override;
|
||||
|
||||
void leftButtonDown(const TPointD& pos, const TMouseEvent&) override;
|
||||
void leftButtonDrag(const TPointD& pos, const TMouseEvent&) override;
|
||||
void leftButtonUp(const TPointD& pos, const TMouseEvent&) override;
|
||||
|
||||
void mouseMove(const TPointD&, const TMouseEvent& e) override;
|
||||
|
||||
void draw() override;
|
||||
|
||||
void transform(const TAffine& aff);
|
||||
|
||||
void onActivate() override;
|
||||
void onDeactivate() override;
|
||||
bool onPropertyChanged(std::string propertyName) override;
|
||||
|
||||
void computeBBox();
|
||||
|
||||
int getCursorId() const override;
|
||||
|
||||
TPropertyGroup* getProperties(int targetType) override { return &m_prop; }
|
||||
|
||||
void updateMatrix() override {
|
||||
setMatrix(
|
||||
getCurrentObjectParentMatrix2()); // getCurrentObjectParentMatrix());
|
||||
}
|
||||
|
||||
void drawText(const TPointD& p, double unit, std::string text);
|
||||
|
||||
QString updateEnabled(int rowIndex, int columnIndex) override;
|
||||
|
||||
signals:
|
||||
void clickFlipHorizontal();
|
||||
void clickFlipVertical();
|
||||
void clickRotateLeft();
|
||||
void clickRotateRight();
|
||||
};
|
||||
|
||||
#endif // EDITTOOL_INCLUDED
|
|
@ -322,8 +322,8 @@ DragSelectionTool::DragTool *createNewScaleTool(
|
|||
// SelectionTool
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class SelectionTool : public TTool, public TSelection::View {
|
||||
Q_DECLARE_TR_FUNCTIONS(SelectionTool)
|
||||
class SelectionTool : public QObject, public TTool, public TSelection::View {
|
||||
Q_OBJECT
|
||||
|
||||
protected:
|
||||
bool m_firstTime;
|
||||
|
@ -467,6 +467,12 @@ public:
|
|||
bool isEventAcceptable(QEvent *e) override;
|
||||
|
||||
virtual bool isSelectionEditable() { return true; }
|
||||
|
||||
signals:
|
||||
void clickFlipHorizontal();
|
||||
void clickFlipVertical();
|
||||
void clickRotateLeft();
|
||||
void clickRotateRight();
|
||||
};
|
||||
|
||||
#endif // SELECTIONTOOL_INCLUDED
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "tools/toolhandle.h"
|
||||
#include "tools/toolcommandids.h"
|
||||
|
||||
#include "edittool.h"
|
||||
#include "selectiontool.h"
|
||||
#include "vectorselectiontool.h"
|
||||
#include "rasterselectiontool.h"
|
||||
|
@ -391,6 +392,8 @@ ArrowToolOptionsBox::ArrowToolOptionsBox(
|
|||
setObjectName("toolOptionsPanel");
|
||||
setFixedHeight(26);
|
||||
|
||||
EditTool *editTool = dynamic_cast<EditTool *>(tool);
|
||||
|
||||
m_axisOptionWidgets = new QWidget *[AllAxis];
|
||||
|
||||
/* --- General Parts --- */
|
||||
|
@ -828,6 +831,11 @@ ArrowToolOptionsBox::ArrowToolOptionsBox(
|
|||
connect(m_vFlipButton, SIGNAL(clicked()), SLOT(onFlipVertical()));
|
||||
connect(m_leftRotateButton, SIGNAL(clicked()), SLOT(onRotateLeft()));
|
||||
connect(m_rightRotateButton, SIGNAL(clicked()), SLOT(onRotateRight()));
|
||||
|
||||
connect(editTool, SIGNAL(clickFlipHorizontal()), SLOT(onFlipHorizontal()));
|
||||
connect(editTool, SIGNAL(clickFlipVertical()), SLOT(onFlipVertical()));
|
||||
connect(editTool, SIGNAL(clickRotateLeft()), SLOT(onRotateLeft()));
|
||||
connect(editTool, SIGNAL(clickRotateRight()), SLOT(onRotateRight()));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -1057,14 +1065,16 @@ void ArrowToolOptionsBox::onFlipVertical() {
|
|||
|
||||
void ArrowToolOptionsBox::onRotateLeft() {
|
||||
m_rotationField->setValue(m_rotationField->getValue() + 90);
|
||||
emit m_rotationField->measuredValueChanged(m_rotationField->getMeasuredValue());
|
||||
emit m_rotationField->measuredValueChanged(
|
||||
m_rotationField->getMeasuredValue());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void ArrowToolOptionsBox::onRotateRight() {
|
||||
m_rotationField->setValue(m_rotationField->getValue() - 90);
|
||||
emit m_rotationField->measuredValueChanged(m_rotationField->getMeasuredValue());
|
||||
emit m_rotationField->measuredValueChanged(
|
||||
m_rotationField->getMeasuredValue());
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -1293,6 +1303,13 @@ SelectionToolOptionsBox::SelectionToolOptionsBox(QWidget *parent, TTool *tool,
|
|||
connect(m_vFlipButton, SIGNAL(clicked()), SLOT(onFlipVertical()));
|
||||
connect(m_leftRotateButton, SIGNAL(clicked()), SLOT(onRotateLeft()));
|
||||
connect(m_rightRotateButton, SIGNAL(clicked()), SLOT(onRotateRight()));
|
||||
|
||||
connect(selectionTool, SIGNAL(clickFlipHorizontal()),
|
||||
SLOT(onFlipHorizontal()));
|
||||
connect(selectionTool, SIGNAL(clickFlipVertical()), SLOT(onFlipVertical()));
|
||||
connect(selectionTool, SIGNAL(clickRotateLeft()), SLOT(onRotateLeft()));
|
||||
connect(selectionTool, SIGNAL(clickRotateRight()), SLOT(onRotateRight()));
|
||||
|
||||
// assert(ret);
|
||||
|
||||
updateStatus();
|
||||
|
@ -3090,3 +3107,75 @@ void ToolOptions::onStageObjectChange() {
|
|||
ToolOptionsBox *panel = it->second;
|
||||
panel->onStageObjectChange();
|
||||
}
|
||||
|
||||
//***********************************************************************************
|
||||
// Command instantiation
|
||||
//***********************************************************************************
|
||||
|
||||
class FlipHorizontalCommandHandler final : public MenuItemHandler {
|
||||
public:
|
||||
FlipHorizontalCommandHandler(CommandId cmdId) : MenuItemHandler(cmdId) {}
|
||||
void execute() override {
|
||||
TTool::Application *app = TTool::getApplication();
|
||||
TTool *tool = app->getCurrentTool()->getTool();
|
||||
if (!tool) return;
|
||||
if (tool->getName() == T_Edit) {
|
||||
EditTool *editTool = dynamic_cast<EditTool *>(tool);
|
||||
emit editTool->clickFlipHorizontal();
|
||||
} else if (tool->getName() == T_Selection) {
|
||||
SelectionTool *selectionTool = dynamic_cast<SelectionTool *>(tool);
|
||||
emit selectionTool->clickFlipHorizontal();
|
||||
}
|
||||
}
|
||||
} flipHorizontalCHInstance("A_ToolOption_FlipHorizontal");
|
||||
|
||||
class FlipVerticalCommandHandler final : public MenuItemHandler {
|
||||
public:
|
||||
FlipVerticalCommandHandler(CommandId cmdId) : MenuItemHandler(cmdId) {}
|
||||
void execute() override {
|
||||
TTool::Application *app = TTool::getApplication();
|
||||
TTool *tool = app->getCurrentTool()->getTool();
|
||||
if (!tool) return;
|
||||
if (tool->getName() == T_Edit) {
|
||||
EditTool *editTool = dynamic_cast<EditTool *>(tool);
|
||||
emit editTool->clickFlipVertical();
|
||||
} else if (tool->getName() == T_Selection) {
|
||||
SelectionTool *selectionTool = dynamic_cast<SelectionTool *>(tool);
|
||||
emit selectionTool->clickFlipVertical();
|
||||
}
|
||||
}
|
||||
} flipVerticalCHInstance("A_ToolOption_FlipVertical");
|
||||
|
||||
class RotateLeftCommandHandler final : public MenuItemHandler {
|
||||
public:
|
||||
RotateLeftCommandHandler(CommandId cmdId) : MenuItemHandler(cmdId) {}
|
||||
void execute() override {
|
||||
TTool::Application *app = TTool::getApplication();
|
||||
TTool *tool = app->getCurrentTool()->getTool();
|
||||
if (!tool) return;
|
||||
if (tool->getName() == T_Edit) {
|
||||
EditTool *editTool = dynamic_cast<EditTool *>(tool);
|
||||
emit editTool->clickRotateLeft();
|
||||
} else if (tool->getName() == T_Selection) {
|
||||
SelectionTool *selectionTool = dynamic_cast<SelectionTool *>(tool);
|
||||
emit selectionTool->clickRotateLeft();
|
||||
}
|
||||
}
|
||||
} rotateLeftCHInstance("A_ToolOption_RotateLeft");
|
||||
|
||||
class RotateRightCommandHandler final : public MenuItemHandler {
|
||||
public:
|
||||
RotateRightCommandHandler(CommandId cmdId) : MenuItemHandler(cmdId) {}
|
||||
void execute() override {
|
||||
TTool::Application *app = TTool::getApplication();
|
||||
TTool *tool = app->getCurrentTool()->getTool();
|
||||
if (!tool) return;
|
||||
if (tool->getName() == T_Edit) {
|
||||
EditTool *editTool = dynamic_cast<EditTool *>(tool);
|
||||
emit editTool->clickRotateRight();
|
||||
} else if (tool->getName() == T_Selection) {
|
||||
SelectionTool *selectionTool = dynamic_cast<SelectionTool *>(tool);
|
||||
emit selectionTool->clickRotateRight();
|
||||
}
|
||||
}
|
||||
} rotateRightCHInstance("A_ToolOption_RotateRight");
|
||||
|
|
|
@ -2925,6 +2925,14 @@ void MainWindow::defineActions() {
|
|||
createToolOptionsAction("A_ToolOption_AutoClose", QT_TR_NOOP("Auto Close"), "");
|
||||
createToolOptionsAction("A_ToolOption_DrawUnder", QT_TR_NOOP("Draw Under"), "");
|
||||
|
||||
createToolOptionsAction("A_ToolOption_FlipHorizontal",
|
||||
QT_TR_NOOP("Flip Selection/Object Horizontally"), "");
|
||||
createToolOptionsAction("A_ToolOption_FlipVertical",
|
||||
QT_TR_NOOP("Flip Selection/Object Vertically"), "");
|
||||
createToolOptionsAction("A_ToolOption_RotateLeft",
|
||||
QT_TR_NOOP("Rotate Selection/Object Left"), "");
|
||||
createToolOptionsAction("A_ToolOption_RotateRight",
|
||||
QT_TR_NOOP("Rotate Selection/Object Right"), "");
|
||||
// Visualization
|
||||
|
||||
createViewerAction(V_ZoomIn, QT_TR_NOOP("Zoom In"), "+");
|
||||
|
|
Loading…
Reference in a new issue