From e53b38e497a5a8547edbedfbee5af5718b065d8f Mon Sep 17 00:00:00 2001 From: Thijs Wenker Date: Mon, 9 Feb 2015 17:16:54 +0100 Subject: [PATCH] style / make sure the magnifier isn't rendered when we don't want it --- examples/controllers/oculus/goTo.js | 62 +++++++++++++++++-------- interface/src/ui/ApplicationOverlay.cpp | 3 ++ 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/examples/controllers/oculus/goTo.js b/examples/controllers/oculus/goTo.js index 9f3daaea42..c991d97fda 100644 --- a/examples/controllers/oculus/goTo.js +++ b/examples/controllers/oculus/goTo.js @@ -51,10 +51,12 @@ function Instructions(imageURL, originalWidth, originalHeight) { } tthis.remove(); } + this.remove = function() { Overlays.deleteOverlay(tthis.overlay); tthis.visible = false; }; + this.rescale = function() { var scale = Math.min(windowDimensions.x / tthis.originalSize.w, windowDimensions.y / tthis.originalSize.h); var newWidth = tthis.originalSize.w * scale; @@ -115,14 +117,14 @@ keyboard.onKeyRelease = function(event) { // you can cancel a key by releasing its focusing before releasing it if (event.focus) { if (event.event == 'delete') { - deleteChar(); + deleteChar(); } else if (event.event == 'submit' || event.event == 'enter') { - print("going to hifi://" + locationURL); - location = "hifi://" + locationURL; - locationURL = ""; - keyboard.hide(); - cursor.hide(); - updateTextOverlay(); + print("going to hifi://" + locationURL); + location = "hifi://" + locationURL; + locationURL = ""; + keyboard.hide(); + cursor.hide(); + updateTextOverlay(); } } }; @@ -131,18 +133,18 @@ keyboard.onFullyLoaded = function() { print("Virtual-keyboard fully loaded."); var dimensions = Controller.getViewportDimensions(); text = Overlays.addOverlay("text", { - x: 0, - y: dimensions.y - keyboard.height() - 260, - width: dimensions.x, - height: 250, - backgroundColor: { red: 255, green: 255, blue: 255}, - color: { red: 0, green: 0, blue: 0}, - topMargin: 5, - leftMargin: 0, - font: {size: textFontSize}, - text: "", - alpha: 0.8, - visible: keyboard.visible + x: 0, + y: dimensions.y - keyboard.height() - 260, + width: dimensions.x, + height: 250, + backgroundColor: { red: 255, green: 255, blue: 255}, + color: { red: 0, green: 0, blue: 0}, + topMargin: 5, + leftMargin: 0, + font: {size: textFontSize}, + text: "", + alpha: 0.8, + visible: keyboard.visible }); updateTextOverlay(); // the cursor is being loaded after the keyboard, else it will be on the background of the keyboard @@ -189,6 +191,7 @@ function scriptEnding() { } function reportButtonValue(button, newValue, oldValue) { + print(button); if (theInstruction.visible) { if (button == Joysticks.BUTTON_FACE_BOTTOM && newValue) { theInstruction.remove(); @@ -201,6 +204,27 @@ function reportButtonValue(button, newValue, oldValue) { } } else if (button == Joysticks.BUTTON_FACE_RIGHT && newValue) { deleteChar(); + } else if (button == Joysticks.BUTTON_FACE_LEFT && newValue) { + keyboard.hide(); + if (cursor !== undefined) { + cursor.hide(); + } + Overlays.editOverlay(text, {visible: false}); + } else if (button == Joysticks.BUTTON_RIGHT_SHOULDER && newValue) { + if (keyboard.visible) { + print("going to hifi://" + locationURL); + location = "hifi://" + locationURL; + locationURL = ""; + keyboard.hide(); + cursor.hide(); + updateTextOverlay(); + return; + } + keyboard.show(); + if (cursor !== undefined) { + cursor.show(); + } + Overlays.editOverlay(text, {visible: true}); } } diff --git a/interface/src/ui/ApplicationOverlay.cpp b/interface/src/ui/ApplicationOverlay.cpp index f80acf5801..8fc55921e7 100644 --- a/interface/src/ui/ApplicationOverlay.cpp +++ b/interface/src/ui/ApplicationOverlay.cpp @@ -719,6 +719,9 @@ void ApplicationOverlay::renderPointersOculus(const glm::vec3& eyePos) { //Renders a small magnification of the currently bound texture at the coordinates void ApplicationOverlay::renderMagnifier(glm::vec2 magPos, float sizeMult, bool showBorder) { + if (!_magnifier) { + return; + } auto glCanvas = DependencyManager::get(); const int widgetWidth = glCanvas->width();