Common parent class Element for Paint and Mapping, with appropriate QProperties.

This commit is contained in:
Tats
2016-01-21 16:18:59 -05:00
parent c656f8246a
commit 8ec9192f69
5 changed files with 23 additions and 5 deletions
+3
View File
@@ -19,8 +19,11 @@
#include "Element.h"
#include <QDebug>
Element::Element(uid id, UidAllocator* allocator) : _name(""), _isLocked(false), _opacity(1.0f), _allocator(allocator)
{
qDebug() << "Trying to create Element with allocator " << allocator << " and id " << id << endl;
if (id == NULL_UID)
id = allocator->allocate();
else
+8 -2
View File
@@ -22,17 +22,21 @@
#include <QtGlobal>
#include <QObject>
#include <QIcon>
#include "UidAllocator.h"
Q_DECLARE_METATYPE(uid)
class Element : public QObject
{
Q_OBJECT
Q_PROPERTY(uid id READ getId)
Q_PROPERTY(QString name READ getName WRITE setName RESET unsetName)
Q_PROPERTY(bool locked READ isLocked WRITE setLocked)
Q_PROPERTY(QString name READ getName WRITE setName RESET unsetName)
Q_PROPERTY(bool locked READ isLocked WRITE setLocked)
Q_PROPERTY(float opacity READ getOpacity WRITE setOpacity)
Q_PROPERTY(QIcon icon READ getIcon)
public:
Element(uid id, UidAllocator* allocator);
@@ -55,6 +59,8 @@ public:
virtual void build() {}
virtual QIcon getIcon() const { return QIcon(); }
private:
uid _id;
QString _name;
+5 -3
View File
@@ -50,11 +50,11 @@ class Mapping : public Element
Q_PROPERTY(bool visible READ isVisible WRITE setVisible)
Q_PROPERTY(int depth READ getDepth WRITE setDepth)
Q_PROPERTY(MShape::ptr shape READ getShape)
Q_PROPERTY(MShape::ptr inputShape READ getInputShape)
// Q_PROPERTY(MShape::ptr shape READ getShape)
// Q_PROPERTY(MShape::ptr inputShape READ getInputShape)
Q_PROPERTY(bool hasInputShape READ hasInputShape STORED false)
Q_PROPERTY(Paint::ptr paint READ getPaint WRITE setPaint)
// Q_PROPERTY(Paint::ptr paint READ getPaint WRITE setPaint)
protected:
/// The input Paint instance.
@@ -126,6 +126,7 @@ public:
*/
class ColorMapping : public Mapping
{
Q_OBJECT
public:
ColorMapping(Paint::ptr paint, MShape::ptr shape,
uid id=NULL_UID)
@@ -143,6 +144,7 @@ public:
*/
class TextureMapping : public Mapping
{
Q_OBJECT
private:
MShape::ptr _inputShape;
+2
View File
@@ -45,10 +45,12 @@ bool Image::setUri(const QString &uri)
Media::Media(const QString uri_, bool live, double rate, uid id):
Texture(id),
uri(uri_),
impl_(NULL)
{
impl_ = new MediaImpl(uri_, live);
setRate(rate);
setVolume(1.0);
}
// vertigo
+5
View File
@@ -37,6 +37,8 @@
#include "Element.h"
Q_DECLARE_METATYPE(GLfloat)
/**
* A Paint is a style that can be applied when drawing potentially any shape.
*
@@ -180,6 +182,7 @@ protected:
QImage image;
public:
Q_INVOKABLE Image(int id=NULL_UID) : Texture(id) {}
Image(const QString uri_, uid id=NULL_UID) :
Texture(id)
{
@@ -207,6 +210,8 @@ public:
}
virtual bool bitsHaveChanged() const { return bitsChanged; }
virtual QIcon getIcon() const { return QIcon(QPixmap::fromImage(image)); }
};
class MediaImpl; // forward declaration