tahoma2d/toonz/sources/include/toonzqt/functionsheet.h

166 lines
4.3 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 FUNCTIONSHEET_H
#define FUNCTIONSHEET_H
#include "tcommon.h"
#include "functiontreeviewer.h"
#include "spreadsheetviewer.h"
#include "functionselection.h"
#include "toonzqt/lineedit.h"
#include <QWidget>
#include <set>
#undef DVAPI
#undef DVVAR
#ifdef TOONZQT_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
class FunctionSheet;
class TDoubleParam;
class TFrameHandle;
class FunctionSelection;
class FunctionSheetRowViewer final : public Spreadsheet::RowPanel {
2016-06-15 18:43:10 +12:00
FunctionSheet *m_sheet;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FunctionSheetRowViewer(FunctionSheet *parent);
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void paintEvent(QPaintEvent *) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void mousePressEvent(QMouseEvent *) override;
void mouseReleaseEvent(QMouseEvent *) override;
void mouseMoveEvent(QMouseEvent *) override;
void contextMenuEvent(QContextMenuEvent *) override;
2016-03-19 06:57:51 +13:00
};
class FunctionSheetColumnHeadViewer final : public Spreadsheet::ColumnPanel {
2016-06-15 18:43:10 +12:00
FunctionSheet *m_sheet;
// enable drag and drop the expression arguments
QPoint m_dragStartPosition;
FunctionTreeModel::Channel *m_draggingChannel;
2016-03-19 06:57:51 +13:00
int m_clickedColumn = -1;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FunctionSheetColumnHeadViewer(FunctionSheet *parent);
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void paintEvent(QPaintEvent *) override;
void mousePressEvent(QMouseEvent *) override;
2016-06-15 18:43:10 +12:00
// update the tooltip
2016-06-19 20:06:29 +12:00
void mouseMoveEvent(QMouseEvent *) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void contextMenuEvent(QContextMenuEvent *) override;
2016-03-19 06:57:51 +13:00
};
class FunctionSheetCellViewer final : public Spreadsheet::CellPanel {
2016-06-15 18:43:10 +12:00
Q_OBJECT
FunctionSheet *m_sheet;
DVGui::LineEdit *m_lineEdit;
int m_editRow, m_editCol;
2016-03-19 06:57:51 +13:00
// for mouse dragging to adjust the value
double m_currentValue = 0.0;
double m_updatedValue = 0.0;
int m_mouseXPosition;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
FunctionSheetCellViewer(FunctionSheet *parent);
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
Spreadsheet::DragTool *createDragTool(QMouseEvent *) override;
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void drawCells(QPainter &p, int r0, int c0, int r1, int c1) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void mouseDoubleClickEvent(QMouseEvent *) override;
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void mousePressEvent(QMouseEvent *) override;
void mouseReleaseEvent(QMouseEvent *) override;
void mouseMoveEvent(QMouseEvent *) override;
2016-06-15 18:43:10 +12:00
void openContextMenu(QMouseEvent *);
2016-03-19 06:57:51 +13:00
private slots:
2016-06-15 18:43:10 +12:00
void onCellEditorEditingFinished();
// double clicking opens the line edit where mouse dragging
// can change the value. It sends a signal to this slot.
void onMouseMovedInLineEdit(QMouseEvent *event);
2016-03-19 06:57:51 +13:00
};
class FunctionSheet final : public SpreadsheetViewer {
2016-06-15 18:43:10 +12:00
Q_OBJECT
bool m_showIbtwnValue = true;
2016-03-19 06:57:51 +13:00
public:
FunctionSheet(QWidget *parent = 0, bool isFloating = false);
2016-06-15 18:43:10 +12:00
~FunctionSheet();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setModel(FunctionTreeModel *model);
FunctionTreeModel *getModel() const { return m_functionTreeModel; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setViewer(FunctionViewer *viewer);
FunctionViewer *getViewer() const { return m_functionViewer; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setCurrentFrame(int frame);
int getCurrentFrame() const;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
int getChannelCount();
TDoubleParam *getCurve(int column);
FunctionTreeModel::Channel *getChannel(int column);
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
QRect getSelectedCells() const override;
void selectCells(const QRect &selectedCells) override;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
FunctionSelection *getSelection() const { return m_selection; }
void setSelection(FunctionSelection *selection); // does NOT get ownership
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QString getSelectedParamName();
int getColumnIndexByCurve(TDoubleParam *param) const;
bool anyWidgetHasFocus();
2016-03-19 06:57:51 +13:00
2019-07-01 19:42:08 +12:00
// Obtains a pointer to the stage object containing the
// parameter of specified column. Returns nullptr for
// fx parameter columns.
TStageObject *getStageObject(int column);
bool isIbtwnValueVisible() { return m_showIbtwnValue; }
void setIbtwnValueVisible(bool visible) {
m_showIbtwnValue = visible;
update();
}
2016-03-19 06:57:51 +13:00
protected:
2016-06-19 20:06:29 +12:00
void showEvent(QShowEvent *e) override;
void hideEvent(QHideEvent *e) override;
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
FunctionSheetRowViewer *m_rowViewer;
FunctionSheetColumnHeadViewer *m_columnHeadViewer;
FunctionSheetCellViewer *m_cellViewer;
FunctionSelection *m_selection;
FunctionTreeModel *m_functionTreeModel;
FunctionViewer *m_functionViewer;
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
QRect m_selectedCells;
bool m_isFloating;
2016-03-19 06:57:51 +13:00
public slots:
2016-06-15 18:43:10 +12:00
void updateAll();
void onFrameSwitched();
/*---
* Channelが切り替わったらNumericalColumnsがそのChannelを表示できるようにスクロールする---*/
void onCurrentChannelChanged(FunctionTreeModel::Channel *);
2016-03-19 06:57:51 +13:00
};
#endif