reset UI to default state & disable controls on removing last wearable

This commit is contained in:
Alexander Ivash 2018-08-10 18:42:08 +03:00
parent 90fb0d7be6
commit 9304d6c5c4
2 changed files with 34 additions and 17 deletions

View file

@ -53,7 +53,10 @@ Rectangle {
} }
wearablesCombobox.model.append(wearable); wearablesCombobox.model.append(wearable);
} }
wearablesCombobox.currentIndex = 0;
if(wearablesCombobox.model.count !== 0) {
wearablesCombobox.currentIndex = 0;
}
} }
function refreshWearable(wearableID, wearableIndex, properties, updateUI) { function refreshWearable(wearableID, wearableIndex, properties, updateUI) {
@ -75,9 +78,9 @@ Rectangle {
if(updateUI) { if(updateUI) {
if(prop === 'localPosition') { if(prop === 'localPosition') {
position.set(wearable[prop]); positionVector.set(wearable[prop]);
} else if(prop === 'localRotationAngles') { } else if(prop === 'localRotationAngles') {
rotation.set(wearable[prop]); rotationVector.set(wearable[prop]);
} else if(prop === 'dimensions') { } else if(prop === 'dimensions') {
scalespinner.set(wearable[prop].x / wearable.naturalDimensions.x); scalespinner.set(wearable[prop].x / wearable.naturalDimensions.x);
} }
@ -88,7 +91,7 @@ Rectangle {
} }
function getCurrentWearable() { function getCurrentWearable() {
return wearablesCombobox.model.get(wearablesCombobox.currentIndex) return wearablesCombobox.currentIndex !== -1 ? wearablesCombobox.model.get(wearablesCombobox.currentIndex) : null;
} }
function selectWearableByID(entityID) { function selectWearableByID(entityID) {
@ -184,6 +187,7 @@ Rectangle {
id: wearablesCombobox id: wearablesCombobox
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
enabled: getCurrentWearable() !== null
comboBox.textRole: "text" comboBox.textRole: "text"
model: ListModel { model: ListModel {
@ -202,14 +206,19 @@ Rectangle {
comboBox.onCurrentIndexChanged: { comboBox.onCurrentIndexChanged: {
var currentWearable = getCurrentWearable(); 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) { 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); wearableSelected(currentWearable.id);
} }
} }
@ -230,7 +239,7 @@ Rectangle {
id: jointsCombobox id: jointsCombobox
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
enabled: !isSoft.checked enabled: getCurrentWearable() !== null && !isSoft.checked
comboBox.displayText: isSoft.checked ? 'Hips' : comboBox.currentText comboBox.displayText: isSoft.checked ? 'Hips' : comboBox.currentText
model: jointNames model: jointNames
@ -247,9 +256,9 @@ Rectangle {
var properties = { var properties = {
parentJointIndex: currentIndex, parentJointIndex: currentIndex,
localPosition: { localPosition: {
x: position.xvalue, x: positionVector.xvalue,
y: position.yvalue, y: positionVector.yvalue,
z: position.zvalue z: positionVector.zvalue
} }
}; };
@ -288,8 +297,9 @@ Rectangle {
} }
Vector3 { Vector3 {
id: position id: positionVector
backgroundColor: "lightgray" backgroundColor: "lightgray"
enabled: getCurrentWearable() !== null
function set(localPosition) { function set(localPosition) {
notify = false; notify = false;
@ -347,8 +357,9 @@ Rectangle {
} }
Vector3 { Vector3 {
id: rotation id: rotationVector
backgroundColor: "lightgray" backgroundColor: "lightgray"
enabled: getCurrentWearable() !== null
function set(localRotationAngles) { function set(localRotationAngles) {
notify = false; notify = false;
@ -386,6 +397,7 @@ Rectangle {
HifiControlsUit.CheckBox { HifiControlsUit.CheckBox {
id: isSoft id: isSoft
enabled: getCurrentWearable() !== null
text: "Is soft" text: "Is soft"
labelFontSize: 15 labelFontSize: 15
labelFontWeight: Font.Bold labelFontWeight: Font.Bold
@ -427,13 +439,14 @@ Rectangle {
HifiControlsUit.SpinBox { HifiControlsUit.SpinBox {
id: scalespinner id: scalespinner
enabled: getCurrentWearable() !== null
decimals: 2 decimals: 2
realStepSize: 0.1 realStepSize: 0.1
realFrom: 0.1 realFrom: 0.1
realTo: 3.0 realTo: 3.0
realValue: 1.0 realValue: 1.0
backgroundColor: "lightgray" backgroundColor: "lightgray"
width: position.spinboxWidth width: positionVector.spinboxWidth
colorScheme: hifi.colorSchemes.light colorScheme: hifi.colorSchemes.light
property bool notify: false; property bool notify: false;

View file

@ -20,6 +20,7 @@ Row {
spacing: spinboxSpace spacing: spinboxSpace
property bool enabled: false;
property alias xvalue: xspinner.realValue property alias xvalue: xspinner.realValue
property alias yvalue: yspinner.realValue property alias yvalue: yspinner.realValue
property alias zvalue: zspinner.realValue property alias zvalue: zspinner.realValue
@ -35,6 +36,7 @@ Row {
realFrom: root.realFrom realFrom: root.realFrom
realTo: root.realTo realTo: root.realTo
realStepSize: root.realStepSize realStepSize: root.realStepSize
enabled: root.enabled
} }
HifiControlsUit.SpinBox { HifiControlsUit.SpinBox {
@ -48,6 +50,7 @@ Row {
realFrom: root.realFrom realFrom: root.realFrom
realTo: root.realTo realTo: root.realTo
realStepSize: root.realStepSize realStepSize: root.realStepSize
enabled: root.enabled
} }
HifiControlsUit.SpinBox { HifiControlsUit.SpinBox {
@ -61,5 +64,6 @@ Row {
realFrom: root.realFrom realFrom: root.realFrom
realTo: root.realTo realTo: root.realTo
realStepSize: root.realStepSize realStepSize: root.realStepSize
enabled: root.enabled
} }
} }