Commit ca9cae6d authored by Sven Langkamp's avatar Sven Langkamp

add templated KisSimplePaintOpFactory to replace most of the copied factorys

svn path=/trunk/koffice/; revision=1066766
parent 0ccde307
set(kritachalkpaintop_PART_SRCS
chalk_paintop_plugin.cpp
kis_chalk_paintop.cpp
kis_chalk_paintop_factory.cpp
kis_chalkop_option.cpp
kis_chalk_paintop_settings.cpp
kis_chalk_paintop_settings_widget.cpp
......
......@@ -29,7 +29,7 @@
#include "kis_chalk_paintop.h"
#include "kis_chalk_paintop_factory.h"
#include "kis_simple_paintop_factory.h"
#include "kis_global.h"
......@@ -43,7 +43,7 @@ ChalkPaintOpPlugin::ChalkPaintOpPlugin(QObject *parent, const QStringList &)
//
setComponentData(ChalkPaintOpPluginFactory::componentData());
KisPaintOpRegistry *r = KisPaintOpRegistry::instance();
r->add(new KisChalkPaintOpFactory);
r->add(new KisSimplePaintOpFactory<KisChalkPaintOp, KisChalkPaintOpSettings, KisChalkPaintOpSettingsWidget>("chalkbrush", i18n("Chalk brush"), "krita-chalk.png"));
}
......
/*
* Copyright (c) 2008 Lukáš Tvrdý <lukast.dev@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.
*/
#include "kis_chalk_paintop_factory.h"
#include "kis_chalk_paintop.h"
#include "kis_chalk_paintop_settings.h"
#include "kis_chalk_paintop_settings_widget.h"
#include <KoInputDevice.h>
#include <kis_image.h>
#include <kis_painter.h>
#include <kis_types.h>
KisChalkPaintOpFactory::KisChalkPaintOpFactory()
{
}
KisChalkPaintOpFactory::~KisChalkPaintOpFactory()
{
}
KisPaintOp * KisChalkPaintOpFactory::createOp(const KisPaintOpSettingsSP settings, KisPainter * painter, KisImageWSP image = 0)
{
const KisChalkPaintOpSettings *chalkSettings =
dynamic_cast<const KisChalkPaintOpSettings *>(settings.data());
Q_ASSERT(settings == 0 || chalkSettings != 0);
KisPaintOp * op = new KisChalkPaintOp(chalkSettings, painter, image);
Q_CHECK_PTR(op);
return op;
}
KisPaintOpSettingsSP KisChalkPaintOpFactory::settings(const KoInputDevice& inputDevice, KisImageWSP image)
{
Q_UNUSED(inputDevice);
Q_UNUSED(image);
return new KisChalkPaintOpSettings();
}
KisPaintOpSettingsSP KisChalkPaintOpFactory::settings(KisImageWSP image)
{
Q_UNUSED(image);
return new KisChalkPaintOpSettings();
}
KisPaintOpSettingsWidget* KisChalkPaintOpFactory::createSettingsWidget(QWidget* parent)
{
return new KisChalkPaintOpSettingsWidget(parent);
}
/*
* Copyright (c) 2008 Boudewijn Rempt <boud@valdyas.org>
* Copyright (c) 2008 Lukas Tvrdy <lukast.dev@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_CHALK_PAINTOP_FACTORY_H_
#define KIS_CHALK_PAINTOP_FACTORY_H_
#include <klocale.h>
#include <kis_paintop_factory.h>
#include <kis_types.h>
#include "kis_chalk_paintop_settings.h"
class KisPainter;
class KisChalkPaintOpSettings;
class KisChalkPaintOpFactory : public KisPaintOpFactory
{
public:
KisChalkPaintOpFactory();
virtual ~KisChalkPaintOpFactory();
virtual KisPaintOp * createOp(const KisPaintOpSettingsSP settings, KisPainter * painter, KisImageWSP image);
virtual QString id() const {
return "chalkbrush";
}
virtual QString name() const {
return i18n("Chalk brush");
}
virtual QString pixmap() {
return "krita-chalk.png";
}
virtual KisPaintOpSettingsSP settings(const KoInputDevice& inputDevice, KisImageWSP image);
virtual KisPaintOpSettingsSP settings(KisImageWSP image);
virtual KisPaintOpSettingsWidget* createSettingsWidget(QWidget* parent);
};
#endif // KIS_CHALK_PAINTOP_FACTORY_H_
......@@ -3,7 +3,6 @@ set(kritacurvepaintop_PART_SRCS
curve_paintop_plugin.cpp
kis_curve_paintop.cpp
kis_curve_paintop_settings.cpp
kis_curve_paintop_factory.cpp
kis_curve_paintop_settings_widget.cpp
)
......
......@@ -29,7 +29,7 @@
#include <kis_paintop_registry.h>
#include "kis_curve_paintop.h"
#include "kis_curve_paintop_factory.h"
#include "kis_simple_paintop_factory.h"
#include "kis_global.h"
typedef KGenericFactory<CurvePaintOpPlugin> CurvePaintOpPluginFactory;
......@@ -41,7 +41,7 @@ CurvePaintOpPlugin::CurvePaintOpPlugin(QObject *parent, const QStringList &)
{
setComponentData(CurvePaintOpPluginFactory::componentData());
KisPaintOpRegistry *r = KisPaintOpRegistry::instance();
r->add(new KisCurvePaintOpFactory);
r->add(new KisSimplePaintOpFactory<KisCurvePaintOp, KisCurvePaintOpSettings, KisCurvePaintOpSettingsWidget>("curvebrush", i18n("Curve brush"), "krita-curve.png"));
}
......
/*
* Copyright (c) 2008 Lukáš Tvrdý (lukast.dev@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.
*/
#include "kis_curve_paintop_factory.h"
#include <kis_painter.h>
#include <kis_paintop_settings.h>
#include <kis_image.h>
#include <KoInputDevice.h>
#include "kis_curve_paintop_settings_widget.h"
#include "kis_curve_paintop_settings.h"
#include "kis_curve_paintop.h"
KisCurvePaintOpFactory::KisCurvePaintOpFactory()
{
}
KisPaintOp * KisCurvePaintOpFactory::createOp(const KisPaintOpSettingsSP settings, KisPainter * painter, KisImageWSP image = 0)
{
const KisCurvePaintOpSettings *curveSettings = dynamic_cast<const KisCurvePaintOpSettings *>(settings.data());
Q_ASSERT(settings == 0 || curveSettings != 0);
KisPaintOp * op = new KisCurvePaintOp(curveSettings, painter, image);
Q_CHECK_PTR(op);
return op;
}
KisPaintOpSettingsSP KisCurvePaintOpFactory::settings(const KoInputDevice& inputDevice, KisImageWSP image)
{
Q_UNUSED(inputDevice);
Q_UNUSED(image);
return new KisCurvePaintOpSettings();
}
KisPaintOpSettingsSP KisCurvePaintOpFactory::settings(KisImageWSP image)
{
Q_UNUSED(image);
return new KisCurvePaintOpSettings();
}
KisPaintOpSettingsWidget* KisCurvePaintOpFactory::createSettingsWidget(QWidget* parent)
{
return new KisCurvePaintOpSettingsWidget(parent);
}
/*
* Copyright (c) 2008 Lukáš Tvrdý (lukast.dev@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_CURVE_PAINTOP_FACTORY_H_
#define KIS_CURVE_PAINTOP_FACTORY_H_
#include <kis_paintop_factory.h>
#include <kis_types.h>
#include <klocale.h>
#include <QString>
class KisPaintOp;
class KisPainter;
class QWidget;
class KoInputDevice;
class KisCurvePaintOpFactory : public KisPaintOpFactory
{
public:
virtual ~KisCurvePaintOpFactory() {}
KisCurvePaintOpFactory();
virtual KisPaintOp * createOp(const KisPaintOpSettingsSP settings, KisPainter * painter, KisImageWSP image);
virtual QString id() const {
return "curvebrush";
}
virtual QString name() const {
return i18n("Curve brush");
}
virtual QString pixmap() {
return "krita-curve.png";
}
virtual KisPaintOpSettingsSP settings(const KoInputDevice& inputDevice, KisImageWSP image);
virtual KisPaintOpSettingsSP settings(KisImageWSP image);
virtual KisPaintOpSettingsWidget* createSettingsWidget(QWidget* parent);
};
#endif
......@@ -9,11 +9,9 @@ include_directories(smudge)
set(kritadefaultpaintops_PART_SRCS
defaultpaintops_plugin.cc
airbrush/kis_airbrushop.cpp
airbrush/kis_airbrushop_factory.cpp
airbrush/kis_airbrushop_settings.cpp
airbrush/kis_airbrushop_settings_widget.cpp
brush/kis_brushop.cpp
brush/kis_brushop_factory.cpp
brush/kis_brushop_settings.cpp
brush/kis_brushop_settings_widget.cpp
duplicate/kis_duplicateop.cpp
......@@ -22,15 +20,12 @@ set(kritadefaultpaintops_PART_SRCS
duplicate/kis_duplicateop_settings_widget.cpp
duplicate/kis_duplicateop_option.cpp
eraser/kis_eraseop.cpp
eraser/kis_eraseop_factory.cpp
eraser/kis_eraseop_settings.cpp
eraser/kis_eraseop_settings_widget.cpp
pen/kis_penop.cpp
pen/kis_penop_factory.cpp
pen/kis_penop_settings.cpp
pen/kis_penop_settings_widget.cpp
smudge/kis_smudgeop.cpp
smudge/kis_smudgeop_factory.cpp
smudge/kis_smudgeop_settings.cpp
smudge/kis_smudgeop_settings_widget.cpp
)
......
......@@ -45,10 +45,11 @@
#include "kis_airbrushop_settings_widget.h"
KisAirbrushOp::KisAirbrushOp(const KisAirbrushOpSettings *settings, KisPainter *painter)
KisAirbrushOp::KisAirbrushOp(const KisAirbrushOpSettings *settings, KisPainter *painter, KisImageWSP image)
: KisBrushBasedPaintOp(painter)
, settings(settings)
{
Q_UNUSED(image);
Q_ASSERT(settings);
Q_ASSERT(painter);
if (settings->m_options) {
......
......@@ -34,7 +34,7 @@ class KisAirbrushOp : public KisBrushBasedPaintOp
public:
KisAirbrushOp(const KisAirbrushOpSettings *settings, KisPainter * painter);
KisAirbrushOp(const KisAirbrushOpSettings *settings, KisPainter * painter, KisImageWSP image);
virtual ~KisAirbrushOp();
// We want to spray even when the pointer doesn't move.
......
/*
* Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
* Copyright (c) 2004-2008 Boudewijn Rempt <boud@valdyas.org>
* Copyright (c) 2004 Clarence Dang <dang@kde.org>
* Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com>
* Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
*
* 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.
*/
#include "kis_airbrushop_factory.h"
#include <KoInputDevice.h>
#include <kis_painter.h>
#include <kis_paintop_settings.h>
#include <kis_image.h>
#include "kis_airbrushop_settings_widget.h"
#include "kis_airbrushop_settings.h"
#include "kis_airbrushop.h"
KisAirbrushOpFactory::KisAirbrushOpFactory()
{
}
KisAirbrushOpFactory::~KisAirbrushOpFactory()
{
}
KisPaintOp * KisAirbrushOpFactory::createOp(const KisPaintOpSettingsSP settings,
KisPainter * painter,
KisImageWSP image)
{
Q_UNUSED(image);
const KisAirbrushOpSettings *airbrushopSettings = dynamic_cast<const KisAirbrushOpSettings *>(settings.data());
Q_ASSERT(settings != 0 && airbrushopSettings != 0);
KisPaintOp * op = new KisAirbrushOp(airbrushopSettings, painter);
Q_CHECK_PTR(op);
return op;
}
KisPaintOpSettingsSP KisAirbrushOpFactory::settings(const KoInputDevice& inputDevice, KisImageWSP image)
{
Q_UNUSED(inputDevice);
Q_UNUSED(image);
return new KisAirbrushOpSettings();
}
KisPaintOpSettingsSP KisAirbrushOpFactory::settings(KisImageWSP image)
{
Q_UNUSED(image);
return new KisAirbrushOpSettings();
}
KisPaintOpSettingsWidget* KisAirbrushOpFactory::createSettingsWidget(QWidget* parent)
{
return new KisAirbrushOpSettingsWidget(parent);
}
......@@ -61,10 +61,11 @@
#include <kis_color_source.h>
#include <kis_pressure_mix_option.h>
KisBrushOp::KisBrushOp(const KisBrushOpSettings *settings, KisPainter *painter)
KisBrushOp::KisBrushOp(const KisBrushOpSettings *settings, KisPainter *painter, KisImageWSP image)
: KisBrushBasedPaintOp(painter)
, settings(settings)
{
Q_UNUSED(image);
Q_ASSERT(settings);
Q_ASSERT(painter);
if (settings && settings->m_options) {
......
......@@ -44,7 +44,7 @@ class KisBrushOp : public KisBrushBasedPaintOp
public:
KisBrushOp(const KisBrushOpSettings *settings, KisPainter * painter);
KisBrushOp(const KisBrushOpSettings *settings, KisPainter * painter, KisImageWSP image);
virtual ~KisBrushOp();
void paintAt(const KisPaintInformation& info);
......
/*
* Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
* Copyright (c) 2004-2008 Boudewijn Rempt <boud@valdyas.org>
* Copyright (c) 2004 Clarence Dang <dang@kde.org>
* Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com>
* Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
*
* 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.
*/
#include "kis_brushop_factory.h"
#include <KoInputDevice.h>
#include <kis_painter.h>
#include <kis_paintop_settings.h>
#include <kis_image.h>
#include "kis_brushop_settings_widget.h"
#include "kis_brushop_settings.h"
#include "kis_brushop.h"
KisBrushOpFactory::KisBrushOpFactory()
{
}
KisBrushOpFactory::~KisBrushOpFactory()
{
}
KisPaintOp * KisBrushOpFactory::createOp(const KisPaintOpSettingsSP settings,
KisPainter * painter,
KisImageWSP image)
{
Q_UNUSED(image);
const KisBrushOpSettings *brushopSettings = dynamic_cast<const KisBrushOpSettings *>(settings.data());
Q_ASSERT(settings != 0 && brushopSettings != 0);
KisPaintOp * op = new KisBrushOp(brushopSettings, painter);
Q_CHECK_PTR(op);
return op;
}
KisPaintOpSettingsSP KisBrushOpFactory::settings(const KoInputDevice& inputDevice, KisImageWSP image)
{
// XXX: store widgets per inputDevice?
Q_UNUSED(inputDevice);
Q_UNUSED(image);
return new KisBrushOpSettings();
}
KisPaintOpSettingsSP KisBrushOpFactory::settings(KisImageWSP image)
{
Q_UNUSED(image);
return new KisBrushOpSettings();
}
KisPaintOpSettingsWidget* KisBrushOpFactory::createSettingsWidget(QWidget* parent)
{
return new KisBrushOpSettingsWidget(parent);
}
/*
* Copyright (c) 2002 Patrick Julien <freak@codepimps.org>
* Copyright (c) 2004-2008 Boudewijn Rempt <boud@valdyas.org>
* Copyright (c) 2004 Clarence Dang <dang@kde.org>
* Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com>
* Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
*
* 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_BRUSHOP_FACTORY_H_
#define KIS_BRUSHOP_FACTORY_H_
#include <kis_paintop_factory.h>
#include <kis_types.h>
#include <klocale.h>
#include <QString>
class KisPaintOp;
class KisPainter;
class QWidget;
class KoInputDevice;
class KisBrushOpFactory : public KisPaintOpFactory
{
public:
KisBrushOpFactory();
virtual ~KisBrushOpFactory();
virtual KisPaintOp * createOp(const KisPaintOpSettingsSP settings, KisPainter * painter, KisImageWSP image);
virtual QString id() const {
return "paintbrush";
}
virtual QString name() const {
return i18n("Pixel Brush");
}
virtual QString pixmap() {
return "krita-paintbrush.png";
}
virtual KisPaintOpSettingsSP settings(const KoInputDevice& inputDevice, KisImageWSP image);
virtual KisPaintOpSettingsSP settings(KisImageWSP image);
virtual KisPaintOpSettingsWidget* createSettingsWidget(QWidget* parent);
};
#endif // KIS_BRUSHOP_FACTORY_H_
......@@ -26,12 +26,19 @@
#include <kis_debug.h>
#include <kgenericfactory.h>
#include "kis_airbrushop_factory.h"
#include "kis_brushop_factory.h"
#include "kis_simple_paintop_factory.h"
#include "kis_airbrushop.h"
#include "kis_airbrushop_settings.h"
#include "kis_airbrushop_settings_widget.h"
#include "kis_brushop.h"
#include "kis_brushop_settings.h"
#include "kis_duplicateop_factory.h"
#include "kis_eraseop_factory.h"
#include "kis_penop_factory.h"
#include "kis_smudgeop_factory.h"
#include "kis_eraseop.h"
#include "kis_eraseop_settings.h"
#include "kis_penop.h"
#include "kis_penop_settings.h"
#include "kis_smudgeop.h"
#include "kis_smudgeop_settings.h"
#include "kis_global.h"
#include "kis_paintop_registry.h"
......@@ -45,12 +52,12 @@ DefaultPaintOpsPlugin::DefaultPaintOpsPlugin(QObject *parent, const QStringList
setComponentData(DefaultPaintOpsPluginFactory::componentData());
KisPaintOpRegistry *r = KisPaintOpRegistry::instance();
r->add(new KisAirbrushOpFactory);
r->add(new KisBrushOpFactory);
r->add(new KisSimplePaintOpFactory<KisAirbrushOp, KisAirbrushOpSettings, KisAirbrushOpSettingsWidget>("airbrush", i18n("Pixel Airbrush"), "krita-airbrush.png"));
r->add(new KisSimplePaintOpFactory<KisBrushOp, KisBrushOpSettings, KisBrushOpSettingsWidget>("paintbrush", i18n("Pixel Brush"), "krita-paintbrush.png"));
r->add(new KisDuplicateOpFactory);
r->add(new KisEraseOpFactory);
r->add(new KisPenOpFactory);
r->add(new KisSmudgeOpFactory);
r->add(new KisSimplePaintOpFactory<KisEraseOp, KisEraseOpSettings, KisEraseOpSettingsWidget>("eraser", i18n("Pixel Eraser"), "krita-eraser.png"));
r->add(new KisSimplePaintOpFactory<KisPenOp, KisPenOpSettings, KisPenOpSettingsWidget>("pencil", "Pixel Pencil", "krita-pencil.png"));
r->add(new KisSimplePaintOpFactory<KisSmudgeOp, KisSmudgeOpSettings, KisSmudgeOpSettingsWidget>("smudge", i18n("Smudge Brush"), "krita-smudgebrush.png"));
}
DefaultPaintOpsPlugin::~DefaultPaintOpsPlugin()
......
......@@ -59,10 +59,11 @@
#include <kis_eraseop_settings_widget.h>
KisEraseOp::KisEraseOp(const KisEraseOpSettings *settings, KisPainter *painter)
KisEraseOp::KisEraseOp(const KisEraseOpSettings *settings, KisPainter *painter, KisImageWSP image)
: KisBrushBasedPaintOp(painter)
, settings(settings)
{
Q_UNUSED(image);
Q_ASSERT(settings);
Q_ASSERT(painter);
if (settings->m_options) {
......
......@@ -50,7 +50,7 @@ class KisEraseOp : public KisBrushBasedPaintOp
public:
KisEraseOp(const KisEraseOpSettings *settings, KisPainter * painter);
KisEraseOp(const KisEraseOpSettings *settings, KisPainter * painter, KisImageWSP image);
virtual ~KisEraseOp();
void paintAt(const KisPaintInformation& info);
......