|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef DOUBLEPAIRFIELD_H
|
|
Toshihiro Shimizu |
890ddd |
#define DOUBLEPAIRFIELD_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/doublefield.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tcommon.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 |
// forward declaration
|
|
Toshihiro Shimizu |
890ddd |
class QSlider;
|
|
Toshihiro Shimizu |
890ddd |
class QLabel;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace DVGui {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Shinya Kitaoka |
120a6e |
/*! \brief The DoubleValuePairField class provides to view an object to manage a
|
|
Shinya Kitaoka |
120a6e |
pair
|
|
Shinya Kitaoka |
120a6e |
of double parameter.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
Inherits \b QWidget.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
The object is composed of an horizontal layout \b QHBoxLayout
|
|
Shinya Kitaoka |
120a6e |
which contains
|
|
Shinya Kitaoka |
120a6e |
two pair [label, text field] and a slider with two grab, one for
|
|
Shinya Kitaoka |
120a6e |
each double
|
|
Shinya Kitaoka |
120a6e |
value to manage. [label, text field] are a \b QLabel and a \b
|
|
Shinya Kitaoka |
120a6e |
DoubleLineEdit.
|
|
Shinya Kitaoka |
120a6e |
Objects are inserted in the following order: a label and
|
|
Shinya Kitaoka |
120a6e |
respective text field,
|
|
Shinya Kitaoka |
120a6e |
the slider and the other pair [lebel,text field].
|
|
Shinya Kitaoka |
120a6e |
Object size width is not fixed, while height is equal to
|
|
Shinya Kitaoka |
120a6e |
DVGui::WidgetHeight, 20;
|
|
MCCCS |
a0ce32 |
labels width depend from its text length, text fields has fixed
|
|
Shinya Kitaoka |
120a6e |
size, while
|
|
Shinya Kitaoka |
120a6e |
slider width change in according with widget size.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
Objects contained in this widget are connected, so if you change
|
|
Shinya Kitaoka |
120a6e |
one value the
|
|
Shinya Kitaoka |
120a6e |
other automatically change, if it is necessary. You can set
|
|
Shinya Kitaoka |
120a6e |
current value,
|
|
Shinya Kitaoka |
120a6e |
getValues(), minimum and max value, getRange(), using
|
|
Shinya Kitaoka |
120a6e |
setValues(), setRange().
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
To know when one of two double parameter value change class
|
|
Shinya Kitaoka |
120a6e |
provides a signal,
|
|
Shinya Kitaoka |
120a6e |
valuesChanged(); class emit signal when a grab slider position
|
|
Shinya Kitaoka |
120a6e |
change or when
|
|
Shinya Kitaoka |
120a6e |
editing text field, left or right is finished and current value
|
|
Shinya Kitaoka |
120a6e |
is changed.
|
|
Shinya Kitaoka |
120a6e |
Editing text field finished may occur if focus is lost or enter
|
|
Shinya Kitaoka |
120a6e |
key is pressed.
|
|
Shinya Kitaoka |
120a6e |
See SLOT: onLeftEditingFinished() and onRightEditingFinished().
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
class DVAPI DoubleValuePairField : public QWidget {
|
|
Shinya Kitaoka |
120a6e |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
QPixmap m_handleLeftPixmap, m_handleRightPixmap, m_handleLeftGrayPixmap,
|
|
Shinya Kitaoka |
120a6e |
m_handleRightGrayPixmap;
|
|
Shinya Kitaoka |
120a6e |
Q_PROPERTY(QPixmap HandleLeftPixmap READ getHandleLeftPixmap WRITE
|
|
Shinya Kitaoka |
120a6e |
setHandleLeftPixmap);
|
|
Shinya Kitaoka |
120a6e |
Q_PROPERTY(QPixmap HandleRightPixmap READ getHandleRightPixmap WRITE
|
|
Shinya Kitaoka |
120a6e |
setHandleRightPixmap);
|
|
Shinya Kitaoka |
120a6e |
Q_PROPERTY(QPixmap HandleLeftGrayPixmap READ getHandleLeftGrayPixmap WRITE
|
|
Shinya Kitaoka |
120a6e |
setHandleLeftGrayPixmap);
|
|
Shinya Kitaoka |
120a6e |
Q_PROPERTY(QPixmap HandleRightGrayPixmap READ getHandleRightGrayPixmap WRITE
|
|
Shinya Kitaoka |
120a6e |
setHandleRightGrayPixmap);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QColor m_lightLineColor; /*-- スライダ溝の明るい色(白) --*/
|
|
Shinya Kitaoka |
120a6e |
QColor m_darkLineColor; /*-- スライダ溝の暗い色(128,128,128) --*/
|
|
Jeremy Bullock |
2739e0 |
QColor m_middleLineColor;
|
|
Jeremy Bullock |
2739e0 |
QColor m_lightLineEdgeColor;
|
|
Shinya Kitaoka |
120a6e |
Q_PROPERTY(
|
|
Shinya Kitaoka |
120a6e |
QColor LightLineColor READ getLightLineColor WRITE setLightLineColor);
|
|
Shinya Kitaoka |
120a6e |
Q_PROPERTY(QColor DarkLineColor READ getDarkLineColor WRITE setDarkLineColor);
|
|
Jeremy Bullock |
2739e0 |
Q_PROPERTY(
|
|
Jeremy Bullock |
2739e0 |
QColor MiddleLineColor READ getMiddleLineColor WRITE setMiddleLineColor);
|
|
Jeremy Bullock |
2739e0 |
Q_PROPERTY(QColor LightLineEdgeColor READ getLightLineEdgeColor WRITE
|
|
Jeremy Bullock |
2739e0 |
setLightLineEdgeColor);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
DoubleValueLineEdit *m_leftLineEdit;
|
|
Shinya Kitaoka |
120a6e |
DoubleValueLineEdit *m_rightLineEdit;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QLabel *m_leftLabel, *m_rightLabel;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::pair<double, double=""> m_values;</double,>
|
|
Shinya Kitaoka |
120a6e |
double m_minValue, m_maxValue;
|
|
Shinya Kitaoka |
120a6e |
int m_grabOffset, m_grabIndex;
|
|
Shinya Kitaoka |
120a6e |
int m_leftMargin, m_rightMargin;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
bool m_isMaxRangeLimited;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
DoubleValuePairField(QWidget *parent, bool isMaxRangeLimited,
|
|
Shinya Kitaoka |
120a6e |
DoubleValueLineEdit *leftLineEdit,
|
|
Shinya Kitaoka |
120a6e |
DoubleValueLineEdit *rightLineEdit);
|
|
Shinya Kitaoka |
120a6e |
~DoubleValuePairField() {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*! Set current values to \b values. */
|
|
Shinya Kitaoka |
120a6e |
void setValues(const std::pair<double, double=""> &values);</double,>
|
|
Shinya Kitaoka |
120a6e |
/*! Return a pair containing current values. */
|
|
Shinya Kitaoka |
120a6e |
std::pair<double, double=""> getValues() const { return m_values; }</double,>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*! Set left label string to \b QString \b text. Recompute left margin adding
|
|
Shinya Kitaoka |
120a6e |
label width. */
|
|
Shinya Kitaoka |
120a6e |
void setLeftText(const QString &text);
|
|
Shinya Kitaoka |
120a6e |
/*! Set right label string to \b QString \b text. Recompute right margin
|
|
Shinya Kitaoka |
120a6e |
adding
|
|
Shinya Kitaoka |
120a6e |
label width. */
|
|
Shinya Kitaoka |
120a6e |
void setRightText(const QString &text);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void setLabelsEnabled(bool enable);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*! Set range of \b DoublePairField to \b minValue, \b maxValue. */
|
|
Shinya Kitaoka |
120a6e |
void setRange(double minValue, double maxValue);
|
|
Shinya Kitaoka |
120a6e |
/*! Set \b minValue and \b maxValue to DoublePairField range. */
|
|
Shinya Kitaoka |
120a6e |
void getRange(double &minValue, double &maxValue);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QPixmap getHandleLeftPixmap() const { return m_handleLeftPixmap; }
|
|
Shinya Kitaoka |
120a6e |
void setHandleLeftPixmap(const QPixmap &pixmap) {
|
|
Shinya Kitaoka |
120a6e |
m_handleLeftPixmap = pixmap;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
QPixmap getHandleRightPixmap() const { return m_handleRightPixmap; }
|
|
Shinya Kitaoka |
120a6e |
void setHandleRightPixmap(const QPixmap &pixmap) {
|
|
Shinya Kitaoka |
120a6e |
m_handleRightPixmap = pixmap;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
QPixmap getHandleLeftGrayPixmap() const { return m_handleLeftGrayPixmap; }
|
|
Shinya Kitaoka |
120a6e |
void setHandleLeftGrayPixmap(const QPixmap &pixmap) {
|
|
Shinya Kitaoka |
120a6e |
m_handleLeftGrayPixmap = pixmap;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
QPixmap getHandleRightGrayPixmap() const { return m_handleRightGrayPixmap; }
|
|
Shinya Kitaoka |
120a6e |
void setHandleRightGrayPixmap(const QPixmap &pixmap) {
|
|
Shinya Kitaoka |
120a6e |
m_handleRightGrayPixmap = pixmap;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void setLightLineColor(const QColor &color) { m_lightLineColor = color; }
|
|
Shinya Kitaoka |
120a6e |
QColor getLightLineColor() const { return m_lightLineColor; }
|
|
Shinya Kitaoka |
120a6e |
void setDarkLineColor(const QColor &color) { m_darkLineColor = color; }
|
|
Shinya Kitaoka |
120a6e |
QColor getDarkLineColor() const { return m_darkLineColor; }
|
|
Jeremy Bullock |
2739e0 |
void setMiddleLineColor(const QColor &color) { m_middleLineColor = color; }
|
|
Jeremy Bullock |
2739e0 |
QColor getMiddleLineColor() const { return m_middleLineColor; }
|
|
Jeremy Bullock |
2739e0 |
void setLightLineEdgeColor(const QColor &color) {
|
|
Jeremy Bullock |
2739e0 |
m_lightLineEdgeColor = color;
|
|
Jeremy Bullock |
2739e0 |
}
|
|
Jeremy Bullock |
2739e0 |
QColor getLightLineEdgeColor() const { return m_lightLineEdgeColor; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
/*! Return value corresponding \b x position. */
|
|
Shinya Kitaoka |
120a6e |
double pos2value(int x) const;
|
|
Shinya Kitaoka |
120a6e |
/*! Return x position corresponding \b value. */
|
|
Shinya Kitaoka |
120a6e |
int value2pos(double v) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*! Set current value to \b value.
|
|
Shinya Kitaoka |
120a6e |
Set left or right value, or both, to value depending on
|
|
Shinya Kitaoka |
120a6e |
current slider
|
|
Shinya Kitaoka |
120a6e |
grab edited and \b value. */
|
|
Shinya Kitaoka |
120a6e |
void setValue(double v);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void paintEvent(QPaintEvent *) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void mousePressEvent(QMouseEvent *event) override;
|
|
Shinya Kitaoka |
473e70 |
void mouseMoveEvent(QMouseEvent *event) override;
|
|
Shinya Kitaoka |
473e70 |
void mouseReleaseEvent(QMouseEvent *event) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected slots:
|
|
Shinya Kitaoka |
120a6e |
/*! Set current left value to value in left text field; if necessary, if left
|
|
Shinya Kitaoka |
120a6e |
value is greater than right, change also current right value.
|
|
Shinya Kitaoka |
120a6e |
\n This protected slot is called when text editing is finished.
|
|
Shinya Kitaoka |
120a6e |
\n Emit valuesChanged().
|
|
Shinya Kitaoka |
120a6e |
\n If current left value is equal to left text field value, return and do
|
|
Shinya Kitaoka |
120a6e |
nothing. */
|
|
Shinya Kitaoka |
120a6e |
void onLeftEditingFinished();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*! Set current right value to value in right text field; if necessary, if
|
|
Shinya Kitaoka |
120a6e |
right
|
|
Shinya Kitaoka |
120a6e |
value is lower than left, change also current left value.
|
|
Shinya Kitaoka |
120a6e |
\n This protected slot is called when text editing is finished.
|
|
Shinya Kitaoka |
120a6e |
\n Emit valuesChanged().
|
|
Shinya Kitaoka |
120a6e |
\n If current right value is equal to right text field value return and
|
|
Shinya Kitaoka |
120a6e |
do nothing. */
|
|
Shinya Kitaoka |
120a6e |
void onRightEditingFinished();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
signals:
|
|
Shinya Kitaoka |
120a6e |
/*! This signal is emitted when change one of two DoubleField value;
|
|
Shinya Kitaoka |
120a6e |
if one slider grab position change or if one text field
|
|
Shinya Kitaoka |
120a6e |
editing is finished. */
|
|
Shinya Kitaoka |
120a6e |
void valuesChanged(bool isDragging);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*! \brief The DoublePairField class provides a DoubleValuePairField with
|
|
Shinya Kitaoka |
120a6e |
left DoubleLineEdit and right DoubleLineEdit.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
Inherits \b DoubleValuePairField.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
\b Example:
|
|
Shinya Kitaoka |
120a6e |
\code
|
|
Shinya Kitaoka |
120a6e |
DoublePairField* doublePairFieldExample = new
|
|
Shinya Kitaoka |
120a6e |
DoublePairField(this);
|
|
Shinya Kitaoka |
120a6e |
doublePairFieldExample->setLeftText(tr("Left Value:"));
|
|
Shinya Kitaoka |
120a6e |
doublePairFieldExample->setRightText(tr("Rigth
|
|
Shinya Kitaoka |
120a6e |
Value:"));
|
|
Shinya Kitaoka |
120a6e |
doublePairFieldExample->setRange(0,10);
|
|
Shinya Kitaoka |
120a6e |
doublePairFieldExample->setValues(std::make_pair(3.58,7.65));
|
|
Shinya Kitaoka |
120a6e |
\endcode
|
|
Shinya Kitaoka |
120a6e |
\b Result:
|
|
Shinya Kitaoka |
120a6e |
\image html DoublePairField.jpg
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI DoublePairField : public DoubleValuePairField {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
DoublePairField(QWidget *parent = 0, bool isMaxRangeLimited = true);
|
|
Shinya Kitaoka |
120a6e |
~DoublePairField() {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Shinya Kitaoka |
120a6e |
/*! \brief The MeasuredDoublePairField class provides a DoubleValuePairField
|
|
Shinya Kitaoka |
120a6e |
with
|
|
Shinya Kitaoka |
120a6e |
left MeasuredDoubleLineEdit and right DoubleLineEdit.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
Inherits \b DoubleValuePairField.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
\b Example:
|
|
Shinya Kitaoka |
120a6e |
\code
|
|
Shinya Kitaoka |
120a6e |
MeasuredDoublePairField* doublePairFieldExample = new
|
|
Shinya Kitaoka |
120a6e |
MeasuredDoublePairField(this);
|
|
Shinya Kitaoka |
120a6e |
doublePairFieldExample->setLeftText(tr("Left Value:"));
|
|
Shinya Kitaoka |
120a6e |
doublePairFieldExample->setRightText(tr("Rigth
|
|
Shinya Kitaoka |
120a6e |
Value:"));
|
|
Shinya Kitaoka |
120a6e |
doublePairFieldExample->setRange(0,10);
|
|
Shinya Kitaoka |
120a6e |
doublePairFieldExample->setValues(std::make_pair(3.58,7.65));
|
|
Shinya Kitaoka |
120a6e |
\endcode
|
|
Shinya Kitaoka |
120a6e |
\b Result:
|
|
Shinya Kitaoka |
120a6e |
\image html DoublePairField.jpg
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class DVAPI MeasuredDoublePairField final : public DoubleValuePairField {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
MeasuredDoublePairField(QWidget *parent = 0, bool isMaxRangeLimited = true);
|
|
Shinya Kitaoka |
120a6e |
~MeasuredDoublePairField() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setMeasure(std::string measureName);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setPrecision(int precision);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
} // namespace DVGui
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // DOUBLEPAIRFIELD_H
|