overte-Armored-Dragon/interface/src/ui/overlays/PanelAttachable.h
Zander Otavka 0b4be8fca2 Improve transforms for panels and attachables.
Add offsetScale to PanelAttachable for scaling all the contents of a
panel properly.  Also reduce the number of transform operations per
second while rendering a PanelAttachable Overlay.
2015-08-06 21:46:55 -07:00

53 lines
1.7 KiB
C++

//
// PanelAttachable.h
// interface/src/ui/overlays
//
// Created by Zander Otavka on 7/1/15.
// Copyright 2015 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_PanelAttachable_h
#define hifi_PanelAttachable_h
#include <memory>
#include <glm/glm.hpp>
#include <Transform.h>
#include <QScriptValue>
#include <QScriptEngine>
#include <QUuid>
class OverlayPanel;
class PanelAttachable {
public:
// getters
std::shared_ptr<OverlayPanel> getParentPanel() const { return _parentPanel; }
glm::vec3 getOffsetPosition() const { return _offset.getTranslation(); }
glm::quat getOffsetRotation() const { return _offset.getRotation(); }
glm::vec3 getOffsetScale() const { return _offset.getScale(); }
bool getParentVisible() const;
// setters
void setParentPanel(std::shared_ptr<OverlayPanel> panel) { _parentPanel = panel; }
void setOffsetPosition(const glm::vec3& position) { _offset.setTranslation(position); }
void setOffsetRotation(const glm::quat& rotation) { _offset.setRotation(rotation); }
void setOffsetScale(float scale) { _offset.setScale(scale); }
void setOffsetScale(const glm::vec3& scale) { _offset.setScale(scale); }
QScriptValue getProperty(QScriptEngine* scriptEngine, const QString& property);
void setProperties(const QScriptValue& properties);
protected:
virtual void applyTransformTo(Transform& transform, bool force = false);
quint64 _transformExpiry = 0;
private:
std::shared_ptr<OverlayPanel> _parentPanel = nullptr;
Transform _offset;
};
#endif // hifi_PanelAttachable_h