|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef DOUBLEFIELD_H
|
|
Toshihiro Shimizu |
890ddd |
#define DOUBLEFIELD_H
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tcommon.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/intfield.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 QDoubleValidator;
|
|
Toshihiro Shimizu |
890ddd |
class QSlider;
|
|
Toshihiro Shimizu |
890ddd |
class TMeasuredValue;
|
|
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 DoubleValueLineEdit is abstract class.
|
|
Shinya Kitaoka |
120a6e |
Inherits \b LineEdit.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
class DVAPI DoubleValueLineEdit : public LineEdit {
|
|
Shinya Kitaoka |
120a6e |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
771290 |
int m_xMouse;
|
|
Jeremy Bullock |
771290 |
bool m_mouseDragEditing = false;
|
|
Jeremy Bullock |
771290 |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
DoubleValueLineEdit(QWidget *parent = 0) : LineEdit(parent) {}
|
|
Shinya Kitaoka |
120a6e |
~DoubleValueLineEdit() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void setValue(double value) = 0;
|
|
Shinya Kitaoka |
120a6e |
virtual double getValue() = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void setRange(double minValue, double maxValue) = 0;
|
|
Shinya Kitaoka |
120a6e |
virtual void getRange(double &minValue, double &maxValue) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual int getDecimals() { return 2; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
/*! If focus is lost and current value is out of range emit signal \b
|
|
Shinya Kitaoka |
120a6e |
* lostFocus. */
|
|
Shinya Kitaoka |
473e70 |
void focusOutEvent(QFocusEvent *) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Jeremy Bullock |
771290 |
// these are only used for mouse dragging
|
|
Jeremy Bullock |
771290 |
// to set the value of the field.
|
|
Jeremy Bullock |
771290 |
void mousePressEvent(QMouseEvent *) override;
|
|
Jeremy Bullock |
771290 |
void mouseMoveEvent(QMouseEvent *) override;
|
|
Jeremy Bullock |
771290 |
void mouseReleaseEvent(QMouseEvent *) override;
|
|
Jeremy Bullock |
771290 |
|
|
Toshihiro Shimizu |
890ddd |
signals:
|
|
Shinya Kitaoka |
120a6e |
/*! To emit when value change. */
|
|
Shinya Kitaoka |
120a6e |
void valueChanged();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*! \brief The DoubleValueField class provides to view an object to manage a
|
|
Shinya Kitaoka |
120a6e |
generic double parameter, with two
|
|
Shinya Kitaoka |
120a6e |
cipher after decimal point.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
Inherits \b QWidget.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
The class is composed of an horizontal layout which contains two
|
|
Shinya Kitaoka |
120a6e |
object,
|
|
Shinya Kitaoka |
120a6e |
\li a vertical layout with a text field \b PrimaryDoubleLineEdit
|
|
Shinya Kitaoka |
120a6e |
and a roller
|
|
Shinya Kitaoka |
120a6e |
\li an horizontal slider QSlider.
|
|
Shinya Kitaoka |
120a6e |
This objects are connected, so if you change one the other
|
|
Shinya Kitaoka |
120a6e |
automatically change.
|
|
Shinya Kitaoka |
120a6e |
It's possible to set current value getValue(), minimum and max
|
|
Shinya Kitaoka |
120a6e |
value, getRange(),
|
|
Shinya Kitaoka |
120a6e |
using setValue(), setRange() or setValues(); by default value =
|
|
Shinya Kitaoka |
120a6e |
0, minimum
|
|
Shinya Kitaoka |
120a6e |
value = -100.0 and maximum value = 100.0.
|
|
Shinya Kitaoka |
120a6e |
\n Maximum height object is fixed to \b DVGui::WidgetHeight, while width
|
|
Shinya Kitaoka |
120a6e |
depend
|
|
Shinya Kitaoka |
120a6e |
on parent width.
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
To know when double parameter value change class provides a
|
|
Shinya Kitaoka |
120a6e |
signal, valueChanged();
|
|
Shinya Kitaoka |
120a6e |
class emit signal when slider value change or when editing text
|
|
Shinya Kitaoka |
120a6e |
field is
|
|
Shinya Kitaoka |
120a6e |
finished and current value is changed. Editing text field
|
|
Shinya Kitaoka |
120a6e |
finished may occur
|
|
Shinya Kitaoka |
120a6e |
if focus is lost or enter key is pressed. See SLOT:
|
|
Shinya Kitaoka |
120a6e |
onSliderChanged(int value),
|
|
Shinya Kitaoka |
120a6e |
onEditingFinished().
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
class DVAPI DoubleValueField : public QWidget {
|
|
Shinya Kitaoka |
120a6e |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
RollerField *m_roller;
|
|
Shinya Kitaoka |
120a6e |
DoubleValueLineEdit *m_lineEdit;
|
|
Shinya Kitaoka |
120a6e |
QSlider *m_slider;
|
|
Shinya Kitaoka |
120a6e |
QWidget *m_spaceWidget;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
DoubleValueField(QWidget *parent, DoubleValueLineEdit *lineEdit);
|
|
Shinya Kitaoka |
120a6e |
~DoubleValueField() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void getRange(double &minValue, double &maxValue);
|
|
Shinya Kitaoka |
120a6e |
void setRange(double minValue = 0, double maxValue = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setValue(double value);
|
|
Shinya Kitaoka |
120a6e |
double getValue();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*! This is provided for convenience.
|
|
Shinya Kitaoka |
120a6e |
Set to \b value current value DoubleField; set to \b minValue
|
|
Shinya Kitaoka |
120a6e |
and \b maxValue
|
|
Shinya Kitaoka |
120a6e |
slider and text field range.
|
|
Shinya Kitaoka |
120a6e |
\sa getValue() */
|
|
Shinya Kitaoka |
120a6e |
void setValues(double value, double minValue = 0, double maxValue = 0);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*! If \b enable is false set slider disable and hide it. */
|
|
Shinya Kitaoka |
120a6e |
void enableSlider(bool enable);
|
|
Shinya Kitaoka |
120a6e |
bool isSliderEnabled();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
/*! If \b enable is false set roller disable and hide it. */
|
|
Shinya Kitaoka |
120a6e |
void enableRoller(bool enable);
|
|
Shinya Kitaoka |
120a6e |
bool isRollerEnabled();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected slots:
|
|
Shinya Kitaoka |
120a6e |
/*! Set to value the text field and roller. If text field value is different
|
|
Shinya Kitaoka |
120a6e |
from \b value
|
|
Shinya Kitaoka |
120a6e |
emit signal valueChanged(int value). */
|
|
Shinya Kitaoka |
120a6e |
void onSliderChanged(int value);
|
|
Shinya Kitaoka |
120a6e |
void onSliderReleased() { emit valueChanged(false); }
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*! Set slider and roller value to current value in text field.
|
|
Shinya Kitaoka |
120a6e |
This protected slot is called when text editing is finished.
|
|
Shinya Kitaoka |
120a6e |
If slider value is different from text field value emit signal
|
|
Shinya Kitaoka |
120a6e |
valueChanged(). */
|
|
Shinya Kitaoka |
120a6e |
void onLineEditValueChanged();
|
|
Shinya Kitaoka |
120a6e |
/*! Set text field and slider to roller current value.
|
|
Shinya Kitaoka |
120a6e |
\n If slider and text field value are different from roller value
|
|
Shinya Kitaoka |
120a6e |
emit signal valueChanged(). */
|
|
Shinya Kitaoka |
120a6e |
void onRollerValueChanged(bool isDragging);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
signals:
|
|
Shinya Kitaoka |
120a6e |
/*! This signal is emitted when DoubleFiel, slider, roller or text field,
|
|
Shinya Kitaoka |
120a6e |
value change;
|
|
Shinya Kitaoka |
120a6e |
if slider position change or text field editing is finished.
|
|
Shinya Kitaoka |
120a6e |
\sa onEditingFinished() and onSliderChanged(int value). */
|
|
Shinya Kitaoka |
120a6e |
void valueChanged(bool);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*! This signal is emitted only when users edited the value by hand
|
|
Shinya Kitaoka |
120a6e |
*/
|
|
Shinya Kitaoka |
120a6e |
void valueEditedByHand();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Shinya Kitaoka |
120a6e |
/*! \brief The DoubleLineEdit class provides to view an object to manage a
|
|
Shinya Kitaoka |
120a6e |
double field.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
Inherits \b LineEdit, set a double validator \b
|
|
Shinya Kitaoka |
120a6e |
QDoubleValidator.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
You can pass to constructor current value, getValue(), minimum
|
|
Shinya Kitaoka |
120a6e |
and max value
|
|
Shinya Kitaoka |
120a6e |
field, getRange(), and number of decimals, getDecimals() or you
|
|
Shinya Kitaoka |
120a6e |
can set this
|
|
Shinya Kitaoka |
120a6e |
value using setValue(), setRange() and setDecimals().
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
d1f6c4 |
class DVAPI DoubleLineEdit final : public DoubleValueLineEdit {
|
|
Shinya Kitaoka |
120a6e |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
QDoubleValidator *m_validator;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
DoubleLineEdit(QWidget *parent = 0, double value = 1);
|
|
Shinya Kitaoka |
120a6e |
~DoubleLineEdit() {}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*! Set text field value to double value \b value. */
|
|
Shinya Kitaoka |
473e70 |
void setValue(double value) override;
|
|
Shinya Kitaoka |
120a6e |
/*! Return a double with field value. */
|
|
Shinya Kitaoka |
473e70 |
double getValue() override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
/*! Set the range of field from \b minValue to \b maxValue;
|
|
Shinya Kitaoka |
120a6e |
set validator value. */
|
|
Shinya Kitaoka |
473e70 |
void setRange(double minValue, double maxValue) override;
|
|
Shinya Kitaoka |
120a6e |
/*! Set \b minValue an \b maxValue to current range; to current
|
|
Shinya Kitaoka |
120a6e |
validator minimum and maximum value. */
|
|
Shinya Kitaoka |
473e70 |
void getRange(double &minValue, double &maxValue) override;
|
|
Shinya Kitaoka |
120a6e |
|
|
MCCCS |
a0ce32 |
/*! Set length of field value decimal part to \b decimals. */
|
|
Shinya Kitaoka |
120a6e |
void setDecimals(int decimals);
|
|
MCCCS |
a0ce32 |
/*! Return length of field value decimal part. */
|
|
Shinya Kitaoka |
473e70 |
int getDecimals() override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Shinya Kitaoka |
120a6e |
/*! \brief The DoubleField class provides a DoubleValueField with a
|
|
Shinya Kitaoka |
120a6e |
DoubleLineEdit.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
Inherits \b DoubleValueField.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DVAPI DoubleField : public DoubleValueField {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
DoubleField(QWidget *parent = 0, bool isRollerHide = true, int decimals = 2);
|
|
Shinya Kitaoka |
120a6e |
~DoubleField() {}
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
/*! \brief The MeasuredDoubleLineEdit class provides to view an object to manage
|
|
Toshihiro Shimizu |
890ddd |
a double lineEdit with its misure.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Shinya Kitaoka |
120a6e |
class DVAPI MeasuredDoubleLineEdit : public DoubleValueLineEdit {
|
|
Shinya Kitaoka |
120a6e |
Q_OBJECT
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TMeasuredValue *m_value;
|
|
Shinya Kitaoka |
120a6e |
double m_minValue;
|
|
Shinya Kitaoka |
120a6e |
double m_maxValue;
|
|
Shinya Kitaoka |
120a6e |
bool m_modified;
|
|
Shinya Kitaoka |
120a6e |
double m_errorHighlighting;
|
|
Shinya Kitaoka |
120a6e |
int m_errorHighlightingTimerId;
|
|
Shinya Kitaoka |
120a6e |
int m_decimals;
|
|
Jeremy Bullock |
771290 |
int m_xMouse;
|
|
Jeremy Bullock |
771290 |
bool m_labelClicked = false;
|
|
Jeremy Bullock |
771290 |
bool m_mouseDragEditing = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
MeasuredDoubleLineEdit(QWidget *parent = 0);
|
|
Shinya Kitaoka |
120a6e |
~MeasuredDoubleLineEdit();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void setValue(double value) override;
|
|
Shinya Kitaoka |
473e70 |
double getValue() override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void setRange(double minValue, double maxValue) override;
|
|
Shinya Kitaoka |
473e70 |
void getRange(double &minValue, double &maxValue) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setMeasure(std::string measureName);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setDecimals(int decimals);
|
|
Shinya Kitaoka |
473e70 |
int getDecimals() override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// called after setText()
|
|
Shinya Kitaoka |
120a6e |
void postSetText() { onEditingFinished(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
private:
|
|
Shinya Kitaoka |
120a6e |
void valueToText();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
473e70 |
void timerEvent(QTimerEvent *e) override;
|
|
Jeremy Bullock |
771290 |
// these are only used for mouse dragging
|
|
Jeremy Bullock |
771290 |
// to set the value of the field.
|
|
Jeremy Bullock |
771290 |
void mousePressEvent(QMouseEvent *) override;
|
|
Jeremy Bullock |
771290 |
void mouseMoveEvent(QMouseEvent *) override;
|
|
Jeremy Bullock |
771290 |
void mouseReleaseEvent(QMouseEvent *) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
protected slots:
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void onEditingFinished();
|
|
Shinya Kitaoka |
120a6e |
void onTextChanged(const QString &);
|
|
Jeremy Bullock |
771290 |
|
|
Jeremy Bullock |
771290 |
// This allows the field to be set by dragging on the label
|
|
Jeremy Bullock |
771290 |
void receiveMouseMove(QMouseEvent *event);
|
|
Jeremy Bullock |
771290 |
void receiveMousePress(QMouseEvent *event);
|
|
Jeremy Bullock |
771290 |
void receiveMouseRelease(QMouseEvent *event);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Shinya Kitaoka |
120a6e |
/*! \brief The MeasuredDoubleField class provides a DoubleValueField with a
|
|
Shinya Kitaoka |
120a6e |
ValueLineEdit.
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
Inherits \b PrimaryDoubleField.
|
|
Toshihiro Shimizu |
890ddd |
*/
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class DVAPI MeasuredDoubleField final : public DoubleValueField {
|
|
Shinya Kitaoka |
120a6e |
Q_OBJECT
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
MeasuredDoubleField(QWidget *parent = 0, bool isRollerHide = true);
|
|
Shinya Kitaoka |
120a6e |
~MeasuredDoubleField() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setMeasure(std::string measureName);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setDecimals(int decimals);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Shinya Kitaoka |
120a6e |
} // namespace DVGui
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // DOUBLEFIELD_H
|