Fix various issues with SpinBox-es and Sliders

This commit is contained in:
vladest 2018-04-20 19:15:29 +02:00
parent b8577bd791
commit 0e28e41107
7 changed files with 53 additions and 52 deletions

View file

@ -24,6 +24,7 @@ Slider {
property alias minimumValue: slider.from
property alias maximumValue: slider.to
property bool tickmarksEnabled: false
height: hifi.fontSizes.textFieldInput + 14 // Match height of TextField control.
y: sliderLabel.visible ? sliderLabel.height + sliderLabel.anchors.bottomMargin : 0

View file

@ -71,16 +71,16 @@ SpinBox {
}
validator: DoubleValidator {
bottom: Math.min(spinBox.from, spinBox.to)*spinBox.factor
top: Math.max(spinBox.from, spinBox.to)*spinBox.factor
bottom: Math.min(spinBox.from, spinBox.to)
top: Math.max(spinBox.from, spinBox.to)
}
textFromValue: function(value, locale) {
return parseFloat(value*1.0/factor).toFixed(decimals);
return parseFloat(value/factor).toFixed(decimals);
}
valueFromText: function(text, locale) {
return Number.fromLocaleString(locale, text);
return Number.fromLocaleString(locale, text)*factor;
}

View file

@ -18,11 +18,11 @@ Preference {
height: control.height + hifi.dimensions.controlInterlineHeight
Component.onCompleted: {
spinner.value = preference.value;
spinner.realValue = preference.value;
}
function save() {
preference.value = spinner.value;
preference.value = spinner.realValue;
preference.save();
}

View file

@ -21,7 +21,7 @@ Preference {
Component.onCompleted: {
slider.value = preference.value;
spinner.value = preference.value;
spinner.realValue = preference.value;
}
function save() {
@ -60,7 +60,7 @@ Preference {
maximumValue: MyAvatar.getDomainMaxScale()
stepSize: preference.step
onValueChanged: {
spinner.value = value
spinner.realValue = value
}
anchors {
right: spinner.left
@ -73,12 +73,12 @@ Preference {
SpinBox {
id: spinner
decimals: preference.decimals
value: preference.value
realValue: preference.value
minimumValue: MyAvatar.getDomainMinScale()
maximumValue: MyAvatar.getDomainMaxScale()
width: 100
onValueChanged: {
slider.value = value;
slider.value = realValue;
}
anchors {
right: button.left
@ -92,10 +92,10 @@ Preference {
id: button
onClicked: {
if (spinner.maximumValue >= 1) {
spinner.value = 1
spinner.realValue = 1
slider.value = 1
} else {
spinner.value = spinner.maximumValue
spinner.realValue = spinner.maximumValue
slider.value = spinner.maximumValue
}
}
@ -108,4 +108,4 @@ Preference {
colorScheme: hifi.colorSchemes.dark
}
}
}
}

View file

@ -181,11 +181,11 @@ Item {
minimumValue: 0.01
maximumValue: 10
realStepSize: 0.05;
value: attachment ? attachment.scale : 1.0
realValue: attachment ? attachment.scale : 1.0
colorScheme: hifi.colorSchemes.dark
onValueChanged: {
if (completed && attachment && attachment.scale !== value) {
attachment.scale = value;
onRealValueChanged: {
if (completed && attachment && attachment.scale !== realValue) {
attachment.scale = realValue;
updateAttachment();
}
}

View file

@ -51,7 +51,7 @@ Item {
id: xspinner
width: root.spinboxWidth
anchors { left: parent.left }
value: root.vector.x
realValue: root.vector.x
labelInside: "X:"
colorScheme: hifi.colorSchemes.dark
colorLabelInside: hifi.colors.redHighlight
@ -72,17 +72,17 @@ Item {
id: yspinner
width: root.spinboxWidth
anchors { horizontalCenter: parent.horizontalCenter }
value: root.vector.y
realValue: root.vector.y
labelInside: "Y:"
colorLabelInside: hifi.colors.greenHighlight
colorScheme: hifi.colorSchemes.dark
decimals: root.decimals
stepSize: root.stepSize
realStepSize: root.stepSize
maximumValue: root.maximumValue
minimumValue: root.minimumValue
onValueChanged: {
if (value !== vector.y) {
vector.y = value
onRealValueChanged: {
if (realValue !== vector.y) {
vector.y = realValue
root.valueChanged();
}
}
@ -93,17 +93,17 @@ Item {
id: zspinner
width: root.spinboxWidth
anchors { right: parent.right; }
value: root.vector.z
realValue: root.vector.z
labelInside: "Z:"
colorLabelInside: hifi.colors.primaryHighlight
colorScheme: hifi.colorSchemes.dark
decimals: root.decimals
stepSize: root.stepSize
realStepSize: root.stepSize
maximumValue: root.maximumValue
minimumValue: root.minimumValue
onValueChanged: {
if (value !== vector.z) {
vector.z = value
onRealValueChanged: {
if (realValue !== vector.z) {
vector.z = realValue
root.valueChanged();
}
}

View file

@ -178,8 +178,8 @@ Rectangle {
label: "Y Offset"
suffix: " cm"
minimumValue: -10
stepSize: 1
value: -5
realStepSize: 1
realValue: -5
colorScheme: hifi.colorSchemes.dark
onEditingFinished: {
@ -193,10 +193,10 @@ Rectangle {
width: 112
label: "Z Offset"
minimumValue: -10
stepSize: 1
realStepSize: 1
decimals: 1
suffix: " cm"
value: -5
realValue: -5
colorScheme: hifi.colorSchemes.dark
onEditingFinished: {
@ -288,7 +288,7 @@ Rectangle {
suffix: " cm"
label: "Y Offset"
minimumValue: -10
stepSize: 1
realStepSize: 1
colorScheme: hifi.colorSchemes.dark
onEditingFinished: {
@ -303,7 +303,7 @@ Rectangle {
label: "Z Offset"
suffix: " cm"
minimumValue: -10
stepSize: 1
realStepSize: 1
decimals: 1
colorScheme: hifi.colorSchemes.dark
@ -535,9 +535,9 @@ Rectangle {
suffix: " cm"
label: "Arm Circumference"
minimumValue: 0
stepSize: 1.0
realStepSize: 1.0
colorScheme: hifi.colorSchemes.dark
value: 33.0
realValue: 33.0
onEditingFinished: {
sendConfigurationSettings();
@ -550,10 +550,10 @@ Rectangle {
label: "Shoulder Width"
suffix: " cm"
minimumValue: 0
stepSize: 1.0
realStepSize: 1.0
decimals: 1
colorScheme: hifi.colorSchemes.dark
value: 48
realValue: 48
onEditingFinished: {
sendConfigurationSettings();
@ -659,13 +659,13 @@ Rectangle {
InputConfiguration.uncalibratePlugin(pluginName);
updateCalibrationButton();
} else {
calibrationTimer.interval = timeToCalibrate.value * 1000
openVrConfiguration.countDown = timeToCalibrate.value;
calibrationTimer.interval = timeToCalibrate.realValue * 1000
openVrConfiguration.countDown = timeToCalibrate.realValue;
var calibratingScreen = screen.createObject();
stack.push(calibratingScreen);
calibratingScreen.canceled.connect(cancelCalibration);
calibratingScreen.restart.connect(restartCalibration);
calibratingScreen.start(calibrationTimer.interval, timeToCalibrate.value);
calibratingScreen.start(calibrationTimer.interval, timeToCalibrate.realValue);
calibrationTimer.start();
}
}
@ -728,12 +728,12 @@ Rectangle {
anchors.leftMargin: leftMargin
minimumValue: 5
value: 5
realValue: 5
colorScheme: hifi.colorSchemes.dark
onEditingFinished: {
calibrationTimer.interval = value * 1000;
openVrConfiguration.countDown = value;
calibrationTimer.interval = realValue * 1000;
openVrConfiguration.countDown = realValue;
numberAnimation.duration = calibrationTimer.interval;
}
}
@ -910,8 +910,8 @@ Rectangle {
var desktopMode = settings["desktopMode"];
var hmdDesktopPosition = settings["hmdDesktopTracking"];
armCircumference.value = settings.armCircumference;
shoulderWidth.value = settings.shoulderWidth;
armCircumference.realValue = settings.armCircumference;
shoulderWidth.realValue = settings.shoulderWidth;
if (HmdHead) {
headBox.checked = true;
@ -1075,22 +1075,22 @@ Rectangle {
var headObject = {
"override": overrideHead,
"Y": headYOffset.value,
"Z": headZOffset.value
"Y": headYOffset.realValue,
"Z": headZOffset.realValue
}
var handObject = {
"override": overrideHandController,
"Y": handYOffset.value,
"Z": handZOffset.value
"Y": handYOffset.realValue,
"Z": handZOffset.realValue
}
var settingsObject = {
"bodyConfiguration": trackerConfiguration,
"headConfiguration": headObject,
"handConfiguration": handObject,
"armCircumference": armCircumference.value,
"shoulderWidth": shoulderWidth.value,
"armCircumference": armCircumference.realValue,
"shoulderWidth": shoulderWidth.realValue,
"desktopMode": viveInDesktop.checked,
"hmdDesktopTracking": hmdInDesktop.checked
}