better calibrate button

This commit is contained in:
Dante Ruiz 2017-06-19 21:40:09 +01:00
parent da29157a3c
commit 734cde33e7
2 changed files with 148 additions and 25 deletions

View file

@ -9,6 +9,8 @@
import QtQuick 2.5 import QtQuick 2.5
import QtQuick.Controls 1.4 import QtQuick.Controls 1.4
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import QtQuick.Controls 1.4 as Original
import QtQuick.Controls.Styles 1.4
import "../../styles-uit" import "../../styles-uit"
import "../../controls" import "../../controls"
import "../../controls-uit" as HifiControls import "../../controls-uit" as HifiControls
@ -125,11 +127,20 @@ Rectangle {
text: "Tracker" text: "Tracker"
color: hifi.colors.lightGrayText color: hifi.colors.lightGrayText
} }
}
Row {
id: headOffsets
anchors.top: headConfig.bottom
anchors.topMargin: 5
anchors.left: openVrConfiguration.left
anchors.leftMargin: leftMargin + 10
spacing: 10
visible: headPuckBox.checked
HifiControls.SpinBox { HifiControls.SpinBox {
id: headYOffset id: headYOffset
decimals: 4 decimals: 4
width: 110 width: 112
label: "Y: offset" label: "Y: offset"
value: -0.0254 value: -0.0254
stepSize: 0.0254 stepSize: 0.0254
@ -142,7 +153,7 @@ Rectangle {
HifiControls.SpinBox { HifiControls.SpinBox {
id: headZOffset id: headZOffset
width: 105 width: 112
label: "Z: offset" label: "Z: offset"
value: -0.152 value: -0.152
stepSize: 0.0254 stepSize: 0.0254
@ -153,6 +164,7 @@ Rectangle {
} }
} }
} }
RalewayBold { RalewayBold {
id: hands id: hands
@ -162,8 +174,8 @@ Rectangle {
color: "white" color: "white"
anchors.top: headConfig.bottom anchors.top: (headOffsets.visible ? headOffsets.bottom : headConfig.bottom)
anchors.topMargin: 10 anchors.topMargin: (headOffsets.visible ? 22 : 10)
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: leftMargin anchors.leftMargin: leftMargin
} }
@ -219,11 +231,21 @@ Rectangle {
text: "Trackers" text: "Trackers"
color: hifi.colors.lightGrayText color: hifi.colors.lightGrayText
} }
}
Row {
id: handOffset
visible: handPuckBox.checked
anchors.top: handConfig.bottom
anchors.topMargin: 5
anchors.left: openVrConfiguration.left
anchors.leftMargin: leftMargin + 10
spacing: 10
HifiControls.SpinBox { HifiControls.SpinBox {
id: handYOffset id: handYOffset
decimals: 4 decimals: 4
width: 105 width: 112
label: "Y: offset" label: "Y: offset"
value: -0.0508 value: -0.0508
stepSize: 0.0254 stepSize: 0.0254
@ -236,7 +258,7 @@ Rectangle {
HifiControls.SpinBox { HifiControls.SpinBox {
id: handZOffset id: handZOffset
width: 105 width: 112
label: "Z: offset" label: "Z: offset"
value: -0.0254 value: -0.0254
stepSize: 0.0254 stepSize: 0.0254
@ -256,8 +278,8 @@ Rectangle {
color: hifi.colors.white color: hifi.colors.white
anchors.top: handConfig.bottom anchors.top: (handOffset.visible ? handOffset.bottom : handConfig.bottom)
anchors.topMargin: 10 anchors.topMargin: (handOffset.visible ? 22 : 10)
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: leftMargin anchors.leftMargin: leftMargin
} }
@ -412,23 +434,120 @@ Rectangle {
} }
HifiControls.Button {
Rectangle {
id: calibrationButton id: calibrationButton
color: hifi.buttons.blue property int color: hifi.buttons.blue
text: "Calibrate" property int colorScheme: hifi.colorSchemes.light
//glyph: hifi.glyphs.avatar1 property string glyph: hifi.glyphs.avatar1
property bool enabled: true
property bool pressed: false
property bool hovered: false
property int size: 32
property string text: "calibrate"
property int padding: 12
width: glyphButton.width + calibrationText.width + padding
height: hifi.dimensions.controlLineHeight
anchors.top: bottomSeperator.bottom anchors.top: bottomSeperator.bottom
anchors.topMargin: 10 anchors.topMargin: 10
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: leftMargin anchors.leftMargin: leftMargin
radius: hifi.buttons.radius
onClicked: { gradient: Gradient {
openVrConfiguration.countDown = timeToCalibrate.value; GradientStop {
numberAnimation.start(); position: 0.2
calibrationTimer.start(); color: {
info.visible = true; if (!calibrationButton.enabled) {
info.showCountDown = true; hifi.buttons.disabledColorStart[calibrationButton.colorScheme]
} else if (calibrationButton.pressed) {
hifi.buttons.pressedColor[calibrationButton.color]
} else if (calibrationButton.hovered) {
hifi.buttons.hoveredColor[calibrationButton.color]
} else {
hifi.buttons.colorStart[calibrationButton.color]
}
}
}
GradientStop {
position: 1.0
color: {
if (!calibrationButton.enabled) {
hifi.buttons.disabledColorFinish[calibrationButton.colorScheme]
} else if (calibrationButton.pressed) {
hifi.buttons.pressedColor[calibrationButton.color]
} else if (calibrationButton.hovered) {
hifi.buttons.hoveredColor[calibrationButton.color]
} else {
hifi.buttons.colorFinish[calibrationButton.color]
}
}
}
}
HiFiGlyphs {
id: glyphButton
color: enabled ? hifi.buttons.textColor[calibrationButton.color]
: hifi.buttons.disabledTextColor[calibrationButton.colorScheme]
text: calibrationButton.glyph
size: calibrationButton.size
anchors {
top: parent.top
bottom: parent.bottom
bottomMargin: 1
verticalCenter: parent.horizontalCenter
}
}
RalewayBold {
id: calibrationText
font.capitalization: Font.AllUppercase
color: enabled ? hifi.buttons.textColor[calibrationButton.color]
: hifi.buttons.disabledTextColor[calibrationButton.colorScheme]
size: hifi.fontSizes.buttonLabel
text: calibrationButton.text
anchors {
left: glyphButton.right
top: parent.top
topMargin: 7
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: {
openVrConfiguration.countDown = timeToCalibrate.value;
numberAnimation.start();
calibrationTimer.start();
info.visible = true;
info.showCountDown = true;
}
onPressed: {
calibrationButton.pressed = true;
}
onReleased: {
calibrationButton.pressed = false;
}
onEntered: {
calibrationButton.hovered = true;
}
onExited: {
calibrationButton.hovered = false;
}
} }
} }
@ -667,11 +786,11 @@ Rectangle {
var headSetting = settings["headConfiguration"]; var headSetting = settings["headConfiguration"];
var headOverride = headSetting["override"]; var headOverride = headSetting["override"];
var handSetting = settings["handConfiguration"]; var handSetting = settings["handConfiguration"];
var handOverride = settings["override"]; var handOverride = handSetting["override"];
var settingsChanged = false; var settingsChanged = false;
if (lastConfiguration["bodyConfiguration"]["override"] !== bodySetting["override"]) { if (lastConfiguration["bodyConfiguration"] !== bodySetting) {
settingsChanged = true; settingsChanged = true;
} }
@ -686,14 +805,17 @@ Rectangle {
} }
if (settingsChanged) { if (settingsChanged) {
if ((!handOverride) && (!headOverride) && (bodySetting === "Auto")) { if ((!handOverride) && (!headOverride) && (bodySetting === "None")) {
state = buttonState.apply; state = buttonState.apply;
console.log("apply");
} else { } else {
state = buttonState.applyAndCalibrate; state = buttonState.applyAndCalibrate;
console.log("apply and calibrate");
} }
} else { } else {
if (state == buttonState.apply) { if (state == buttonState.apply) {
state = buttonState.disabled; state = buttonState.disabled;
console.log("disable");
} }
} }
@ -768,6 +890,6 @@ Rectangle {
function sendConfigurationSettings() { function sendConfigurationSettings() {
var settings = composeConfigurationSettings(); var settings = composeConfigurationSettings();
InputConfiguration.setConfigurationSettings(settings, pluginName); InputConfiguration.setConfigurationSettings(settings, pluginName);
//updateCalibrationText(); updateCalibrationText();
} }
} }

View file

@ -345,7 +345,6 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso
bool overrideHands = handsObject["override"].toBool(); bool overrideHands = handsObject["override"].toBool();
if (overrideHands) { if (overrideHands) {
_handConfig = HandConfig::Pucks; _handConfig = HandConfig::Pucks;
qDebug() << "--------> configure hands <---------";
} else { } else {
_handConfig = HandConfig::HandController; _handConfig = HandConfig::HandController;
} }
@ -354,6 +353,8 @@ void ViveControllerManager::InputDevice::configureCalibrationSettings(const QJso
} }
} }
qDebug() << configToString(_preferedConfig);
saveSettings(); saveSettings();
} }