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