From 192c8e0e4e54e9305f532ed30d556face70be5e4 Mon Sep 17 00:00:00 2001 From: shun-iwasawa Date: Wed, 14 Mar 2018 14:45:08 +0900 Subject: [PATCH] fix double slider (#1843) --- toonz/sources/toonzqt/doublefield.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/toonz/sources/toonzqt/doublefield.cpp b/toonz/sources/toonzqt/doublefield.cpp index 8f5f5c9d..756c7a4f 100644 --- a/toonz/sources/toonzqt/doublefield.cpp +++ b/toonz/sources/toonzqt/doublefield.cpp @@ -145,8 +145,8 @@ void DoubleValueField::setRange(double minValue, double maxValue) { m_roller->setRange(minValue, maxValue); int dicimal = m_lineEdit->getDecimals(); - int sliderMax = maxValue * pow(10., dicimal); - int sliderMin = minValue * pow(10., dicimal); + int sliderMax = (int)round(maxValue * pow(10., dicimal)); + int sliderMin = (int)round(minValue * pow(10., dicimal)); m_slider->setRange(sliderMin, sliderMax); @@ -161,7 +161,7 @@ void DoubleValueField::setValue(double value) { m_roller->setValue(value); int dicimal = m_lineEdit->getDecimals(); - int sliderValue = value * pow(10., dicimal); + int sliderValue = (int)round(value * pow(10., dicimal)); m_slider->setValue(sliderValue); // forzo il repaint... non sempre si aggiorna e l'update non sembra risolvere @@ -237,12 +237,12 @@ void DoubleValueField::onSliderChanged(int value) { //----------------------------------------------------------------------------- void DoubleValueField::onLineEditValueChanged() { - double value = m_lineEdit->getValue(); - int dicimal = m_lineEdit->getDecimals(); - double sliderValue = value * pow(10., dicimal); + double value = m_lineEdit->getValue(); + int dicimal = m_lineEdit->getDecimals(); + int sliderValue = (int)round(value * pow(10., dicimal)); - // Controllo necessario per evitare che il segnale di cambiamento venga emesso - // piu' volte. + // Control necessary to prevent the change signal from being emitted more than + // once. if ((m_slider->value() == sliderValue && m_slider->isVisible()) || (m_roller->getValue() == value && m_roller->isVisible())) return;