diff --git a/examples/overlaysExample.js b/examples/overlaysExample.js index c1835f8957..778de0421e 100644 --- a/examples/overlaysExample.js +++ b/examples/overlaysExample.js @@ -32,7 +32,7 @@ for (s = 0; s < numberOfSwatches; s++) { imageFromY = 55; } - swatches[s] = Overlays.addOverlay({ + swatches[s] = Overlays.addOverlay("image", { x: 100 + (30 * s), y: 200, width: 31, @@ -44,7 +44,7 @@ for (s = 0; s < numberOfSwatches; s++) { }); } -var toolA = Overlays.addOverlay({ +var toolA = Overlays.addOverlay("image", { x: 100, y: 100, width: 62, @@ -56,7 +56,7 @@ var toolA = Overlays.addOverlay({ visible: false }); -var slider = Overlays.addOverlay({ +var slider = Overlays.addOverlay("image", { // alternate form of expressing bounds bounds: { x: 100, y: 300, width: 158, height: 35}, imageURL: "https://s3-us-west-1.amazonaws.com/highfidelity-public/images/slider.png", @@ -67,7 +67,7 @@ var slider = Overlays.addOverlay({ var minThumbX = 130; var maxThumbX = minThumbX + 65; var thumbX = (minThumbX + maxThumbX) / 2; -var thumb = Overlays.addOverlay({ +var thumb = Overlays.addOverlay("image", { x: thumbX, y: 309, width: 18, diff --git a/interface/src/ui/ImageOverlay.cpp b/interface/src/ui/ImageOverlay.cpp index 5849fdae7d..5d7d7efcc0 100644 --- a/interface/src/ui/ImageOverlay.cpp +++ b/interface/src/ui/ImageOverlay.cpp @@ -202,7 +202,6 @@ void ImageOverlay::setProperties(const QScriptValue& properties) { if (properties.property("visible").isValid()) { setVisible(properties.property("visible").toVariant().toBool()); - qDebug() << "setting visible to " << getVisible(); } } diff --git a/interface/src/ui/Overlays.cpp b/interface/src/ui/Overlays.cpp index fef2e94a85..5c19dc5529 100644 --- a/interface/src/ui/Overlays.cpp +++ b/interface/src/ui/Overlays.cpp @@ -27,13 +27,17 @@ void Overlays::render() { } // TODO: make multi-threaded safe -unsigned int Overlays::addOverlay(const QScriptValue& properties) { - unsigned int thisID = _nextOverlayID; - _nextOverlayID++; - ImageOverlay* thisOverlay = new ImageOverlay(); - thisOverlay->init(_parent); - thisOverlay->setProperties(properties); - _imageOverlays[thisID] = thisOverlay; +unsigned int Overlays::addOverlay(const QString& type, const QScriptValue& properties) { + unsigned int thisID = 0; + + if (type == "image") { + thisID = _nextOverlayID; + _nextOverlayID++; + ImageOverlay* thisOverlay = new ImageOverlay(); + thisOverlay->init(_parent); + thisOverlay->setProperties(properties); + _imageOverlays[thisID] = thisOverlay; + } return thisID; } diff --git a/interface/src/ui/Overlays.h b/interface/src/ui/Overlays.h index a1ced3979d..ed686dc024 100644 --- a/interface/src/ui/Overlays.h +++ b/interface/src/ui/Overlays.h @@ -36,7 +36,7 @@ public: public slots: /// adds an overlay with the specific properties - unsigned int addOverlay(const QScriptValue& properties); + unsigned int addOverlay(const QString& type, const QScriptValue& properties); /// edits an overlay updating only the included properties, will return the identified OverlayID in case of /// successful edit, if the input id is for an unknown overlay this function will have no effect