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