From 9304d6c5c4f85185653c93b275427d1c8bf006a6 Mon Sep 17 00:00:00 2001 From: Alexander Ivash Date: Fri, 10 Aug 2018 18:42:08 +0300 Subject: [PATCH] reset UI to default state & disable controls on removing last wearable --- .../qml/hifi/avatarapp/AdjustWearables.qml | 47 ++++++++++++------- .../resources/qml/hifi/avatarapp/Vector3.qml | 4 ++ 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml b/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml index 27ae590fc5..bf3c62410e 100644 --- a/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml +++ b/interface/resources/qml/hifi/avatarapp/AdjustWearables.qml @@ -53,7 +53,10 @@ Rectangle { } wearablesCombobox.model.append(wearable); } - wearablesCombobox.currentIndex = 0; + + if(wearablesCombobox.model.count !== 0) { + wearablesCombobox.currentIndex = 0; + } } function refreshWearable(wearableID, wearableIndex, properties, updateUI) { @@ -75,9 +78,9 @@ Rectangle { if(updateUI) { if(prop === 'localPosition') { - position.set(wearable[prop]); + positionVector.set(wearable[prop]); } else if(prop === 'localRotationAngles') { - rotation.set(wearable[prop]); + rotationVector.set(wearable[prop]); } else if(prop === 'dimensions') { scalespinner.set(wearable[prop].x / wearable.naturalDimensions.x); } @@ -88,7 +91,7 @@ Rectangle { } function getCurrentWearable() { - return wearablesCombobox.model.get(wearablesCombobox.currentIndex) + return wearablesCombobox.currentIndex !== -1 ? wearablesCombobox.model.get(wearablesCombobox.currentIndex) : null; } function selectWearableByID(entityID) { @@ -184,6 +187,7 @@ Rectangle { id: wearablesCombobox anchors.left: parent.left anchors.right: parent.right + enabled: getCurrentWearable() !== null comboBox.textRole: "text" model: ListModel { @@ -202,14 +206,19 @@ Rectangle { comboBox.onCurrentIndexChanged: { var currentWearable = getCurrentWearable(); + var position = currentWearable ? currentWearable.localPosition : { x : 0, y : 0, z : 0 }; + var rotation = currentWearable ? currentWearable.localRotationAngles : { x : 0, y : 0, z : 0 }; + var scale = currentWearable ? currentWearable.dimensions.x / currentWearable.naturalDimensions.x : 1.0; + var joint = currentWearable ? currentWearable.parentJointIndex : -1; + var soft = currentWearable ? currentWearable.relayParentJoints : false; + + positionVector.set(position); + rotationVector.set(rotation); + scalespinner.set(scale); + jointsCombobox.set(joint); + isSoft.set(soft); if(currentWearable) { - position.set(currentWearable.localPosition); - rotation.set(currentWearable.localRotationAngles); - scalespinner.set(currentWearable.dimensions.x / currentWearable.naturalDimensions.x) - jointsCombobox.set(currentWearable.parentJointIndex) - isSoft.set(currentWearable.relayParentJoints) - wearableSelected(currentWearable.id); } } @@ -230,7 +239,7 @@ Rectangle { id: jointsCombobox anchors.left: parent.left anchors.right: parent.right - enabled: !isSoft.checked + enabled: getCurrentWearable() !== null && !isSoft.checked comboBox.displayText: isSoft.checked ? 'Hips' : comboBox.currentText model: jointNames @@ -247,9 +256,9 @@ Rectangle { var properties = { parentJointIndex: currentIndex, localPosition: { - x: position.xvalue, - y: position.yvalue, - z: position.zvalue + x: positionVector.xvalue, + y: positionVector.yvalue, + z: positionVector.zvalue } }; @@ -288,8 +297,9 @@ Rectangle { } Vector3 { - id: position + id: positionVector backgroundColor: "lightgray" + enabled: getCurrentWearable() !== null function set(localPosition) { notify = false; @@ -347,8 +357,9 @@ Rectangle { } Vector3 { - id: rotation + id: rotationVector backgroundColor: "lightgray" + enabled: getCurrentWearable() !== null function set(localRotationAngles) { notify = false; @@ -386,6 +397,7 @@ Rectangle { HifiControlsUit.CheckBox { id: isSoft + enabled: getCurrentWearable() !== null text: "Is soft" labelFontSize: 15 labelFontWeight: Font.Bold @@ -427,13 +439,14 @@ Rectangle { HifiControlsUit.SpinBox { id: scalespinner + enabled: getCurrentWearable() !== null decimals: 2 realStepSize: 0.1 realFrom: 0.1 realTo: 3.0 realValue: 1.0 backgroundColor: "lightgray" - width: position.spinboxWidth + width: positionVector.spinboxWidth colorScheme: hifi.colorSchemes.light property bool notify: false; diff --git a/interface/resources/qml/hifi/avatarapp/Vector3.qml b/interface/resources/qml/hifi/avatarapp/Vector3.qml index 33e82fe0ee..d77665f992 100644 --- a/interface/resources/qml/hifi/avatarapp/Vector3.qml +++ b/interface/resources/qml/hifi/avatarapp/Vector3.qml @@ -20,6 +20,7 @@ Row { spacing: spinboxSpace + property bool enabled: false; property alias xvalue: xspinner.realValue property alias yvalue: yspinner.realValue property alias zvalue: zspinner.realValue @@ -35,6 +36,7 @@ Row { realFrom: root.realFrom realTo: root.realTo realStepSize: root.realStepSize + enabled: root.enabled } HifiControlsUit.SpinBox { @@ -48,6 +50,7 @@ Row { realFrom: root.realFrom realTo: root.realTo realStepSize: root.realStepSize + enabled: root.enabled } HifiControlsUit.SpinBox { @@ -61,5 +64,6 @@ Row { realFrom: root.realFrom realTo: root.realTo realStepSize: root.realStepSize + enabled: root.enabled } }