示例#1
0
MotionViewDoubleItemEditor::MotionViewDoubleItemEditor(const MotionViewItemDelegate* d, QWidget* p)
: DoubleValueEditor(p), m_delegate(d)
{
	setDecimals(3);
	setMinimum(0.001);
	setSingleStep(0.1);
	connect(this, SIGNAL(valueUpdated()), this, SLOT(spinnerValueChanged()));
}
/******************************************************************************
* Sets the current value of the spinner.
******************************************************************************/
void SpinnerWidget::setFloatValue(FloatType newVal, bool emitChangeSignal)
{
	// Clamp value.
	if(newVal == _value) return;
	newVal = std::max(minValue(), newVal);
	newVal = std::min(maxValue(), newVal);
	if(_value != newVal) {
		_value = newVal;
		if(emitChangeSignal)
			Q_EMIT spinnerValueChanged();
	}
	updateTextBox();
}
/******************************************************************************
* Sets the current integer value of the spinner.
******************************************************************************/
void SpinnerWidget::setIntValue(int newValInt, bool emitChangeSignal)
{
	FloatType newVal = (FloatType)newValInt;

	if(newVal == _value) return;
	// Clamp value.
	newVal = std::max((FloatType)ceil(minValue()), newVal);
	newVal = std::min((FloatType)floor(maxValue()), newVal);
	if(_value != newVal) {
		_value = newVal;
		if(emitChangeSignal)
			Q_EMIT spinnerValueChanged();
	}
	updateTextBox();
}
示例#4
0
MotionViewIntItemEditor::MotionViewIntItemEditor(const MotionViewItemDelegate* d, QWidget* p)
: IntValueEditor(p), m_delegate(d)
{
	setMinimum(1);
	connect(this, SIGNAL(valueUpdated()), this, SLOT(spinnerValueChanged()));
}