tahoma2d/toonz/sources/include/tools/pinchtool.h

104 lines
2.3 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef PINCHTOOL_H
#define PINCHTOOL_H
#include "tools/tool.h"
#include "tproperty.h"
#include "toonz/observer.h"
#include "ext/ContextStatus.h"
#include "ext/Selector.h"
// For Qt translation support
#include <QCoreApplication>
class TUndo;
2016-06-15 18:43:10 +12:00
namespace ToonzExt {
2016-03-19 06:57:51 +13:00
class StrokeDeformation;
}
#undef DVAPI
#undef DVVAR
#ifdef TNZTOOLS_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
//=============================================================================
//
// PinchTool (private data)
//
//=============================================================================
2016-06-15 18:43:10 +12:00
class DVAPI PinchTool : public TTool {
Q_DECLARE_TR_FUNCTIONS(PinchTool)
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TMouseEvent m_lastMouseEvent;
ToonzExt::StrokeDeformation *m_deformation;
ToonzExt::ContextStatus m_status;
ToonzExt::Selector m_selector;
TUndo *m_undo;
bool m_draw, m_active, m_cursorEnabled;
TThickPoint m_cursor;
TPointD m_prev, m_curr, m_down;
unsigned int m_n;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool m_showSelector;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TDoubleProperty m_toolRange;
TDoubleProperty m_toolCornerSize;
TBoolProperty m_autoOrManual;
TPropertyGroup m_prop;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void updateInterfaceStatus(const TMouseEvent &);
void updateStrokeStatus(TStroke *stroke, double w);
int updateCursor() const;
TStroke *getClosestStroke(const TPointD &pos, double &w) const;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
PinchTool();
virtual ~PinchTool();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
ToolType getToolType() const { return TTool::LevelWriteTool; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setShowSelector(bool show) { m_showSelector = show; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void onEnter();
void onLeave();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void updateTranslation();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void draw();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void leftButtonDown(const TPointD &pos, const TMouseEvent &);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void leftButtonDrag(const TPointD &pos, const TMouseEvent &e);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void leftButtonUp(const TPointD &pos, const TMouseEvent &e);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void invalidateCursorArea();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void mouseMove(const TPointD &pos, const TMouseEvent &e);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool moveCursor(const TPointD &pos);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
bool keyDown(int key, TUINT32 flags, const TPoint &pos);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void onActivate();
void onDeactivate();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
// viene usato??
void update(const TGlobalChange &);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void onImageChanged();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int getCursorId() const { return updateCursor(); }
TPropertyGroup *getProperties(int targetType) { return &m_prop; }
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
#endif // PINCHTOOL_H