Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TONECURVEFIELD_H
Toshihiro Shimizu 890ddd
#define TONECURVEFIELD_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
#include "tstroke.h"
Toshihiro Shimizu 890ddd
#include "toonzqt/histogram.h"
Toshihiro Shimizu 890ddd
#include <qwidget></qwidget>
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
// forward declaration
Toshihiro Shimizu 890ddd
class TStroke;
Toshihiro Shimizu 890ddd
class QPainterPath;
Toshihiro Shimizu 890ddd
class QStackedWidget;
Toshihiro Shimizu 890ddd
class FxHistogramRender;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Shinya Kitaoka 120a6e
namespace DVGui {
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// forward declaration
Toshihiro Shimizu 890ddd
class IntPairField;
Toshihiro Shimizu 890ddd
class CheckBox;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// ChennelCurveEditor
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI ChennelCurveEditor : public QWidget {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  HistogramView *m_histogramView;
Shinya Kitaoka 120a6e
  ChannelBar *m_verticalChannelBar;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QList<qpointf> m_points;</qpointf>
Shinya Kitaoka 120a6e
  int m_currentControlPointIndex;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  Qt::MouseButton m_mouseButton;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int m_curveHeight;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int m_LeftRightMargin;
Shinya Kitaoka 120a6e
  int m_TopMargin;
Shinya Kitaoka 120a6e
  int m_BottomMargin;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool m_isLinear;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ChennelCurveEditor(QWidget *parent = 0, HistogramView *histogramView = 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setPoints(QList<tpointd> points);</tpointd>
Shinya Kitaoka 120a6e
  QList<tpointd> getPoints();</tpointd>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int getCurrentControlPointIndex() { return m_currentControlPointIndex; };
Shinya Kitaoka 120a6e
  void setCurrentControlPointIndex(int index) {
Shinya Kitaoka 120a6e
    m_currentControlPointIndex = index;
Shinya Kitaoka 120a6e
  };
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool eventFilter(QObject *object, QEvent *event);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setFirstLastXPosition(std::pair<int, int=""> values, bool isDragging);</int,>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setLinear(bool isLinear);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected:
Shinya Kitaoka 120a6e
  QPointF strokeToViewPoint(const TPointD p);
Shinya Kitaoka 120a6e
  TPointD viewToStrokePoint(const QPointF &p);
Shinya Kitaoka 120a6e
  int getClosestPointIndex(const QPointF &pos, double &minDistance2) const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  bool isCentralControlPoint(int index) { return index % 3 == 0; }
Shinya Kitaoka 120a6e
  bool isLeftControlPoint(int index) { return index % 3 == 2; }
Shinya Kitaoka 120a6e
  bool isRightControlPoint(int index) { return index % 3 == 1; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void movePoint(int index, const QPointF delta);
Shinya Kitaoka 120a6e
  void setPoint(int index, const QPointF point);
Shinya Kitaoka 120a6e
  QPointF checkPoint(const QPointF p);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void moveCurrentControlPoint(const QPointF delta);
Shinya Kitaoka 120a6e
  void moveCentralControlPoint(int index, const QPointF delta);
Shinya Kitaoka 120a6e
  //	bool eraseControlPointWhileMove(int index, const QPointF delta);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void addControlPoint(double percent);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void removeControlPoint(int index);
Shinya Kitaoka 120a6e
  void removeCurrentControlPoint();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QPainterPath getPainterPath();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void paintEvent(QPaintEvent *);
Shinya Kitaoka 120a6e
  void mouseMoveEvent(QMouseEvent *);
Shinya Kitaoka 120a6e
  void mousePressEvent(QMouseEvent *);
Shinya Kitaoka 120a6e
  void mouseReleaseEvent(QMouseEvent *);
Shinya Kitaoka 120a6e
  void keyPressEvent(QKeyEvent *e);
Shinya Kitaoka 120a6e
  void enterEvent(QEvent *);
Shinya Kitaoka 120a6e
  void leaveEvent(QEvent *);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void focusInEvent(QFocusEvent *fe);
Shinya Kitaoka 120a6e
  void focusOutEvent(QFocusEvent *fe);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
signals:
Shinya Kitaoka 120a6e
  void focusOut();
Shinya Kitaoka 120a6e
  void controlPointChanged(bool isDragging);
Shinya Kitaoka 120a6e
  void controlPointAdded(int index);
Shinya Kitaoka 120a6e
  void controlPointRemoved(int index);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void firstLastXPostionChanged(int, int);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// ToneCurveField
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI ToneCurveField : public QWidget {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QStackedWidget *m_toneCurveStackedWidget;
Shinya Kitaoka 120a6e
  QStackedWidget *m_sliderStackedWidget;
Shinya Kitaoka 120a6e
  QComboBox *m_channelListChooser;
Shinya Kitaoka 120a6e
  CheckBox *m_isLinearCheckBox;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ToneCurveField(QWidget *parent = 0, FxHistogramRender *fxHistogramRender = 0);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setCurrentChannel(int currentChannel);
Shinya Kitaoka 120a6e
  ChennelCurveEditor *getChannelEditor(int channel) const;
Shinya Kitaoka 120a6e
  ChennelCurveEditor *getCurrentChannelEditor() const;
Shinya Kitaoka 120a6e
  IntPairField *getCurrentSlider() const;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  int getChannelCount() { return m_toneCurveStackedWidget->count(); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setIsLinearCheckBox(bool isChecked);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
protected slots:
Shinya Kitaoka 120a6e
  void sliderValueChanged(bool);
Shinya Kitaoka 120a6e
  void onFirstLastXPostionChanged(int, int);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public slots:
Shinya Kitaoka 120a6e
  void setLinear(bool);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setLinearManually(bool);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
signals:
Shinya Kitaoka 120a6e
  void currentChannelIndexChanged(int);
Shinya Kitaoka 120a6e
  void isLinearChanged(bool);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // TONECURVEFIELD_H