Commit f7fce9cd authored by Boudewijn Rempt's avatar Boudewijn Rempt

Krita can paint again! A single black 200x200 brush, but it's

painting. Detailed status update at 10. (Also fix compile problem
in KSpread's shape due to namespace clash)

svn path=/trunk/koffice/; revision=605423
parent ebfb9c49
......@@ -62,8 +62,8 @@ public:
/// Load brush from the specified data, at position dataPos, and set the filename
KisBrush(const QString& filename,
const QByteArray & data,
qint32 & dataPos);
const QByteArray & data,
qint32 & dataPos);
/// Load brush from the specified paint device, in the specified region
KisBrush(KisPaintDevice* image, int x, int y, int w, int h);
......
......@@ -41,7 +41,6 @@
#include "kis_brush.h"
#include "kis_paintop.h"
#include "kis_paintop_registry.h"
#include "kis_cmb_composite.h"
#include "kis_cursor.h"
#include "kis_painter.h"
#include "kis_tool_brush.h"
......@@ -85,10 +84,14 @@ void KisToolBrush::initPaint(KoPointerEvent *e)
}
KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_currentPaintOp, m_currentPaintOpSettings, m_painter);
if (!op) return;
#if 0
// XXX: TOOL_REFACTOR: how to update all of the canvas?
// XXX: TOOL_REFACTOR: how to update all of the canvas? Or how to
// find out the cursor area around the cursor so we can remove the
// outline?
m_canvas->updateCanvas(); // remove the outline
#endif
m_painter->setPaintOp(op); // And now the painter owns the op and will destroy it.
if (op->incremental()) {
......
......@@ -3,8 +3,7 @@ set(kritaui_LIB_SRCS
# kis_birdeye_box.cc
# kis_paintop_box.cc # Needs to know about the active input device a lot
# kis_selection_manager.cc
# kis_tool_shape.cc
#kis_tool_non_paint.cc
kis_tool_shape.cc
imageviewer.cc
kcurve.cc
kis_autobrush.cc
......
......@@ -118,6 +118,7 @@ KoShapeManager* KisCanvas2::shapeManager() const
void KisCanvas2::updateCanvas(const QRectF& rc)
{
kDebug() << "KisCanvas2::updateCanvas: " << rc << endl;
m_d->canvasWidget->widget()->update( rc.toRect() );
}
......
......@@ -18,6 +18,9 @@
#include "kis_resource_provider.h"
#include <QImage>
#include <QPainter>
#include <KoCanvasBase.h>
#include <KoID.h>
......@@ -34,9 +37,35 @@ KisResourceProvider::KisResourceProvider(KisView2 * view )
QVariant v;
v.setValue( KoColor(Qt::black, view->image()->colorSpace()) );
m_resourceProvider->setResource( ForegroundColor, v );
v.setValue( KoColor(Qt::white, view->image()->colorSpace()) );
m_resourceProvider->setResource( BackgroundColor, v );
m_resourceProvider->setKoID(CurrentPaintop, KoID( "paintbrush" ) );
v = qVariantFromValue( ( void * ) 0 );
m_resourceProvider->setResource( CurrentPaintopSettings, v );
// Create a big default brush. XXX: We really need to have a way
// to get at the loaded brushes, gradients etc. The data structure
// is now completely hidden behind the gui in really, really old
// code.
QImage img( 100, 100, QImage::Format_ARGB32 );
QPainter p( &img );
p.setRenderHint( QPainter::Antialiasing );
p.fillRect( 0, 0, 100, 100, QBrush(QColor( 255, 255, 255, 0) ) );
p.setBrush( QBrush( QColor( 0, 0, 0, 255 ) ) );
p.drawEllipse( 0, 0, 100, 100 );
p.end();
m_defaultBrush = new KisBrush( img );
v = qVariantFromValue( static_cast<void *>( m_defaultBrush ) );
m_resourceProvider->setResource( CurrentBrush, v );
}
KisResourceProvider::~KisResourceProvider()
{
delete m_defaultBrush;
}
......
......@@ -51,6 +51,7 @@ class KisResourceProvider : public QObject {
public:
KisResourceProvider(KisView2 * view);
~KisResourceProvider();
KoCanvasBase * canvas() const;
......@@ -97,6 +98,7 @@ private:
KisView2 * m_view;
KoCanvasResourceProvider * m_resourceProvider;
KisBrush * m_defaultBrush;
};
#endif
......@@ -101,11 +101,10 @@ void KisToolFreehand::mousePressEvent(KoPointerEvent *e)
}
else {
m_target->setDirty( r );
// Just update the canvas.
// XXX: After 1.5, find a better way to make sure tools don't set dirty what they didn't touch.
m_canvas->updateCanvas( r ); // XXX are we working in the
// right coordinates?
}
m_canvas->updateCanvas( r ); // XXX are we working in the
// right coordinates?
}
}
}
......@@ -127,14 +126,15 @@ void KisToolFreehand::mouseMoveEvent(KoPointerEvent *e)
m_dirtyRect |= r;
if (!m_paintOnSelection) {
m_currentImage->activeLayer()->setDirty(r);
m_currentImage->activeLayer()->setDirty(r);
}
else {
// Just update the canvas
r = QRect(r.left()-1, r.top()-1, r.width()+2, r.height()+2); //needed to update selectionvisualization
m_target->setDirty(r);
m_canvas->updateCanvas( r );
}
m_canvas->updateCanvas( r );
}
}
}
......@@ -152,6 +152,13 @@ void KisToolFreehand::initPaint(KoPointerEvent *)
{
if (!m_currentImage || !m_currentImage->activeDevice()) return;
if (m_compositeOp == 0 ) {
KisPaintDeviceSP device = m_currentImage->activeDevice();
if (device) {
m_compositeOp = device->colorSpace()->compositeOp( COMPOSITE_OVER );
}
}
m_mode = PAINT;
m_dragDist = 0;
......
......@@ -169,7 +169,7 @@ void KisToolPaint::mouseReleaseEvent( KoPointerEvent *e )
void KisToolPaint::createOptionWidget()
{
m_optionWidget = new QWidget();
KoTool::createOptionWidget();
m_lbOpacity = new QLabel(i18n("Opacity: "), m_optionWidget);
m_slOpacity = new KisIntSpinbox( m_optionWidget, "int_m_optionwidget");
......
......@@ -58,7 +58,14 @@ class KoCanvasBase;
class KisCmbComposite;
class KisIntSpinbox;
class KisPaintOpSettings;
/*
static const QString TOOL_TYPE_SHAPE = "Krita/Shape"; // Geometric shapes like ellipses and lines
static const QString TOOL_TYPE_FREEHAND = "Krita/Freehand"; // Freehand drawing tools
static const QString TOOL_TYPE_TRANSFORM = "Krita/Transform"; // Tools that transform the layer;
static const QString TOOL_TYPE_FILL = "Krita/Fill"; // Tools that fill parts of the canvas
static const QString TOOL_TYPE_VIEW = "Krita/View"; // Tools that affect the canvas: pan, zoom, etc.
static const QString TOOL_TYPE_SELECTED = "Krita/Select"; // Tools that select pixels
*/
enum enumBrushMode {
PAINT,
PAINT_STYLUS,
......
......@@ -27,8 +27,8 @@
#include "kis_tool_shape.h"
KisToolShape::KisToolShape(KoCanvasBase * canvas)
: KisPaintTool(canvas)
KisToolShape::KisToolShape(KoCanvasBase * canvas, const QCursor & cursor)
: KisToolPaint(canvas, cursor)
{
m_shapeOptionsWidget = 0;
m_optionLayout = 0;
......@@ -38,24 +38,22 @@ KisToolShape::~KisToolShape()
{
}
QWidget* KisToolShape::createOptionWidget()
void KisToolShape::createOptionWidget()
{
QWidget *widget = KisPaintTool::createOptionWidget(parent);
KisToolPaint::createOptionWidget();
m_shapeOptionsWidget = new WdgGeometryOptions(0);
Q_CHECK_PTR(m_shapeOptionsWidget);
m_optionLayout = new QGridLayout(widget);
m_optionLayout = new QGridLayout(m_optionWidget);
m_shapeOptionsWidget->cmbFill->setParent(widget);
m_shapeOptionsWidget->cmbFill->setParent(m_optionWidget);
m_shapeOptionsWidget->cmbFill->move(QPoint(0, 0));
m_shapeOptionsWidget->cmbFill->show();
m_shapeOptionsWidget->textLabel3->setParent(widget);
m_shapeOptionsWidget->textLabel3->setParent(m_optionWidget);
m_shapeOptionsWidget->textLabel3->move(QPoint(0, 0));
m_shapeOptionsWidget->textLabel3->show();
addOptionWidgetOption(m_shapeOptionsWidget->cmbFill, m_shapeOptionsWidget->textLabel3);
return widget;
}
KisPainter::FillStyle KisToolShape::fillStyle(void)
......
......@@ -46,12 +46,12 @@ class KRITAUI_EXPORT KisToolShape : public KisToolPaint {
Q_OBJECT
public:
KisToolShape(KoCanvasBase * canvas);
KisToolShape(KoCanvasBase * canvas, const QCursor & cursor);
virtual ~KisToolShape();
protected:
virtual QWidget* createOptionWidget();
virtual void createOptionWidget();
KisPainter::FillStyle fillStyle();
......
......@@ -87,7 +87,7 @@ public:
virtual KoShapeManager *shapeManager() const = 0;
/**
* Tell the canvas repaint the specified rectangle. The coordinates
* Tell the canvas to repaint the specified rectangle. The coordinates
* are document coordinates, not view coordinates.
*/
virtual void updateCanvas(const QRectF& rc) = 0;
......
......@@ -32,12 +32,12 @@ enum EnumCanvasResource {
BackgroundColor, ///< The active background color selected for this canvas.
CompositeOperation,
CompositeOpacity,
Karbon = 1000, ///< Base number for karbon specific values.
Kexi = 2000, ///< Base number for kexi specific values.
Kivio = 3000, ///< Base number for kivio specific values.
KPlato = 4000, ///< Base number for kplato specific values.
KPresenter = 5000, ///< Base number for kpresenter specific values.
Krita = 6000, ///< Base number for krita specific values.
KarbonStart = 1000, ///< Base number for karbon specific values.
KexiStart = 2000, ///< Base number for kexi specific values.
KivioStart = 3000, ///< Base number for kivio specific values.
KPlatoStart = 4000, ///< Base number for kplato specific values.
KPresenterStart = 5000, ///< Base number for kpresenter specific values.
KritaStart = 6000, ///< Base number for krita specific values.
// XXX: Maybe we should move the next section to Kritas classes.
// (where there is a new enum with the first value being
// Foo = KoCanvasResourceProvider::Krita+1
......@@ -48,8 +48,8 @@ enum EnumCanvasResource {
CurrentPaintop,
CurrentPaintopSettings,
CurrentKritaLayer,
KSpread = 7000, ///< Base number for kspread specific values.
KWord = 8000 ///< Base number for kword specific values.
KSpreadStart = 7000, ///< Base number for kspread specific values.
KWordStart = 8000 ///< Base number for kword specific values.
};
/**
......
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