From c22f1aa7e100033c9ac578137bd5ff845ddeb2b2 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 22 Jun 2015 15:24:54 -0700 Subject: [PATCH] Overlay2D return correct getBounds --- interface/src/ui/overlays/Overlay2D.cpp | 7 ++++++- interface/src/ui/overlays/Overlay2D.h | 6 ++++-- interface/src/ui/overlays/Overlays.cpp | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/interface/src/ui/overlays/Overlay2D.cpp b/interface/src/ui/overlays/Overlay2D.cpp index f60d44a472..10131ab7a6 100644 --- a/interface/src/ui/overlays/Overlay2D.cpp +++ b/interface/src/ui/overlays/Overlay2D.cpp @@ -28,6 +28,11 @@ Overlay2D::Overlay2D(const Overlay2D* overlay2D) : Overlay2D::~Overlay2D() { } +AABox Overlay2D::getBounds() const { + return AABox(glm::vec3(_bounds.x(), _bounds.y(), 0.0f), + glm::vec3(_bounds.width(), _bounds.height(), 0.01f)); +} + void Overlay2D::setProperties(const QScriptValue& properties) { Overlay::setProperties(properties); @@ -40,7 +45,7 @@ void Overlay2D::setProperties(const QScriptValue& properties) { boundsRect.setHeight(bounds.property("height").toVariant().toInt()); setBounds(boundsRect); } else { - QRect oldBounds = getBounds(); + QRect oldBounds = _bounds; QRect newBounds = oldBounds; if (properties.property("x").isValid()) { diff --git a/interface/src/ui/overlays/Overlay2D.h b/interface/src/ui/overlays/Overlay2D.h index 20641206c2..51781ea468 100644 --- a/interface/src/ui/overlays/Overlay2D.h +++ b/interface/src/ui/overlays/Overlay2D.h @@ -30,6 +30,8 @@ public: Overlay2D(const Overlay2D* overlay2D); ~Overlay2D(); + virtual AABox getBounds() const; + virtual bool is3D() const { return false; } // getters @@ -37,8 +39,8 @@ public: int getY() const { return _bounds.y(); } int getWidth() const { return _bounds.width(); } int getHeight() const { return _bounds.height(); } - const QRect& getBounds() const { return _bounds; } - + const QRect& getBoundingRect() const { return _bounds; } + // setters void setX(int x) { _bounds.setX(x); } void setY(int y) { _bounds.setY(y); } diff --git a/interface/src/ui/overlays/Overlays.cpp b/interface/src/ui/overlays/Overlays.cpp index 1bb81319e4..b86f7fa8e6 100644 --- a/interface/src/ui/overlays/Overlays.cpp +++ b/interface/src/ui/overlays/Overlays.cpp @@ -284,7 +284,7 @@ unsigned int Overlays::getOverlayAtPoint(const glm::vec2& point) { } else { Overlay2D* thisOverlay = static_cast(i.value().get()); if (thisOverlay->getVisible() && thisOverlay->isLoaded() && - thisOverlay->getBounds().contains(pointCopy.x, pointCopy.y, false)) { + thisOverlay->getBoundingRect().contains(pointCopy.x, pointCopy.y, false)) { return thisID; } }