tahoma2d/toonz/sources/toonzqt/functionpaneltools.h

155 lines
3.9 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 FUNCTIONPANELTOOLS_H
#define FUNCTIONPANELTOOLS_H
#include "toonzqt/functionpanel.h"
#include "tdoublekeyframe.h"
#include "toonz/doubleparamcmd.h"
// class QMouseEvent;
class KeyframeSetter;
class TDoubleParam;
2016-06-15 18:43:10 +12:00
class FunctionPanel::DragTool {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
DragTool() {}
virtual ~DragTool() {}
virtual void click(QMouseEvent *e) {}
virtual void drag(QMouseEvent *e) {}
virtual void release(QMouseEvent *e) {}
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
virtual void draw(QPainter &p) {}
2016-03-19 06:57:51 +13:00
};
class MoveFrameDragTool final : public FunctionPanel::DragTool {
2016-06-15 18:43:10 +12:00
FunctionPanel *m_panel;
TFrameHandle *m_frameHandle;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
MoveFrameDragTool(FunctionPanel *panel, TFrameHandle *frameHandle);
2016-06-19 20:06:29 +12:00
void drag(QMouseEvent *e) override;
2016-03-19 06:57:51 +13:00
};
class PanDragTool final : public FunctionPanel::DragTool {
2016-06-15 18:43:10 +12:00
FunctionPanel *m_panel;
QPoint m_oldPos;
bool m_xLocked, m_yLocked;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
PanDragTool(FunctionPanel *panel, bool xLocked, bool yLocked);
2016-06-19 20:06:29 +12:00
void click(QMouseEvent *e) override;
void drag(QMouseEvent *e) override;
2016-03-19 06:57:51 +13:00
};
class ZoomDragTool final : public FunctionPanel::DragTool {
2016-06-15 18:43:10 +12:00
FunctionPanel *m_panel;
QPoint m_startPos, m_oldPos;
int m_zoomType;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
enum ZoomType { FrameZoom = 1, ValueZoom = 2 };
ZoomDragTool(FunctionPanel *panel, ZoomType zoomType)
: m_panel(panel), m_zoomType((int)zoomType) {}
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void click(QMouseEvent *e) override;
void drag(QMouseEvent *e) override;
void release(QMouseEvent *e) override;
2016-03-19 06:57:51 +13:00
};
class RectSelectTool final : public FunctionPanel::DragTool {
2016-06-15 18:43:10 +12:00
FunctionPanel *m_panel;
TDoubleParam *m_curve;
QPoint m_startPos;
QRect m_rect;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
RectSelectTool(FunctionPanel *panel, TDoubleParam *curve)
: m_panel(panel), m_curve(curve) {}
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void click(QMouseEvent *e) override;
void drag(QMouseEvent *e) override;
void release(QMouseEvent *e) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void draw(QPainter &painter) override;
2016-03-19 06:57:51 +13:00
};
class MovePointDragTool final : public FunctionPanel::DragTool {
2016-06-15 18:43:10 +12:00
FunctionPanel *m_panel;
QPoint m_startPos, m_oldPos;
double m_deltaFrame;
// length and kIndex of speedinout handles which can change because of point
// moving
double m_speed0Length;
int m_speed0Index;
double m_speed1Length;
int m_speed1Index;
std::vector<KeyframeSetter *> m_setters;
bool m_groupEnabled;
FunctionSelection *m_selection;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
MovePointDragTool(FunctionPanel *panel, TDoubleParam *curve);
~MovePointDragTool();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void addKeyframe2(int kIndex);
// void addKeyframe(int kIndex) {m_setter->selectKeyframe(kIndex);}
void createKeyframe(double frame);
void selectKeyframes(double frame);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setSelection(FunctionSelection *selection);
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void click(QMouseEvent *e) override;
void drag(QMouseEvent *e) override;
void release(QMouseEvent *e) override;
2016-03-19 06:57:51 +13:00
};
class MoveHandleDragTool final : public FunctionPanel::DragTool {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
typedef FunctionPanel::Handle Handle;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
FunctionPanel *m_panel;
TDoubleParam *m_curve;
QPoint m_startPos; //, m_oldPos;
double m_deltaFrame;
Handle m_handle;
int m_kIndex;
TDoubleKeyframe m_keyframe;
KeyframeSetter m_setter;
double m_segmentWidth;
QPointF m_nSpeed; // speedInOut constraint
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FunctionTreeModel::ChannelGroup *m_channelGroup;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
MoveHandleDragTool(FunctionPanel *panel, TDoubleParam *curve, int kIndex,
Handle handle);
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void click(QMouseEvent *e) override;
void drag(QMouseEvent *e) override;
void release(QMouseEvent *e) override;
2016-03-19 06:57:51 +13:00
};
class MoveGroupHandleDragTool final : public FunctionPanel::DragTool {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
typedef FunctionPanel::Handle Handle;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
FunctionPanel *m_panel;
double m_keyframePosition;
Handle m_handle;
std::vector<std::pair<TDoubleKeyframe, KeyframeSetter *>> m_setters;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
MoveGroupHandleDragTool(FunctionPanel *panel, double keyframePosition,
Handle handle);
~MoveGroupHandleDragTool();
2016-06-19 20:06:29 +12:00
void click(QMouseEvent *e) override;
void drag(QMouseEvent *e) override;
void release(QMouseEvent *e) override;
2016-03-19 06:57:51 +13:00
};
#endif