2017-01-09 16:55:03 +00:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
2016-12-03 14:14:06 +00:00
|
|
|
#ifndef FGQCANVASIMAGE_H
|
|
|
|
#define FGQCANVASIMAGE_H
|
|
|
|
|
|
|
|
#include <QPixmap>
|
2017-01-09 16:55:03 +00:00
|
|
|
#include <QQmlEngine>
|
2016-12-03 14:14:06 +00:00
|
|
|
|
|
|
|
#include "fgcanvaselement.h"
|
|
|
|
|
2017-02-17 05:38:40 +00:00
|
|
|
class ImageQuickItem;
|
|
|
|
|
2016-12-03 14:14:06 +00:00
|
|
|
class FGQCanvasImage : public FGCanvasElement
|
|
|
|
{
|
2016-12-21 10:25:58 +00:00
|
|
|
Q_OBJECT
|
2016-12-03 14:14:06 +00:00
|
|
|
public:
|
|
|
|
FGQCanvasImage(FGCanvasGroup* pr, LocalProp* prop);
|
|
|
|
|
2017-01-09 16:55:03 +00:00
|
|
|
CanvasItem* createQuickItem(QQuickItem *parent) override;
|
|
|
|
CanvasItem* quickItem() const override;
|
2018-06-24 13:11:38 +00:00
|
|
|
|
|
|
|
void dumpElement() override;
|
2016-12-03 14:14:06 +00:00
|
|
|
protected:
|
|
|
|
virtual void doPaint(FGCanvasPaintContext* context) const override;
|
|
|
|
|
|
|
|
virtual void markStyleDirty() override;
|
|
|
|
|
2017-11-28 22:54:12 +00:00
|
|
|
void doDestroy() override;
|
2017-01-09 16:55:03 +00:00
|
|
|
|
2017-11-03 13:56:43 +00:00
|
|
|
void doPolish() override;
|
2016-12-21 10:25:58 +00:00
|
|
|
private slots:
|
|
|
|
void markImageDirty();
|
2016-12-21 15:26:20 +00:00
|
|
|
void markSourceDirty();
|
2016-12-21 10:25:58 +00:00
|
|
|
|
2016-12-03 14:14:06 +00:00
|
|
|
private:
|
|
|
|
bool onChildAdded(LocalProp *prop) override;
|
|
|
|
|
|
|
|
void rebuildImage() const;
|
2016-12-21 15:26:20 +00:00
|
|
|
void recomputeSourceRect() const;
|
2016-12-21 10:25:58 +00:00
|
|
|
|
2016-12-03 14:14:06 +00:00
|
|
|
private:
|
|
|
|
mutable bool _imageDirty;
|
2016-12-21 15:26:20 +00:00
|
|
|
mutable bool _sourceRectDirty = true;
|
2016-12-03 14:14:06 +00:00
|
|
|
mutable QPixmap _image;
|
|
|
|
QString _source;
|
2016-12-18 23:52:16 +00:00
|
|
|
mutable QSizeF _destSize;
|
2016-12-21 15:26:20 +00:00
|
|
|
mutable QRectF _sourceRect;
|
2017-01-09 16:55:03 +00:00
|
|
|
|
2017-02-17 05:38:40 +00:00
|
|
|
ImageQuickItem* _quickItem = nullptr;
|
2016-12-03 14:14:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // FGQCANVASIMAGE_H
|