From 19bff20ebffdd457c8ed97814b2c29374cc0be67 Mon Sep 17 00:00:00 2001 From: Faye Li Date: Wed, 15 Feb 2017 16:19:56 -0800 Subject: [PATCH] event handling - can now load models --- .../render/photobooth/html/photobooth.html | 12 +++- .../render/photobooth/photoboothApp.js | 62 +++++++------------ 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/scripts/developer/utilities/render/photobooth/html/photobooth.html b/scripts/developer/utilities/render/photobooth/html/photobooth.html index 0250084a54..6165896bf0 100644 --- a/scripts/developer/utilities/render/photobooth/html/photobooth.html +++ b/scripts/developer/utilities/render/photobooth/html/photobooth.html @@ -93,13 +93,19 @@ elPictureButton.addEventListener('click', function() { emit("onClickPictureButton", {value: "faye"}); }); - - }); + } $(document).ready(function() { // Send a ready event to hifi emit("ready", null); - + // Send an event to hifi to trigger snapshot + $("#picture-button").click(function() { + emit("onClickPictureButton", null); + }); + // Send an event to hifi for loading the given model URL + $("#reload-model-button").click(function() { + emit("onClickReloadModelButton", {value: $("#model-url").val()}); + }); }); diff --git a/scripts/developer/utilities/render/photobooth/photoboothApp.js b/scripts/developer/utilities/render/photobooth/photoboothApp.js index ca298d00de..c32744fe63 100644 --- a/scripts/developer/utilities/render/photobooth/photoboothApp.js +++ b/scripts/developer/utilities/render/photobooth/photoboothApp.js @@ -34,7 +34,29 @@ event = JSON.parse(event); } if (event.app === "photobooth") { - + if (event.type === "onClickPictureButton") { + print("clicked picture button"); + // // hide HUD tool bar + // toolbar.writeProperty("visible", false); + // // hide Overlays (such as Running Scripts or other Dialog UI) + // Menu.setIsOptionChecked("Overlays", false); + // // hide mouse cursor + // Reticle.visible = false; + // // giving a delay here before snapshotting so that there is time to hide toolbar and other UIs + // // void WindowScriptingInterface::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio) + // Script.setTimeout(function () { + // Window.takeSnapshot(false, false, 1.91); + // // show hidden items after snapshot is taken + // toolbar.writeProperty("visible", true); + // Menu.setIsOptionChecked("Overlays", true); + // // unknown issue: somehow we don't need to reset cursor to visible in script and the mouse still returns after snapshot + // // Reticle.visible = true; + // }, SNAPSHOT_DELAY); + + } else if (event.type === "onClickReloadModelButton"){ + print("clicked reload model button " + event.data.value); + PhotoBooth.changeModel(event.data.value); + } } } @@ -131,12 +153,6 @@ var main = function () { var photoboothWindowListener = {}; - photoboothWindowListener.onLoad = function (event) { - print("loaded" + event.value); - if (!event.hasOwnProperty("value")){ - return; - } - }; photoboothWindowListener.onSelectCamera = function (event) { print("selected camera " + event.value); @@ -151,38 +167,6 @@ Camera.setCameraEntity(cameraID); } }; - - photoboothWindowListener.onSelectLightingPreset = function (event) { - print("selected lighting preset" + event.value); - if (!event.hasOwnProperty("value")){ - return; - } - }; - - photoboothWindowListener.onClickPictureButton = function (event) { - print("clicked picture button"); - // hide HUD tool bar - toolbar.writeProperty("visible", false); - // hide Overlays (such as Running Scripts or other Dialog UI) - Menu.setIsOptionChecked("Overlays", false); - // hide mouse cursor - Reticle.visible = false; - // giving a delay here before snapshotting so that there is time to hide toolbar and other UIs - // void WindowScriptingInterface::takeSnapshot(bool notify, bool includeAnimated, float aspectRatio) - Script.setTimeout(function () { - Window.takeSnapshot(false, false, 1.91); - // show hidden items after snapshot is taken - toolbar.writeProperty("visible", true); - Menu.setIsOptionChecked("Overlays", true); - // unknown issue: somehow we don't need to reset cursor to visible in script and the mouse still returns after snapshot - // Reticle.visible = true; - }, SNAPSHOT_DELAY); - }; - - photoboothWindowListener.onClickReloadModelButton = function (event) { - print("clicked reload model button " + event.value); - PhotoBooth.changeModel(event.value); - }; }; main();