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
QString path = Snapshot::saveSnapshot(getActiveDisplayPlugin()->getScreenshot(aspectRatio));
// 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.
emit DependencyManager::get<WindowScriptingInterface>()->stillSnapshotTaken(path, notify);
} else {

View file

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

View file

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

View file

@ -77,9 +77,13 @@ body {
hr {
border: none;
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%;
margin: 21px -21px 0 -21px;
padding: 14px 21px 0 21px;
position: absolute;
}
.hifi-glyph {

View file

@ -149,40 +149,25 @@ function handleCaptureSetting(setting) {
stillAndGif.onclick = function () {
EventBridge.emitWebEvent(JSON.stringify({
type: "captureSettings",
action: true
type: "snapshot",
action: "captureStillAndGif"
}));
}
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({
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 () {
// TESTING FUNCTIONS START
// Uncomment and modify the lines below to test SnapshotReview in a browser.
imageCount = 2;
addImage({ localPath: 'D:/Dropbox/Screenshots/High Fidelity Snapshots/2017-01-27 50 Avatars!/!!!.gif' });
addImage({ localPath: 'http://lorempixel.com/553/255' });
//imageCount = 2;
//addImage({ localPath: 'C:/Users/Zach Fox/Desktop/hifi-snap-by-zfox-on-2017-04-20_14-59-12.gif' });
//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'});
// TESTING FUNCTIONS END
@ -192,36 +177,42 @@ window.onload = function () {
message = JSON.parse(message);
switch (message.type) {
case 'snapshot':
if (message.type !== "snapshot") {
return;
}
switch (message.action) {
case 'addImages':
// The last element of the message contents list contains a bunch of options,
// including whether or not we can share stuff
// The other elements of the list contain image paths.
var messageOptions = message.action.pop();
handleShareButtons(messageOptions);
var messageOptions = message.options;
if (messageOptions.containsGif) {
if (messageOptions.processingGif) {
imageCount = message.action.length + 1; // "+1" for the GIF that'll finish processing soon
message.action.unshift({ localPath: messageOptions.loadingGifPath });
message.action.forEach(addImage);
imageCount = message.data.length + 1; // "+1" for the GIF that'll finish processing soon
message.data.unshift({ localPath: messageOptions.loadingGifPath });
message.data.forEach(addImage);
} else {
var gifPath = message.action[0].localPath;
var gifPath = message.data[0].localPath;
document.getElementById('p0img').src = gifPath;
paths[0].localPath = gifPath;
}
} else {
imageCount = message.action.length;
message.action.forEach(addImage);
imageCount = message.data.length;
message.data.forEach(addImage);
}
break;
case 'snapshotSettings':
handleCaptureSetting(message.action);
case 'captureSettings':
handleCaptureSetting(message.setting);
break;
default:
return;
print("Unknown message action received in SnapshotReview.js.");
break;
}
});
EventBridge.emitWebEvent(JSON.stringify({
type: "snapshot",
action: "ready"

View file

@ -43,7 +43,8 @@ function showFeedWindow() {
}
var outstanding;
var readyData;
var snapshotOptions;
var imageData;
var shareAfterLogin = false;
var snapshotToShareAfterLogin;
function onMessage(message) {
@ -62,12 +63,15 @@ function onMessage(message) {
switch (message.action) {
case 'ready': // Send it.
tablet.emitScriptEvent(JSON.stringify({
type: "snapshotSettings",
action: Settings.getValue("alsoTakeAnimatedSnapshot", true)
type: "snapshot",
action: "captureSettings",
setting: Settings.getValue("alsoTakeAnimatedSnapshot", true)
}));
tablet.emitScriptEvent(JSON.stringify({
type: "snapshot",
action: readyData
action: "addImages",
options: snapshotOptions,
data: imageData
}));
outstanding = 0;
break;
@ -79,20 +83,19 @@ function onMessage(message) {
tablet.loadQMLOnTop("TabletGeneralPreferences.qml");
}
break;
case 'captureSettings':
Settings.setValue("alsoTakeAnimatedSnapshot", message.action);
case 'captureStillAndGif':
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;
case 'takeSnapshot':
// In settings, first store the paths to the last snapshot
//
onClicked();
break;
case 'setOpenFeedFalse':
Settings.setValue('openFeedAfterShare', false);
break;
case 'setOpenFeedTrue':
Settings.setValue('openFeedAfterShare', true);
break;
default:
//tablet.webEventReceived.disconnect(onMessage); // <<< It's probably this that's missing?!
HMD.closeTablet();
@ -135,9 +138,8 @@ function onMessage(message) {
var SNAPSHOT_REVIEW_URL = Script.resolvePath("html/SnapshotReview.html");
var isInSnapshotReview = false;
function confirmShare(data) {
function reviewSnapshot() {
tablet.gotoWebScreen(SNAPSHOT_REVIEW_URL);
readyData = data;
tablet.webEventReceived.connect(onMessage);
HMD.openTablet();
isInSnapshotReview = true;
@ -182,7 +184,7 @@ function onClicked() {
Script.setTimeout(function () {
HMD.closeTablet();
Script.setTimeout(function () {
Window.takeSnapshot(false, true, 1.91);
Window.takeSnapshot(false, Settings.getValue("alsoTakeAnimatedSnapshot", true), 1.91);
}, SNAPSHOT_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
// 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
var confirmShareContents = [
{ localPath: pathStillSnapshot, href: href },
{
containsGif: false,
processingGif: false,
canShare: !!isDomainOpen(domainId),
openFeedAfterShare: shouldOpenFeedAfterShare()
}];
confirmShare(confirmShareContents);
snapshotOptions = {
containsGif: false,
processingGif: false,
canShare: !!isDomainOpen(domainId),
openFeedAfterShare: shouldOpenFeedAfterShare()
};
imageData = [{ localPath: pathStillSnapshot, href: href }];
reviewSnapshot();
if (clearOverlayWhenMoving) {
MyAvatar.setClearOverlayWhenMoving(true); // not until after the share dialog
}
@ -237,8 +238,10 @@ function stillSnapshotTaken(pathStillSnapshot, notify) {
function processingGifStarted(pathStillSnapshot) {
Window.processingGifStarted.disconnect(processingGifStarted);
button.clicked.disconnect(onClicked);
buttonConnected = false;
if (buttonConnected) {
button.clicked.disconnect(onClicked);
buttonConnected = false;
}
// show hud
Reticle.visible = reticleVisible;
// show overlays if they were on
@ -246,16 +249,15 @@ function processingGifStarted(pathStillSnapshot) {
Menu.setIsOptionChecked("Overlays", true);
}
var confirmShareContents = [
{ localPath: pathStillSnapshot, href: href },
{
containsGif: true,
processingGif: true,
loadingGifPath: Script.resolvePath(Script.resourcesPath() + 'icons/loadingDark.gif'),
canShare: !!isDomainOpen(domainId),
openFeedAfterShare: shouldOpenFeedAfterShare()
}];
confirmShare(confirmShareContents);
snapshotOptions = {
containsGif: true,
processingGif: true,
loadingGifPath: Script.resolvePath(Script.resourcesPath() + 'icons/loadingDark.gif'),
canShare: !!isDomainOpen(domainId),
openFeedAfterShare: shouldOpenFeedAfterShare()
};
imageData = [{ localPath: pathStillSnapshot, href: href }];
reviewSnapshot();
if (clearOverlayWhenMoving) {
MyAvatar.setClearOverlayWhenMoving(true); // not until after the share dialog
}
@ -264,22 +266,24 @@ function processingGifStarted(pathStillSnapshot) {
function processingGifCompleted(pathAnimatedSnapshot) {
Window.processingGifCompleted.disconnect(processingGifCompleted);
button.clicked.connect(onClicked);
buttonConnected = true;
if (!buttonConnected) {
button.clicked.connect(onClicked);
buttonConnected = true;
}
var confirmShareContents = [
{ localPath: pathAnimatedSnapshot, href: href },
{
containsGif: true,
processingGif: false,
canShare: !!isDomainOpen(domainId),
openFeedAfterShare: shouldOpenFeedAfterShare()
}];
readyData = confirmShareContents;
snapshotOptions = {
containsGif: true,
processingGif: false,
canShare: !!isDomainOpen(domainId),
openFeedAfterShare: shouldOpenFeedAfterShare()
}
imageData = [{ localPath: pathAnimatedSnapshot, href: href }];
tablet.emitScriptEvent(JSON.stringify({
type: "snapshot",
action: readyData
action: "addImages",
options: snapshotOptions,
data: imageData
}));
}