Mass renaming to be more logical/concise.

FloatingUIPanel -> OverlayPanel
anchorPosition -> position
offsetRotation -> rotation
facingRotation -> offsetRotation
floatingUIExample.js -> overlayPanelExample.js
This commit is contained in:
Zander Otavka 2015-08-06 14:23:04 -07:00
parent 6165e7e6ca
commit b94be926f8
9 changed files with 139 additions and 150 deletions

View file

@ -5,7 +5,7 @@
// Created by Zander Otavka on 7/15/15. // Created by Zander Otavka on 7/15/15.
// Copyright 2015 High Fidelity, Inc. // Copyright 2015 High Fidelity, Inc.
// //
// Shows a few common controls in a FloatingUIPanel on right click. // Shows a few common controls in a OverlayPanel on right click.
// //
// Distributed under the Apache License, Version 2.0. // Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -22,10 +22,10 @@ var MIC_IMAGE_URL = HIFI_PUBLIC_BUCKET + "images/tools/mic-toggle.svg";
var FACE_IMAGE_URL = HIFI_PUBLIC_BUCKET + "images/tools/face-toggle.svg"; var FACE_IMAGE_URL = HIFI_PUBLIC_BUCKET + "images/tools/face-toggle.svg";
var ADDRESS_BAR_IMAGE_URL = HIFI_PUBLIC_BUCKET + "images/tools/address-bar-toggle.svg"; var ADDRESS_BAR_IMAGE_URL = HIFI_PUBLIC_BUCKET + "images/tools/address-bar-toggle.svg";
var panel = new FloatingUIPanel({ var panel = new OverlayPanel({
anchorPositionBinding: { avatar: "MyAvatar" }, positionBinding: { avatar: "MyAvatar" },
offsetPosition: { x: 0, y: 0.4, z: 1 }, offsetPosition: { x: 0, y: 0.4, z: 1 },
facingRotation: { w: 0, x: 0, y: 1, z: 0 } offsetRotation: { w: 0, x: 0, y: 1, z: 0 }
}); });
var background = new Image3DOverlay({ var background = new Image3DOverlay({
@ -192,7 +192,7 @@ function onMouseUp(event) {
if (event.isRightButton && Vec3.distance(mouseDown.pos, { x: event.x, y: event.y }) < 10) { if (event.isRightButton && Vec3.distance(mouseDown.pos, { x: event.x, y: event.y }) < 10) {
panel.setProperties({ panel.setProperties({
visible: !panel.visible, visible: !panel.visible,
offsetRotation: Quat.multiply(MyAvatar.orientation, { x: 0, y: 1, z: 0, w: 0 }) rotation: Quat.multiply(MyAvatar.orientation, { x: 0, y: 1, z: 0, w: 0 })
}); });
} }

View file

@ -1,5 +1,5 @@
// //
// floatingUI.js // overlayPanelExample.js
// examples/example/ui // examples/example/ui
// //
// Created by Alexander Otavka // Created by Alexander Otavka
@ -18,14 +18,14 @@ var BG_IMAGE_URL = HIFI_PUBLIC_BUCKET + "images/card-bg.svg";
var RED_DOT_IMAGE_URL = HIFI_PUBLIC_BUCKET + "images/red-dot.svg"; var RED_DOT_IMAGE_URL = HIFI_PUBLIC_BUCKET + "images/red-dot.svg";
var BLUE_SQUARE_IMAGE_URL = HIFI_PUBLIC_BUCKET + "images/blue-square.svg"; var BLUE_SQUARE_IMAGE_URL = HIFI_PUBLIC_BUCKET + "images/blue-square.svg";
var mainPanel = new FloatingUIPanel({ var mainPanel = new OverlayPanel({
anchorPositionBinding: { avatar: "MyAvatar" }, positionBinding: { avatar: "MyAvatar" },
offsetRotation: { w: 1, x: 0, y: 0, z: 0 }, rotation: { w: 1, x: 0, y: 0, z: 0 },
offsetPosition: { x: 0, y: 0.4, z: 1 }, offsetPosition: { x: 0, y: 0.4, z: 1 },
facingRotation: { w: 0, x: 0, y: 1, z: 0 } offsetRotation: { w: 0, x: 0, y: 1, z: 0 }
}); });
var bluePanel = mainPanel.addChild(new FloatingUIPanel ({ var bluePanel = mainPanel.addChild(new OverlayPanel ({
offsetPosition: { x: 0.1, y: 0.1, z: 0.2 } offsetPosition: { x: 0.1, y: 0.1, z: 0.2 }
})); }));

View file

@ -95,7 +95,7 @@
if (!Overlays.isAddedPanel(id)) { if (!Overlays.isAddedPanel(id)) {
return null; return null;
} }
var panel = new FloatingUIPanel(); var panel = new OverlayPanel();
panel._id = id; panel._id = id;
overlays[id] = overlay; overlays[id] = overlay;
return overlay; return overlay;
@ -234,7 +234,7 @@
// Supports multiple inheritance of properties. Just `concat` them onto the end of the // Supports multiple inheritance of properties. Just `concat` them onto the end of the
// properties list. // properties list.
var PANEL_ATTACHABLE_FIELDS = ["offsetPosition", "facingRotation"]; var PANEL_ATTACHABLE_FIELDS = ["offsetPosition", "offsetRotation"];
Overlay = (function() { Overlay = (function() {
var that = function(type, params) { var that = function(type, params) {
@ -374,7 +374,7 @@
// //
// Object oriented abstraction layer for panels. // Object oriented abstraction layer for panels.
// //
FloatingUIPanel = (function() { OverlayPanel = (function() {
var that = function(params) { var that = function(params) {
this._id = Overlays.addPanel(params); this._id = Overlays.addPanel(params);
panels[this._id] = this; panels[this._id] = this;
@ -383,8 +383,8 @@
that.prototype.constructor = that; that.prototype.constructor = that;
[ [
"anchorPosition", "anchorPositionBinding", "offsetRotation", "offsetRotationBinding", "position", "positionBinding", "rotation", "rotationBinding",
"offsetPosition", "facingRotation", "visible" "offsetPosition", "offsetRotation", "visible"
].forEach(function(prop) { ].forEach(function(prop) {
Object.defineProperty(that.prototype, prop, { Object.defineProperty(that.prototype, prop, {
get: function() { get: function() {

View file

@ -1,5 +1,5 @@
// //
// FloatingUIPanel.cpp // OverlayPanel.cpp
// interface/src/ui/overlays // interface/src/ui/overlays
// //
// Created by Zander Otavka on 7/2/15. // Created by Zander Otavka on 7/2/15.
@ -9,7 +9,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#include "FloatingUIPanel.h" #include "OverlayPanel.h"
#include <QVariant> #include <QVariant>
#include <RegisteredMetaTypes.h> #include <RegisteredMetaTypes.h>
@ -21,42 +21,33 @@
#include "Application.h" #include "Application.h"
#include "Base3DOverlay.h" #include "Base3DOverlay.h"
glm::vec3 FloatingUIPanel::getComputedAnchorPosition() const { glm::vec3 OverlayPanel::getComputedPosition() const {
glm::vec3 pos = {};
if (getAttachedPanel()) { if (getAttachedPanel()) {
pos = getAttachedPanel()->getPosition(); return getAttachedPanel()->getComputedRotation() * getAttachedPanel()->getOffsetPosition() +
} else if (_anchorPositionBindMyAvatar) { getAttachedPanel()->getComputedPosition();
pos = DependencyManager::get<AvatarManager>()->getMyAvatar()->getPosition(); } else if (_positionBindMyAvatar) {
} else if (!_anchorPositionBindEntity.isNull()) { return DependencyManager::get<AvatarManager>()->getMyAvatar()->getPosition();
pos = DependencyManager::get<EntityScriptingInterface>()->getEntityTree()-> } else if (!_positionBindEntity.isNull()) {
findEntityByID(_anchorPositionBindEntity)->getPosition(); return DependencyManager::get<EntityScriptingInterface>()->getEntityTree()->
findEntityByID(_positionBindEntity)->getPosition();
} }
return pos + getAnchorPosition(); return getPosition();
} }
glm::quat FloatingUIPanel::getComputedOffsetRotation() const { glm::quat OverlayPanel::getComputedRotation() const {
glm::quat rot = {1, 0, 0, 0};
if (getAttachedPanel()) { if (getAttachedPanel()) {
rot = getAttachedPanel()->getRotation(); return getAttachedPanel()->getComputedRotation() * getAttachedPanel()->getFacingRotation();
} else if (_offsetRotationBindMyAvatar) { } else if (_rotationBindMyAvatar) {
rot = DependencyManager::get<AvatarManager>()->getMyAvatar()->getOrientation() * return DependencyManager::get<AvatarManager>()->getMyAvatar()->getOrientation() *
glm::angleAxis(glm::pi<float>(), IDENTITY_UP); glm::angleAxis(glm::pi<float>(), IDENTITY_UP);
} else if (!_offsetRotationBindEntity.isNull()) { } else if (!_rotationBindEntity.isNull()) {
rot = DependencyManager::get<EntityScriptingInterface>()->getEntityTree()-> return DependencyManager::get<EntityScriptingInterface>()->getEntityTree()->
findEntityByID(_offsetRotationBindEntity)->getRotation(); findEntityByID(_rotationBindEntity)->getRotation();
} }
return rot * getOffsetRotation(); return getRotation();
} }
glm::vec3 FloatingUIPanel::getPosition() const { bool OverlayPanel::getParentVisible() const {
return getComputedOffsetRotation() * getOffsetPosition() + getComputedAnchorPosition();
}
glm::quat FloatingUIPanel::getRotation() const {
return getComputedOffsetRotation() * getFacingRotation();
}
bool FloatingUIPanel::getParentVisible() const {
if (getAttachedPanel()) { if (getAttachedPanel()) {
return getAttachedPanel()->getVisible() && getAttachedPanel()->getParentVisible(); return getAttachedPanel()->getVisible() && getAttachedPanel()->getParentVisible();
} else { } else {
@ -64,53 +55,53 @@ bool FloatingUIPanel::getParentVisible() const {
} }
} }
void FloatingUIPanel::addChild(unsigned int childId) { void OverlayPanel::addChild(unsigned int childId) {
if (!_children.contains(childId)) { if (!_children.contains(childId)) {
_children.append(childId); _children.append(childId);
} }
} }
void FloatingUIPanel::removeChild(unsigned int childId) { void OverlayPanel::removeChild(unsigned int childId) {
if (_children.contains(childId)) { if (_children.contains(childId)) {
_children.removeOne(childId); _children.removeOne(childId);
} }
} }
QScriptValue FloatingUIPanel::getProperty(const QString &property) { QScriptValue OverlayPanel::getProperty(const QString &property) {
if (property == "anchorPosition") { if (property == "position") {
return vec3toScriptValue(_scriptEngine, getAnchorPosition()); return vec3toScriptValue(_scriptEngine, getPosition());
} }
if (property == "anchorPositionBinding") { if (property == "positionBinding") {
QScriptValue obj = _scriptEngine->newObject(); QScriptValue obj = _scriptEngine->newObject();
if (_anchorPositionBindMyAvatar) { if (_positionBindMyAvatar) {
obj.setProperty("avatar", "MyAvatar"); obj.setProperty("avatar", "MyAvatar");
} else if (!_anchorPositionBindEntity.isNull()) { } else if (!_positionBindEntity.isNull()) {
obj.setProperty("entity", _scriptEngine->newVariant(_anchorPositionBindEntity)); obj.setProperty("entity", _scriptEngine->newVariant(_positionBindEntity));
} }
obj.setProperty("computed", vec3toScriptValue(_scriptEngine, getComputedAnchorPosition())); obj.setProperty("computed", vec3toScriptValue(_scriptEngine, getComputedPosition()));
return obj; return obj;
} }
if (property == "offsetRotation") { if (property == "rotation") {
return quatToScriptValue(_scriptEngine, getOffsetRotation()); return quatToScriptValue(_scriptEngine, getRotation());
} }
if (property == "offsetRotationBinding") { if (property == "rotationBinding") {
QScriptValue obj = _scriptEngine->newObject(); QScriptValue obj = _scriptEngine->newObject();
if (_offsetRotationBindMyAvatar) { if (_rotationBindMyAvatar) {
obj.setProperty("avatar", "MyAvatar"); obj.setProperty("avatar", "MyAvatar");
} else if (!_offsetRotationBindEntity.isNull()) { } else if (!_rotationBindEntity.isNull()) {
obj.setProperty("entity", _scriptEngine->newVariant(_offsetRotationBindEntity)); obj.setProperty("entity", _scriptEngine->newVariant(_rotationBindEntity));
} }
obj.setProperty("computed", quatToScriptValue(_scriptEngine, getComputedOffsetRotation())); obj.setProperty("computed", quatToScriptValue(_scriptEngine, getComputedRotation()));
return obj; return obj;
} }
if (property == "offsetPosition") { if (property == "offsetPosition") {
return vec3toScriptValue(_scriptEngine, getOffsetPosition()); return vec3toScriptValue(_scriptEngine, getOffsetPosition());
} }
if (property == "facingRotation") { if (property == "offsetRotation") {
return quatToScriptValue(_scriptEngine, getFacingRotation()); return quatToScriptValue(_scriptEngine, getFacingRotation());
} }
if (property == "visible") { if (property == "visible") {
@ -127,42 +118,42 @@ QScriptValue FloatingUIPanel::getProperty(const QString &property) {
return QScriptValue(); return QScriptValue();
} }
void FloatingUIPanel::setProperties(const QScriptValue &properties) { void OverlayPanel::setProperties(const QScriptValue &properties) {
QScriptValue anchorPosition = properties.property("anchorPosition"); QScriptValue position = properties.property("position");
if (anchorPosition.isValid()) { if (position.isValid()) {
QScriptValue x = anchorPosition.property("x"); QScriptValue x = position.property("x");
QScriptValue y = anchorPosition.property("y"); QScriptValue y = position.property("y");
QScriptValue z = anchorPosition.property("z"); QScriptValue z = position.property("z");
if (x.isValid() && y.isValid() && z.isValid()) { if (x.isValid() && y.isValid() && z.isValid()) {
glm::vec3 newPosition; glm::vec3 newPosition;
newPosition.x = x.toVariant().toFloat(); newPosition.x = x.toVariant().toFloat();
newPosition.y = y.toVariant().toFloat(); newPosition.y = y.toVariant().toFloat();
newPosition.z = z.toVariant().toFloat(); newPosition.z = z.toVariant().toFloat();
setAnchorPosition(newPosition); setPosition(newPosition);
} }
} }
QScriptValue anchorPositionBinding = properties.property("anchorPositionBinding"); QScriptValue positionBinding = properties.property("positionBinding");
if (anchorPositionBinding.isValid()) { if (positionBinding.isValid()) {
_anchorPositionBindMyAvatar = false; _positionBindMyAvatar = false;
_anchorPositionBindEntity = QUuid(); _positionBindEntity = QUuid();
QScriptValue avatar = anchorPositionBinding.property("avatar"); QScriptValue avatar = positionBinding.property("avatar");
QScriptValue entity = anchorPositionBinding.property("entity"); QScriptValue entity = positionBinding.property("entity");
if (avatar.isValid()) { if (avatar.isValid()) {
_anchorPositionBindMyAvatar = (avatar.toVariant().toString() == "MyAvatar"); _positionBindMyAvatar = (avatar.toVariant().toString() == "MyAvatar");
} else if (entity.isValid() && !entity.isNull()) { } else if (entity.isValid() && !entity.isNull()) {
_anchorPositionBindEntity = entity.toVariant().toUuid(); _positionBindEntity = entity.toVariant().toUuid();
} }
} }
QScriptValue offsetRotation = properties.property("offsetRotation"); QScriptValue rotation = properties.property("rotation");
if (offsetRotation.isValid()) { if (rotation.isValid()) {
QScriptValue x = offsetRotation.property("x"); QScriptValue x = rotation.property("x");
QScriptValue y = offsetRotation.property("y"); QScriptValue y = rotation.property("y");
QScriptValue z = offsetRotation.property("z"); QScriptValue z = rotation.property("z");
QScriptValue w = offsetRotation.property("w"); QScriptValue w = rotation.property("w");
if (x.isValid() && y.isValid() && z.isValid() && w.isValid()) { if (x.isValid() && y.isValid() && z.isValid() && w.isValid()) {
glm::quat newRotation; glm::quat newRotation;
@ -170,22 +161,22 @@ void FloatingUIPanel::setProperties(const QScriptValue &properties) {
newRotation.y = y.toVariant().toFloat(); newRotation.y = y.toVariant().toFloat();
newRotation.z = z.toVariant().toFloat(); newRotation.z = z.toVariant().toFloat();
newRotation.w = w.toVariant().toFloat(); newRotation.w = w.toVariant().toFloat();
setOffsetRotation(newRotation); setRotation(newRotation);
} }
} }
QScriptValue offsetRotationBinding = properties.property("offsetRotationBinding"); QScriptValue rotationBinding = properties.property("rotationBinding");
if (offsetRotationBinding.isValid()) { if (rotationBinding.isValid()) {
_offsetRotationBindMyAvatar = false; _rotationBindMyAvatar = false;
_offsetRotationBindEntity = QUuid(); _rotationBindEntity = QUuid();
QScriptValue avatar = offsetRotationBinding.property("avatar"); QScriptValue avatar = rotationBinding.property("avatar");
QScriptValue entity = anchorPositionBinding.property("entity"); QScriptValue entity = positionBinding.property("entity");
if (avatar.isValid()) { if (avatar.isValid()) {
_offsetRotationBindMyAvatar = (avatar.toVariant().toString() == "MyAvatar"); _rotationBindMyAvatar = (avatar.toVariant().toString() == "MyAvatar");
} else if (entity.isValid() && !entity.isNull()) { } else if (entity.isValid() && !entity.isNull()) {
_offsetRotationBindEntity = entity.toVariant().toUuid(); _rotationBindEntity = entity.toVariant().toUuid();
} }
} }
@ -203,12 +194,12 @@ void FloatingUIPanel::setProperties(const QScriptValue &properties) {
} }
} }
QScriptValue facingRotation = properties.property("facingRotation"); QScriptValue offsetRotation = properties.property("offsetRotation");
if (facingRotation.isValid()) { if (offsetRotation.isValid()) {
QScriptValue x = facingRotation.property("x"); QScriptValue x = offsetRotation.property("x");
QScriptValue y = facingRotation.property("y"); QScriptValue y = offsetRotation.property("y");
QScriptValue z = facingRotation.property("z"); QScriptValue z = offsetRotation.property("z");
QScriptValue w = facingRotation.property("w"); QScriptValue w = offsetRotation.property("w");
if (x.isValid() && y.isValid() && z.isValid() && w.isValid()) { if (x.isValid() && y.isValid() && z.isValid() && w.isValid()) {
glm::quat newRotation; glm::quat newRotation;

View file

@ -1,5 +1,5 @@
// //
// FloatingUIPanel.h // OverlayPanel.h
// interface/src/ui/overlays // interface/src/ui/overlays
// //
// Created by Zander Otavka on 7/2/15. // Created by Zander Otavka on 7/2/15.
@ -9,8 +9,8 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
#ifndef hifi_FloatingUIPanel_h #ifndef hifi_OverlayPanel_h
#define hifi_FloatingUIPanel_h #define hifi_OverlayPanel_h
#include <memory> #include <memory>
@ -19,32 +19,30 @@
#include <QScriptValue> #include <QScriptValue>
#include <QUuid> #include <QUuid>
class FloatingUIPanel : public QObject { class OverlayPanel : public QObject {
Q_OBJECT Q_OBJECT
public: public:
typedef std::shared_ptr<FloatingUIPanel> Pointer; typedef std::shared_ptr<OverlayPanel> Pointer;
void init(QScriptEngine* scriptEngine) { _scriptEngine = scriptEngine; } void init(QScriptEngine* scriptEngine) { _scriptEngine = scriptEngine; }
// getters // getters
glm::vec3 getAnchorPosition() const { return _anchorPosition; } glm::vec3 getPosition() const { return _position; }
glm::vec3 getComputedAnchorPosition() const; glm::vec3 getComputedPosition() const;
glm::quat getOffsetRotation() const { return _offsetRotation; } glm::quat getRotation() const { return _rotation; }
glm::quat getComputedOffsetRotation() const; glm::quat getComputedRotation() const;
glm::vec3 getOffsetPosition() const { return _offsetPosition; } glm::vec3 getOffsetPosition() const { return _offsetPosition; }
glm::quat getFacingRotation() const { return _facingRotation; } glm::quat getFacingRotation() const { return _offsetRotation; }
glm::vec3 getPosition() const;
glm::quat getRotation() const;
Pointer getAttachedPanel() const { return _attachedPanel; } Pointer getAttachedPanel() const { return _attachedPanel; }
bool getVisible() const { return _visible; } bool getVisible() const { return _visible; }
bool getParentVisible() const; bool getParentVisible() const;
// setters // setters
void setAnchorPosition(const glm::vec3& position) { _anchorPosition = position; } void setPosition(const glm::vec3& position) { _position = position; }
void setOffsetRotation(const glm::quat& rotation) { _offsetRotation = rotation; } void setRotation(const glm::quat& rotation) { _rotation = rotation; }
void setOffsetPosition(const glm::vec3& position) { _offsetPosition = position; } void setOffsetPosition(const glm::vec3& position) { _offsetPosition = position; }
void setFacingRotation(const glm::quat& rotation) { _facingRotation = rotation; } void setFacingRotation(const glm::quat& rotation) { _offsetRotation = rotation; }
void setAttachedPanel(Pointer panel) { _attachedPanel = panel; } void setAttachedPanel(Pointer panel) { _attachedPanel = panel; }
void setVisible(bool visible) { _visible = visible; } void setVisible(bool visible) { _visible = visible; }
@ -57,16 +55,16 @@ public:
void setProperties(const QScriptValue& properties); void setProperties(const QScriptValue& properties);
private: private:
glm::vec3 _anchorPosition = {0, 0, 0}; glm::vec3 _position = {0, 0, 0};
glm::quat _offsetRotation = {1, 0, 0, 0}; glm::quat _rotation = {1, 0, 0, 0};
glm::vec3 _offsetPosition = {0, 0, 0}; glm::vec3 _offsetPosition = {0, 0, 0};
glm::quat _facingRotation = {1, 0, 0, 0}; glm::quat _offsetRotation = {1, 0, 0, 0};
bool _anchorPositionBindMyAvatar = false; bool _positionBindMyAvatar = false;
QUuid _anchorPositionBindEntity; QUuid _positionBindEntity;
bool _offsetRotationBindMyAvatar = false; bool _rotationBindMyAvatar = false;
QUuid _offsetRotationBindEntity; QUuid _rotationBindEntity;
Pointer _attachedPanel = nullptr; Pointer _attachedPanel = nullptr;
QList<unsigned int> _children; QList<unsigned int> _children;
@ -75,4 +73,4 @@ private:
QScriptEngine* _scriptEngine; QScriptEngine* _scriptEngine;
}; };
#endif // hifi_FloatingUIPanel_h #endif // hifi_OverlayPanel_h

View file

@ -303,7 +303,7 @@ void Overlays::setAttachedPanel(unsigned int childId, unsigned int panelId) {
} }
} }
} else if (_panels.contains(childId)) { } else if (_panels.contains(childId)) {
FloatingUIPanel::Pointer child = getPanel(childId); OverlayPanel::Pointer child = getPanel(childId);
if (_panels.contains(panelId)) { if (_panels.contains(panelId)) {
auto panel = getPanel(panelId); auto panel = getPanel(panelId);
panel->addChild(childId); panel->addChild(childId);
@ -531,7 +531,7 @@ QSizeF Overlays::textSize(unsigned int id, const QString& text) const {
return QSizeF(0.0f, 0.0f); return QSizeF(0.0f, 0.0f);
} }
unsigned int Overlays::addPanel(FloatingUIPanel::Pointer panel) { unsigned int Overlays::addPanel(OverlayPanel::Pointer panel) {
QWriteLocker lock(&_lock); QWriteLocker lock(&_lock);
unsigned int thisID = _nextOverlayID; unsigned int thisID = _nextOverlayID;
@ -542,7 +542,7 @@ unsigned int Overlays::addPanel(FloatingUIPanel::Pointer panel) {
} }
unsigned int Overlays::addPanel(const QScriptValue& properties) { unsigned int Overlays::addPanel(const QScriptValue& properties) {
FloatingUIPanel::Pointer panel = std::make_shared<FloatingUIPanel>(); OverlayPanel::Pointer panel = std::make_shared<OverlayPanel>();
panel->init(_scriptEngine); panel->init(_scriptEngine);
panel->setProperties(properties); panel->setProperties(properties);
return addPanel(panel); return addPanel(panel);
@ -557,7 +557,7 @@ void Overlays::editPanel(unsigned int panelId, const QScriptValue& properties) {
OverlayPropertyResult Overlays::getPanelProperty(unsigned int panelId, const QString& property) { OverlayPropertyResult Overlays::getPanelProperty(unsigned int panelId, const QString& property) {
OverlayPropertyResult result; OverlayPropertyResult result;
if (_panels.contains(panelId)) { if (_panels.contains(panelId)) {
FloatingUIPanel::Pointer thisPanel = getPanel(panelId); OverlayPanel::Pointer thisPanel = getPanel(panelId);
QReadLocker lock(&_lock); QReadLocker lock(&_lock);
result.value = thisPanel->getProperty(property); result.value = thisPanel->getProperty(property);
} }
@ -566,7 +566,7 @@ OverlayPropertyResult Overlays::getPanelProperty(unsigned int panelId, const QSt
void Overlays::deletePanel(unsigned int panelId) { void Overlays::deletePanel(unsigned int panelId) {
FloatingUIPanel::Pointer panelToDelete; OverlayPanel::Pointer panelToDelete;
{ {
QWriteLocker lock(&_lock); QWriteLocker lock(&_lock);

View file

@ -5,7 +5,7 @@
// Modified by Zander Otavka on 7/15/15 // Modified by Zander Otavka on 7/15/15
// Copyright 2014 High Fidelity, Inc. // Copyright 2014 High Fidelity, Inc.
// //
// Exposes methods for managing `Overlay`s and `FloatingUIPanel`s to scripts. // Exposes methods for managing `Overlay`s and `OverlayPanel`s to scripts.
// //
// YOU SHOULD NOT USE `Overlays` DIRECTLY, unless you like pain and deprecation. Instead, use the // YOU SHOULD NOT USE `Overlays` DIRECTLY, unless you like pain and deprecation. Instead, use the
// object oriented abstraction layer found in `examples/libraries/overlayUtils.js`. // object oriented abstraction layer found in `examples/libraries/overlayUtils.js`.
@ -22,7 +22,7 @@
#include "Overlay.h" #include "Overlay.h"
#include "FloatingUIPanel.h" #include "OverlayPanel.h"
#include "PanelAttachable.h" #include "PanelAttachable.h"
class PickRay; class PickRay;
@ -67,7 +67,7 @@ public:
void renderHUD(RenderArgs* renderArgs); void renderHUD(RenderArgs* renderArgs);
Overlay::Pointer getOverlay(unsigned int id) const; Overlay::Pointer getOverlay(unsigned int id) const;
FloatingUIPanel::Pointer getPanel(unsigned int id) const { return _panels[id]; } OverlayPanel::Pointer getPanel(unsigned int id) const { return _panels[id]; }
public slots: public slots:
/// adds an overlay with the specific properties /// adds an overlay with the specific properties
@ -111,7 +111,7 @@ public slots:
/// adds a panel that has already been created /// adds a panel that has already been created
unsigned int addPanel(FloatingUIPanel::Pointer panel); unsigned int addPanel(OverlayPanel::Pointer panel);
/// creates and adds a panel based on a set of properties /// creates and adds a panel based on a set of properties
unsigned int addPanel(const QScriptValue& properties); unsigned int addPanel(const QScriptValue& properties);
@ -140,7 +140,7 @@ private:
QMap<unsigned int, Overlay::Pointer> _overlaysHUD; QMap<unsigned int, Overlay::Pointer> _overlaysHUD;
QMap<unsigned int, Overlay::Pointer> _overlaysWorld; QMap<unsigned int, Overlay::Pointer> _overlaysWorld;
QMap<unsigned int, FloatingUIPanel::Pointer> _panels; QMap<unsigned int, OverlayPanel::Pointer> _panels;
QList<Overlay::Pointer> _overlaysToDelete; QList<Overlay::Pointer> _overlaysToDelete;
unsigned int _nextOverlayID; unsigned int _nextOverlayID;

View file

@ -16,14 +16,14 @@
PanelAttachable::PanelAttachable() : PanelAttachable::PanelAttachable() :
_attachedPanel(nullptr), _attachedPanel(nullptr),
_offsetPosition(0, 0, 0), _offsetPosition(0, 0, 0),
_facingRotation(1, 0, 0, 0) _offsetRotation(1, 0, 0, 0)
{ {
} }
PanelAttachable::PanelAttachable(const PanelAttachable* panelAttachable) : PanelAttachable::PanelAttachable(const PanelAttachable* panelAttachable) :
_attachedPanel(panelAttachable->_attachedPanel), _attachedPanel(panelAttachable->_attachedPanel),
_offsetPosition(panelAttachable->_offsetPosition), _offsetPosition(panelAttachable->_offsetPosition),
_facingRotation(panelAttachable->_facingRotation) _offsetRotation(panelAttachable->_offsetRotation)
{ {
} }
@ -37,8 +37,8 @@ bool PanelAttachable::getParentVisible() const {
void PanelAttachable::setTransforms(Transform& transform) { void PanelAttachable::setTransforms(Transform& transform) {
if (getAttachedPanel()) { if (getAttachedPanel()) {
transform.setTranslation(getAttachedPanel()->getComputedAnchorPosition()); transform.setTranslation(getAttachedPanel()->getComputedPosition());
transform.setRotation(getAttachedPanel()->getComputedOffsetRotation()); transform.setRotation(getAttachedPanel()->getComputedRotation());
transform.postTranslate(getAttachedPanel()->getOffsetPosition()); transform.postTranslate(getAttachedPanel()->getOffsetPosition());
transform.postRotate(getAttachedPanel()->getFacingRotation()); transform.postRotate(getAttachedPanel()->getFacingRotation());
transform.postTranslate(getOffsetPosition()); transform.postTranslate(getOffsetPosition());
@ -50,7 +50,7 @@ QScriptValue PanelAttachable::getProperty(QScriptEngine* scriptEngine, const QSt
if (property == "offsetPosition") { if (property == "offsetPosition") {
return vec3toScriptValue(scriptEngine, getOffsetPosition()); return vec3toScriptValue(scriptEngine, getOffsetPosition());
} }
if (property == "facingRotation") { if (property == "offsetRotation") {
return quatToScriptValue(scriptEngine, getFacingRotation()); return quatToScriptValue(scriptEngine, getFacingRotation());
} }
return QScriptValue(); return QScriptValue();
@ -72,12 +72,12 @@ void PanelAttachable::setProperties(const QScriptValue &properties) {
} }
} }
QScriptValue facingRotation = properties.property("facingRotation"); QScriptValue offsetRotation = properties.property("offsetRotation");
if (facingRotation.isValid()) { if (offsetRotation.isValid()) {
QScriptValue x = facingRotation.property("x"); QScriptValue x = offsetRotation.property("x");
QScriptValue y = facingRotation.property("y"); QScriptValue y = offsetRotation.property("y");
QScriptValue z = facingRotation.property("z"); QScriptValue z = offsetRotation.property("z");
QScriptValue w = facingRotation.property("w"); QScriptValue w = offsetRotation.property("w");
if (x.isValid() && y.isValid() && z.isValid() && w.isValid()) { if (x.isValid() && y.isValid() && z.isValid() && w.isValid()) {
glm::quat newRotation; glm::quat newRotation;

View file

@ -12,7 +12,7 @@
#ifndef hifi_PanelAttachable_h #ifndef hifi_PanelAttachable_h
#define hifi_PanelAttachable_h #define hifi_PanelAttachable_h
#include "FloatingUIPanel.h" #include "OverlayPanel.h"
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <Transform.h> #include <Transform.h>
@ -22,14 +22,14 @@ public:
PanelAttachable(); PanelAttachable();
PanelAttachable(const PanelAttachable* panelAttachable); PanelAttachable(const PanelAttachable* panelAttachable);
FloatingUIPanel::Pointer getAttachedPanel() const { return _attachedPanel; } OverlayPanel::Pointer getAttachedPanel() const { return _attachedPanel; }
virtual glm::vec3 getOffsetPosition() const { return _offsetPosition; } virtual glm::vec3 getOffsetPosition() const { return _offsetPosition; }
virtual glm::quat getFacingRotation() const { return _facingRotation; } virtual glm::quat getFacingRotation() const { return _offsetRotation; }
bool getParentVisible() const; bool getParentVisible() const;
void setAttachedPanel(FloatingUIPanel::Pointer panel) { _attachedPanel = panel; } void setAttachedPanel(OverlayPanel::Pointer panel) { _attachedPanel = panel; }
virtual void setOffsetPosition(const glm::vec3& position) { _offsetPosition = position; } virtual void setOffsetPosition(const glm::vec3& position) { _offsetPosition = position; }
virtual void setFacingRotation(const glm::quat& rotation) { _facingRotation = rotation; } virtual void setFacingRotation(const glm::quat& rotation) { _offsetRotation = rotation; }
QScriptValue getProperty(QScriptEngine* scriptEngine, const QString& property); QScriptValue getProperty(QScriptEngine* scriptEngine, const QString& property);
void setProperties(const QScriptValue& properties); void setProperties(const QScriptValue& properties);
@ -38,9 +38,9 @@ protected:
virtual void setTransforms(Transform& transform); virtual void setTransforms(Transform& transform);
private: private:
FloatingUIPanel::Pointer _attachedPanel; OverlayPanel::Pointer _attachedPanel;
glm::vec3 _offsetPosition; glm::vec3 _offsetPosition;
glm::quat _facingRotation; glm::quat _offsetRotation;
}; };
#endif // hifi_PanelAttachable_h #endif // hifi_PanelAttachable_h