Пример #1
0
void Scroller::setValue(float newValue, bool notify)
{
  newValue = clamp(newValue, minValue, maxValue);
  if (newValue == value)
    return;

  value = newValue;

  if (notify)
    valueChangedSignal(*this);

  invalidate();
}
Пример #2
0
/**
 * Set the value.
 *
 * The value will be clamped to the range of the slider.
 *
 * @param value The value.
 */
void Slider::SetValue(double value)
{
	if (value < min) value = min;
	else if (value > max) value = max;
	else {
		// Clamp to the nearest step.
		value = round(value * (1.0 / step)) * step;
	}

	if (this->value != value) {
		this->value = value;
		FireModelUpdate(Props::VALUE);
		valueChangedSignal(value);
		RequestLayout();
	}
}