Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 73e29047 authored by Blackbeard (alberto flores)'s avatar Blackbeard (alberto flores) 🚢

Added draft of kis_animated_brushes

parent 0348ca49
/*
* Copyright (c) 2012 Dmitry Kazakov <dimula73@gmail.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 KIS_ANIMATED_BRUSHES_
#define KIS_ANIMATED_BRUSHES_
#include <kis_animated_brushes.h>
#include <kis_brushes_pipe.h>
#include <kis_vectoranimated_brush.h>
class KisAnimatedBrushes : public KisVectorAnimatedBrush
{
public:
KisAnimatedBrushes()
: m_isInitialized(false)
{
}
protected:
int chooseNextBrush(const KisPaintInformation& info) override {
if (!m_isInitialized) {
m_imageIndex = 0;
m_isInitialized = true;
} else {
m_imageIndex ++;
}
return m_imageIndex;
}
};
#endif /* __KIS_ANIMATED_BRUSHES_ */
......@@ -16,83 +16,25 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __KIS_ANIMATED_BRUSHES_H
#define __KIS_ANIMATED_BRUSHES_H
#ifndef KIS_ANIMATED_BRUSHES_
#define KIS_ANIMATED_BRUSHES_
template<class BrushType>
class KisAnimatedBrushes
{
public:
KisAnimatedBrushes() {
}
/* save the state of the brush here and change the brush here */
/* TODO: Fix a lot of things */
KisAnimatedBrushes(const KisBrushesPipe &rhs) {
qDeleteAll(m_brushes);
m_brushes.clear();
Q_FOREACH (BrushType * brush, rhs.m_brushes) {
BrushType *clonedBrush = dynamic_cast<BrushType*>(brush->clone());
KIS_ASSERT_RECOVER(clonedBrush) {continue;}
m_brushes.append(clonedBrush);
}
}
virtual ~KisBrushesPipe() {
qDeleteAll(m_brushes);
}
virtual void clear() {
qDeleteAll(m_brushes);
m_brushes.clear();
}
#include <kis_brushes_pipe.h>
#include <kis_vectoranimated_brush.h>
BrushType* firstBrush() const {
return m_brushes.first();
}
BrushType* lastBrush() const {
return m_brushes.last();
}
class KisImageBrushesPipe();
BrushType* currentBrush(const KisPaintInformation& info) {
return !m_brushes.isEmpty() ? m_brushes.at(chooseNextBrush(info)) : 0;
}
int brushIndex(const KisPaintInformation& info) {
return chooseNextBrush(info);
}
protected:
void addBrush(BrushType *brush) {
m_brushes.append(brush);
}
/**
* Returns the index of the brush that corresponds to the current
* values of \p info. This method is called *before* the dab is
* actually painted.
*
* The method is const, so no internal counters of the brush should
* change during its execution
*/
virtual int chooseNextBrush(const KisPaintInformation& info) = 0;
class BRUSH_EXPORT KisAnimatedBrushes : public KisVectorAnimatedBrush
{
public:
KisAnimatedBrushes(const QString& filename);
/**
* Updates internal counters of the brush *after* a dab has been
* painted on the canvas. Some incremental switching of the brushes
* may me implemented in this method.
*
* If \p seqNo is equal or greater than zero, then incremental iteration is
* overridden by this seqNo value
*/
virtual void updateBrushIndexes(const KisPaintInformation& info, int seqNo) = 0;
private:
int m_imageIndex;
struct Private;
Private * const m_d;
protected:
QVector<BrushType*> m_brushes;
};
#endif /* __KIS_ANIMATED_BRUSHES_H */
#endif /* __KIS_ANIMATED_BRUSHES_ */
......@@ -28,26 +28,28 @@
#include <KoDocumentResourceManager.h>
#include <KoXmlReader.h>
#include <KoShapePainter.h>
#include <kis_brushes_pipe.h>
#include <QDebug>
KisVectorAnimatedBrush::KisVectorAnimatedBrush(const QString& filename)
: KisScalingSizeBrush(filename)
/* , m_imageNumber(0)
, m_isInitialized(false) */
{
setBrushType(INVALID);
setSpacing(0.25);
setHasColor(false);
m_imageNumber = 0;
m_numberOfImages = 0;
m_isInitialized = false;
if (m_isInitialized) {
/*
if (!m_isInitialized) {
if (m_imageNumber == m_numberOfImages) {
m_imageNumber = 0;
qDebug() << "m_imageNumber" << m_imageNumber;
} else {
m_imageNumber ++;
qDebug() << "m_imageNumber" << m_imageNumber;
}
}
} */
}
KisVectorAnimatedBrush::KisVectorAnimatedBrush(const KisVectorAnimatedBrush& rhs)
......@@ -107,7 +109,7 @@ bool KisVectorAnimatedBrush::loadFromDevice(QIODevice *dev)
qDebug() << list.at(i);
}
*/
// m_imageNumber = 0;
m_imageNumber = 0;
qDebug() << "Numero:" << m_imageNumber;
QList<KoShape*> single;
......@@ -126,7 +128,7 @@ bool KisVectorAnimatedBrush::loadFromDevice(QIODevice *dev)
*/
m_numberOfImages = list.size();
m_isInitialized = true;
qDebug() << "numberImages" << m_numberOfImages << "initialized" << m_isInitialized << "numero" << m_imageNumber ;
// qDebug() << "numberImages" << m_numberOfImages << "initialized" << m_isInitialized << "numero" << m_imageNumber ;
KoShapePainter painter;
painter.setShapes(single);
......@@ -225,3 +227,11 @@ void KisVectorAnimatedBrush::toXML(QDomDocument& d, QDomElement& e) const
predefinedBrushToXML("svg_brush", e);
KisBrush::toXML(d, e);
}
int KisVectorAnimatedBrush::currentIndex()
{
qDebug() << "m_imageNumber" << m_imageNumber;
return m_imageNumber;
}
......@@ -36,11 +36,15 @@ public:
QString defaultFileExtension() const override;
void toXML(QDomDocument& d, QDomElement& e) const override;
int currentIndex();
private:
QByteArray m_svg;
int m_imageNumber;
int m_numberOfImages;
bool m_isInitialized;
/* struct Private;
Private * const m_d; */
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment