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