Skip to content

Commit

Permalink
Add Flip and Rotate Selection/Object shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
manongjohn committed Jan 8, 2023
1 parent edf5e1e commit 19dec58
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 135 deletions.
3 changes: 2 additions & 1 deletion toonz/sources/tnztools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ set(MOC_HEADERS
tooloptionscontrols.h
toonzrasterbrushtool.h
viewtools.h
selectiontool.h
edittool.h
controlpointeditortool.h
../include/tools/imagegrouping.h
../include/tools/screenpicker.h
Expand All @@ -25,7 +27,6 @@ set(HEADERS
rasterselectiontool.h
rgbpickertool.h
rulertool.h
selectiontool.h
setsaveboxtool.h
shifttracetool.h
stylepickertool.h
Expand Down
129 changes: 1 addition & 128 deletions toonz/sources/tnztools/edittool.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@


#include "edittool.h"
#include "tools/tool.h"
#include "tools/cursors.h"
#include "tproperty.h"
Expand Down Expand Up @@ -636,134 +637,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)
Expand Down
147 changes: 147 additions & 0 deletions toonz/sources/tnztools/edittool.h
Original file line number Diff line number Diff line change
@@ -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
10 changes: 8 additions & 2 deletions toonz/sources/tnztools/selectiontool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -467,6 +467,12 @@ class SelectionTool : public TTool, public TSelection::View {
bool isEventAcceptable(QEvent *e) override;

virtual bool isSelectionEditable() { return true; }

signals:
void clickFlipHorizontal();
void clickFlipVertical();
void clickRotateLeft();
void clickRotateRight();
};

#endif // SELECTIONTOOL_INCLUDED
Loading

0 comments on commit 19dec58

Please sign in to comment.