|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef INTFIELD_H
|
|
Toshihiro Shimizu |
890ddd |
#define INTFIELD_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tcommon.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/lineedit.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qtoolbar></qtoolbar>
|
|
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 QIntValidator;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
namespace DVGui
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*! \brief The RollerField class provides an object to change an integer value.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Inherits \b QWidget.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI RollerField : public QWidget
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double m_value;
|
|
Toshihiro Shimizu |
890ddd |
double m_minValue;
|
|
Toshihiro Shimizu |
890ddd |
double m_maxValue;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
double m_step;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
int m_xPos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
RollerField(QWidget *parent = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
~RollerField() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setValue(double value);
|
|
Toshihiro Shimizu |
890ddd |
double getValue() const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setRange(double minValue, double maxValue);
|
|
Toshihiro Shimizu |
890ddd |
void getRange(double &minValue, double &maxValue);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setStep(double _step)
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
m_step = _step;
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
void paintEvent(QPaintEvent *e);
|
|
Toshihiro Shimizu |
890ddd |
void mousePressEvent(QMouseEvent *);
|
|
Toshihiro Shimizu |
890ddd |
void mouseMoveEvent(QMouseEvent *);
|
|
Toshihiro Shimizu |
890ddd |
void mouseReleaseEvent(QMouseEvent *);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void addValue(bool isDragging);
|
|
Toshihiro Shimizu |
890ddd |
void removeValue(bool isDragging);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
signals:
|
|
Toshihiro Shimizu |
890ddd |
void valueChanged(bool isDragging);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*! \brief The IntLineEdit class provides an object to manage an integer line edit.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Inherits \b LineEdit, set an integer validator \b QIntValidator.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
You can pass to constructor current value, minimum and max value field
|
|
Toshihiro Shimizu |
890ddd |
or set this value using setValue(), setRange() .
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI IntLineEdit : public LineEdit
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
QIntValidator *m_validator;
|
|
Toshihiro Shimizu |
890ddd |
//! The number of digits showed int the line edit.
|
|
Toshihiro Shimizu |
890ddd |
//! If digits is less than 1 the line edit show the natural number without prepend zeros.
|
|
Toshihiro Shimizu |
890ddd |
int m_showedDigits;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
IntLineEdit(QWidget *parent = 0, int value = 1,
|
|
Toshihiro Shimizu |
890ddd |
int minValue = (-(std::numeric_limits<int>::max)()),</int>
|
|
Toshihiro Shimizu |
890ddd |
int maxValue = ((std::numeric_limits<int>::max)()),</int>
|
|
Toshihiro Shimizu |
890ddd |
int showedDigits = 0);
|
|
Toshihiro Shimizu |
890ddd |
~IntLineEdit() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! Set text in field to \b value. */
|
|
Toshihiro Shimizu |
890ddd |
void setValue(int value);
|
|
Toshihiro Shimizu |
890ddd |
/*! Return an integer with text field value. */
|
|
Toshihiro Shimizu |
890ddd |
int getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! Set the range of field from \b minValue to \b maxValue;
|
|
Toshihiro Shimizu |
890ddd |
set validator value. */
|
|
Toshihiro Shimizu |
890ddd |
void setRange(int minValue, int maxValue);
|
|
Toshihiro Shimizu |
890ddd |
/*! Set to \b minValue minimum range value.
|
|
Toshihiro Shimizu |
890ddd |
\sa setRange() */
|
|
Toshihiro Shimizu |
890ddd |
void setBottomRange(int minValue);
|
|
Toshihiro Shimizu |
890ddd |
/*! Set to \b maxValue maximum range value.
|
|
Toshihiro Shimizu |
890ddd |
\sa getRange() */
|
|
Toshihiro Shimizu |
890ddd |
void setTopRange(int maxValue);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! Set \b minValue an \b maxValue to current range; to current
|
|
Toshihiro Shimizu |
890ddd |
validator minimum and maximum value. */
|
|
Toshihiro Shimizu |
890ddd |
void getRange(int &minValue, int &maxValue);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setLineEditBackgroundColor(QColor color);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Toshihiro Shimizu |
890ddd |
/*! If focus is lost and current text value is out of range emit signal
|
|
Toshihiro Shimizu |
890ddd |
\b editingFinished.*/
|
|
Toshihiro Shimizu |
890ddd |
void focusOutEvent(QFocusEvent *);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*! \brief The IntField class provides to view an object to manage an integer
|
|
Toshihiro Shimizu |
890ddd |
parameter.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
Inherits \b QWidget.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
The class is composed of an horizontal layout which contains two object,
|
|
Toshihiro Shimizu |
890ddd |
\li a vertical layout with a text field \b IntLineEdit and a roller
|
|
Toshihiro Shimizu |
890ddd |
\li an horizontal slider QSlider.
|
|
Toshihiro Shimizu |
890ddd |
This objects are connected, so if you change one the other automatically change.
|
|
Toshihiro Shimizu |
890ddd |
You can set current value getValue(), minimum and max value using setValue(),
|
|
Toshihiro Shimizu |
890ddd |
setRange() or setValues(); by default is value = 0, minimum value = 0
|
|
Toshihiro Shimizu |
890ddd |
and maximum value = 100.
|
|
Toshihiro Shimizu |
890ddd |
\n Maximum height object is fixed to \b DVGui::WidgetHeight, width depend
|
|
Toshihiro Shimizu |
890ddd |
on parent width.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
To know when integer parameter value change class provides a signal, valueChanged();
|
|
Toshihiro Shimizu |
890ddd |
class emit signal when slider value change or when editing text field is
|
|
Toshihiro Shimizu |
890ddd |
finished and current value is changed. Editing text field finished may occur
|
|
Toshihiro Shimizu |
890ddd |
if focus is lost or enter key is pressed. See SLOT: onSliderChanged(int value),
|
|
Toshihiro Shimizu |
890ddd |
onEditingFinished().
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
class DVAPI IntField : public QWidget
|
|
Toshihiro Shimizu |
890ddd |
{
|
|
Toshihiro Shimizu |
890ddd |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
RollerField *m_roller;
|
|
Toshihiro Shimizu |
890ddd |
IntLineEdit *m_lineEdit;
|
|
Toshihiro Shimizu |
890ddd |
QSlider *m_slider;
|
|
Toshihiro Shimizu |
890ddd |
bool m_isMaxRangeLimited;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Toshihiro Shimizu |
890ddd |
IntField(QWidget *parent = 0, bool isMaxRangeLimited = true, bool isRollerHide = true);
|
|
Toshihiro Shimizu |
890ddd |
~IntField() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! Set to \b minValue and \b maxValue slider and text field range.
|
|
Toshihiro Shimizu |
890ddd |
\sa getRange() */
|
|
Toshihiro Shimizu |
890ddd |
void setRange(int minValue, int maxValue);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! Set \b minValue and \b maxValue to IntField range.
|
|
Toshihiro Shimizu |
890ddd |
\sa setRange() */
|
|
Toshihiro Shimizu |
890ddd |
void getRange(int &minValue, int &maxValue);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! Set to \b value current value IntField.
|
|
Toshihiro Shimizu |
890ddd |
\sa getValue() */
|
|
Toshihiro Shimizu |
890ddd |
void setValue(int value);
|
|
Toshihiro Shimizu |
890ddd |
/*! Return current value.
|
|
Toshihiro Shimizu |
890ddd |
\sa setValue() */
|
|
Toshihiro Shimizu |
890ddd |
int getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! This is provided for convenience.
|
|
Toshihiro Shimizu |
890ddd |
Set to \b value current value IntField; set to \b minValue and \b maxValue
|
|
Toshihiro Shimizu |
890ddd |
slider and text field range.
|
|
Toshihiro Shimizu |
890ddd |
\sa getValue() */
|
|
Toshihiro Shimizu |
890ddd |
void setValues(int value, int minValue, int maxValue);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! If \b enable is false set slider disable and hide it. */
|
|
Toshihiro Shimizu |
890ddd |
void enableSlider(bool enable);
|
|
Toshihiro Shimizu |
890ddd |
bool sliderIsEnabled();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! If \b enable is false set roller disable and hide it. */
|
|
Toshihiro Shimizu |
890ddd |
void enableRoller(bool enable);
|
|
Toshihiro Shimizu |
890ddd |
bool rollerIsEnabled();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
void setLineEditBackgroundColor(QColor color);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected slots:
|
|
Toshihiro Shimizu |
890ddd |
/*! Set to value the text field. If text field value is different from \b value
|
|
Toshihiro Shimizu |
890ddd |
emit signal valueChanged(). */
|
|
Toshihiro Shimizu |
890ddd |
void onSliderChanged(int value);
|
|
Toshihiro Shimizu |
890ddd |
void onSliderReleased() { emit valueChanged(false); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! Set slider and roller value to current value in text field.
|
|
Toshihiro Shimizu |
890ddd |
\n This protected slot is called when text editing is finished.
|
|
Toshihiro Shimizu |
890ddd |
\n If slider value is different from text field value emit signal valueChanged(). */
|
|
Toshihiro Shimizu |
890ddd |
void onEditingFinished();
|
|
Toshihiro Shimizu |
890ddd |
/*! Set text field and slider to roller current value.
|
|
Toshihiro Shimizu |
890ddd |
\n If slider and text field value are different from roller value
|
|
Toshihiro Shimizu |
890ddd |
emit signal valueChanged(). */
|
|
Toshihiro Shimizu |
890ddd |
void onRollerValueChanged(bool isDragging);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
signals:
|
|
Toshihiro Shimizu |
890ddd |
/*! This is a signal emitted when IntField, slider or text field, value change;
|
|
Toshihiro Shimizu |
890ddd |
if slider position change or text field editing is finished.
|
|
Toshihiro Shimizu |
890ddd |
\sa onEditingFinished() and onSliderChanged(int value). */
|
|
Toshihiro Shimizu |
890ddd |
void valueChanged(bool isDragging);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
/*! This signal is emitted only when the user edit the value by hand */
|
|
Toshihiro Shimizu |
890ddd |
void valueEditedByHand();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
} //namespace DVGui
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif // INTFIELD_H
|