From 30dade242c5dc2fb6f13a41e4e5887aeb6838251 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Thu, 1 Dec 2016 14:53:18 -0800 Subject: [PATCH] GIFs: Quality improvements; duration tweaks; processing notif (#9139) --- .../src/scripting/WindowScriptingInterface.h | 1 + interface/src/ui/PreferencesDialog.cpp | 4 +-- interface/src/ui/SnapshotAnimated.cpp | 3 ++ interface/src/ui/SnapshotAnimated.h | 4 +-- scripts/system/notifications.js | 5 +++ scripts/system/snapshot.js | 36 ++++++++++++++----- 6 files changed, 41 insertions(+), 12 deletions(-) diff --git a/interface/src/scripting/WindowScriptingInterface.h b/interface/src/scripting/WindowScriptingInterface.h index 2e552d44d1..6aa8707496 100644 --- a/interface/src/scripting/WindowScriptingInterface.h +++ b/interface/src/scripting/WindowScriptingInterface.h @@ -62,6 +62,7 @@ signals: void domainConnectionRefused(const QString& reasonMessage, int reasonCode, const QString& extraInfo); void snapshotTaken(const QString& pathStillSnapshot, const QString& pathAnimatedSnapshot, bool notify); void snapshotShared(const QString& error); + void processingGif(); private: QString getPreviousBrowseLocation() const; diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index dea1c49346..e888419ace 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -105,8 +105,8 @@ void setupPreferences() { auto getter = []()->float { return SnapshotAnimated::snapshotAnimatedDuration.get(); }; auto setter = [](float value) { SnapshotAnimated::snapshotAnimatedDuration.set(value); }; auto preference = new SpinnerPreference(SNAPSHOTS, "Animated Snapshot Duration", getter, setter); - preference->setMin(3); - preference->setMax(10); + preference->setMin(1); + preference->setMax(5); preference->setStep(1); preferences->addPreference(preference); } diff --git a/interface/src/ui/SnapshotAnimated.cpp b/interface/src/ui/SnapshotAnimated.cpp index c8edbfc028..62dbc7aea4 100644 --- a/interface/src/ui/SnapshotAnimated.cpp +++ b/interface/src/ui/SnapshotAnimated.cpp @@ -92,6 +92,9 @@ void SnapshotAnimated::captureFrames() { SnapshotAnimated::snapshotAnimatedTimestamp = 0; SnapshotAnimated::snapshotAnimatedFirstFrameTimestamp = 0; + // Notify the user that we're processing the snapshot + emit SnapshotAnimated::snapshotAnimatedDM->processingGif(); + // Kick off the thread that'll pack the frames into the GIF QtConcurrent::run(processFrames); // Stop the snapshot QTimer. This action by itself DOES NOT GUARANTEE diff --git a/interface/src/ui/SnapshotAnimated.h b/interface/src/ui/SnapshotAnimated.h index 78b1529ab4..1cf21edfb8 100644 --- a/interface/src/ui/SnapshotAnimated.h +++ b/interface/src/ui/SnapshotAnimated.h @@ -21,8 +21,8 @@ #include "scripting/WindowScriptingInterface.h" // If the snapshot width or the framerate are too high for the -// application to handle, the framerate of the output GIF will drop. -#define SNAPSNOT_ANIMATED_WIDTH (480) +// computer to handle, the framerate of the output GIF will drop. +#define SNAPSNOT_ANIMATED_WIDTH (720) // This value should divide evenly into 100. Snapshot framerate is NOT guaranteed. #define SNAPSNOT_ANIMATED_TARGET_FRAMERATE (25) #define SNAPSNOT_ANIMATED_DURATION_SECS (3) diff --git a/scripts/system/notifications.js b/scripts/system/notifications.js index d2589cb72f..3ae071c7e3 100644 --- a/scripts/system/notifications.js +++ b/scripts/system/notifications.js @@ -532,6 +532,10 @@ function onSnapshotTaken(pathStillSnapshot, pathAnimatedSnapshot, notify) { } } +function processingGif() { + createNotification("Processing GIF snapshot...", NotificationType.SNAPSHOT); +} + // handles mouse clicks on buttons function mousePressEvent(event) { var pickRay, @@ -631,6 +635,7 @@ Script.scriptEnding.connect(scriptEnding); Menu.menuItemEvent.connect(menuItemEvent); Window.domainConnectionRefused.connect(onDomainConnectionRefused); Window.snapshotTaken.connect(onSnapshotTaken); +Window.processingGif.connect(processingGif); Window.notifyEditError = onEditError; setup(); diff --git a/scripts/system/snapshot.js b/scripts/system/snapshot.js index f78b7ec985..edc2eb6a20 100644 --- a/scripts/system/snapshot.js +++ b/scripts/system/snapshot.js @@ -156,19 +156,22 @@ function isDomainOpen(id) { } function resetButtons(pathStillSnapshot, pathAnimatedSnapshot, notify) { - // show hud - toolBar.writeProperty("visible", true); - Reticle.visible = reticleVisible; - + // If we're not taking an animated snapshot, we have to show the HUD. + // If we ARE taking an animated snapshot, we've already re-enabled the HUD by this point. + if (pathAnimatedSnapshot === "") { + // show hud + toolBar.writeProperty("visible", true); + Reticle.visible = reticleVisible; + // show overlays if they were on + if (resetOverlays) { + Menu.setIsOptionChecked("Overlays", true); + } + } // update button states button.writeProperty("buttonState", 1); button.writeProperty("defaultState", 1); button.writeProperty("hoverState", 3); Window.snapshotTaken.disconnect(resetButtons); - // show overlays if they were on - if (resetOverlays) { - Menu.setIsOptionChecked("Overlays", true); - } // A Snapshot Review dialog might be left open indefinitely after taking the picture, // during which time the user may have moved. So stash that info in the dialog so that @@ -187,13 +190,30 @@ function resetButtons(pathStillSnapshot, pathAnimatedSnapshot, notify) { } } +function processingGif() { + // show hud + toolBar.writeProperty("visible", true); + Reticle.visible = reticleVisible; + + // update button states + button.writeProperty("buttonState", 1); + button.writeProperty("defaultState", 1); + button.writeProperty("hoverState", 3); + // show overlays if they were on + if (resetOverlays) { + Menu.setIsOptionChecked("Overlays", true); + } +} + button.clicked.connect(onClicked); Window.snapshotShared.connect(snapshotShared); +Window.processingGif.connect(processingGif); Script.scriptEnding.connect(function () { toolBar.removeButton("snapshot"); button.clicked.disconnect(onClicked); Window.snapshotShared.disconnect(snapshotShared); + Window.processingGif.disconnect(processingGif); }); }()); // END LOCAL_SCOPE