Rearchitecture

This commit is contained in:
Zach Fox 2017-04-20 16:25:21 -07:00
parent 2880b22f9f
commit 16b4af8a9d
6 changed files with 95 additions and 107 deletions

View file

@ -6448,7 +6448,7 @@ void Application::takeSnapshot(bool notify, bool includeAnimated, float aspectRa
// Get a screenshot and save it // Get a screenshot and save it
QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio)); QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio));
// If we're not doing an animated snapshot as well... // If we're not doing an animated snapshot as well...
if (!includeAnimated || !(SnapshotAnimated::alsoTakeAnimatedSnapshot.get())) { if (!includeAnimated) {
// Tell the dependency manager that the capture of the still snapshot has taken place. // Tell the dependency manager that the capture of the still snapshot has taken place.
emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(path, notify); emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(path, notify);
} else { } else {

View file

@ -26,7 +26,7 @@
</head> </head>
<body> <body>
<div class="snapsection title"> <div class="title">
<label>Snap</label> <label>Snap</label>
<label id="settingsLabel" for="snapshotSettings">Settings</label> <label id="settingsLabel" for="snapshotSettings">Settings</label>
<input type="button" class="hifi-glyph naked" id="snapshotSettings" value="@" onclick="snapshotSettings()" /> <input type="button" class="hifi-glyph naked" id="snapshotSettings" value="@" onclick="snapshotSettings()" />
@ -40,7 +40,7 @@
<div id="snap-settings"> <div id="snap-settings">
<label>CAMERA CAPTURES</label><br /> <label>CAMERA CAPTURES</label><br />
<form action=""> <form action="">
<input type="radio" name="cameraCaptures" id="stillAndGif" value="stillAndGif" checked="checked" /> <input type="radio" name="cameraCaptures" id="stillAndGif" value="stillAndGif" />
<label for="stillAndGif">Still + GIF</label><br /> <label for="stillAndGif">Still + GIF</label><br />
<input type="radio" name="cameraCaptures" id="stillOnly" value="stillOnly" /> <input type="radio" name="cameraCaptures" id="stillOnly" value="stillOnly" />
<label for="stillOnly">Still Only</label> <label for="stillOnly">Still Only</label>

View file

@ -16,41 +16,34 @@ body {
/* /*
// START styling of top bar and its contents // START styling of top bar and its contents
*/ */
.snapsection {
padding-left: 8px;
padding-right: 8px;
padding-top: 12px;
margin: 8px;
}
.snapsection.title { .title {
padding-top: 0; padding: 6px 10px;
text-align: left; text-align: left;
height: 24px; height: 20px;
line-height: 20px;
clear: both; clear: both;
} }
.title label { .title label {
position: relative; position: relative;
top: 10px;
font-size: 18px; font-size: 18px;
float: left; float: left;
} }
#snapshotSettings { #snapshotSettings {
position: relative; position: relative;
top: 4px;
float: right; float: right;
} }
#settingsLabel { #settingsLabel {
position: relative; position: relative;
float: right; float: right;
top: 12px;
font-family: Raleway-SemiBold; font-family: Raleway-SemiBold;
font-size: 14px; font-size: 14px;
} }
.hifi-glyph { .hifi-glyph {
font-size: 30px; font-size: 30px;
top: -7px;
} }
input[type=button].naked { input[type=button].naked {
color: #afafaf; color: #afafaf;
@ -71,7 +64,7 @@ input[type=button].naked:active {
*/ */
#snapshot-pane { #snapshot-pane {
width: 100%; width: 100%;
height: 510px; height: 574px;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
@ -169,17 +162,13 @@ input[type=button].naked:active {
width: 100%; width: 100%;
position: absolute; position: absolute;
left: 0; left: 0;
bottom: 14px; margin-top: 8px;
margin-bottom: 4px;
overflow: hidden; overflow: hidden;
} }
#snap-settings { #snap-settings {
float: left; float: left;
margin-left: 10px; margin-left: 10px;
} }
#snap-settings label {
height: 50px;
}
#snap-settings form input { #snap-settings form input {
margin-bottom: 10px; margin-bottom: 10px;
} }

View file

