Commit 8d7dfb84 authored by Boudewijn Rempt's avatar Boudewijn Rempt

The airbrush tool now does do something -- it paints transparently and

increases paint deposition using a timer, but it's not close to what I
intended.

svn path=/trunk/koffice/; revision=296145
parent 93ff75a6
......@@ -71,3 +71,6 @@ Files and classes
It's preferred (and strongly preferred) to have only one class per .h/.cpp file.
(Which is logical, because otherwise you won't be able to keep to the naming scheme.)
Spaces
Keep the source airy and open: put spaces around -> and * and the like.
* Fix speed of painting.
* Move composite ops and paint ops to capability framework
* Add tranform dialog (scale, shear etc.) and debug transform code.
* Fix drawing position to be middle of each brush, instead of under the brush -- see linetool
* Fix linetool to use pressure to draw tapered lines.
* The image which you see and the one on which you paint are not alyways the same.
* Brush cursor shapes for tools (updating cursors from the tools doesn't work yet).
* Give each layer its own imagetype; allow layers of diverse types in one image.
* Option dialog for tools
* Make tools kparts
* Fix scrollbars
* make brush tool antialiased; make un-antialiased pen tool
......
......@@ -40,7 +40,8 @@ enum enumBrushType {
MASK,
IMAGE,
PIPE_MASK,
PIPE_IMAGE
PIPE_IMAGE,
AIRBRUSH
};
class KisBrush : public KisResource {
......
......@@ -625,6 +625,9 @@ float KisPainter::paintLine(const enumPaintOp paintOp,
case PAINTOP_ERASE:
eraseAt(p, pressure, xTilt, yTilt);
break;
case PAINTOP_AIRBRUSH:
airBrushAt(p, pressure, xTilt, yTilt);
break;
default:
kdDebug() << "Paint operation not implemented yet.\n";
}
......@@ -739,7 +742,7 @@ void KisPainter::eraseAt(const QPoint &pos,
"eraser_dab");
if (m_device -> alpha()) {
kdDebug() << "Erase to inverted brush transparency.\n";
//kdDebug() << "Erase to inverted brush transparency.\n";
m_dab -> setOpacity(OPACITY_OPAQUE);
for (int y = 0; y < mask -> height(); y++) {
for (int x = 0; x < mask -> width(); x++) {
......@@ -749,7 +752,7 @@ void KisPainter::eraseAt(const QPoint &pos,
}
bitBlt( r.x(), r.y(), COMPOSITE_ERASE, m_dab.data() );
} else {
kdDebug() << "Erase to background colour.\n";
//kdDebug() << "Erase to background colour.\n";
m_dab -> setOpacity(OPACITY_TRANSPARENT);
for (int y = 0; y < mask -> height(); y++) {
for (int x = 0; x < mask -> width(); x++) {
......@@ -803,6 +806,44 @@ void KisPainter::airBrushAt(const QPoint &pos,
// Anyway, it's exactly twenty years ago that I have held a real
// airbrush, for the first and up to now the last time...
//
// For now: use the current brush shape -- it beats calculating
// ellipes and cones, and it shows the working of the timer.
if (!m_device) return;
QPoint hotSpot = m_brush -> hotSpot(pressure);
Q_INT32 x = pos.x() - hotSpot.x();
Q_INT32 y = pos.y() - hotSpot.y();
// This is going to be sloooooow!
if (m_pressure != pressure || m_brush -> brushType() == PIPE_MASK || m_brush -> brushType() == PIPE_IMAGE || m_dab == 0) {
if (m_brush -> brushType() == IMAGE || m_brush -> brushType() == PIPE_IMAGE) {
m_dab = m_brush -> image(pressure);
}
else {
KisAlphaMask * mask = m_brush -> mask(pressure);
computeDab(mask);
}
m_pressure = pressure;
}
// Draw correctly near the left and top edges
Q_INT32 sx = 0;
Q_INT32 sy = 0;
if (x < 0) {
sx = -x;
x = 0;
}
if (y < 0) {
sy = -y;
y = 0;
}
bitBlt( x, y, COMPOSITE_OVER, m_dab.data(), OPACITY_OPAQUE / 50, sx, sy, m_dab -> width(), m_dab -> height());
m_dirtyRect |= QRect(x, y, m_dab -> width(), m_dab -> height());
#if 0
KisView *view = getCurrentView();
......
/*
* kis_tool_airbrush.cc - part of Krayon^WKrita
* kis_tool_airbrush.cc - part of KimageShop^WKrayon^WKrita
*
* Copyright (c) 1999 Matthias Elter <me@kde.org>
* Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
......@@ -21,17 +21,18 @@
#include <qevent.h>
#include <qtimer.h>
#include <kdebug.h>
#include <kaction.h>
#include <kcommand.h>
#include <kdebug.h>
#include <klocale.h>
#include "kis_brush.h"
#include "kis_cursor.h"
#include "kis_dlg_toolopts.h"
#include "kis_doc.h"
#include "kis_painter.h"
#include "kis_view.h"
#include "kis_tool_airbrush.h"
#include "kis_view.h"
namespace {
Q_INT32 RATE = 100;
......@@ -61,11 +62,16 @@ KisToolAirBrush::~KisToolAirBrush()
void KisToolAirBrush::timeoutPaint()
{
if (m_painter) m_painter -> airBrushAt(m_currentPos, m_pressure, m_xTilt, m_yTilt);
if (m_painter) {
kdDebug() << "timeout airbrush\n";
m_painter -> airBrushAt(m_currentPos, m_pressure, m_xTilt, m_yTilt);
m_currentImage -> notify( m_painter -> dirtyRect() );
}
}
void KisToolAirBrush::update(KisCanvasSubject *subject)
{
kdDebug() << "Airbrush update\n";
m_subject = subject;
m_currentImage = subject -> currentImg();
......@@ -74,6 +80,7 @@ void KisToolAirBrush::update(KisCanvasSubject *subject)
void KisToolAirBrush::mousePress(QMouseEvent *e)
{
kdDebug() << "Airbrush mousepress\n";
if (!m_subject) return;
if (!m_currentImage) return;
if (!m_currentImage -> activeDevice()) return;
......@@ -155,6 +162,7 @@ void KisToolAirBrush::initPaint(const QPoint & pos)
m_painter -> beginTransaction(i18n("airbrush"));
}
m_painter -> setBrush(m_subject -> currentBrush());
m_painter -> setPaintColor(m_subject -> fgColor());
// Set the cursor -- ideally. this should be a mask created from the brush,
......@@ -165,7 +173,7 @@ void KisToolAirBrush::initPaint(const QPoint & pos)
setCursor(KisCursor::brushCursor());
#endif
m_timer -> start( RATE);
m_timer -> start( RATE );
}
void KisToolAirBrush::endPaint()
......@@ -206,7 +214,7 @@ void KisToolAirBrush::setup(KActionCollection *collection)
KToggleAction * toggle;
toggle = new KToggleAction(i18n("&Airbrush Tool"),
"airbrush", 0, this,
SLOT(active()), collection,
SLOT(activate()), collection,
"tool_airbrush");
toggle -> setExclusiveGroup("tools");
}
......
......@@ -27,6 +27,7 @@ class QPoint;
class QTimer;
class KisPainter;
class KisBrush;
class KisToolAirBrush : public KisToolPaint {
Q_OBJECT
......@@ -47,6 +48,7 @@ class KisToolAirBrush : public KisToolPaint {
virtual KDialog * optionsDialog(QWidget * parent);
protected slots:
void timeoutPaint();
......@@ -75,6 +77,12 @@ class KisToolAirBrush : public KisToolPaint {
KisCanvasSubject *m_subject;
KisImageSP m_currentImage;
KisBrush *m_dummyBrush; // The airbrush doesn't use a real
// brush-shape, but still needs a way
// to get the initial size info into
// KisPainter.
};
#endif // KIS_TOOL_AIRBRUSH_H
......@@ -158,8 +158,8 @@ void KisToolBrush::initPaint(const QPoint & pos)
m_painter -> setPaintColor(m_subject -> fgColor());
m_painter -> setBrush(m_subject -> currentBrush());
m_painter->setOpacity(m_opacity);
m_painter->setCompositeOp(m_compositeOp);
m_painter -> setOpacity(m_opacity);
m_painter -> setCompositeOp(m_compositeOp);
// Set the cursor -- ideally. this should be a mask created from the brush,
// now that X11 can handle colored cursors.
......
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