Shinya Kitaoka 810553
#pragma once
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
Shinya Kitaoka 120a6e
namespace ToonzExt {
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
Shinya Kitaoka 120a6e
class DVAPI PinchTool : public TTool {
Shinya Kitaoka 120a6e
  Q_DECLARE_TR_FUNCTIONS(PinchTool)
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TMouseEvent m_lastMouseEvent;
Shinya Kitaoka 120a6e
  ToonzExt::StrokeDeformation *m_deformation;
Shinya Kitaoka 120a6e
  ToonzExt::ContextStatus m_status;
Shinya Kitaoka 120a6e
  ToonzExt::Selector m_selector;
Shinya Kitaoka 120a6e
  TUndo *m_undo;
Shinya Kitaoka 120a6e
  bool m_draw, m_active, m_cursorEnabled;
Shinya Kitaoka 120a6e
  TThickPoint m_cursor;
Shinya Kitaoka 120a6e
  TPointD m_prev, m_curr, m_down;
Shinya Kitaoka 120a6e
  unsigned int m_n;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool m_showSelector;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TDoubleProperty m_toolRange;
Shinya Kitaoka 120a6e
  TDoubleProperty m_toolCornerSize;
Shinya Kitaoka 120a6e
  TBoolProperty m_autoOrManual;
Shinya Kitaoka 120a6e
  TPropertyGroup m_prop;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void updateInterfaceStatus(const TMouseEvent &);
Shinya Kitaoka 120a6e
  void updateStrokeStatus(TStroke *stroke, double w);
Shinya Kitaoka 120a6e
  int updateCursor() const;
Shinya Kitaoka 120a6e
  TStroke *getClosestStroke(const TPointD &pos, double &w) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  PinchTool();
Shinya Kitaoka 120a6e
  virtual ~PinchTool();
Toshihiro Shimizu 890ddd
artisteacher fd1c1e
  ToolType getToolType() const override { return TTool::LevelWriteTool; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setShowSelector(bool show) { m_showSelector = show; }
Toshihiro Shimizu 890ddd
artisteacher fd1c1e
  void onEnter() override;
artisteacher fd1c1e
  void onLeave() override;
Toshihiro Shimizu 890ddd
artisteacher fd1c1e
  void updateTranslation() override;
Toshihiro Shimizu 890ddd
artisteacher fd1c1e
  void draw() override;
Toshihiro Shimizu 890ddd
artisteacher fd1c1e
  void leftButtonDown(const TPointD &pos, const TMouseEvent &) override;
Toshihiro Shimizu 890ddd
artisteacher fd1c1e
  void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override;
Toshihiro Shimizu 890ddd
artisteacher fd1c1e
  void leftButtonUp(const TPointD &pos, const TMouseEvent &e) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void invalidateCursorArea();
Toshihiro Shimizu 890ddd
artisteacher fd1c1e
  void mouseMove(const TPointD &pos, const TMouseEvent &e) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool moveCursor(const TPointD &pos);
Toshihiro Shimizu 890ddd
shun-iwasawa 7f1e30
  bool keyDown(QKeyEvent *) override;
Toshihiro Shimizu 890ddd
artisteacher fd1c1e
  void onActivate() override;
artisteacher fd1c1e
  void onDeactivate() override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // viene usato??
Shinya Kitaoka 120a6e
  void update(const TGlobalChange &);
Toshihiro Shimizu 890ddd
artisteacher fd1c1e
  void onImageChanged() override;
Toshihiro Shimizu 890ddd
artisteacher fd1c1e
  int getCursorId() const override { return updateCursor(); }
artisteacher fd1c1e
  TPropertyGroup *getProperties(int targetType) override { return &m_prop; }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // PINCHTOOL_H