1 #pragma once 2 3 #ifndef FUNCTIONPANELTOOLS_H 4 #define FUNCTIONPANELTOOLS_H 5 6 #include "toonzqt/functionpanel.h" 7 #include "tdoublekeyframe.h" 8 #include "toonz/doubleparamcmd.h" 9 10 // class QMouseEvent; 11 class KeyframeSetter; 12 class TDoubleParam; 13 14 class FunctionPanel::DragTool { 15 public: DragTool()16 DragTool() {} ~DragTool()17 virtual ~DragTool() {} click(QMouseEvent * e)18 virtual void click(QMouseEvent *e) {} drag(QMouseEvent * e)19 virtual void drag(QMouseEvent *e) {} release(QMouseEvent * e)20 virtual void release(QMouseEvent *e) {} 21 draw(QPainter & p)22 virtual void draw(QPainter &p) {} 23 }; 24 25 class MoveFrameDragTool final : public FunctionPanel::DragTool { 26 FunctionPanel *m_panel; 27 TFrameHandle *m_frameHandle; 28 29 public: 30 MoveFrameDragTool(FunctionPanel *panel, TFrameHandle *frameHandle); 31 void drag(QMouseEvent *e) override; 32 }; 33 34 class PanDragTool final : public FunctionPanel::DragTool { 35 FunctionPanel *m_panel; 36 QPoint m_oldPos; 37 bool m_xLocked, m_yLocked; 38 39 public: 40 PanDragTool(FunctionPanel *panel, bool xLocked, bool yLocked); 41 void click(QMouseEvent *e) override; 42 void drag(QMouseEvent *e) override; 43 }; 44 45 class ZoomDragTool final : public FunctionPanel::DragTool { 46 FunctionPanel *m_panel; 47 QPoint m_startPos, m_oldPos; 48 int m_zoomType; 49 50 public: 51 enum ZoomType { FrameZoom = 1, ValueZoom = 2 }; ZoomDragTool(FunctionPanel * panel,ZoomType zoomType)52 ZoomDragTool(FunctionPanel *panel, ZoomType zoomType) 53 : m_panel(panel), m_zoomType((int)zoomType) {} 54 55 void click(QMouseEvent *e) override; 56 void drag(QMouseEvent *e) override; 57 void release(QMouseEvent *e) override; 58 }; 59 60 class RectSelectTool final : public FunctionPanel::DragTool { 61 FunctionPanel *m_panel; 62 TDoubleParam *m_curve; 63 QPoint m_startPos; 64 QRect m_rect; 65 66 public: RectSelectTool(FunctionPanel * panel,TDoubleParam * curve)67 RectSelectTool(FunctionPanel *panel, TDoubleParam *curve) 68 : m_panel(panel), m_curve(curve) {} 69 70 void click(QMouseEvent *e) override; 71 void drag(QMouseEvent *e) override; 72 void release(QMouseEvent *e) override; 73 74 void draw(QPainter &painter) override; 75 }; 76 77 class MovePointDragTool final : public FunctionPanel::DragTool { 78 FunctionPanel *m_panel; 79 QPoint m_startPos, m_oldPos; 80 double m_deltaFrame; 81 // length and kIndex of speedinout handles which can change because of point 82 // moving 83 double m_speed0Length; 84 int m_speed0Index; 85 double m_speed1Length; 86 int m_speed1Index; 87 std::vector<KeyframeSetter *> m_setters; 88 bool m_groupEnabled; 89 FunctionSelection *m_selection; 90 91 public: 92 MovePointDragTool(FunctionPanel *panel, TDoubleParam *curve); 93 ~MovePointDragTool(); 94 95 void addKeyframe2(int kIndex); 96 // void addKeyframe(int kIndex) {m_setter->selectKeyframe(kIndex);} 97 void createKeyframe(double frame); 98 void selectKeyframes(double frame); 99 100 void setSelection(FunctionSelection *selection); 101 102 void click(QMouseEvent *e) override; 103 void drag(QMouseEvent *e) override; 104 void release(QMouseEvent *e) override; 105 }; 106 107 class MoveHandleDragTool final : public FunctionPanel::DragTool { 108 public: 109 typedef FunctionPanel::Handle Handle; 110 111 private: 112 FunctionPanel *m_panel; 113 TDoubleParam *m_curve; 114 QPoint m_startPos; //, m_oldPos; 115 double m_deltaFrame; 116 Handle m_handle; 117 int m_kIndex; 118 TDoubleKeyframe m_keyframe; 119 KeyframeSetter m_setter; 120 double m_segmentWidth; 121 QPointF m_nSpeed; // speedInOut constraint 122 123 public: 124 FunctionTreeModel::ChannelGroup *m_channelGroup; 125 126 MoveHandleDragTool(FunctionPanel *panel, TDoubleParam *curve, int kIndex, 127 Handle handle); 128 129 void click(QMouseEvent *e) override; 130 void drag(QMouseEvent *e) override; 131 void release(QMouseEvent *e) override; 132 }; 133 134 class MoveGroupHandleDragTool final : public FunctionPanel::DragTool { 135 public: 136 typedef FunctionPanel::Handle Handle; 137 138 private: 139 FunctionPanel *m_panel; 140 double m_keyframePosition; 141 Handle m_handle; 142 std::vector<std::pair<TDoubleKeyframe, KeyframeSetter *>> m_setters; 143 144 public: 145 MoveGroupHandleDragTool(FunctionPanel *panel, double keyframePosition, 146 Handle handle); 147 ~MoveGroupHandleDragTool(); 148 149 void click(QMouseEvent *e) override; 150 void drag(QMouseEvent *e) override; 151 void release(QMouseEvent *e) override; 152 }; 153 154 #endif 155