diff --git a/interface/resources/qml/controlsUit/SpinBox.qml b/interface/resources/qml/controlsUit/SpinBox.qml index a888bbd07c..719b0d00c1 100644 --- a/interface/resources/qml/controlsUit/SpinBox.qml +++ b/interface/resources/qml/controlsUit/SpinBox.qml @@ -73,9 +73,9 @@ SpinBox { } } - stepSize: realStepSize * factor - to : realTo*factor - from : realFrom*factor + stepSize: Math.round(realStepSize * factor) + to : Math.round(realTo*factor) + from : Math.round(realFrom*factor) font.family: "Fira Sans SemiBold" font.pixelSize: hifi.fontSizes.textFieldInput @@ -97,11 +97,11 @@ SpinBox { } textFromValue: function(value, locale) { - return parseFloat(value / factor).toFixed(decimals); + return (value / factor).toFixed(decimals); } valueFromText: function(text, locale) { - return Number.fromLocaleString(locale, text) * factor; + return Math.round(Number.fromLocaleString(locale, text) * factor); } diff --git a/interface/resources/qml/dialogs/preferences/SpinBoxPreference.qml b/interface/resources/qml/dialogs/preferences/SpinBoxPreference.qml index 1b080c2759..5b3a28cd1d 100644 --- a/interface/resources/qml/dialogs/preferences/SpinBoxPreference.qml +++ b/interface/resources/qml/dialogs/preferences/SpinBoxPreference.qml @@ -51,6 +51,7 @@ Preference { decimals: preference.decimals minimumValue: preference.min maximumValue: preference.max + realStepSize: preference.step width: 100 anchors { verticalCenter: parent.verticalCenter diff --git a/interface/resources/qml/dialogs/preferences/SpinnerSliderPreference.qml b/interface/resources/qml/dialogs/preferences/SpinnerSliderPreference.qml index cbc804d9d7..bf7ea08d3a 100644 --- a/interface/resources/qml/dialogs/preferences/SpinnerSliderPreference.qml +++ b/interface/resources/qml/dialogs/preferences/SpinnerSliderPreference.qml @@ -76,6 +76,7 @@ Preference { realValue: preference.value minimumValue: preference.min maximumValue: preference.max + realStepSize: preference.step width: 100 onValueChanged: { slider.value = realValue; diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 9589fc26ff..c2f1abdd94 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -362,10 +362,10 @@ void setupPreferences() { auto getter = [myAvatar]()->float { return qApp->getCamera().getSensitivity(); }; auto setter = [myAvatar](float value) { qApp->getCamera().setSensitivity(value); }; auto preference = new SpinnerSliderPreference(VR_MOVEMENT, "Camera Sensitivity", getter, setter); - preference->setMin(0.01f); + preference->setMin(0.1f); preference->setMax(5.0f); preference->setStep(0.1f); - preference->setDecimals(2); + preference->setDecimals(1); preferences->addPreference(preference); } { @@ -385,7 +385,7 @@ void setupPreferences() { preference->setMin(6.0f); preference->setMax(30.0f); preference->setStep(1); - preference->setDecimals(2); + preference->setDecimals(0); preferences->addPreference(preference); } { @@ -465,8 +465,8 @@ void setupPreferences() { auto preference = new SpinnerPreference(VR_MOVEMENT, "User real-world height (meters)", getter, setter); preference->setMin(1.0f); preference->setMax(2.2f); - preference->setDecimals(3); - preference->setStep(0.001f); + preference->setDecimals(2); + preference->setStep(0.01f); preferences->addPreference(preference); } @@ -478,7 +478,7 @@ void setupPreferences() { preference->setMin(1.0f); preference->setMax(360.0f); preference->setStep(1); - preference->setDecimals(1); + preference->setDecimals(0); preferences->addPreference(preference); } { @@ -488,7 +488,7 @@ void setupPreferences() { preference->setMin(1.0f); preference->setMax(360.0f); preference->setStep(1); - preference->setDecimals(1); + preference->setDecimals(0); preferences->addPreference(preference); } diff --git a/libraries/shared/src/Preferences.h b/libraries/shared/src/Preferences.h index 9147117792..a195dc457f 100644 --- a/libraries/shared/src/Preferences.h +++ b/libraries/shared/src/Preferences.h @@ -153,7 +153,7 @@ class FloatPreference : public Preference { Q_PROPERTY(float min READ getMin CONSTANT) Q_PROPERTY(float max READ getMax CONSTANT) Q_PROPERTY(float step READ getStep CONSTANT) - Q_PROPERTY(float decimals READ getDecimals CONSTANT) + Q_PROPERTY(uint decimals READ getDecimals CONSTANT) public: using Getter = std::function; @@ -194,10 +194,10 @@ protected: const Getter _getter; const Setter _setter; - float _decimals { 0 }; + uint _decimals { 0 }; float _min { 0 }; float _max { 1 }; - float _step { 0.1f }; + float _step { 1 }; }; class IntPreference : public Preference {