When a display texture isn't set, show preview instructions

This commit is contained in:
Zach Fox 2017-07-05 12:22:16 -07:00
parent 8c0697f26b
commit aea5779ed6
2 changed files with 36 additions and 15 deletions

View file

@ -217,39 +217,57 @@ Rectangle {
} }
} }
// Spectator Camera Preview // Instructions or Preview
Hifi.ResourceImageItem { Item {
id: spectatorCameraPreview; id: spectatorCameraImageContainer;
url: "resource://spectatorCameraFrame";
ready: cameraToggleCheckBox.checked;
mirrorVertically: true;
height: 250;
anchors.left: parent.left; anchors.left: parent.left;
anchors.top: cameraToggleCheckBox.bottom; anchors.top: cameraToggleCheckBox.bottom;
anchors.topMargin: 20; anchors.topMargin: 20;
anchors.right: parent.right; anchors.right: parent.right;
onVisibleChanged: { height: 250;
ready = cameraToggleCheckBox.checked;
update(); // Instructions (visible when display texture isn't set)
Image {
id: spectatorCameraInstructions;
visible: !spectatorCameraPreview.visible;
anchors.fill: parent;
fillMode: Image.PreserveAspectFit;
horizontalAlignment: Image.AlignHCenter;
verticalAlignment: Image.AlignVCenter;
source: "http://1.bp.blogspot.com/-1GABEq__054/T03B00j_OII/AAAAAAAAAa8/jo55LcvEPHI/s1600/Winning.jpg";
}
// Spectator Camera Preview
Hifi.ResourceImageItem {
id: spectatorCameraPreview;
visible: false;
url: "resource://spectatorCameraFrame";
ready: cameraToggleCheckBox.checked;
mirrorVertically: true;
anchors.fill: parent;
onVisibleChanged: {
ready = cameraToggleCheckBox.checked;
update();
}
} }
} }
// "Monitor Shows" Switch Label Glyph // "Monitor Shows" Switch Label Glyph
HiFiGlyphs { HiFiGlyphs {
id: monitorShowsSwitchLabelGlyph; id: monitorShowsSwitchLabelGlyph;
text: hifi.glyphs.screen; text: hifi.glyphs.screen;
size: 32; size: 32;
color: hifi.colors.blueHighlight; color: hifi.colors.blueHighlight;
anchors.top: spectatorCameraPreview.bottom; anchors.top: spectatorCameraImageContainer.bottom;
anchors.topMargin: 20; anchors.topMargin: 13;
anchors.left: parent.left; anchors.left: parent.left;
} }
// "Monitor Shows" Switch Label // "Monitor Shows" Switch Label
RalewayLight { RalewayLight {
id: monitorShowsSwitchLabel; id: monitorShowsSwitchLabel;
text: "MONITOR SHOWS:"; text: "MONITOR SHOWS:";
anchors.top: spectatorCameraPreview.bottom; anchors.top: spectatorCameraImageContainer.bottom;
anchors.topMargin: 20; anchors.topMargin: 20;
anchors.left: monitorShowsSwitchLabelGlyph.right; anchors.left: monitorShowsSwitchLabelGlyph.right;
anchors.leftMargin: 6; anchors.leftMargin: 6;
@ -330,6 +348,9 @@ Rectangle {
switchViewFromControllerCheckBox.enabled = false; switchViewFromControllerCheckBox.enabled = false;
} }
break; break;
case 'showPreviewTextureNotInstructions':
spectatorCameraPreview.visible = message.setting;
break;
default: default:
console.log('Unrecognized message from spectatorCamera.js:', JSON.stringify(message)); console.log('Unrecognized message from spectatorCamera.js:', JSON.stringify(message));
} }

View file

@ -217,8 +217,8 @@
// 3. Camera is on; "Monitor Shows" is "HMD Preview": "url" is "" // 3. Camera is on; "Monitor Shows" is "HMD Preview": "url" is ""
// 4. Camera is on; "Monitor Shows" is "Camera View": "url" is "resource://spectatorCameraFrame" // 4. Camera is on; "Monitor Shows" is "Camera View": "url" is "resource://spectatorCameraFrame"
function setDisplay(showCameraView) { function setDisplay(showCameraView) {
// It would be fancy if the app would show instructions when (url === ""), but that's out of scope for now.
var url = (camera && showCameraView) ? "resource://spectatorCameraFrame" : ""; var url = (camera && showCameraView) ? "resource://spectatorCameraFrame" : "";
sendToQml({ method: 'showPreviewTextureNotInstructions', setting: !!url });
Window.setDisplayTexture(url); Window.setDisplayTexture(url);
} }
const MONITOR_SHOWS_CAMERA_VIEW_DEFAULT = false; const MONITOR_SHOWS_CAMERA_VIEW_DEFAULT = false;