* Add more rounding in SpinBox.qml, allowing FloatPreference::step to work reliably for the spinners without needing double precision (suggestion from ctrlaltdavid: https://github.com/vircadia/vircadia/pull/930#issuecomment-765838930).

* Change FloatPreference::step from double back to float.
This commit is contained in:
Phil Palmer 2021-02-01 20:26:18 -05:00
parent da2a3f67cf
commit a2e4b81ed8
3 changed files with 10 additions and 10 deletions

View file

@ -73,9 +73,9 @@ SpinBox {
} }
} }
stepSize: realStepSize * factor stepSize: Math.round(realStepSize * factor)
to : realTo*factor to : Math.round(realTo*factor)
from : realFrom*factor from : Math.round(realFrom*factor)
font.family: "Fira Sans SemiBold" font.family: "Fira Sans SemiBold"
font.pixelSize: hifi.fontSizes.textFieldInput font.pixelSize: hifi.fontSizes.textFieldInput

View file

@ -466,7 +466,7 @@ void setupPreferences() {
preference->setMin(1.0f); preference->setMin(1.0f);
preference->setMax(2.2f); preference->setMax(2.2f);
preference->setDecimals(2); preference->setDecimals(2);
preference->setStep(0.01); preference->setStep(0.01f);
preferences->addPreference(preference); preferences->addPreference(preference);
} }

View file

@ -152,7 +152,7 @@ class FloatPreference : public Preference {
Q_PROPERTY(float value READ getValue WRITE setValue NOTIFY valueChanged) Q_PROPERTY(float value READ getValue WRITE setValue NOTIFY valueChanged)
Q_PROPERTY(float min READ getMin CONSTANT) Q_PROPERTY(float min READ getMin CONSTANT)
Q_PROPERTY(float max READ getMax CONSTANT) Q_PROPERTY(float max READ getMax CONSTANT)
Q_PROPERTY(double step READ getStep CONSTANT) Q_PROPERTY(float step READ getStep CONSTANT)
Q_PROPERTY(uint decimals READ getDecimals CONSTANT) Q_PROPERTY(uint decimals READ getDecimals CONSTANT)
public: public:
@ -178,11 +178,11 @@ public:
float getMax() const { return _max; } float getMax() const { return _max; }
void setMax(float max) { _max = max; }; void setMax(float max) { _max = max; };
double getStep() const { return _step; } float getStep() const { return _step; }
void setStep(double step) { _step = step; }; void setStep(float step) { _step = step; };
uint getDecimals() const { return _decimals; } float getDecimals() const { return _decimals; }
void setDecimals(uint decimals) { _decimals = decimals; }; void setDecimals(float decimals) { _decimals = decimals; };
signals: signals:
void valueChanged(); void valueChanged();
@ -197,7 +197,7 @@ protected:
uint _decimals { 0 }; uint _decimals { 0 };
float _min { 0 }; float _min { 0 };
float _max { 1 }; float _max { 1 };
double _step { 0.1 }; float _step { 0.1f };
}; };
class IntPreference : public Preference { class IntPreference : public Preference {