From 30c13fd9882a2453c88474370b566fd346ae40a5 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Wed, 22 May 2019 12:01:38 -0700 Subject: [PATCH] Fix environment volume slider (BUGZ-213); optimize sliders --- .../simplifiedUI/settingsApp/audio/Audio.qml | 55 +++++++++++++++---- .../simplifiedControls/Slider.qml | 1 + 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/interface/resources/qml/hifi/simplifiedUI/settingsApp/audio/Audio.qml b/interface/resources/qml/hifi/simplifiedUI/settingsApp/audio/Audio.qml index da924615e3..3e2e4bf752 100644 --- a/interface/resources/qml/hifi/simplifiedUI/settingsApp/audio/Audio.qml +++ b/interface/resources/qml/hifi/simplifiedUI/settingsApp/audio/Audio.qml @@ -68,57 +68,88 @@ Flickable { SimplifiedControls.Slider { id: peopleVolume + property real lastValueSent anchors.left: parent.left anchors.right: parent.right Layout.topMargin: simplifiedUI.margins.settings.settingsGroupTopMargin height: 30 labelText: "People Volume" - from: -60 - to: 10 + from: -60.0 + to: 20.0 defaultValue: 0.0 + stepSize: 5.0 value: AudioScriptingInterface.getAvatarGain() live: true + function updatePeopleGain(sliderValue) { + if (AudioScriptingInterface.getAvatarGain() !== sliderValue) { + AudioScriptingInterface.setAvatarGain(sliderValue); + } + } onValueChanged: { - if (AudioScriptingInterface.getAvatarGain() != peopleVolume.value) { - AudioScriptingInterface.setAvatarGain(peopleVolume.value); + updatePeopleGain(value); + } + onPressedChanged: { + if (!pressed) { + updatePeopleGain(value); } } } SimplifiedControls.Slider { id: environmentVolume + property real lastValueSent anchors.left: parent.left anchors.right: parent.right Layout.topMargin: 2 height: 30 labelText: "Environment Volume" - from: -60 - to: 10 + from: -60.0 + to: 20.0 defaultValue: 0.0 + stepSize: 5.0 value: AudioScriptingInterface.getInjectorGain() live: true + function updateEnvironmentGain(sliderValue) { + if (AudioScriptingInterface.getInjectorGain() !== sliderValue) { + AudioScriptingInterface.setInjectorGain(sliderValue); + AudioScriptingInterface.setLocalInjectorGain(sliderValue); + } + } onValueChanged: { - if (AudioScriptingInterface.getInjectorGain() != environmentVolume.value) { - AudioScriptingInterface.setInjectorGain(environmentVolume.value); + updateEnvironmentGain(value); + } + onPressedChanged: { + if (!pressed) { + updateEnvironmentGain(value); } } } SimplifiedControls.Slider { id: systemSoundVolume + property real lastValueSent anchors.left: parent.left anchors.right: parent.right Layout.topMargin: 2 height: 30 labelText: "System Sound Volume" - from: -60 - to: 10 + from: -60.0 + to: 20.0 defaultValue: 0.0 + stepSize: 5.0 value: AudioScriptingInterface.getSystemInjectorGain() live: true + function updateSystemGain(sliderValue) { + if (AudioScriptingInterface.getSystemInjectorGain() !== sliderValue) { + AudioScriptingInterface.setSystemInjectorGain(sliderValue); + } + } onValueChanged: { - if (AudioScriptingInterface.getSystemInjectorGain() != systemSoundVolume.value) { - AudioScriptingInterface.setSystemInjectorGain(systemSoundVolume.value); + updateSystemGain(value); + } + onPressedChanged: { + if (!pressed) { + updateSystemGain(value); } } } diff --git a/interface/resources/qml/hifi/simplifiedUI/simplifiedControls/Slider.qml b/interface/resources/qml/hifi/simplifiedUI/simplifiedControls/Slider.qml index 2b1dc68261..38b114e9d2 100644 --- a/interface/resources/qml/hifi/simplifiedUI/simplifiedControls/Slider.qml +++ b/interface/resources/qml/hifi/simplifiedUI/simplifiedControls/Slider.qml @@ -30,6 +30,7 @@ Item { property alias live: sliderControl.live property alias stepSize: sliderControl.stepSize property alias snapMode: sliderControl.snapMode + property alias pressed: sliderControl.pressed property real defaultValue: 0.0 HifiStylesUit.GraphikRegular {