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 d1f6c4
class FunctionSheetRowViewer final : 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 473e70
  void paintEvent(QPaintEvent *) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void mousePressEvent(QMouseEvent *) override;
Shinya Kitaoka 473e70
  void mouseReleaseEvent(QMouseEvent *) override;
Shinya Kitaoka 473e70
  void mouseMoveEvent(QMouseEvent *) override;
Shinya Kitaoka 473e70
  void contextMenuEvent(QContextMenuEvent *) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class FunctionSheetColumnHeadViewer final : 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 473e70
  void paintEvent(QPaintEvent *) override;
Shinya Kitaoka 473e70
  void mousePressEvent(QMouseEvent *) override;
Shinya Kitaoka 120a6e
  // update the tooltip
Shinya Kitaoka 473e70
  void mouseMoveEvent(QMouseEvent *) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void contextMenuEvent(QContextMenuEvent *) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class FunctionSheetCellViewer final : 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
Jeremy Bullock 771290
  // for mouse dragging to adjust the value
Jeremy Bullock 771290
  double m_currentValue = 0.0;
Jeremy Bullock 771290
  double m_updatedValue = 0.0;
Jeremy Bullock 771290
  int m_mouseXPosition;
Jeremy Bullock 771290
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  FunctionSheetCellViewer(FunctionSheet *parent);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  Spreadsheet::DragTool *createDragTool(QMouseEvent *) override;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 473e70
  void drawCells(QPainter &p, int r0, int c0, int r1, int c1) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void mouseDoubleClickEvent(QMouseEvent *) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void mousePressEvent(QMouseEvent *) override;
Shinya Kitaoka 473e70
  void mouseReleaseEvent(QMouseEvent *) override;
Shinya Kitaoka 473e70
  void mouseMoveEvent(QMouseEvent *) override;
Shinya Kitaoka 120a6e
  void openContextMenu(QMouseEvent *);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private slots:
Shinya Kitaoka 120a6e
  void onCellEditorEditingFinished();
Jeremy Bullock 771290
Jeremy Bullock 771290
  // double clicking opens the line edit where mouse dragging
Jeremy Bullock 771290
  // can change the value.  It sends a signal to this slot.
Jeremy Bullock 771290
  void onMouseMovedInLineEdit(QMouseEvent *event);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class FunctionSheet final : public SpreadsheetViewer {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Jeremy Bullock 4ce953
  FunctionSheet(QWidget *parent = 0, bool isFloating = false);
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 473e70
  QRect getSelectedCells() const override;
Shinya Kitaoka 473e70
  void selectCells(const QRect &selectedCells) override;
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 473e70
  void showEvent(QShowEvent *e) override;
Shinya Kitaoka 473e70
  void hideEvent(QHideEvent *e) override;
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;
Jeremy Bullock 4ce953
  bool m_isFloating;
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