Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef FUNCTIONPANELTOOLS_H
Toshihiro Shimizu 890ddd
#define FUNCTIONPANELTOOLS_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "toonzqt/functionpanel.h"
Toshihiro Shimizu 890ddd
#include "tdoublekeyframe.h"
Toshihiro Shimizu 890ddd
#include "toonz/doubleparamcmd.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// class QMouseEvent;
Toshihiro Shimizu 890ddd
class KeyframeSetter;
Toshihiro Shimizu 890ddd
class TDoubleParam;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class FunctionPanel::DragTool {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  DragTool() {}
Shinya Kitaoka 120a6e
  virtual ~DragTool() {}
Shinya Kitaoka 120a6e
  virtual void click(QMouseEvent *e) {}
Shinya Kitaoka 120a6e
  virtual void drag(QMouseEvent *e) {}
Shinya Kitaoka 120a6e
  virtual void release(QMouseEvent *e) {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual void draw(QPainter &p) {}
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class MoveFrameDragTool final : public FunctionPanel::DragTool {
Shinya Kitaoka 120a6e
  FunctionPanel *m_panel;
Shinya Kitaoka 120a6e
  TFrameHandle *m_frameHandle;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  MoveFrameDragTool(FunctionPanel *panel, TFrameHandle *frameHandle);
Shinya Kitaoka 473e70
  void drag(QMouseEvent *e) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class PanDragTool final : public FunctionPanel::DragTool {
Shinya Kitaoka 120a6e
  FunctionPanel *m_panel;
Shinya Kitaoka 120a6e
  QPoint m_oldPos;
Shinya Kitaoka 120a6e
  bool m_xLocked, m_yLocked;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  PanDragTool(FunctionPanel *panel, bool xLocked, bool yLocked);
Shinya Kitaoka 473e70
  void click(QMouseEvent *e) override;
Shinya Kitaoka 473e70
  void drag(QMouseEvent *e) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class ZoomDragTool final : public FunctionPanel::DragTool {
Shinya Kitaoka 120a6e
  FunctionPanel *m_panel;
Shinya Kitaoka 120a6e
  QPoint m_startPos, m_oldPos;
Shinya Kitaoka 120a6e
  int m_zoomType;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  enum ZoomType { FrameZoom = 1, ValueZoom = 2 };
Shinya Kitaoka 120a6e
  ZoomDragTool(FunctionPanel *panel, ZoomType zoomType)
Shinya Kitaoka 120a6e
      : m_panel(panel), m_zoomType((int)zoomType) {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void click(QMouseEvent *e) override;
Shinya Kitaoka 473e70
  void drag(QMouseEvent *e) override;
Shinya Kitaoka 473e70
  void release(QMouseEvent *e) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class RectSelectTool final : public FunctionPanel::DragTool {
Shinya Kitaoka 120a6e
  FunctionPanel *m_panel;
Shinya Kitaoka 120a6e
  TDoubleParam *m_curve;
Shinya Kitaoka 120a6e
  QPoint m_startPos;
Shinya Kitaoka 120a6e
  QRect m_rect;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  RectSelectTool(FunctionPanel *panel, TDoubleParam *curve)
Shinya Kitaoka 120a6e
      : m_panel(panel), m_curve(curve) {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void click(QMouseEvent *e) override;
Shinya Kitaoka 473e70
  void drag(QMouseEvent *e) override;
Shinya Kitaoka 473e70
  void release(QMouseEvent *e) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void draw(QPainter &painter) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class MovePointDragTool final : public FunctionPanel::DragTool {
Shinya Kitaoka 120a6e
  FunctionPanel *m_panel;
Shinya Kitaoka 120a6e
  QPoint m_startPos, m_oldPos;
Shinya Kitaoka 120a6e
  double m_deltaFrame;
Shinya Kitaoka 120a6e
  // length and kIndex of speedinout handles which can change because of point
Shinya Kitaoka 120a6e
  // moving
Shinya Kitaoka 120a6e
  double m_speed0Length;
Shinya Kitaoka 120a6e
  int m_speed0Index;
Shinya Kitaoka 120a6e
  double m_speed1Length;
Shinya Kitaoka 120a6e
  int m_speed1Index;
Shinya Kitaoka 120a6e
  std::vector<keyframesetter *=""> m_setters;</keyframesetter>
Shinya Kitaoka 120a6e
  bool m_groupEnabled;
Shinya Kitaoka 120a6e
  FunctionSelection *m_selection;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  MovePointDragTool(FunctionPanel *panel, TDoubleParam *curve);
Shinya Kitaoka 120a6e
  ~MovePointDragTool();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void addKeyframe2(int kIndex);
Shinya Kitaoka 120a6e
  // void addKeyframe(int kIndex) {m_setter->selectKeyframe(kIndex);}
Shinya Kitaoka 120a6e
  void createKeyframe(double frame);
Shinya Kitaoka 120a6e
  void selectKeyframes(double frame);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setSelection(FunctionSelection *selection);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void click(QMouseEvent *e) override;
Shinya Kitaoka 473e70
  void drag(QMouseEvent *e) override;
Shinya Kitaoka 473e70
  void release(QMouseEvent *e) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class MoveHandleDragTool final : public FunctionPanel::DragTool {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  typedef FunctionPanel::Handle Handle;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  FunctionPanel *m_panel;
Shinya Kitaoka 120a6e
  TDoubleParam *m_curve;
Shinya Kitaoka 120a6e
  QPoint m_startPos;  //, m_oldPos;
Shinya Kitaoka 120a6e
  double m_deltaFrame;
Shinya Kitaoka 120a6e
  Handle m_handle;
Shinya Kitaoka 120a6e
  int m_kIndex;
Shinya Kitaoka 120a6e
  TDoubleKeyframe m_keyframe;
Shinya Kitaoka 120a6e
  KeyframeSetter m_setter;
Shinya Kitaoka 120a6e
  double m_segmentWidth;
Shinya Kitaoka 120a6e
  QPointF m_nSpeed;  // speedInOut constraint
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  FunctionTreeModel::ChannelGroup *m_channelGroup;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  MoveHandleDragTool(FunctionPanel *panel, TDoubleParam *curve, int kIndex,
Shinya Kitaoka 120a6e
                     Handle handle);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void click(QMouseEvent *e) override;
Shinya Kitaoka 473e70
  void drag(QMouseEvent *e) override;
Shinya Kitaoka 473e70
  void release(QMouseEvent *e) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class MoveGroupHandleDragTool final : public FunctionPanel::DragTool {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  typedef FunctionPanel::Handle Handle;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  FunctionPanel *m_panel;
Shinya Kitaoka 120a6e
  double m_keyframePosition;
Shinya Kitaoka 120a6e
  Handle m_handle;
Shinya Kitaoka 120a6e
  std::vector<std::pair<tdoublekeyframe, *="" keyframesetter="">> m_setters;</std::pair<tdoublekeyframe,>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  MoveGroupHandleDragTool(FunctionPanel *panel, double keyframePosition,
Shinya Kitaoka 120a6e
                          Handle handle);
Shinya Kitaoka 120a6e
  ~MoveGroupHandleDragTool();
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void click(QMouseEvent *e) override;
Shinya Kitaoka 473e70
  void drag(QMouseEvent *e) override;
Shinya Kitaoka 473e70
  void release(QMouseEvent *e) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif