Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef FUNCTIONSHEET_H
Toshihiro Shimizu 890ddd
#define FUNCTIONSHEET_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
#include "functiontreeviewer.h"
Toshihiro Shimizu 890ddd
#include "spreadsheetviewer.h"
Toshihiro Shimizu 890ddd
#include "functionselection.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/lineedit.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qwidget></qwidget>
Toshihiro Shimizu 890ddd
#include <set></set>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TOONZQT_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
class FunctionSheet;
Toshihiro Shimizu 890ddd
class TDoubleParam;
Toshihiro Shimizu 890ddd
class TFrameHandle;
Toshihiro Shimizu 890ddd
class FunctionSelection;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class FunctionSheetRowViewer : public Spreadsheet::RowPanel
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FunctionSheet *m_sheet;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	FunctionSheetRowViewer(FunctionSheet *parent);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	void paintEvent(QPaintEvent *);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void mousePressEvent(QMouseEvent *);
Toshihiro Shimizu 890ddd
	void mouseReleaseEvent(QMouseEvent *);
Toshihiro Shimizu 890ddd
	void mouseMoveEvent(QMouseEvent *);
Toshihiro Shimizu 890ddd
	void contextMenuEvent(QContextMenuEvent *);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class FunctionSheetColumnHeadViewer : public Spreadsheet::ColumnPanel
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	FunctionSheet *m_sheet;
Toshihiro Shimizu 890ddd
	//enable drag and drop the expression arguments
Toshihiro Shimizu 890ddd
	QPoint m_dragStartPosition;
Toshihiro Shimizu 890ddd
	FunctionTreeModel::Channel *m_draggingChannel;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	FunctionSheetColumnHeadViewer(FunctionSheet *parent);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	void paintEvent(QPaintEvent *);
Toshihiro Shimizu 890ddd
	void mousePressEvent(QMouseEvent *);
Toshihiro Shimizu 890ddd
	//update the tooltip
Toshihiro Shimizu 890ddd
	void mouseMoveEvent(QMouseEvent *);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void contextMenuEvent(QContextMenuEvent *);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class FunctionSheetCellViewer : public Spreadsheet::CellPanel
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
	FunctionSheet *m_sheet;
Toshihiro Shimizu 890ddd
	DVGui::LineEdit *m_lineEdit;
Toshihiro Shimizu 890ddd
	int m_editRow, m_editCol;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	FunctionSheetCellViewer(FunctionSheet *parent);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	Spreadsheet::DragTool *createDragTool(QMouseEvent *);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	void drawCells(QPainter &p, int r0, int c0, int r1, int c1);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void mouseDoubleClickEvent(QMouseEvent *);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void mousePressEvent(QMouseEvent *);
Toshihiro Shimizu 890ddd
	void mouseReleaseEvent(QMouseEvent *);
Toshihiro Shimizu 890ddd
	void mouseMoveEvent(QMouseEvent *);
Toshihiro Shimizu 890ddd
	void openContextMenu(QMouseEvent *);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private slots:
Toshihiro Shimizu 890ddd
	void onCellEditorEditingFinished();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class FunctionSheet : public SpreadsheetViewer
Toshihiro Shimizu 890ddd
{
Toshihiro Shimizu 890ddd
	Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Toshihiro Shimizu 890ddd
	FunctionSheet(QWidget *parent = 0);
Toshihiro Shimizu 890ddd
	~FunctionSheet();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setModel(FunctionTreeModel *model);
Toshihiro Shimizu 890ddd
	FunctionTreeModel *getModel() const { return m_functionTreeModel; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setViewer(FunctionViewer *viewer);
Toshihiro Shimizu 890ddd
	FunctionViewer *getViewer() const { return m_functionViewer; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void setCurrentFrame(int frame);
Toshihiro Shimizu 890ddd
	int getCurrentFrame() const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	int getChannelCount();
Toshihiro Shimizu 890ddd
	TDoubleParam *getCurve(int column);
Toshihiro Shimizu 890ddd
	FunctionTreeModel::Channel *getChannel(int column);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QRect getSelectedCells() const;
Toshihiro Shimizu 890ddd
	void selectCells(const QRect &selectedCells);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	FunctionSelection *getSelection() const { return m_selection; }
Toshihiro Shimizu 890ddd
	void setSelection(FunctionSelection *selection); // does NOT get ownership
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QString getSelectedParamName();
Toshihiro Shimizu 890ddd
	int getColumnIndexByCurve(TDoubleParam *param) const;
Toshihiro Shimizu 890ddd
	bool anyWidgetHasFocus();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Toshihiro Shimizu 890ddd
	void showEvent(QShowEvent *e);
Toshihiro Shimizu 890ddd
	void hideEvent(QHideEvent *e);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Toshihiro Shimizu 890ddd
	FunctionSheetRowViewer *m_rowViewer;
Toshihiro Shimizu 890ddd
	FunctionSheetColumnHeadViewer *m_columnHeadViewer;
Toshihiro Shimizu 890ddd
	FunctionSheetCellViewer *m_cellViewer;
Toshihiro Shimizu 890ddd
	FunctionSelection *m_selection;
Toshihiro Shimizu 890ddd
	FunctionTreeModel *m_functionTreeModel;
Toshihiro Shimizu 890ddd
	FunctionViewer *m_functionViewer;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	QRect m_selectedCells;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public slots:
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
	void updateAll();
Toshihiro Shimizu 890ddd
	void onFrameSwitched();
Toshihiro Shimizu 890ddd
	/*--- カレントChannelが切り替わったら、NumericalColumnsがそのChannelを表示できるようにスクロールする。---*/
Toshihiro Shimizu 890ddd
	void onCurrentChannelChanged(FunctionTreeModel::Channel *);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif