Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef FUNCTION_SEGMENT_VIEWER_H
Toshihiro Shimizu 890ddd
#define FUNCTION_SEGMENT_VIEWER_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <qlabel></qlabel>
Toshihiro Shimizu 890ddd
#include <qcombobox></qcombobox>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tdoubleparam.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/lineedit.h"
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 FunctionSegmentPage;
Toshihiro Shimizu 890ddd
class FunctionSheet;
Toshihiro Shimizu 890ddd
class TXsheetHandle;
Toshihiro Shimizu 890ddd
class KeyframeSetter;
Toshihiro Shimizu 890ddd
class FunctionPanel;
Toshihiro Shimizu 890ddd
class QPushButton;
Toshihiro Shimizu 890ddd
class QStackedWidget;
Shinya Kitaoka 120a6e
namespace DVGui {
Toshihiro Shimizu 890ddd
class MeasuredDoubleLineEdit;
Toshihiro Shimizu 890ddd
class ExpressionField;
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class FunctionSegmentViewer final : public QFrame, public TParamObserver {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TDoubleParam *m_curve;
Shinya Kitaoka 120a6e
  int m_segmentIndex;
Shinya Kitaoka 120a6e
  int m_r0, m_r1;
Shinya Kitaoka 120a6e
  QWidget *m_topbar;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QLineEdit *m_fromFld;
Shinya Kitaoka 120a6e
  QLineEdit *m_toFld;
Shinya Kitaoka 120a6e
  QLabel *m_paramNameLabel;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QComboBox *m_typeCombo;
Shinya Kitaoka 120a6e
  DVGui::LineEdit *m_stepFld;
Shinya Kitaoka 120a6e
  QStackedWidget *m_parametersPanel;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  FunctionSegmentPage *m_pages[9];
Shinya Kitaoka 120a6e
  int m_typeId[9];
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  FunctionSheet *m_sheet;
Shinya Kitaoka 120a6e
  TXsheetHandle *m_xshHandle;
Shinya Kitaoka 120a6e
  FunctionPanel *m_panel;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // buttons for move segments
Shinya Kitaoka 120a6e
  QPushButton *m_prevCurveButton;
Shinya Kitaoka 120a6e
  QPushButton *m_nextCurveButton;
Shinya Kitaoka 120a6e
  QPushButton *m_prevLinkButton;
Shinya Kitaoka 120a6e
  QPushButton *m_nextLinkButton;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  FunctionSegmentViewer(QWidget *parent, FunctionSheet *sheet = 0,
Shinya Kitaoka 120a6e
                        FunctionPanel *panel = 0);
Shinya Kitaoka 120a6e
  ~FunctionSegmentViewer();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TDoubleParam *getCurve() const { return m_curve; }
Shinya Kitaoka 120a6e
  int getR0() const { return m_r0; }
Shinya Kitaoka 120a6e
  int getR1() const { return m_r1; }
Shinya Kitaoka 120a6e
  int getSegmentIndex() const { return m_segmentIndex; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void refresh();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // overriden from TDoubleParamObserver
Shinya Kitaoka 473e70
  void onChange(const TParamChange &) override { refresh(); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setXsheetHandle(TXsheetHandle *xshHandle) { m_xshHandle = xshHandle; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool anyWidgetHasFocus();
Shinya Kitaoka 120a6e
  // in order to avoid FunctionViewer to get focus while editing the expression
Shinya Kitaoka 120a6e
  bool isExpressionPageActive();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  int typeToIndex(int type) const;
Shinya Kitaoka 120a6e
  int indexToType(int typeIndex) const { return m_typeId[typeIndex]; }
Shinya Kitaoka 120a6e
  bool segmentIsValid() const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // for displaying the types of neighbor segments
Shinya Kitaoka 120a6e
  QString typeToString(int type) const;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private slots:
Shinya Kitaoka 120a6e
  void onSegmentTypeChanged(int type);
Shinya Kitaoka 120a6e
  void onCurveChanged();
Shinya Kitaoka 120a6e
  void onStepFieldChanged(const QString &);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void onApplyButtonPressed();
Shinya Kitaoka 120a6e
  void onPrevCurveButtonPressed();
Shinya Kitaoka 120a6e
  void onNextCurveButtonPressed();
Shinya Kitaoka 120a6e
  void onPrevLinkButtonPressed();
Shinya Kitaoka 120a6e
  void onNextLinkButtonPressed();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public slots:
Shinya Kitaoka 120a6e
  void setSegment(TDoubleParam *curve, int segmentIndex);
Shinya Kitaoka 120a6e
  void setSegmentByFrame(TDoubleParam *curve, int frame);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class FunctionSegmentPage : public QWidget {
Shinya Kitaoka 120a6e
  Q_OBJECT
Shinya Kitaoka 120a6e
  FunctionSegmentViewer *m_viewer;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  FunctionSegmentPage(FunctionSegmentViewer *parent);
Shinya Kitaoka 120a6e
  ~FunctionSegmentPage();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  FunctionSegmentViewer *getViewer() const { return m_viewer; }
Shinya Kitaoka 120a6e
  TDoubleParam *getCurve() const { return m_viewer->getCurve(); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int getR0() const { return m_viewer->getR0(); }
Shinya Kitaoka 120a6e
  int getR1() const { return m_viewer->getR1(); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual void refresh() = 0;
Shinya Kitaoka 120a6e
  virtual void apply()   = 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  virtual void init(int segmentLength) = 0;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public slots:
Shinya Kitaoka 120a6e
  void onFieldChanged() { apply(); }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class SpeedInOutSegmentPage final : public FunctionSegmentPage {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  DVGui::LineEdit *m_speed0xFld;
Shinya Kitaoka 120a6e
  DVGui::MeasuredDoubleLineEdit *m_speed0yFld;
Shinya Kitaoka 120a6e
  DVGui::LineEdit *m_speed1xFld;
Shinya Kitaoka 120a6e
  DVGui::MeasuredDoubleLineEdit *m_speed1yFld;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  DVGui::MeasuredDoubleLineEdit *m_firstSpeedFld;
Shinya Kitaoka 120a6e
  DVGui::MeasuredDoubleLineEdit *m_lastSpeedFld;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  SpeedInOutSegmentPage(FunctionSegmentViewer *parent = 0);
Shinya Kitaoka 473e70
  void refresh() override;
Shinya Kitaoka 38fd86
  void apply() override{};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void getGuiValues(TPointD &speedIn, TPointD &speedOut);
Shinya Kitaoka 473e70
  void init(int segmentLength) override;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public slots:
Shinya Kitaoka 120a6e
  void onFirstHandleXChanged();
Shinya Kitaoka 120a6e
  void onFirstHandleYChanged();
Shinya Kitaoka 120a6e
  void onLastHandleXChanged();
Shinya Kitaoka 120a6e
  void onLastHandleYChanged();
Shinya Kitaoka 120a6e
  void onFirstSpeedChanged();
Shinya Kitaoka 120a6e
  void onLastSpeedChanged();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class EaseInOutSegmentPage final : public FunctionSegmentPage {
Shinya Kitaoka 120a6e
  Q_OBJECT
Shinya Kitaoka 120a6e
  DVGui::MeasuredDoubleLineEdit *m_ease0Fld, *m_ease1Fld;
Shinya Kitaoka 120a6e
  double m_fieldScale;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool m_isPercentage;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  EaseInOutSegmentPage(bool percentage, FunctionSegmentViewer *parent = 0);
Shinya Kitaoka 473e70
  void refresh() override;
Shinya Kitaoka 473e70
  void apply() override {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void getGuiValues(TPointD &easeIn, TPointD &easeOut);
Shinya Kitaoka 473e70
  void init(int segmentLength) override;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public slots:
Shinya Kitaoka 120a6e
  void onEase0Changed();
Shinya Kitaoka 120a6e
  void onEase1Changed();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class FunctionExpressionSegmentPage final : public FunctionSegmentPage {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  DVGui::ExpressionField *m_expressionFld;
Shinya Kitaoka 120a6e
  DVGui::LineEdit *m_unitFld;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  FunctionExpressionSegmentPage(FunctionSegmentViewer *parent = 0);
Shinya Kitaoka 473e70
  void refresh() override;
Shinya Kitaoka 473e70
  void apply() override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // return false if a circular reference is occured
Shinya Kitaoka 120a6e
  bool getGuiValues(std::string &expressionText, std::string &unitName);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void init(int segmentLength) override;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class SimilarShapeSegmentPage final : public FunctionSegmentPage {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  DVGui::ExpressionField *m_expressionFld;
Shinya Kitaoka 120a6e
  DVGui::LineEdit *m_offsetFld;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  SimilarShapeSegmentPage(FunctionSegmentViewer *parent = 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void refresh() override;
Shinya Kitaoka 473e70
  void apply() override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void init(int segmentLength) override;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void getGuiValues(std::string &expressionText, double &similarShapeOffset);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif