|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef INTPAIRFIELD_H
|
|
Toshihiro Shimizu |
890ddd |
#define INTPAIRFIELD_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/intfield.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 |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*! \brief The IntPairField class provides to view an object to manage a pair
|
|
Shinya Kitaoka |
120a6e |
of int 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 int
|
|
Shinya Kitaoka |
120a6e |
value to manage. [label, text field] are a \b QLabel and a \b
|
|
Shinya Kitaoka |
120a6e |
IntLineEdit.
|
|
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;
|
|
Shinya Kitaoka |
120a6e |
labels width depend from its text lenght, 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 int 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().
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
\b Example:
|
|
Shinya Kitaoka |
120a6e |
\code
|
|
Shinya Kitaoka |
120a6e |
IntPairField* intPairFieldExample = new
|
|
Shinya Kitaoka |
120a6e |
IntPairField(this);
|
|
Shinya Kitaoka |
120a6e |
intPairFieldExample->setLeftText(tr("Left Value:"));
|
|
Shinya Kitaoka |
120a6e |
intPairFieldExample->setRightText(tr("Rigth Value:"));
|
|
Shinya Kitaoka |
120a6e |
intPairFieldExample->setRange(0,10);
|
|
Shinya Kitaoka |
120a6e |
intPairFieldExample->setValues(std::make_pair(3,8));
|
|
Shinya Kitaoka |
120a6e |
\endcode
|
|
Shinya Kitaoka |
120a6e |
\b Result:
|
|
Shinya Kitaoka |
120a6e |
\image html DoublePairField.jpg
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
class DVAPI IntPairField : public QWidget {
|
|
Shinya Kitaoka |
120a6e |
Q_OBJECT
|
|
Shinya Kitaoka |
120a6e |
|
|
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 |
IntLineEdit *m_leftLineEdit;
|
|
Shinya Kitaoka |
120a6e |
IntLineEdit *m_rightLineEdit;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QColor m_lightLineColor; /*-- スライダ溝の明るい色(白) --*/
|
|
Shinya Kitaoka |
120a6e |
QColor m_darkLineColor; /*-- スライダ溝の暗い色(128,128,128) --*/
|
|
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);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QLabel *m_leftLabel, *m_rightLabel;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
std::pair<int, int=""> m_values;</int,>
|
|
Shinya Kitaoka |
120a6e |
int 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 |
IntPairField(QWidget *parent = 0, bool isMaxRangeLimited = true);
|
|
Shinya Kitaoka |
120a6e |
~IntPairField() {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*! Set current values to \b values. */
|
|
Shinya Kitaoka |
120a6e |
void setValues(const std::pair<int, int=""> &values);</int,>
|
|
Shinya Kitaoka |
120a6e |
/*! Return a pair containing current values. */
|
|
Shinya Kitaoka |
120a6e |
std::pair<int, int=""> getValues() const { return m_values; }</int,>
|
|
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 IntPairField to \b minValue, \b maxValue. */
|
|
Shinya Kitaoka |
120a6e |
void setRange(int minValue, int maxValue);
|
|
Shinya Kitaoka |
120a6e |
/*! Set \b minValue and \b maxValue to IntPairField range. */
|
|
Shinya Kitaoka |
120a6e |
void getRange(int &minValue, int &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; }
|
|
Shinya Kitaoka |
120a6e |
|
|
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(int 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 IntField 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 |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
} // namespace DVGui
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // INTPAIRFIELD_H
|