Commit bfdadc4a authored by Boudewijn Rempt's avatar Boudewijn Rempt

* Brush is now default paintop

* Extended paintops and paintop factories with optional images and
  some capability getters
* Added a nice paintbrush image for the paintbrush.

svn path=/trunk/koffice/; revision=428047
parent 770d6a6f
......@@ -42,7 +42,8 @@ Core
* Histogram computations (#Boudewijn)
* Adjustment layers (Layers that dynamically apply a filter to
the layer they are linked to, these do not store actual
image date, except for an occasional mask)
image date, except for an occasional mask) These should work on object
layers (embedded KOFfice objects), too.
* Mask layers
* Layer groups or even better: a hierachy of collapsable folders with layers
* Loading and saving of selections
......@@ -57,6 +58,7 @@ Core
layer to anything.
* Long painter operations (e.g., convolution painter) should use the
progressbar and be cancelable.
* Add embedding of KOffice objects as layers.
File Format:
......
......@@ -23,6 +23,8 @@
#ifndef KIS_PAINTOP_H_
#define KIS_PAINTOP_H_
#include <qstring.h>
#include <ksharedptr.h>
#include <klocale.h>
......@@ -49,6 +51,11 @@ public:
const double /*xTilt*/,
const double /*yTilt*/) = 0;
void setSource(KisPaintDeviceSP p);
// Whether this paintop wants to deposit paint even when not moving, i.e. the
// tool needs to activate its timer.
virtual bool incremental() { return false; }
protected:
virtual KisLayerSP computeDab(KisAlphaMaskSP mask);
......@@ -73,6 +80,13 @@ public:
virtual KisPaintOp * createOp(KisPainter * painter) = 0;
virtual KisID id() { return KisID("abstractpaintop", i18n("Abstract PaintOp")); }
// The filename of the pixmap we can use to represent this paintop in the ui.
virtual QString pixmap() { return ""; };
// Whether this paintop is internal to a certain tool or can be used
// in various tools. If false, it won't show up in the toolchest.
virtual bool userVisible() { return true; }
/**
* Slot the paint op into the relevant toolbox, if so desired. It's
* up to the paintop to decide whether it want to so something with this
......
......@@ -15,9 +15,15 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <qpixmap.h>
#include "kdebug.h"
#include <kdebug.h>
#include <kinstance.h>
#include <kglobal.h>
#include <klocale.h>
#include <kstandarddirs.h>
#include "kis_factory.h"
#include "kis_generic_registry.h"
#include "kis_types.h"
#include "kis_paintop_registry.h"
......@@ -62,3 +68,37 @@ KisPaintOp * KisPaintOpRegistry::paintOp(const QString & id, KisPainter * painte
{
return paintOp(KisID(id, ""), painter);
}
bool KisPaintOpRegistry::userVisible(const KisID & id) const
{
KisPaintOpFactorySP f = get(id);
if (!f) {
kdDebug() << "No paintop " << id.id() << "\n";
return false;
}
return f->userVisible();
}
QPixmap KisPaintOpRegistry::getPixmap(const KisID & id) const
{
KisPaintOpFactorySP f = get(id);
if (!f) {
kdDebug() << "No paintop " << id.id() << "\n";
return QPixmap();
}
QString pname = f->pixmap();
if (pname.isEmpty() || pname.isNull() || pname == "") {
return QPixmap();
}
QString fname = KisFactory::global()->dirs()->findResource("kis_images", pname);
kdDebug() << "Found pixmap " << fname << " for " << id.id() << "\n";
return QPixmap(fname);
}
......@@ -32,6 +32,14 @@ public:
KisPaintOp * paintOp(const KisID& id, KisPainter * painter) const;
KisPaintOp * paintOp(const QString& id, KisPainter * painter) const;
// Whether we should show this paintop in the toolchest
bool userVisible(const KisID & id) const;
// Get the pixmap to show in the toolchest
QPixmap getPixmap(const KisID & id) const;
public:
static KisPaintOpRegistry* instance();
......
kritaimagesdir = $(prefix)/share/apps/krita/images
kritaimages_DATA = evenings.jpg hakonepa.jpg hiro_awate.jpg Azay-Le-Rideau.jpg
kritaimages_DATA = evenings.jpg hakonepa.jpg hiro_awate.jpg Azay-Le-Rideau.jpg paintbrush.png
......@@ -50,6 +50,9 @@ public:
KisAirbrushOp(KisPainter * painter);
virtual ~KisAirbrushOp();
// We want to spray even when the pointer doesn't move.
virtual bool incremental() { return true; }
void paintAt(const KisPoint &pos,
const double pressure,
const double /*xTilt*/,
......
......@@ -38,6 +38,7 @@ public:
virtual KisPaintOp * createOp(KisPainter * painter);
virtual KisID id() { return KisID("paintbrush", i18n("paintbrush")); }
virtual QString pixmap() { return "paintbrush.png"; };
};
class KisBrushOp : public KisPaintOp {
......
......@@ -37,6 +37,8 @@ public:
virtual KisPaintOp * createOp(KisPainter * painter);
virtual KisID id() { return KisID("duplicate", i18n("duplicate")); }
virtual bool userVisible() { return false; }
};
class KisDuplicateOp : public KisPaintOp {
......@@ -48,6 +50,7 @@ public:
KisDuplicateOp(KisPainter * painter);
virtual ~KisDuplicateOp();
void paintAt(const KisPoint &pos,
const double pressure,
const double /*xTilt*/,
......
......@@ -20,10 +20,15 @@
#include <qwidget.h>
#include <qstring.h>
#include <qvaluelist.h>
#include <qpixmap.h>
#include <klocale.h>
#include <kis_id.h>
#include <kis_paintop_registry.h>
#include <kis_view.h>
#include <kis_painter.h>
#include <kis_paintop.h>
#include "kis_paintop_box.h"
......@@ -31,6 +36,7 @@ KisPaintopBox::KisPaintopBox (KisView * parent, const char * name, WFlags f)
: super (parent, name, f),
m_view(parent)
{
setCaption(i18n("Painters toolchest"));
m_paintops = new QValueList<KisID>();
connect(this, SIGNAL(selected(const KisID &)), m_view, SLOT(paintopActivated(const KisID &)));
......@@ -39,8 +45,12 @@ KisPaintopBox::KisPaintopBox (KisView * parent, const char * name, WFlags f)
// XXX: Let's see... Are all paintops loaded and ready?
KisIDList keys = KisPaintOpRegistry::instance()->listKeys();
for ( KisIDList::Iterator it = keys.begin(); it != keys.end(); ++it ) {
addItem(*it);
kdDebug() << "Paintop: " << (*it).id() << "\n";
if (KisPaintOpRegistry::instance()->userVisible(*it)) {
addItem(*it);
}
}
setCurrentItem( m_paintops->findIndex(KisID("paintbrush","")));
}
......@@ -52,7 +62,14 @@ KisPaintopBox::~KisPaintopBox()
void KisPaintopBox::addItem(const KisID & paintop, const QString & /*category*/)
{
m_paintops->append(paintop);
insertItem(paintop.name());
QPixmap pm = KisPaintOpRegistry::instance()->getPixmap(paintop);
if (pm.isNull()) {
insertItem(paintop.name());
}
else {
insertItem(pm, paintop.name());
}
}
void KisPaintopBox::slotItemSelected(int index)
......
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