@ -77,9 +77,13 @@ body {
hr { hr {
border: none; border: none;
background: #404040 url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAjSURBVBhXY1RVVf3PgARYjIyMoEwIYHRwcEBRwQSloYCBAQCwjgPMiI7W2QAAAABJRU5ErkJggg==) repeat-x top left; background: #404040 url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAAjSURBVBhXY1RVVf3PgARYjIyMoEwIYHRwcEBRwQSloYCBAQCwjgPMiI7W2QAAAABJRU5ErkJggg==) repeat-x top left;
padding: 1px;
-webkit-margin-before: 0;
-webkit-margin-after: 0;
-webkit-margin-start: 0;
-webkit-margin-end: 0;
width: 100%; width: 100%;
margin: 21px -21px 0 -21px; position: absolute;
padding: 14px 21px 0 21px;
} }
.hifi-glyph { .hifi-glyph {

View file

@ -149,40 +149,25 @@ function handleCaptureSetting(setting) {
stillAndGif.onclick = function () { stillAndGif.onclick = function () {
EventBridge.emitWebEvent(JSON.stringify({ EventBridge.emitWebEvent(JSON.stringify({
type: "captureSettings", type: "snapshot",
action: true action: "captureStillAndGif"
})); }));
} }
stillOnly.onclick = function () { stillOnly.onclick = function () {
EventBridge.emitWebEvent(JSON.stringify({
type: "captureSettings",
action: false
}));
}
}
function handleShareButtons(messageOptions) {
var openFeed = document.getElementById('openFeed');
openFeed.checked = messageOptions.openFeedAfterShare;
openFeed.onchange = function () {
EventBridge.emitWebEvent(JSON.stringify({ EventBridge.emitWebEvent(JSON.stringify({
type: "snapshot", type: "snapshot",
action: (openFeed.checked ? "setOpenFeedTrue" : "setOpenFeedFalse") action: "captureStillOnly"
})); }));
};
if (!messageOptions.canShare) {
// this means you may or may not be logged in, but can't share
// because you are not in a public place.
document.getElementById("sharing").innerHTML = "<p class='prompt'>Snapshots can be shared when they're taken in shareable places.";
} }
} }
window.onload = function () { window.onload = function () {
// TESTING FUNCTIONS START // TESTING FUNCTIONS START
// Uncomment and modify the lines below to test SnapshotReview in a browser. // Uncomment and modify the lines below to test SnapshotReview in a browser.
imageCount = 2; //imageCount = 2;
addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/2017-01-27 50 Avatars!/!!!.gif' }); //addImage({ localPath: 'C:/Users/Zach Fox/Desktop/hifi-snap-by-zfox-on-2017-04-20_14-59-12.gif' });
addImage({ localPath: 'http://lorempixel.com/553/255' }); //addImage({ localPath: 'C:/Users/Zach Fox/Desktop/hifi-snap-by-zfox-on-2017-04-20_14-59-12.jpg' });
//addImage({ localPath: 'http://lorempixel.com/553/255' });
//addImage({localPath: 'c:/Users/howar/OneDrive/Pictures/hifi-snap-by--on-2016-07-27_12-58-43.jpg'}); //addImage({localPath: 'c:/Users/howar/OneDrive/Pictures/hifi-snap-by--on-2016-07-27_12-58-43.jpg'});
// TESTING FUNCTIONS END // TESTING FUNCTIONS END
@ -192,36 +177,42 @@ window.onload = function () {
message = JSON.parse(message); message = JSON.parse(message);
switch (message.type) { if (message.type !== "snapshot") {
case 'snapshot': return;
}
switch (message.action) {
case 'addImages':
// The last element of the message contents list contains a bunch of options, // The last element of the message contents list contains a bunch of options,
// including whether or not we can share stuff // including whether or not we can share stuff
// The other elements of the list contain image paths. // The other elements of the list contain image paths.
var messageOptions = message.action.pop(); var messageOptions = message.options;
handleShareButtons(messageOptions);
if (messageOptions.containsGif) { if (messageOptions.containsGif) {
if (messageOptions.processingGif) { if (messageOptions.processingGif) {
imageCount = message.action.length + 1; // "+1" for the GIF that'll finish processing soon imageCount = message.data.length + 1; // "+1" for the GIF that'll finish processing soon
message.action.unshift({ localPath: messageOptions.loadingGifPath }); message.data.unshift({ localPath: messageOptions.loadingGifPath });
message.action.forEach(addImage); message.data.forEach(addImage);
} else { } else {
var gifPath = message.action[0].localPath; var gifPath = message.data[0].localPath;
document.getElementById('p0img').src = gifPath; document.getElementById('p0img').src = gifPath;
paths[0].localPath = gifPath; paths[0].localPath = gifPath;
} }
} else { } else {
imageCount = message.action.length; imageCount = message.data.length;
message.action.forEach(addImage); message.data.forEach(addImage);
} }
break; break;
case 'snapshotSettings': case 'captureSettings':
handleCaptureSetting(message.action); handleCaptureSetting(message.setting);
break; break;
default: default:
return; print("Unknown message action received in SnapshotReview.js.");
break;
} }
}); });
EventBridge.emitWebEvent(JSON.stringify({ EventBridge.emitWebEvent(JSON.stringify({
type: "snapshot", type: "snapshot",
action: "ready" action: "ready"

View file

@ -43,7 +43,8 @@ function showFeedWindow() {
} }
var outstanding; var outstanding;
var readyData; var snapshotOptions;
var imageData;
var shareAfterLogin = false; var shareAfterLogin = false;
var snapshotToShareAfterLogin; var snapshotToShareAfterLogin;
function onMessage(message) { function onMessage(message) {
@ -62,12 +63,15 @@ function onMessage(message) {
switch (message.action) { switch (message.action) {
case 'ready': // Send it. case 'ready': // Send it.
tablet.emitScriptEvent(JSON.stringify({ tablet.emitScriptEvent(JSON.stringify({
type: "snapshotSettings", type: "snapshot",
action: Settings.getValue("alsoTakeAnimatedSnapshot", true) action: "captureSettings",
setting: Settings.getValue("alsoTakeAnimatedSnapshot", true)
})); }));
tablet.emitScriptEvent(JSON.stringify({ tablet.emitScriptEvent(JSON.stringify({
type: "snapshot", type: "snapshot",
action: readyData action: "addImages",
options: snapshotOptions,
data: imageData
})); }));
outstanding = 0; outstanding = 0;
break; break;
@ -79,20 +83,19 @@ function onMessage(message) {
tablet.loadQMLOnTop("TabletGeneralPreferences.qml"); tablet.loadQMLOnTop("TabletGeneralPreferences.qml");
} }
break; break;
case 'captureSettings': case 'captureStillAndGif':
Settings.setValue("alsoTakeAnimatedSnapshot", message.action); print("Changing Snapshot Capture Settings to Capture Still + GIF");
Settings.setValue("alsoTakeAnimatedSnapshot", true);
break;
case 'captureStillOnly':
print("Changing Snapshot Capture Settings to Capture Still Only");
Settings.setValue("alsoTakeAnimatedSnapshot", false);
break; break;
case 'takeSnapshot': case 'takeSnapshot':
// In settings, first store the paths to the last snapshot // In settings, first store the paths to the last snapshot
// //
onClicked(); onClicked();
break; break;
case 'setOpenFeedFalse':
Settings.setValue('openFeedAfterShare', false);
break;
case 'setOpenFeedTrue':
Settings.setValue('openFeedAfterShare', true);
break;
default: default:
//tablet.webEventReceived.disconnect(onMessage); // <<< It's probably this that's missing?! //tablet.webEventReceived.disconnect(onMessage); // <<< It's probably this that's missing?!
HMD.closeTablet(); HMD.closeTablet();
@ -135,9 +138,8 @@ function onMessage(message) {
var SNAPSHOT_REVIEW_URL = Script.resolvePath("html/SnapshotReview.html"); var SNAPSHOT_REVIEW_URL = Script.resolvePath("html/SnapshotReview.html");
var isInSnapshotReview = false; var isInSnapshotReview = false;
function confirmShare(data) { function reviewSnapshot() {
tablet.gotoWebScreen(SNAPSHOT_REVIEW_URL); tablet.gotoWebScreen(SNAPSHOT_REVIEW_URL);
readyData = data;
tablet.webEventReceived.connect(onMessage); tablet.webEventReceived.connect(onMessage);
HMD.openTablet(); HMD.openTablet();
isInSnapshotReview = true; isInSnapshotReview = true;
@ -182,7 +184,7 @@ function onClicked() {
Script.setTimeout(function () { Script.setTimeout(function () {
HMD.closeTablet(); HMD.closeTablet();
Script.setTimeout(function () { Script.setTimeout(function () {
Window.takeSnapshot(false, true, 1.91); Window.takeSnapshot(false, Settings.getValue("alsoTakeAnimatedSnapshot", true), 1.91);
}, SNAPSHOT_DELAY); }, SNAPSHOT_DELAY);
}, FINISH_SOUND_DELAY); }, FINISH_SOUND_DELAY);
} }
@ -220,15 +222,14 @@ function stillSnapshotTaken(pathStillSnapshot, notify) {
// during which time the user may have moved. So stash that info in the dialog so that // during which time the user may have moved. So stash that info in the dialog so that
// it records the correct href. (We can also stash in .jpegs, but not .gifs.) // it records the correct href. (We can also stash in .jpegs, but not .gifs.)
// last element in data array tells dialog whether we can share or not // last element in data array tells dialog whether we can share or not
var confirmShareContents = [ snapshotOptions = {
{ localPath: pathStillSnapshot, href: href }, containsGif: false,
{ processingGif: false,
containsGif: false, canShare: !!isDomainOpen(domainId),
processingGif: false, openFeedAfterShare: shouldOpenFeedAfterShare()
canShare: !!isDomainOpen(domainId), };
openFeedAfterShare: shouldOpenFeedAfterShare() imageData = [{ localPath: pathStillSnapshot, href: href }];
}]; reviewSnapshot();
confirmShare(confirmShareContents);
if (clearOverlayWhenMoving) { if (clearOverlayWhenMoving) {
MyAvatar.setClearOverlayWhenMoving(true); // not until after the share dialog MyAvatar.setClearOverlayWhenMoving(true); // not until after the share dialog
} }
@ -237,8 +238,10 @@ function stillSnapshotTaken(pathStillSnapshot, notify) {
function processingGifStarted(pathStillSnapshot) { function processingGifStarted(pathStillSnapshot) {
Window.processingGifStarted.disconnect(processingGifStarted); Window.processingGifStarted.disconnect(processingGifStarted);
button.clicked.disconnect(onClicked); if (buttonConnected) {
buttonConnected = false; button.clicked.disconnect(onClicked);
buttonConnected = false;
}
// show hud // show hud
Reticle.visible = reticleVisible; Reticle.visible = reticleVisible;
// show overlays if they were on // show overlays if they were on
@ -246,16 +249,15 @@ function processingGifStarted(pathStillSnapshot) {
Menu.setIsOptionChecked("Overlays", true); Menu.setIsOptionChecked("Overlays", true);
} }
var confirmShareContents = [ snapshotOptions = {
{ localPath: pathStillSnapshot, href: href }, containsGif: true,
{ processingGif: true,
containsGif: true, loadingGifPath: Script.resolvePath(Script.resourcesPath() + 'icons/loadingDark.gif'),
processingGif: true, canShare: !!isDomainOpen(domainId),
loadingGifPath: Script.resolvePath(Script.resourcesPath() + 'icons/loadingDark.gif'), openFeedAfterShare: shouldOpenFeedAfterShare()
canShare: !!isDomainOpen(domainId), };
openFeedAfterShare: shouldOpenFeedAfterShare() imageData = [{ localPath: pathStillSnapshot, href: href }];
}]; reviewSnapshot();
confirmShare(confirmShareContents);
if (clearOverlayWhenMoving) { if (clearOverlayWhenMoving) {
MyAvatar.setClearOverlayWhenMoving(true); // not until after the share dialog MyAvatar.setClearOverlayWhenMoving(true); // not until after the share dialog
} }
@ -264,22 +266,24 @@ function processingGifStarted(pathStillSnapshot) {
function processingGifCompleted(pathAnimatedSnapshot) { function processingGifCompleted(pathAnimatedSnapshot) {
Window.processingGifCompleted.disconnect(processingGifCompleted); Window.processingGifCompleted.disconnect(processingGifCompleted);
button.clicked.connect(onClicked); if (!buttonConnected) {
buttonConnected = true; button.clicked.connect(onClicked);
buttonConnected = true;
}
var confirmShareContents = [ snapshotOptions = {
{ localPath: pathAnimatedSnapshot, href: href }, containsGif: true,
{ processingGif: false,
containsGif: true, canShare: !!isDomainOpen(domainId),
processingGif: false, openFeedAfterShare: shouldOpenFeedAfterShare()
canShare: !!isDomainOpen(domainId), }
openFeedAfterShare: shouldOpenFeedAfterShare() imageData = [{ localPath: pathAnimatedSnapshot, href: href }];
}];
readyData = confirmShareContents;
tablet.emitScriptEvent(JSON.stringify({ tablet.emitScriptEvent(JSON.stringify({
type: "snapshot", type: "snapshot",
action: readyData action: "addImages",
options: snapshotOptions,
data: imageData
})); }));
} }