61bf6b0f58
Currently displayed alongside the QPainter version, while establishing the accuracy of each mode, but this is temporary.
115 lines
2.8 KiB
C++
115 lines
2.8 KiB
C++
//
|
|
// Copyright (C) 2017 James Turner zakalawe@mac.com
|
|
//
|
|
// This program is free software; you can redistribute it and/or
|
|
// modify it under the terms of the GNU General Public License as
|
|
// published by the Free Software Foundation; either version 2 of the
|
|
// License, or (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful, but
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
// General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program; if not, write to the Free Software
|
|
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
#ifndef FGCANVASELEMENT_H
|
|
#define FGCANVASELEMENT_H
|
|
|
|
#include <QObject>
|
|
#include <QTransform>
|
|
#include <QColor>
|
|
#include <QVariant>
|
|
|
|
#include <vector>
|
|
|
|
class LocalProp;
|
|
class FGCanvasPaintContext;
|
|
class FGCanvasGroup;
|
|
class CanvasItem;
|
|
class QQuickItem;
|
|
|
|
class FGCanvasElement : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
explicit FGCanvasElement(FGCanvasGroup* pr, LocalProp* prop);
|
|
|
|
void paint(FGCanvasPaintContext* context) const;
|
|
|
|
QTransform combinedTransform() const;
|
|
|
|
bool isVisible() const;
|
|
|
|
int zIndex() const;
|
|
|
|
const FGCanvasGroup* parentGroup() const;
|
|
|
|
static bool isStyleProperty(QByteArray name);
|
|
|
|
LocalProp* property() const;
|
|
|
|
void setHighlighted(bool hilighted);
|
|
bool isHighlighted() const;
|
|
|
|
virtual CanvasItem* createQuickItem(QQuickItem* parent);
|
|
virtual CanvasItem* quickItem() const;
|
|
|
|
protected:
|
|
virtual void doPaint(FGCanvasPaintContext* context) const;
|
|
|
|
virtual bool onChildAdded(LocalProp* prop);
|
|
virtual bool onChildRemoved(LocalProp* prop);
|
|
|
|
const LocalProp* _propertyRoot;
|
|
const FGCanvasGroup* _parent;
|
|
|
|
QColor fillColor() const;
|
|
|
|
QColor parseColorValue(QVariant value) const;
|
|
|
|
virtual void markStyleDirty();
|
|
|
|
QVariant getCascadedStyle(const char* name, QVariant defaultValue = QVariant()) const;
|
|
private:
|
|
|
|
void onCenterChanged(QVariant value);
|
|
|
|
void markTransformsDirty();
|
|
|
|
void markZIndexDirty(QVariant value);
|
|
|
|
void onVisibleChanged(QVariant value);
|
|
|
|
void markClipDirty();
|
|
|
|
private:
|
|
friend class FGCanvasGroup;
|
|
|
|
bool _visible = true;
|
|
bool _highlighted = false;
|
|
|
|
mutable bool _transformsDirty = true;
|
|
mutable bool _styleDirty = true;
|
|
|
|
mutable QTransform _combinedTransform;
|
|
|
|
QPointF _center;
|
|
|
|
mutable QColor _fillColor;
|
|
int _zIndex = 0;
|
|
QByteArray _svgElementId;
|
|
|
|
mutable bool _clipDirty = true;
|
|
mutable bool _hasClip = false;
|
|
mutable QRectF _clipRect;
|
|
|
|
void parseCSSClip(QByteArray value) const;
|
|
float parseCSSValue(QByteArray value) const;
|
|
};
|
|
|
|
using FGCanvasElementVec = std::vector<FGCanvasElement*>;
|
|
|
|
#endif // FGCANVASELEMENT_H
|