Commit 9f310c48 authored by Halla Rempt's avatar Halla Rempt
Browse files

Port the krita tool factories to the koffice tool factories, add some stuff,

port a few icons, add the option widget back to kotool and so on. Work in progress,
which is whjy the krita tools still aren't compiled.

svn path=/trunk/koffice/; revision=599825
parent 9a01a70c
......@@ -91,7 +91,7 @@ add_subdirectory(kchart)
add_subdirectory(kivio)
#add_subdirectory(koshell)
add_subdirectory(kounavail)
add_subdirectory(kplato)
#add_subdirectory(kplato)
add_subdirectory(kpresenter)
add_subdirectory(krita)
add_subdirectory(kspread)
......
......@@ -29,6 +29,8 @@
#include <QApplication>
#include <QThread>
#include <QDateTime>
#include <QRect>
#include <QRegion>
#include <kcommand.h>
#include <kdebug.h>
......@@ -994,6 +996,11 @@ QRegion KisImage::extent() const
return v.region();
}
QRegion KisImage::dirtyRegion() const
{
return QRegion(m_d->dirtyRect);
}
KisPaintDeviceSP KisImage::activeDevice()
{
if (KisPaintLayer* layer = dynamic_cast<KisPaintLayer*>(m_d->activeLayer.data())) {
......
......@@ -263,6 +263,11 @@ public:
*/
QRegion extent() const;
/**
* @return a region built from all the dirty rects in all layers in this image
*/
QRegion dirtyRegion() const;
/**
* returns a paintdevice that contains the merged layers of this image, within
* the bounds of this image (with the colorspace and profile of this image)
......
add_subdirectory( filters )
#add_subdirectory( filters )
add_subdirectory( paintops )
#add_subdirectory( tools )
#add_subdirectory( viewplugins )
......
......@@ -31,7 +31,8 @@ install(TARGETS kritadefaulttools DESTINATION ${PLUGIN_INSTALL_DIR})
########### install files ###############
install( FILES tool_rectangle_cursor.png tool_ellipse_cursor.png tool_line_cursor.png tool_freehand_cursor.png tool_duplicate_cursor.png tool_fill_cursor.png tool_text_cursor.png tool_gradient_cursor.png tool_gradient.png tool_line.png tool_rectangle.png tool_ellipse.png tool_pan.png tool_freehand.png tool_text.png openhand_cursor.xpm closedhand_cursor.xpm tool_zoom_plus_cursor.png tool_zoom_minus_cursor.png DESTINATION ${DATA_INSTALL_DIR}/krita/pics)
install( FILES tool_color_fill.png tool_colorpicker.png
tool_duplicate.png tool_move.png tool_zoom.png tool_rectangle_cursor.png tool_ellipse_cursor.png tool_line_cursor.png tool_freehand_cursor.png tool_duplicate_cursor.png tool_fill_cursor.png tool_text_cursor.png tool_gradient_cursor.png tool_gradient.png tool_line.png tool_rectangle.png tool_ellipse.png tool_pan.png tool_freehand.png tool_text.png openhand_cursor.xpm closedhand_cursor.xpm tool_zoom_plus_cursor.png tool_zoom_minus_cursor.png DESTINATION ${DATA_INSTALL_DIR}/krita/pics)
install( FILES kritadefaulttools.desktop DESTINATION ${SERVICES_INSTALL_DIR})
......
......@@ -33,7 +33,7 @@
#include <kis_global.h>
#include <kis_types.h>
#include <kis_tool.h>
#include <kis_tool_registry.h>
#include <KoToolRegistry.h>
#include "default_tools.h"
//#include "kis_tool_fill.h"
......@@ -60,22 +60,22 @@ DefaultTools::DefaultTools(QObject *parent, const QStringList &)
{
setInstance(DefaultToolsFactory::instance());
if ( parent->inherits("KisToolRegistry") )
if ( parent->inherits("KoToolRegistry") )
{
KisToolRegistry * r = dynamic_cast<KisToolRegistry*>(parent);
KoToolRegistry * r = dynamic_cast<KoToolRegistry*>(parent);
//r->add(KisToolFactorySP(new KisToolFillFactory()));
//r->add(KisToolFactorySP(new KisToolGradientFactory()));
r->add(KisToolFactorySP(new KisToolBrushFactory()));
//r->add(KisToolFactorySP(new KisToolColorPickerFactory()));
//r->add(KisToolFactorySP(new KisToolLineFactory()));
//r->add(KisToolFactorySP(new KisToolTextFactory()));
//r->add(KisToolFactorySP(new KisToolDuplicateFactory()));
//r->add(KisToolFactorySP(new KisToolMoveFactory()));
//r->add(KisToolFactorySP(new KisToolZoomFactory()));
//r->add(KisToolFactorySP(new KisToolEllipseFactory()));
//r->add(KisToolFactorySP(new KisToolRectangleFactory()));
//r->add(KisToolFactorySP(new KisToolPanFactory()));
//r->add(KoToolFactorySP(new KisToolFillFactory()));
//r->add(KoToolFactorySP(new KisToolGradientFactory()));
r->add(KoToolFactorySP(new KisToolBrushFactory()));
//r->add(KoToolFactorySP(new KisToolColorPickerFactory()));
//r->add(KoToolFactorySP(new KisToolLineFactory()));
//r->add(KoToolFactorySP(new KisToolTextFactory()));
//r->add(KoToolFactorySP(new KisToolDuplicateFactory()));
//r->add(KoToolFactorySP(new KisToolMoveFactory()));
//r->add(KoToolFactorySP(new KisToolZoomFactory()));
//r->add(KoToolFactorySP(new KisToolEllipseFactory()));
//r->add(KoToolFactorySP(new KisToolRectangleFactory()));
//r->add(KoToolFactorySP(new KisToolPanFactory()));
}
}
......
......@@ -20,7 +20,7 @@
#define KIS_TOOL_BRUSH_H_
#include "kis_tool_freehand.h"
#include "kis_tool_factory.h"
#include "KoToolFactory.h"
class QTimer;
class KoPoint;
......@@ -62,19 +62,25 @@ private:
QCheckBox * m_chkDirect;
};
class KisToolBrushFactory : public KisToolFactory {
typedef KisToolFactory super;
class KisToolBrushFactory : public KoToolFactory {
public:
KisToolBrushFactory() : super() {};
KisToolBrushFactory(QObject *parent, const QStringList&)
: KoToolFactory(parent, "KisToolBrush", i18n( "Paint" ))
{
setToolTip( i18n( "Paint freely" ) );
setToolType( TOOL_TYPE_SHAPE );
setIcon( "tool_freehand" );
setShortcut( Qt::Key_B );
setPriority( 0 );
};
virtual ~KisToolBrushFactory(){};
virtual KisTool * createTool(KActionCollection * ac) {
KisTool * t = new KisToolBrush();
Q_CHECK_PTR(t);
t->setup(ac);
return t;
virtual KoTool * createTool(KoCanvasBase *canvas) {
return new KisToolBrush(canvas);
}
virtual KoID id() { return KoID("brush", i18n("Brush Tool")); }
};
......
......@@ -23,7 +23,7 @@
#include <QList>
#include "kis_tool_non_paint.h"
#include "kis_tool_factory.h"
#include "KoToolFactory.h"
#include "ui_wdgcolorpicker.h"
class KisResource;
......@@ -76,19 +76,25 @@ private:
QList<KisPalette*> m_palettes;
};
class KisToolColorPickerFactory : public KisToolFactory {
typedef KisToolFactory super;
class KisToolColorPickerFactory : public KoToolFactory {
public:
KisToolColorPickerFactory() : super() {};
KisToolColorPickerFactory(QObject *parent, const QStringList&)
: KoToolFactory(parent, "KisToolColorPicker", i18n( "Color Picker" ))
{
setToolTip(i18n("Select a color from the image or current layer"));
setToolType(TOOL_TYPE_SELECTED);
setPriority(0);
setIcon("colorpicker");
setShortcut( Qt::Key_P );
};
virtual ~KisToolColorPickerFactory(){};
virtual KisTool * createTool(KActionCollection * ac) {
KisTool * t = new KisToolColorPicker();
Q_CHECK_PTR(t);
t->setup(ac);
return t;
virtual KoTool * createTool(KoCanvasBase *canvas) {
return new KisToolColorPicker(canvas);
}
virtual KoID id() { return KoID("colorpicker", i18n("Color Picker")); }
};
......
......@@ -22,7 +22,7 @@
#define __KIS_TOOL_DUPLICATE_H__
#include "kis_tool_freehand.h"
#include "kis_tool_factory.h"
#include "KoToolFactory.h"
class KoPointerEvent;
class KoPointerEvent;
......@@ -38,12 +38,12 @@ class KisToolDuplicate : public KisToolFreehand {
public:
KisToolDuplicate();
virtual ~KisToolDuplicate();
virtual void setup(KActionCollection *collection);
virtual enumToolType toolType() { return TOOL_FREEHAND; }
virtual void buttonPress(KoPointerEvent *e);
virtual void move(KoPointerEvent *e);
virtual void paintAt(const KoPoint &pos,
const double pressure,
const double xTilt,
......@@ -69,19 +69,25 @@ protected:
};
class KisToolDuplicateFactory : public KisToolFactory {
typedef KisToolFactory super;
class KisToolDuplicateFactory : public KoToolFactory {
public:
KisToolDuplicateFactory() : super() {};
KisToolDuplicateFactory(QObject *parent, const QStringList&)
: KoToolFactory(parent, "KisToolDuplicate", i18n( "Duplicate Brush" ))
{
setToolTip( i18n( "Duplicate parts of the image. Shift-click to select the point to duplicate from to begin." ) );
setToolType( TOOL_TYPE_FREEHAND );
setIcon( "tool_duplicate" );
setPriority( 0 );
};
virtual ~KisToolDuplicateFactory(){};
virtual KisTool * createTool(KActionCollection * ac) {
KisTool * t = new KisToolDuplicate();
Q_CHECK_PTR(t);
t->setup(ac);
return t;
virtual KoTool * createTool(KoCanvasBase *canvas) {
return new KisToolDuplicate(canvas);
}
virtual KoID id() { return KoID("duplicate", i18n("Duplicate Tool")); }
};
......
......@@ -106,7 +106,7 @@ void KisToolEllipse::move(KoPointerEvent *event)
}
}
void KisToolEllipse::buttonRelease(KisButtonReleaseEvent *event)
void KisToolEllipse::buttonRelease(KoPointerEvent *event)
{
if (!m_subject || !m_currentImage)
return;
......
......@@ -53,7 +53,7 @@ public:
virtual enumToolType toolType() { return TOOL_SHAPE; }
virtual void buttonPress(KoPointerEvent *event);
virtual void move(KoPointerEvent *event);
virtual void buttonRelease(KisButtonReleaseEvent *event);
virtual void buttonRelease(KoPointerEvent *event);
protected:
virtual void draw(const KoPoint& start, const KoPoint& stop);
......@@ -68,21 +68,26 @@ protected:
};
#include "kis_tool_factory.h"
#include "KoToolFactory.h"
class KisToolEllipseFactory : public KoToolFactory {
class KisToolEllipseFactory : public KisToolFactory {
typedef KisToolFactory super;
public:
KisToolEllipseFactory() : super() {};
KisToolEllipseFactory(QObject *parent, const QStringList&)
: KoToolFactory(parent, "KisToolEllipse", i18n( "Ellipse" ))
{
setToolTip( i18n( "Draw an ellipse" ) );
setToolType( TOOL_TYPE_SHAPE );
setIcon( "tool_ellipse" );
setPriority( 0 );
};
virtual ~KisToolEllipseFactory(){};
virtual KisTool * createTool(KActionCollection * ac) {
KisTool * t = new KisToolEllipse();
Q_CHECK_PTR(t);
t->setup(ac);
return t;
virtual KoTool * createTool(KoCanvasBase *canvas) {
return new KisToolEllipse(canvas);
}
virtual KoID id() { return KoID("ellipse", i18n("Ellipse Tool")); }
};
......
......@@ -143,7 +143,7 @@ void KisToolFill::buttonPress(KoPointerEvent *e)
m_startPos = e->pos();
}
void KisToolFill::buttonRelease(KisButtonReleaseEvent *e)
void KisToolFill::buttonRelease(KoPointerEvent *e)
{
if (!m_subject) return;
if (!m_currentImage || !m_currentImage->activeDevice()) return;
......
......@@ -51,7 +51,7 @@ public:
virtual void update(KisCanvasSubject *subject);
virtual void buttonPress(KoPointerEvent*);
virtual void buttonRelease(KisButtonReleaseEvent*);
virtual void buttonRelease(KoPointerEvent*);
bool flood(int startX, int startY);
......@@ -83,21 +83,27 @@ private:
};
#include "kis_tool_factory.h"
#include "KoToolFactory.h"
class KisToolFillFactory : public KoToolFactory {
class KisToolFillFactory : public KisToolFactory {
typedef KisToolFactory super;
public:
KisToolFillFactory() : super() {};
KisToolFillFactory(QObject *parent, const QStringList&)
: KoToolFactory(parent, "KisTooLFill", i18n( "Contiguous Fill" ))
{
setToolTip( i18n( "Fill a contiguous area of color with a color, or fill a selection." ) );
setToolType( TOOL_TYPE_FILL );
setIcon( "color_fill" );
setShortcut( Qt::Key_F );
setPriority( 0 );
};
virtual ~KisToolFillFactory(){};
virtual KisTool * createTool(KActionCollection * ac) {
KisToolFill * t = new KisToolFill();
Q_CHECK_PTR(t);
t->setup(ac);
return t;
virtual KoTool * createTool(KoCanvasBase *canvas) {
return new KisToolFill(canvas);
}
virtual KoID id() { return KoID("fill", i18n("Fill Tool")); }
};
......
......@@ -117,7 +117,7 @@ void KisToolGradient::move(KoPointerEvent *e)
}
}
void KisToolGradient::buttonRelease(KisButtonReleaseEvent *e)
void KisToolGradient::buttonRelease(KoPointerEvent *e)
{
if (m_dragging && e->button() == Qt::LeftButton) {
......
......@@ -29,7 +29,7 @@
#include "kis_global.h"
#include "kis_types.h"
#include "kis_gradient_painter.h"
#include "kis_tool_factory.h"
#include "KoToolFactory.h"
class KIntNumInput;
class KDoubleNumInput;
......@@ -58,7 +58,7 @@ public:
virtual void buttonPress(KoPointerEvent *event);
virtual void move(KoPointerEvent *event);
virtual void buttonRelease(KisButtonReleaseEvent *event);
virtual void buttonRelease(KoPointerEvent *event);
virtual void paint(QPainter& gc);
virtual void paint(QPainter& gc, const QRect& rc);
......@@ -99,19 +99,25 @@ private:
KDoubleNumInput *m_slAntiAliasThreshold;
};
class KisToolGradientFactory : public KisToolFactory {
typedef KisToolFactory super;
class KisToolGradientFactory : public KoToolFactory {
public:
KisToolGradientFactory() : super() {};
KisToolGradientFactory(QObject *parent, const QStringList&)
: KoToolFactory(parent, "KisToolGradient", i18n( "Gradient" ))
{
setToolTip( i18n( "Draw a gradient." ) );
setToolType( TOOL_TYPE_FILL );
setIcon( "tool_gradient" );
setShortcut( Qt::Key_G );
setPriority( 0 );
};
virtual ~KisToolGradientFactory(){};
virtual KisTool * createTool(KActionCollection * ac) {
KisTool * t = new KisToolGradient();
Q_CHECK_PTR(t);
t->setup(ac);
return t;
virtual KoTool * createTool(KoCanvasBase *canvas) {
return new KisToolGradient(canvas);
}
virtual KoID id() { return KoID("gradient", i18n("Gradient Tool")); }
};
......
......@@ -115,7 +115,7 @@ void KisToolLine::move(KoPointerEvent *e)
}
}
void KisToolLine::buttonRelease(KisButtonReleaseEvent *e)
void KisToolLine::buttonRelease(KoPointerEvent *e)
{
if (m_dragging && e->button() == Qt::LeftButton) {
m_dragging = false;
......
......@@ -27,7 +27,7 @@
#include "kis_global.h"
#include "kis_types.h"
#include "kis_tool_factory.h"
#include "KoToolFactory.h"
class KisBrush;
class KisPainter;
......@@ -52,7 +52,7 @@ class KisToolLine : public KisToolPaint {
virtual void buttonPress(KoPointerEvent *event);
virtual void move(KoPointerEvent *event);
virtual void buttonRelease(KisButtonReleaseEvent *event);
virtual void buttonRelease(KoPointerEvent *event);
virtual void paint(QPainter& gc);
virtual void paint(QPainter& gc, const QRect& rc);
......@@ -77,19 +77,25 @@ class KisToolLine : public KisToolPaint {
};
class KisToolLineFactory : public KisToolFactory {
typedef KisToolFactory super;
class KisToolLineFactory : public KoToolFactory {
public:
KisToolLineFactory() : super() {};
KisToolLineFactory(QObject *parent, const QStringList&)
: KoToolFactory(parent, "KisToolLine", i18n( "Line" ))
{
setToolTip(i18n("Draw a line with the current brush"));
setToolType(TOOL_TYPE_SHAPE);
setPriority(0);
setIcon("tool_line");
};
virtual ~KisToolLineFactory(){};
virtual KisTool * createTool(KActionCollection * ac) {
KisTool * t = new KisToolLine();
Q_CHECK_PTR(t);
t->setup(ac);
return t;
virtual KoTool * createTool(KoCanvasBase *canvas) {
return new KisToolLine(canvas);
}
virtual KoID id() { return KoID("line", i18n("Line Tool")); }
};
......
......@@ -89,7 +89,7 @@ void KisToolMove::move(KoPointerEvent *e)
}
}
void KisToolMove::buttonRelease(KisButtonReleaseEvent *e)
void KisToolMove::buttonRelease(KoPointerEvent *e)
{
if (m_subject && e->button() == Qt::LeftButton) {
m_strategy.endDrag(e->pos().floorQPoint());
......
......@@ -23,7 +23,7 @@
#include "kis_strategy_move.h"
#include "kis_tool_non_paint.h"
#include "kis_tool_factory.h"
#include "KoToolFactory.h"
// XXX: Moving is not nearly smooth enough!
class KisToolMove : public KisToolNonPaint {
......@@ -45,7 +45,7 @@ public:
virtual void buttonPress(KoPointerEvent *e);
virtual void move(KoPointerEvent *e);
virtual void buttonRelease(KisButtonReleaseEvent *e);
virtual void buttonRelease(KoPointerEvent *e);
private:
KisCanvasSubject *m_subject;
......@@ -54,19 +54,25 @@ private:
};
class KisToolMoveFactory : public KisToolFactory {
typedef KisToolFactory super;
class KisToolMoveFactory : public KoToolFactory {
public:
KisToolMoveFactory() : super() {};
KisToolMoveFactory(QObject *parent, const QStringList&)
: KoToolFactory(parent, "KisToolMove", i18n( "Move" ))
{
setToolTip(i18n("Move a layer"));
setToolType(TOOL_TYPE_TRANSFORM);
setPriority(0);
setIcon("tool_move");
setShortcut( Qt::SHIFT + Qt::Key_V );
};
virtual ~KisToolMoveFactory(){};
virtual KisTool * createTool(KActionCollection * ac) {
KisTool * t = new KisToolMove();
Q_CHECK_PTR(t);
t->setup(ac);
return t;
virtual KoTool * createTool(KoCanvasBase *canvas) {
return new KisToolMove(canvas);
}
virtual KoID id() { return KoID("move", i18n("Move Tool")); }
};
......
......@@ -73,7 +73,7 @@ void KisToolPan::move(KoPointerEvent *e)
}
}
void KisToolPan::buttonRelease(KisButtonReleaseEvent *e)
void KisToolPan::buttonRelease(KoPointerEvent *e)
{
if (m_subject && m_dragging && e->button() == Qt::LeftButton) {
setCursor(m_openHandCursor);
......
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