summaryrefslogtreecommitdiffstats
path: root/krita/plugins/tools/defaulttools
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 01:29:50 +0000
commit8362bf63dea22bbf6736609b0f49c152f975eb63 (patch)
tree0eea3928e39e50fae91d4e68b21b1e6cbae25604 /krita/plugins/tools/defaulttools
downloadkoffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz
koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'krita/plugins/tools/defaulttools')
-rw-r--r--krita/plugins/tools/defaulttools/Makefile.am82
-rw-r--r--krita/plugins/tools/defaulttools/closedhand_cursor.xpm28
-rw-r--r--krita/plugins/tools/defaulttools/default_tools.cc88
-rw-r--r--krita/plugins/tools/defaulttools/default_tools.h43
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_brush.cc167
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_brush.h86
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_colorpicker.cc298
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_colorpicker.h87
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_duplicate.cc255
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_duplicate.h91
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_ellipse.cc186
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_ellipse.h90
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_fill.cc233
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_fill.h108
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_gradient.cc309
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_gradient.h123
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_line.cc254
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_line.h99
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_move.cc181
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_move.h88
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_pan.cc96
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_pan.h79
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_rectangle.cc187
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_rectangle.h95
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_text.cc198
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_text.h80
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_zoom.cc191
-rw-r--r--krita/plugins/tools/defaulttools/kis_tool_zoom.h97
-rw-r--r--krita/plugins/tools/defaulttools/kritadefaulttools.desktop56
-rw-r--r--krita/plugins/tools/defaulttools/openhand_cursor.xpm28
-rw-r--r--krita/plugins/tools/defaulttools/tool_color_fill.pngbin0 -> 1101 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_colorpicker.pngbin0 -> 711 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_duplicate.pngbin0 -> 1086 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_duplicate_cursor.pngbin0 -> 308 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_ellipse.pngbin0 -> 523 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_ellipse_cursor.pngbin0 -> 308 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_fill_cursor.pngbin0 -> 515 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_freehand.pngbin0 -> 657 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_freehand_cursor.pngbin0 -> 260 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_gradient.pngbin0 -> 385 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_gradient_cursor.pngbin0 -> 293 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_line.pngbin0 -> 353 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_line_cursor.pngbin0 -> 247 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_move.pngbin0 -> 662 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_pan.pngbin0 -> 862 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_rectangle.pngbin0 -> 333 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_rectangle_cursor.pngbin0 -> 229 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_text.pngbin0 -> 890 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_text_cursor.pngbin0 -> 299 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_zoom.pngbin0 -> 876 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_zoom_minus_cursor.pngbin0 -> 282 bytes
-rw-r--r--krita/plugins/tools/defaulttools/tool_zoom_plus_cursor.pngbin0 -> 301 bytes
-rw-r--r--krita/plugins/tools/defaulttools/wdgcolorpicker.ui167
53 files changed, 4170 insertions, 0 deletions
diff --git a/krita/plugins/tools/defaulttools/Makefile.am b/krita/plugins/tools/defaulttools/Makefile.am
new file mode 100644
index 00000000..6f28508a
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/Makefile.am
@@ -0,0 +1,82 @@
+kde_services_DATA = kritadefaulttools.desktop
+
+# all_includes must remain last!
+INCLUDES = -I$(srcdir)/../../../sdk \
+ -I$(srcdir)/../../../core \
+ -I$(srcdir)/../../../kritacolor/ \
+ -I$(srcdir)/../../../ui \
+ -I$/../../../ui \
+ $(KOFFICE_INCLUDES) \
+ $(all_includes)
+
+kritadefaulttools_la_SOURCES = \
+ default_tools.cc \
+ kis_tool_colorpicker.cc \
+ kis_tool_move.cc \
+ kis_tool_zoom.cc \
+ kis_tool_brush.cc \
+ kis_tool_line.cc \
+ kis_tool_duplicate.cc \
+ kis_tool_fill.cc \
+ kis_tool_rectangle.cc \
+ kis_tool_ellipse.cc \
+ kis_tool_pan.cc \
+ kis_tool_text.cc \
+ kis_tool_gradient.cc \
+ wdgcolorpicker.ui
+
+# Install this plugin in the KDE modules directory
+kde_module_LTLIBRARIES = kritadefaulttools.la
+
+noinst_HEADERS = \
+ default_tools.h \
+ kis_tool_fill.h \
+ kis_tool_brush.h \
+ kis_tool_gradient.h \
+ kis_tool_rectangle.h \
+ kis_tool_colorpicker.h \
+ kis_tool_line.h \
+ kis_tool_text.h \
+ kis_tool_duplicate.h \
+ kis_tool_move.h \
+ kis_tool_zoom.h \
+ kis_tool_ellipse.h \
+ kis_tool_pan.h
+
+
+kritadefaulttools_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+kritadefaulttools_la_LIBADD = ../../../libkritacommon.la $(LIB_KOPAINTER) $(LIB_KOFFICECORE)
+
+kritadefaulttools_la_METASOURCES = AUTO
+
+KDE_OPTIONS = nofinal
+
+kritapics_DATA = \
+ 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_color_fill.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 \
+ tool_move.png \
+ tool_colorpicker.png \
+ tool_duplicate.png \
+ tool_zoom.png
+
+
+kritapicsdir = $(kde_datadir)/krita/pics
+
diff --git a/krita/plugins/tools/defaulttools/closedhand_cursor.xpm b/krita/plugins/tools/defaulttools/closedhand_cursor.xpm
new file mode 100644
index 00000000..b3d98f85
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/closedhand_cursor.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static char *closedhand_cursor[]={
+"22 22 3 1",
+". c None",
+"# c #000000",
+"a c #ffffff",
+"......................",
+"......................",
+"......................",
+"......................",
+".......##.##.##.......",
+"......#aa#aa#aa###....",
+"......#aa#aa#aa#aa#...",
+"......#aa#aa#aa#aa#...",
+".....##aaaaaaaa#aa#...",
+"....#a#aaaaaaaaaaa#...",
+"....#a#aaaaaaaaaaa#...",
+"....#a#aaaaaaaaaaa#...",
+"....#aaaaaaaaaaaaa#...",
+".....#aaaaaaaaaaaa#...",
+".....#aaaaaaaaaaa#....",
+"......#aaaaaaaaaa#....",
+"......#aaaaaaaaaa#....",
+".......#aaaaaaaa#.....",
+".......#aaaaaaaa#.....",
+".......##########.....",
+"......................",
+"......................"};
diff --git a/krita/plugins/tools/defaulttools/default_tools.cc b/krita/plugins/tools/defaulttools/default_tools.cc
new file mode 100644
index 00000000..c4edcfb3
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/default_tools.cc
@@ -0,0 +1,88 @@
+/*
+ * default_tools.cc -- Part of Krita
+ *
+ * Copyright (c) 2004 Boudewijn Rempt ([email protected])
+ *
+ * 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 <stdlib.h>
+#include <vector>
+
+#include <qpoint.h>
+
+#include <klocale.h>
+#include <kiconloader.h>
+#include <kinstance.h>
+#include <kmessagebox.h>
+#include <kstandarddirs.h>
+#include <ktempfile.h>
+#include <kdebug.h>
+#include <kgenericfactory.h>
+
+#include <kis_global.h>
+#include <kis_types.h>
+#include <kis_tool.h>
+#include <kis_tool_registry.h>
+#include "default_tools.h"
+
+#include "kis_tool_fill.h"
+#include "kis_tool_brush.h"
+#include "kis_tool_freehand.h"
+#include "kis_tool_gradient.h"
+#include "kis_tool_rectangle.h"
+#include "kis_tool_colorpicker.h"
+#include "kis_tool_line.h"
+#include "kis_tool_text.h"
+#include "kis_tool_duplicate.h"
+#include "kis_tool_move.h"
+#include "kis_tool_zoom.h"
+#include "kis_tool_ellipse.h"
+#include "kis_tool_pan.h"
+
+
+typedef KGenericFactory<DefaultTools> DefaultToolsFactory;
+K_EXPORT_COMPONENT_FACTORY( kritadefaulttools, DefaultToolsFactory( "krita" ) )
+
+
+DefaultTools::DefaultTools(QObject *parent, const char *name, const QStringList &)
+ : KParts::Plugin(parent, name)
+{
+ setInstance(DefaultToolsFactory::instance());
+
+ if ( parent->inherits("KisToolRegistry") )
+ {
+ KisToolRegistry * r = dynamic_cast<KisToolRegistry*>(parent);
+
+ r->add(new KisToolFillFactory());
+ r->add(new KisToolGradientFactory());
+ r->add(new KisToolBrushFactory());
+ r->add(new KisToolColorPickerFactory());
+ r->add(new KisToolLineFactory());
+ r->add(new KisToolTextFactory());
+ r->add(new KisToolDuplicateFactory());
+ r->add(new KisToolMoveFactory());
+ r->add(new KisToolZoomFactory());
+ r->add(new KisToolEllipseFactory());
+ r->add(new KisToolRectangleFactory());
+ r->add(new KisToolPanFactory());
+
+ }
+}
+
+DefaultTools::~DefaultTools()
+{
+}
+
+#include "default_tools.moc"
diff --git a/krita/plugins/tools/defaulttools/default_tools.h b/krita/plugins/tools/defaulttools/default_tools.h
new file mode 100644
index 00000000..0088263d
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/default_tools.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2003 Boudewijn Rempt ([email protected])
+ *
+ * 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 DEFAULT_TOOLS_H_
+#define DEFAULT_TOOLS_H_
+
+#include <kparts/plugin.h>
+
+/**
+ * A module wrapper around Krita's default tools.
+ * Despite the fact that new tools are created for every new view,
+ * it is not possible to make tools standard parts of the type of the
+ * imagesize plugin, because we need to create a new set of tools for every
+ * pointer device (mouse, stylus, eraser, puck, etc.). So this plugin is
+ * a module which is loaded once into Krita. For every tool there is a factory
+ * class that is registered with the tool registry, and that is used to create
+ * new instances of the tools.
+ */
+class DefaultTools : public KParts::Plugin
+{
+ Q_OBJECT
+public:
+ DefaultTools(QObject *parent, const char *name, const QStringList &);
+ virtual ~DefaultTools();
+
+};
+
+#endif // DEFAULT_TOOLS_H_
diff --git a/krita/plugins/tools/defaulttools/kis_tool_brush.cc b/krita/plugins/tools/defaulttools/kis_tool_brush.cc
new file mode 100644
index 00000000..a65795d1
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_brush.cc
@@ -0,0 +1,167 @@
+/*
+ * kis_tool_brush.cc - part of Krita
+ *
+ * Copyright (c) 2003-2004 Boudewijn Rempt <[email protected]>
+ *
+ * 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 <qevent.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qwidget.h>
+#include <qtimer.h>
+#include <qpushbutton.h>
+#include <qpainter.h>
+#include <qrect.h>
+#include <qcheckbox.h>
+
+#include <kdebug.h>
+#include <kaction.h>
+#include <kcommand.h>
+#include <klocale.h>
+
+#include "kis_config.h"
+#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"
+#include "kis_canvas_subject.h"
+#include "kis_boundary.h"
+#include "kis_move_event.h"
+#include "kis_canvas.h"
+#include "kis_layer.h"
+
+KisToolBrush::KisToolBrush()
+ : super(i18n("Brush"))
+{
+ setName("tool_brush");
+ setCursor(KisCursor::load("tool_freehand_cursor.png", 5, 5));
+ m_rate = 100; // Conveniently hardcoded for now
+ m_timer = new QTimer(this);
+ Q_CHECK_PTR(m_timer);
+
+ connect(m_timer, SIGNAL(timeout()), this, SLOT(timeoutPaint()));
+
+}
+
+KisToolBrush::~KisToolBrush()
+{
+ delete m_timer;
+ m_timer = 0;
+}
+
+void KisToolBrush::timeoutPaint()
+{
+ if (currentImage() && painter()) {
+ painter()->paintAt(m_prevPos, m_prevPressure, m_prevXTilt, m_prevYTilt);
+ currentImage()->activeLayer()->setDirty(painter()->dirtyRect());
+ }
+}
+
+
+void KisToolBrush::update(KisCanvasSubject *subject)
+{
+ super::update(subject);
+}
+
+void KisToolBrush::initPaint(KisEvent *e)
+{
+ super::initPaint(e);
+
+ if (!m_painter) {
+ kdWarning() << "Didn't create a painter! Something is wrong!\n";
+ return;
+ }
+ KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), m_painter);
+ if (!op) return;
+
+ m_subject->canvasController()->kiscanvas()->update(); // remove the outline
+
+ painter()->setPaintOp(op); // And now the painter owns the op and will destroy it.
+
+ if (op->incremental()) {
+ m_timer->start( m_rate );
+ }
+}
+
+
+void KisToolBrush::endPaint()
+{
+ m_timer->stop();
+ super::endPaint();
+}
+
+
+void KisToolBrush::setup(KActionCollection *collection)
+{
+
+ m_action = static_cast<KRadioAction *>(collection->action(name()));
+
+ if (m_action == 0) {
+ m_action = new KRadioAction(i18n("&Brush"),
+ "tool_freehand", Qt::Key_B, this,
+ SLOT(activate()), collection,
+ name());
+ m_action->setToolTip(i18n("Draw freehand"));
+ m_action->setExclusiveGroup("tools");
+ m_ownAction = true;
+ }
+}
+
+void KisToolBrush::move(KisMoveEvent *e) {
+ KisToolFreehand::move(e);
+ KisConfig cfg;
+ if (m_mode != PAINT && cfg.cursorStyle() == CURSOR_STYLE_OUTLINE)
+ paintOutline(e->pos());
+}
+
+void KisToolBrush::leave(QEvent */*e*/) {
+ m_subject->canvasController()->kiscanvas()->update(); // remove the outline
+}
+
+
+void KisToolBrush::slotSetPaintingMode( int mode )
+{
+ if (mode == QButton::On) {
+ // Direct painting
+ m_paintIncremental = true;
+ }
+ else {
+ m_paintIncremental = false;
+ }
+}
+
+
+QWidget* KisToolBrush::createOptionWidget(QWidget* parent)
+{
+ QWidget *widget = super::createOptionWidget(parent);
+ m_chkDirect = new QCheckBox(i18n("Paint direct"), widget, "chkDirect");
+ m_chkDirect->setChecked(true);
+ connect(m_chkDirect, SIGNAL(stateChanged(int)), this, SLOT(slotSetPaintingMode(int)));
+
+ m_optionLayout = new QGridLayout(widget, 3, 2, 0, 6);
+ Q_CHECK_PTR(m_optionLayout);
+
+ super::addOptionWidgetLayout(m_optionLayout);
+ m_optionLayout->addWidget(m_chkDirect, 0, 0);
+
+ return widget;
+}
+
+#include "kis_tool_brush.moc"
+
diff --git a/krita/plugins/tools/defaulttools/kis_tool_brush.h b/krita/plugins/tools/defaulttools/kis_tool_brush.h
new file mode 100644
index 00000000..0024213d
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_brush.h
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2003-2004 Boudewijn Rempt <[email protected]>
+ *
+ * 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_TOOL_BRUSH_H_
+#define KIS_TOOL_BRUSH_H_
+
+
+#include "kis_tool_freehand.h"
+
+#include "kis_tool_factory.h"
+#include "koffice_export.h"
+
+class QTimer;
+class KisPoint;
+class QHBoxLayout;
+class QPainter;
+class QRect;
+class QCheckBox;
+class QGridLayout;
+
+class KRITACORE_EXPORT KisToolBrush : public KisToolFreehand {
+ Q_OBJECT
+ typedef KisToolFreehand super;
+
+public:
+ KisToolBrush();
+ virtual ~KisToolBrush();
+ virtual void update(KisCanvasSubject *subject);
+ virtual void setup(KActionCollection *collection);
+ virtual enumToolType toolType() { return TOOL_SHAPE; }
+ virtual Q_UINT32 priority() { return 0; }
+ QWidget* createOptionWidget(QWidget* parent);
+
+protected:
+
+ virtual void initPaint(KisEvent *e);
+ virtual void endPaint();
+ virtual void move(KisMoveEvent *e);
+ virtual void leave(QEvent *e);
+
+private slots:
+
+ void timeoutPaint();
+ void slotSetPaintingMode( int mode );
+
+private:
+
+ Q_INT32 m_rate;
+ QTimer * m_timer;
+ QGridLayout* m_optionLayout;
+ QCheckBox * m_chkDirect;
+};
+
+class KisToolBrushFactory : public KisToolFactory {
+ typedef KisToolFactory super;
+public:
+ KisToolBrushFactory() : super() {};
+ virtual ~KisToolBrushFactory(){};
+
+ virtual KisTool * createTool(KActionCollection * ac) {
+ KisTool * t = new KisToolBrush();
+ Q_CHECK_PTR(t);
+ t->setup(ac);
+ return t;
+ }
+ virtual KisID id() { return KisID("brush", i18n("Brush Tool")); }
+};
+
+
+#endif // KIS_TOOL_BRUSH_H_
+
diff --git a/krita/plugins/tools/defaulttools/kis_tool_colorpicker.cc b/krita/plugins/tools/defaulttools/kis_tool_colorpicker.cc
new file mode 100644
index 00000000..ae553952
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_colorpicker.cc
@@ -0,0 +1,298 @@
+/*
+ * Copyright (c) 1999 Matthias Elter <[email protected]>
+ * Copyright (c) 2002 Patrick Julien <[email protected]>
+ *
+ * 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 <string.h>
+
+#include <qpoint.h>
+#include <qlayout.h>
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qlistview.h>
+#include <qspinbox.h>
+
+#include <kaction.h>
+#include <klocale.h>
+#include <qcolor.h>
+#include <kmessagebox.h>
+
+#include "kis_layer.h"
+#include "kis_cursor.h"
+#include "kis_canvas_subject.h"
+#include "kis_image.h"
+#include "kis_paint_device.h"
+#include "kis_tool_colorpicker.h"
+#include "kis_tool_colorpicker.moc"
+#include "kis_button_press_event.h"
+#include "kis_canvas_subject.h"
+#include "kis_iterators_pixel.h"
+#include "kis_color.h"
+#include "kis_resourceserver.h"
+#include "kis_palette.h"
+#include "wdgcolorpicker.h"
+
+namespace {
+ // The location of the sample all visible layers in the combobox
+ const int SAMPLE_MERGED = 0;
+}
+
+KisToolColorPicker::KisToolColorPicker()
+ : super (i18n("Color Picker"))
+{
+ setName("tool_colorpicker");
+ setCursor(KisCursor::pickerCursor());
+ m_optionsWidget = 0;
+ m_subject = 0;
+ m_radius = 1;
+ m_addPalette = false;
+ m_updateColor = true;
+ m_normaliseValues = false;
+ m_pickedColor = KisColor();
+}
+
+KisToolColorPicker::~KisToolColorPicker()
+{
+}
+
+void KisToolColorPicker::update(KisCanvasSubject *subject)
+{
+ m_subject = subject;
+ super::update(m_subject);
+}
+
+void KisToolColorPicker::buttonPress(KisButtonPressEvent *e)
+{
+ if (m_subject) {
+ if (e->button() != QMouseEvent::LeftButton && e->button() != QMouseEvent::RightButton)
+ return;
+
+ KisImageSP img;
+
+ if (!m_subject || !(img = m_subject->currentImg()))
+ return;
+
+ KisPaintDeviceSP dev = img->activeDevice();
+
+ if (!dev) return;
+
+ bool sampleMerged = m_optionsWidget->cmbSources->currentItem() == SAMPLE_MERGED;
+ if (!sampleMerged) {
+ if (!img->activeLayer())
+ {
+ KMessageBox::information(0, i18n("Cannot pick a color as no layer is active."));
+ return;
+ }
+ if (!img->activeLayer()-> visible()) {
+ KMessageBox::information(0, i18n("Cannot pick a color as the active layer is not visible."));
+ return;
+ }
+ }
+
+ QPoint pos = QPoint(e->pos().floorX(), e->pos().floorY());
+
+ if (!img->bounds().contains(pos)) {
+ return;
+ }
+
+ if (sampleMerged) {
+ dev = img->mergedImage();
+ }
+
+ if (m_radius == 1) {
+ m_pickedColor = dev->colorAt (pos.x(), pos.y());
+ } else {
+ // radius 2 ==> 9 pixels, 3 => 9 pixels, etc
+ static int counts[] = { 0, 1, 9, 25, 45, 69, 109, 145, 193, 249 };
+
+ KisColorSpace* cs = dev->colorSpace();
+ int pixelSize = cs->pixelSize();
+
+ Q_UINT8* data = new Q_UINT8[pixelSize];
+ Q_UINT8** pixels = new Q_UINT8*[counts[m_radius]];
+ Q_UINT8* weights = new Q_UINT8[counts[m_radius]];
+
+ int i = 0;
+ // dummy init
+ KisHLineIteratorPixel iter = dev->createHLineIterator(0, 0, 1, false);;
+ for (int y = - m_radius; y <= m_radius; y++) {
+ for (int x = - m_radius; x <= m_radius; x++) {
+ if (x*x + y*y < m_radius * m_radius) {
+ iter = dev->createHLineIterator(pos.x() + x, pos.y() + y, 1, false);
+
+ pixels[i] = new Q_UINT8[pixelSize];
+ memcpy(pixels[i], iter.rawData(), pixelSize);
+
+ if (x == 0 && y == 0) {
+ // Because the sum of the weights must be 255,
+ // we cheat a bit, and weigh the center pixel differently in order
+ // to sum to 255 in total
+ // It's -(counts -1), because we'll add the center one implicitly
+ // through that calculation
+ weights[i] = 255 - (counts[m_radius]-1) * (255 / counts[m_radius]);
+ } else {
+ weights[i] = 255 / counts[m_radius];
+ }
+ i++;
+ }
+ }
+ }
+ // Weird, I can't do that directly :/
+ const Q_UINT8** cpixels = const_cast<const Q_UINT8**>(pixels);
+ cs->mixColors(cpixels, weights, counts[m_radius], data);
+ m_pickedColor = KisColor(data, cs);
+
+ for (i = 0; i < counts[m_radius]; i++)
+ delete[] pixels[i];
+ delete[] pixels;
+ delete[] data;
+ }
+
+ displayPickedColor();
+
+ if (m_updateColor) {
+ if (e->button() == QMouseEvent::LeftButton)
+ m_subject->setFGColor(m_pickedColor);
+ else
+ m_subject->setBGColor(m_pickedColor);
+ }
+
+ if (m_addPalette) {
+ // Convert to RGB to add to palette, we ought to have our own format :(
+ KisPaletteEntry ent;
+ ent.color = m_pickedColor.toQColor();
+ // We don't ask for a name, too intrusive here
+
+ KisPalette* palette = m_palettes.at(m_optionsWidget-> cmbPalette->currentItem());
+ palette->add(ent);
+
+ if (!palette->save()) {
+ KMessageBox::error(0, i18n("Cannot write to palette file %1. Maybe it is read-only.").arg(palette->filename()), i18n("Palette"));
+ }
+ }
+ }
+}
+
+void KisToolColorPicker::displayPickedColor()
+{
+ if (m_pickedColor.data() && m_optionsWidget) {
+
+ QValueVector<KisChannelInfo *> channels = m_pickedColor.colorSpace()->channels();
+ m_optionsWidget->listViewChannels->clear();
+
+ for (int i = channels.count() - 1; i >= 0 ; --i) {
+ QString channelValueText;
+
+ if (m_normaliseValues) {
+ channelValueText = i18n("%1%").arg(m_pickedColor.colorSpace()->normalisedChannelValueText(m_pickedColor.data(), i));
+ } else {
+ channelValueText = m_pickedColor.colorSpace()->channelValueText(m_pickedColor.data(), i);
+ }
+
+ m_optionsWidget->listViewChannels->insertItem(new QListViewItem(m_optionsWidget->listViewChannels,
+ channels[i]->name(),
+ channelValueText));
+ }
+ }
+}
+
+void KisToolColorPicker::setup(KActionCollection *collection)
+{
+ m_action = static_cast<KRadioAction *>(collection->action(name()));
+
+ if (m_action == 0) {
+ m_action = new KRadioAction(i18n("&Color Picker"), "tool_colorpicker", Qt::Key_P, this, SLOT(activate()), collection, name());
+ m_action->setToolTip(i18n("Color picker"));
+ m_action->setExclusiveGroup("tools");
+ m_ownAction = true;
+ }
+}
+
+QWidget* KisToolColorPicker::createOptionWidget(QWidget* parent)
+{
+ m_optionsWidget = new ColorPickerOptionsWidget(parent);
+
+ m_optionsWidget->cbUpdateCurrentColour->setChecked(m_updateColor);
+
+ m_optionsWidget->cmbSources->setCurrentItem(0);
+
+ m_optionsWidget->cbNormaliseValues->setChecked(m_normaliseValues);
+ m_optionsWidget->cbPalette->setChecked(m_addPalette);
+ m_optionsWidget->radius->setValue(m_radius);
+
+ m_optionsWidget->listViewChannels->setSorting(-1);
+
+ connect(m_optionsWidget->cbUpdateCurrentColour, SIGNAL(toggled(bool)), SLOT(slotSetUpdateColor(bool)));
+ connect(m_optionsWidget->cbNormaliseValues, SIGNAL(toggled(bool)), SLOT(slotSetNormaliseValues(bool)));
+ connect(m_optionsWidget->cbPalette, SIGNAL(toggled(bool)),
+ SLOT(slotSetAddPalette(bool)));
+ connect(m_optionsWidget->radius, SIGNAL(valueChanged(int)),
+ SLOT(slotChangeRadius(int)));
+
+ KisResourceServerBase* srv = KisResourceServerRegistry::instance()->get("PaletteServer");
+
+ if (!srv) {
+ return m_optionsWidget;
+ }
+
+ QValueList<KisResource*> palettes = srv->resources();
+
+ for(uint i = 0; i < palettes.count(); i++) {
+ KisPalette* palette = dynamic_cast<KisPalette*>(*palettes.at(i));
+ if (palette) {
+ m_optionsWidget->cmbPalette->insertItem(palette->name());
+ m_palettes.append(palette);
+ }
+ }
+
+ connect(srv, SIGNAL(resourceAdded(KisResource*)), this, SLOT(slotAddPalette(KisResource*)));
+
+ return m_optionsWidget;
+}
+
+QWidget* KisToolColorPicker::optionWidget()
+{
+ return m_optionsWidget;
+}
+
+void KisToolColorPicker::slotSetUpdateColor(bool state)
+{
+ m_updateColor = state;
+}
+
+
+void KisToolColorPicker::slotSetNormaliseValues(bool state)
+{
+ m_normaliseValues = state;
+ displayPickedColor();
+}
+
+void KisToolColorPicker::slotSetAddPalette(bool state) {
+ m_addPalette = state;
+}
+
+void KisToolColorPicker::slotChangeRadius(int value) {
+ m_radius = value;
+}
+
+void KisToolColorPicker::slotAddPalette(KisResource* resource) {
+ KisPalette* palette = dynamic_cast<KisPalette*>(resource);
+ if (palette) {
+ m_optionsWidget-> cmbPalette->insertItem(palette->name());
+ m_palettes.append(palette);
+ }
+}
+
diff --git a/krita/plugins/tools/defaulttools/kis_tool_colorpicker.h b/krita/plugins/tools/defaulttools/kis_tool_colorpicker.h
new file mode 100644
index 00000000..2834b8c6
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_colorpicker.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 1999 Matthias Elter
+ * Copyright (c) 2002 Patrick Julien
+ *
+ * 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_TOOL_COLOR_PICKER_H_
+#define KIS_TOOL_COLOR_PICKER_H_
+
+#include "kis_tool_non_paint.h"
+#include "kis_tool_factory.h"
+#include "qvaluevector.h"
+
+class ColorPickerOptionsWidget;
+class KisResource;
+class KisPalette;
+
+class KisToolColorPicker : public KisToolNonPaint {
+
+ Q_OBJECT
+ typedef KisToolNonPaint super;
+
+public:
+ KisToolColorPicker();
+ virtual ~KisToolColorPicker();
+
+public:
+ virtual void update(KisCanvasSubject *subject);
+ virtual void setup(KActionCollection *collection);
+ virtual void buttonPress(KisButtonPressEvent *e);
+ virtual QWidget* createOptionWidget(QWidget* parent);
+ virtual QWidget* optionWidget();
+ virtual enumToolType toolType() { return TOOL_FILL; }
+ virtual Q_UINT32 priority() { return 3; }
+
+public slots:
+ void slotSetUpdateColor(bool);
+ void slotSetNormaliseValues(bool);
+ void slotSetAddPalette(bool);
+ void slotChangeRadius(int);
+ void slotAddPalette(KisResource* resource);
+
+private:
+ void displayPickedColor();
+
+ bool m_updateColor;
+ bool m_addPalette;
+ bool m_normaliseValues;
+ int m_radius;
+ KisColor m_pickedColor;
+
+ ColorPickerOptionsWidget *m_optionsWidget;
+ KisCanvasSubject *m_subject;
+ QValueVector<KisPalette*> m_palettes;
+};
+
+class KisToolColorPickerFactory : public KisToolFactory {
+ typedef KisToolFactory super;
+public:
+ KisToolColorPickerFactory() : super() {};
+ virtual ~KisToolColorPickerFactory(){};
+
+ virtual KisTool * createTool(KActionCollection * ac) {
+ KisTool * t = new KisToolColorPicker();
+ Q_CHECK_PTR(t);
+ t->setup(ac);
+ return t;
+ }
+ virtual KisID id() { return KisID("colorpicker", i18n("Color Picker")); }
+};
+
+
+#endif // KIS_TOOL_COLOR_PICKER_H_
+
diff --git a/krita/plugins/tools/defaulttools/kis_tool_duplicate.cc b/krita/plugins/tools/defaulttools/kis_tool_duplicate.cc
new file mode 100644
index 00000000..71678e6f
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_duplicate.cc
@@ -0,0 +1,255 @@
+/*
+ * kis_tool_duplicate.cc - part of Krita
+ *
+ * Copyright (c) 2004 Cyrille Berger <[email protected]>
+ *
+ * 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 <qbitmap.h>
+#include <qcheckbox.h>
+#include <qpainter.h>
+#include <qlabel.h>
+
+#include <kaction.h>
+#include <kdebug.h>
+#include <knuminput.h>
+#include <klocale.h>
+
+#include "kis_brush.h"
+#include "kis_cursor.h"
+#include "kis_image.h"
+#include "kis_tool_duplicate.h"
+#include "kis_painter.h"
+#include "kis_vec.h"
+#include "kis_button_press_event.h"
+#include "kis_button_release_event.h"
+#include "kis_move_event.h"
+#include "kis_paintop.h"
+#include "kis_paintop_registry.h"
+#include "kis_canvas_subject.h"
+#include "kis_perspective_grid.h"
+
+#include "kis_canvas_painter.h"
+#include "kis_boundary_painter.h"
+
+KisToolDuplicate::KisToolDuplicate()
+ : super(i18n("Duplicate Brush")), m_isOffsetNotUptodate(true), m_position(QPoint(-1,-1))
+{
+ setName("tool_duplicate");
+ m_subject = 0;
+ setCursor(KisCursor::load("tool_duplicate_cursor.png", 5, 5));
+}
+
+KisToolDuplicate::~KisToolDuplicate()
+{
+}
+
+void KisToolDuplicate::activate()
+{
+ m_position = QPoint(-1,-1);
+ super::activate();
+ if( m_subject->currentImg()->perspectiveGrid()->countSubGrids() != 1 )
+ {
+ m_perspectiveCorrection->setEnabled( false );
+ m_perspectiveCorrection->setChecked( false );
+ } else {
+ m_perspectiveCorrection->setEnabled( true );
+ }
+}
+
+void KisToolDuplicate::buttonPress(KisButtonPressEvent *e)
+{
+ if (e->state() == ShiftButton) {
+ m_position = e->pos();
+ m_isOffsetNotUptodate = true;
+ } else {
+ if (m_position != QPoint(-1, -1)) {
+ super::buttonPress(e);
+ }
+ }
+}
+
+
+void KisToolDuplicate::setup(KActionCollection *collection)
+{
+ m_action = static_cast<KRadioAction *>(collection->action(name()));
+
+ if (m_action == 0) {
+ m_action = new KRadioAction(i18n("&Duplicate Brush"),
+ "tool_duplicate", Qt::Key_C, this,
+ SLOT(activate()), collection,
+ name());
+ m_action->setToolTip(i18n("Duplicate parts of the image. Shift-click to select the point to duplicate from to begin."));
+ m_action->setExclusiveGroup("tools");
+ m_ownAction = true;
+ }
+}
+
+void KisToolDuplicate::initPaint(KisEvent *e)
+{
+ if( m_position != QPoint(-1,-1))
+ {
+ if(m_isOffsetNotUptodate)
+ {
+ m_offset = e->pos() - m_position;
+ m_isOffsetNotUptodate = false;
+ }
+ m_paintIncremental = false;
+ super::initPaint(e);
+ painter()->setDuplicateOffset( m_offset );
+ KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp("duplicate", 0, painter());
+ if (op && m_source) {
+ op->setSource(m_source);
+ painter()->setPaintOp(op);
+ }
+ m_positionStartPainting = e->pos();
+ painter()->setDuplicateStart( e->pos() );
+ }
+}
+
+void KisToolDuplicate::move(KisMoveEvent *e)
+{
+
+ // Paint the outline where we will (or are) copying from
+ if( m_position == QPoint(-1,-1) )
+ return;
+
+ QPoint srcPos;
+ if (m_mode == PAINT) {
+ // if we are in perspective correction mode, update the offset when moving
+ if(m_perspectiveCorrection->isChecked())
+ {
+ double startM[3][3];
+ double endM[3][3];
+ for(int i = 0; i < 3; i++)
+ {
+ for(int j = 0; j < 3; j++)
+ {
+ startM[i][j] = 0.;
+ endM[i][j] = 0.;
+ }
+ startM[i][i] = 1.;
+ endM[i][i] = 1.;
+ }
+
+ // First look for the grid corresponding to the start point
+ KisSubPerspectiveGrid* subGridStart = *m_subject->currentImg()->perspectiveGrid()->begin();//device->image()->perspectiveGrid()->gridAt(KisPoint(srcPoint.x() +hotSpot.x(),srcPoint.y() +hotSpot.y()));
+ QRect r = QRect(0,0, m_subject->currentImg()->width(), m_subject->currentImg()->height());
+
+ if(subGridStart)
+ {
+ double* b = KisPerspectiveMath::computeMatrixTransfoFromPerspective( r, *subGridStart->topLeft(), *subGridStart->topRight(), *subGridStart->bottomLeft(), *subGridStart->bottomRight());
+ for(int i = 0; i < 3; i++)
+ {
+ for(int j = 0; j < 3; j++)
+ {
+ startM[i][j] = b[3*i+j];
+ }
+ }
+
+ }
+ // Second look for the grid corresponding to the end point
+ KisSubPerspectiveGrid* subGridEnd = *m_subject->currentImg()->perspectiveGrid()->begin();// device->image()->perspectiveGrid()->gridAt(pos);
+ if(subGridEnd)
+ {
+ double* b = KisPerspectiveMath::computeMatrixTransfoToPerspective(*subGridEnd->topLeft(), *subGridEnd->topRight(), *subGridEnd->bottomLeft(), *subGridEnd->bottomRight(), r);
+ for(int i = 0; i < 3; i++)
+ {
+ for(int j = 0; j < 3; j++)
+ {
+ endM[i][j] = b[3*i+j];
+ }
+ }
+ }
+ // Compute the translation in the perspective transformation space:
+ KisPoint translat;
+ {
+ KisPoint positionStartPaintingT = KisPerspectiveMath::matProd(endM, m_positionStartPainting);
+ KisPoint currentPositionT = KisPerspectiveMath::matProd(endM, e->pos() );
+ KisPoint duplicateStartPoisitionT = KisPerspectiveMath::matProd(endM, m_positionStartPainting - m_offset);
+ KisPoint duplicateRealPosition = KisPerspectiveMath::matProd(startM, duplicateStartPoisitionT + (currentPositionT - positionStartPaintingT) );
+ KisPoint p = e->pos() - duplicateRealPosition;
+ srcPos = p.floorQPoint();
+ }
+
+ }else {
+ srcPos = painter()->duplicateOffset().floorQPoint();
+ }
+ } else {
+ if(m_isOffsetNotUptodate)
+ srcPos = e->pos().floorQPoint() - m_position.floorQPoint();
+ else
+ srcPos = m_offset.floorQPoint();
+ }
+
+ Q_INT32 x;
+ Q_INT32 y;
+
+ // like KisPaintOp::splitCoordinate
+ x = (Q_INT32)((e->x() < 0) ? e->x() - 1 : e->x());
+ y = (Q_INT32)((e->y() < 0) ? e->y() - 1 : e->y());
+ srcPos = QPoint(x - srcPos.x(), y - srcPos.y());
+
+ paintOutline(srcPos);
+ super::move(e);
+}
+
+void KisToolDuplicate::paintAt(const KisPoint &pos,
+ const double pressure,
+ const double xtilt,
+ const double ytilt)
+{
+ if( m_position != QPoint(-1,-1))
+ {
+ if(m_isOffsetNotUptodate)
+ {
+ m_offset = pos - m_position;
+ m_isOffsetNotUptodate = false;
+ }
+ painter()->setDuplicateHealing( m_healing->isChecked() );
+ painter()->setDuplicateHealingRadius( m_healingRadius->value() );
+ painter()->setDuplicatePerspectiveCorrection( m_perspectiveCorrection->isChecked() );
+ painter()->paintAt( pos, pressure, xtilt, ytilt);
+ }
+}
+
+QString KisToolDuplicate::quickHelp() const {
+ return i18n("To start, shift-click on the place you want to duplicate from. Then you can start painting. An indication of where you are copying from will be displayed while drawing and moving the mouse.");
+}
+
+QWidget* KisToolDuplicate::createOptionWidget(QWidget* parent)
+{
+ QWidget* widget = KisToolPaint::createOptionWidget(parent);
+ m_healing = new QCheckBox(widget);
+ m_healing->setChecked( false);
+ addOptionWidgetOption(m_healing, new QLabel(i18n("Healing"), widget ));
+ m_healingRadius = new KIntNumInput(widget);
+
+ KisBrush *brush = m_subject->currentBrush();
+ int healingradius = 20;
+ if( brush )
+ {
+ healingradius = 2 * QMAX(brush->width(),brush->height());
+ }
+
+ m_healingRadius->setValue( healingradius );
+ addOptionWidgetOption(m_healingRadius, new QLabel(i18n("Healing radius"), widget ));
+ m_perspectiveCorrection = new QCheckBox(widget);
+ addOptionWidgetOption(m_perspectiveCorrection, new QLabel(i18n("Correct the perspective"), widget ));
+ return widget;
+}
+
+#include "kis_tool_duplicate.moc"
diff --git a/krita/plugins/tools/defaulttools/kis_tool_duplicate.h b/krita/plugins/tools/defaulttools/kis_tool_duplicate.h
new file mode 100644
index 00000000..758542b8
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_duplicate.h
@@ -0,0 +1,91 @@
+/*
+ * kis_tool_duplicate.h - part of Krita
+ *
+ * Copyright (c) 2004 Cyrille Berger <[email protected]>
+ *
+ * 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_TOOL_DUPLICATE_H__
+#define __KIS_TOOL_DUPLICATE_H__
+
+#include "kis_tool_freehand.h"
+#include "kis_tool_factory.h"
+
+class KisEvent;
+class KisButtonPressEvent;
+
+class QCheckBox;
+class KIntNumInput;
+
+class KisToolDuplicate : public KisToolFreehand {
+
+ typedef KisToolFreehand super;
+ Q_OBJECT
+
+public:
+ KisToolDuplicate();
+ virtual ~KisToolDuplicate();
+
+ virtual void setup(KActionCollection *collection);
+ virtual enumToolType toolType() { return TOOL_FREEHAND; }
+ virtual Q_UINT32 priority() { return 0; }
+ virtual void buttonPress(KisButtonPressEvent *e);
+ virtual void move(KisMoveEvent *e);
+
+ virtual void paintAt(const KisPoint &pos,
+ const double pressure,
+ const double xTilt,
+ const double yTilt);
+
+ virtual QString quickHelp() const;
+ virtual QWidget* createOptionWidget(QWidget* parent);
+
+protected slots:
+ virtual void activate();
+
+protected:
+ virtual void initPaint(KisEvent *e);
+
+ // Tool starting duplicate
+ KisPoint m_offset; // This member give the offset from the click position to the point where we take the duplication
+ bool m_isOffsetNotUptodate; // Tells if the offset is update
+ KisPoint m_position; // Give the position of the last alt-click
+ KisPoint m_positionStartPainting;
+ QCheckBox* m_healing;
+ KIntNumInput* m_healingRadius;
+ QCheckBox* m_perspectiveCorrection;
+};
+
+
+class KisToolDuplicateFactory : public KisToolFactory {
+ typedef KisToolFactory super;
+public:
+ KisToolDuplicateFactory() : super() {};
+ virtual ~KisToolDuplicateFactory(){};
+
+ virtual KisTool * createTool(KActionCollection * ac) {
+ KisTool * t = new KisToolDuplicate();
+ Q_CHECK_PTR(t);
+ t->setup(ac);
+ return t;
+ }
+ virtual KisID id() { return KisID("duplicate", i18n("Duplicate Tool")); }
+};
+
+
+
+#endif //__KIS_TOOL_DUPLICATE_H__
+
diff --git a/krita/plugins/tools/defaulttools/kis_tool_ellipse.cc b/krita/plugins/tools/defaulttools/kis_tool_ellipse.cc
new file mode 100644
index 00000000..dd8867c6
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_ellipse.cc
@@ -0,0 +1,186 @@
+/*
+ * kis_tool_ellipse.cc - part of Krayon
+ *
+ * Copyright (c) 2000 John Califf <[email protected]>
+ * Copyright (c) 2002 Patrick Julien <[email protected]>
+ * Copyright (c) 2004 Boudewijn Rempt <[email protected]>
+ * Copyright (c) 2004 Clarence Dang <[email protected]>
+ *
+ * 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 <qpainter.h>
+
+#include <kaction.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+#include "kis_painter.h"
+#include "kis_canvas_subject.h"
+#include "kis_canvas_controller.h"
+#include "kis_tool_ellipse.h"
+#include "kis_button_press_event.h"
+#include "kis_button_release_event.h"
+#include "kis_move_event.h"
+#include "kis_paintop_registry.h"
+#include "kis_undo_adapter.h"
+#include "kis_canvas.h"
+#include "kis_canvas_painter.h"
+#include "kis_cursor.h"
+
+KisToolEllipse::KisToolEllipse()
+ : super(i18n ("Ellipse")),
+ m_dragging (false),
+ m_currentImage (0)
+{
+ setName("tool_ellipse");
+ setCursor(KisCursor::load("tool_ellipse_cursor.png", 6, 6));
+}
+
+KisToolEllipse::~KisToolEllipse()
+{
+}
+
+void KisToolEllipse::update (KisCanvasSubject *subject)
+{
+ super::update (subject);
+ if (m_subject)
+ m_currentImage = m_subject->currentImg ();
+}
+
+void KisToolEllipse::buttonPress(KisButtonPressEvent *event)
+{
+ if (m_currentImage && event->button() == LeftButton) {
+ m_dragging = true;
+ m_dragStart = m_dragCenter = m_dragEnd = event->pos();
+ draw(m_dragStart, m_dragEnd);
+ }
+}
+
+void KisToolEllipse::move(KisMoveEvent *event)
+{
+ if (m_dragging) {
+ // erase old lines on canvas
+ draw(m_dragStart, m_dragEnd);
+ // move (alt) or resize ellipse
+ if (event->state() & Qt::AltButton) {
+ KisPoint trans = event->pos() - m_dragEnd;
+ m_dragStart += trans;
+ m_dragEnd += trans;
+ } else {
+ KisPoint diag = event->pos() - (event->state() & Qt::ControlButton
+ ? m_dragCenter : m_dragStart);
+ // circle?
+ if (event->state() & Qt::ShiftButton) {
+ double size = QMAX(fabs(diag.x()), fabs(diag.y()));
+ double w = diag.x() < 0 ? -size : size;
+ double h = diag.y() < 0 ? -size : size;
+ diag = KisPoint(w, h);
+ }
+
+ // resize around center point?
+ if (event->state() & Qt::ControlButton) {
+ m_dragStart = m_dragCenter - diag;
+ m_dragEnd = m_dragCenter + diag;
+ } else {
+ m_dragEnd = m_dragStart + diag;
+ }
+ }
+ // draw new lines on canvas
+ draw(m_dragStart, m_dragEnd);
+ m_dragCenter = KisPoint((m_dragStart.x() + m_dragEnd.x()) / 2,
+ (m_dragStart.y() + m_dragEnd.y()) / 2);
+ }
+}
+
+void KisToolEllipse::buttonRelease(KisButtonReleaseEvent *event)
+{
+ if (!m_subject || !m_currentImage)
+ return;
+
+ if (m_dragging && event->button() == LeftButton) {
+ // erase old lines on canvas
+ draw(m_dragStart, m_dragEnd);
+ m_dragging = false;
+
+ if (m_dragStart == m_dragEnd)
+ return;
+
+ if (!m_currentImage)
+ return;
+
+ if (!m_currentImage->activeDevice())
+ return;
+
+ KisPaintDeviceSP device = m_currentImage->activeDevice ();
+ KisPainter painter (device);
+ if (m_currentImage->undo()) painter.beginTransaction (i18n ("Ellipse"));
+
+ painter.setPaintColor(m_subject->fgColor());
+ painter.setBackgroundColor(m_subject->bgColor());
+ painter.setFillStyle(fillStyle());
+ painter.setBrush(m_subject->currentBrush());
+ painter.setPattern(m_subject->currentPattern());
+ painter.setOpacity(m_opacity);
+ painter.setCompositeOp(m_compositeOp);
+ KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), &painter);
+ painter.setPaintOp(op); // Painter takes ownership
+
+ painter.paintEllipse(m_dragStart, m_dragEnd, PRESSURE_DEFAULT/*event->pressure()*/, event->xTilt(), event->yTilt());
+ device->setDirty( painter.dirtyRect() );
+ notifyModified();
+
+ KisUndoAdapter *adapter = m_currentImage->undoAdapter();
+ if (adapter) {
+ adapter->addCommand(painter.endTransaction());
+ }
+ }
+}
+
+void KisToolEllipse::draw(const KisPoint& start, const KisPoint& end )
+{
+ if (!m_subject || !m_currentImage)
+ return;
+
+ KisCanvasController *controller = m_subject->canvasController ();
+ KisCanvas *canvas = controller->kiscanvas();
+ KisCanvasPainter p (canvas);
+
+ p.setRasterOp (Qt::NotROP);
+ p.drawEllipse (QRect (controller->windowToView (start).floorQPoint(), controller->windowToView (end).floorQPoint()));
+ p.end ();
+}
+
+void KisToolEllipse::setup(KActionCollection *collection)
+{
+ m_action = static_cast<KRadioAction *>(collection->action(name()));
+
+ if (m_action == 0) {
+ KShortcut shortcut(Qt::Key_Plus);
+ shortcut.append(KShortcut(Qt::Key_F7));
+ m_action = new KRadioAction(i18n("&Ellipse"),
+ "tool_ellipse",
+ shortcut,
+ this,
+ SLOT(activate()),
+ collection,
+ name());
+ m_action->setToolTip(i18n("Draw an ellipse"));
+ m_action->setExclusiveGroup("tools");
+ m_ownAction = true;
+ }
+}
+
+#include "kis_tool_ellipse.moc"
diff --git a/krita/plugins/tools/defaulttools/kis_tool_ellipse.h b/krita/plugins/tools/defaulttools/kis_tool_ellipse.h
new file mode 100644
index 00000000..a7bd595c
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_ellipse.h
@@ -0,0 +1,90 @@
+/*
+ * kis_tool_ellipse.h - part of Krayon
+ *
+ * Copyright (c) 2000 John Califf <[email protected]>
+ * Copyright (c) 2002 Patrick Julien <[email protected]>
+ * Copyright (c) 2004 Clarence Dang <[email protected]>
+ *
+ * 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_TOOL_ELLIPSE_H__
+#define __KIS_TOOL_ELLIPSE_H__
+
+#include "kis_tool_shape.h"
+
+class KisCanvas;
+class KisPainter;
+class KisRect;
+
+class KisToolEllipse : public KisToolShape {
+
+ typedef KisToolShape super;
+ Q_OBJECT
+
+public:
+ KisToolEllipse();
+ virtual ~KisToolEllipse();
+
+ //
+ // KisCanvasObserver interface
+ //
+
+ virtual void update (KisCanvasSubject *subject);
+
+ //
+ // KisToolPaint interface
+ //
+
+ virtual void setup(KActionCollection *collection);
+ virtual Q_UINT32 priority() { return 3; }
+ virtual enumToolType toolType() { return TOOL_SHAPE; }
+ virtual void buttonPress(KisButtonPressEvent *event);
+ virtual void move(KisMoveEvent *event);
+ virtual void buttonRelease(KisButtonReleaseEvent *event);
+
+protected:
+ virtual void draw(const KisPoint& start, const KisPoint& stop);
+
+protected:
+ KisPoint m_dragCenter;
+ KisPoint m_dragStart;
+ KisPoint m_dragEnd;
+
+ bool m_dragging;
+ KisImageSP m_currentImage;
+};
+
+
+#include "kis_tool_factory.h"
+
+class KisToolEllipseFactory : public KisToolFactory {
+ typedef KisToolFactory super;
+public:
+ KisToolEllipseFactory() : super() {};
+ virtual ~KisToolEllipseFactory(){};
+
+ virtual KisTool * createTool(KActionCollection * ac) {
+ KisTool * t = new KisToolEllipse();
+ Q_CHECK_PTR(t);
+ t->setup(ac);
+ return t;
+ }
+ virtual KisID id() { return KisID("ellipse", i18n("Ellipse Tool")); }
+};
+
+
+#endif //__KIS_TOOL_ELLIPSE_H__
+
diff --git a/krita/plugins/tools/defaulttools/kis_tool_fill.cc b/krita/plugins/tools/defaulttools/kis_tool_fill.cc
new file mode 100644
index 00000000..3edd4f17
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_fill.cc
@@ -0,0 +1,233 @@
+/*
+ * kis_tool_fill.cc - part of Krayon
+ *
+ * Copyright (c) 2000 John Califf <[email protected]>
+ * Copyright (c) 2004 Boudewijn Rempt <[email protected]>
+ * Copyright (c) 2004 Bart Coppens <[email protected]>
+ *
+ * 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 <kaction.h>
+#include <kdebug.h>
+#include <klocale.h>
+#include <kcommand.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qcheckbox.h>
+
+#include <qcolor.h>
+
+#include "knuminput.h"
+
+#include "kis_layer.h"
+#include "kis_cursor.h"
+#include "kis_painter.h"
+#include "kis_tool_brush.h"
+#include "kis_cmb_composite.h"
+#include "kis_tool_fill.h"
+#include "kis_colorspace.h"
+#include "kis_button_press_event.h"
+#include "kis_button_release_event.h"
+#include "kis_move_event.h"
+#include "kis_pattern.h"
+#include "kis_fill_painter.h"
+#include "kis_progress_display_interface.h"
+#include "kis_undo_adapter.h"
+#include "kis_canvas_subject.h"
+#include "kis_selection.h"
+
+KisToolFill::KisToolFill()
+ : super(i18n("Fill")), m_wasPressed(false)
+{
+ setName("tool_fill");
+ m_subject = 0;
+ m_oldColor = 0;
+ m_threshold = 15;
+ m_usePattern = false;
+ m_unmerged = false;
+ m_fillOnlySelection = false;
+
+ setCursor(KisCursor::load("tool_fill_cursor.png", 6, 6));
+}
+
+void KisToolFill::update(KisCanvasSubject *subject)
+{
+ m_subject = subject;
+ m_currentImage = subject->currentImg();
+
+ super::update(m_subject);
+}
+
+KisToolFill::~KisToolFill()
+{
+}
+
+bool KisToolFill::flood(int startX, int startY)
+{
+ KisPaintDeviceSP device = m_currentImage->activeDevice();
+ if (!device) return false;
+
+ if (m_fillOnlySelection) {
+ QRect rc = device->selection()->selectedRect();
+ KisPaintDeviceSP filled = new KisPaintDevice(device->colorSpace(), "filled");
+ KisFillPainter painter(filled);
+ if (m_usePattern)
+ painter.fillRect(rc.x(), rc.y(), rc.width(), rc.height(),
+ m_subject->currentPattern());
+ else
+ painter.fillRect(rc.x(), rc.y(), rc.width(), rc.height(),
+ m_subject->fgColor(), m_opacity);
+ painter.end();
+ KisPainter painter2(device);
+ if (m_currentImage->undo()) painter2.beginTransaction(i18n("Fill"));
+ painter2.bltSelection(rc.x(), rc.y() , m_compositeOp, filled, m_opacity,
+ rc.x(), rc.y(), rc.width(), rc.height());
+
+ device->setDirty(filled->extent());
+ notifyModified();
+
+ if (m_currentImage->undo()) {
+ m_currentImage->undoAdapter()->addCommand(painter2.endTransaction());
+ }
+ return true;
+ }
+
+ KisFillPainter painter(device);
+ if (m_currentImage->undo()) painter.beginTransaction(i18n("Flood Fill"));
+ painter.setPaintColor(m_subject->fgColor());
+ painter.setOpacity(m_opacity);
+ painter.setFillThreshold(m_threshold);
+ painter.setCompositeOp(m_compositeOp);
+ painter.setPattern(m_subject->currentPattern());
+ painter.setSampleMerged(!m_unmerged);
+ painter.setCareForSelection(true);
+
+ KisProgressDisplayInterface *progress = m_subject->progressDisplay();
+ if (progress) {
+ progress->setSubject(&painter, true, true);
+ }
+
+ if (m_usePattern)
+ painter.fillPattern(startX, startY);
+ else
+ painter.fillColor(startX, startY);
+
+ device->setDirty(painter.dirtyRect());
+ notifyModified();
+
+ if (m_currentImage->undo()) {
+ m_currentImage->undoAdapter()->addCommand(painter.endTransaction());
+ }
+
+ return true;
+}
+
+void KisToolFill::buttonPress(KisButtonPressEvent *e)
+{
+ m_startPos = e->pos();
+ m_wasPressed = true;
+}
+
+void KisToolFill::buttonRelease(KisButtonReleaseEvent *e)
+{
+ if (!m_subject) return;
+ if (!m_currentImage || !m_currentImage->activeDevice()) return;
+ if (e->button() != QMouseEvent::LeftButton) return;
+ if(!m_wasPressed) return;
+ m_wasPressed = false;
+ int x, y;
+ x = m_startPos.floorX();
+ y = m_startPos.floorY();
+ if (!m_currentImage->bounds().contains(x, y)) {
+ return;
+ }
+ flood(x, y);
+ notifyModified();
+}
+
+QWidget* KisToolFill::createOptionWidget(QWidget* parent)
+{
+ QWidget *widget = super::createOptionWidget(parent);
+
+ m_lbThreshold = new QLabel(i18n("Threshold: "), widget);
+ m_slThreshold = new KIntNumInput( widget, "int_widget");
+ m_slThreshold->setRange( 1, 100);
+ m_slThreshold->setSteps( 3, 3);
+ m_slThreshold->setValue(m_threshold);
+ connect(m_slThreshold, SIGNAL(valueChanged(int)), this, SLOT(slotSetThreshold(int)));
+
+ m_checkUsePattern = new QCheckBox(i18n("Use pattern"), widget);
+ m_checkUsePattern->setChecked(m_usePattern);
+ connect(m_checkUsePattern, SIGNAL(toggled(bool)), this, SLOT(slotSetUsePattern(bool)));
+
+ m_checkSampleMerged = new QCheckBox(i18n("Limit to current layer"), widget);
+ m_checkSampleMerged->setChecked(m_unmerged);
+ connect(m_checkSampleMerged, SIGNAL(toggled(bool)), this, SLOT(slotSetSampleMerged(bool)));
+
+ m_checkFillSelection = new QCheckBox(i18n("Fill entire selection"), widget);
+ m_checkFillSelection->setChecked(m_fillOnlySelection);
+ connect(m_checkFillSelection, SIGNAL(toggled(bool)), this, SLOT(slotSetFillSelection(bool)));
+
+ addOptionWidgetOption(m_slThreshold, m_lbThreshold);
+
+ addOptionWidgetOption(m_checkFillSelection);
+ addOptionWidgetOption(m_checkSampleMerged);
+ addOptionWidgetOption(m_checkUsePattern);
+
+ return widget;
+}
+
+void KisToolFill::slotSetThreshold(int threshold)
+{
+ m_threshold = threshold;
+}
+
+void KisToolFill::slotSetUsePattern(bool state)
+{
+ m_usePattern = state;
+}
+
+void KisToolFill::slotSetSampleMerged(bool state)
+{
+ m_unmerged = state;
+}
+
+void KisToolFill::slotSetFillSelection(bool state)
+{
+ m_fillOnlySelection = state;
+ m_slThreshold->setEnabled(!state);
+ m_checkSampleMerged->setEnabled(!state);
+}
+
+void KisToolFill::setup(KActionCollection *collection)
+{
+ m_action = static_cast<KRadioAction *>(collection->action(name()));
+
+ if (m_action == 0) {
+ m_action = new KRadioAction(i18n("&Fill"),
+ "tool_color_fill",
+ Qt::Key_F,
+ this,
+ SLOT(activate()),
+ collection,
+ name());
+ m_action->setToolTip(i18n("Contiguous fill"));
+ m_action->setExclusiveGroup("tools");
+ m_ownAction = true;
+ }
+}
+
+#include "kis_tool_fill.moc"
diff --git a/krita/plugins/tools/defaulttools/kis_tool_fill.h b/krita/plugins/tools/defaulttools/kis_tool_fill.h
new file mode 100644
index 00000000..2b121d9c
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_fill.h
@@ -0,0 +1,108 @@
+/*
+ * kis_tool_fill.h - part of Krayon^Krita
+ *
+ * Copyright (c) 2004 Bart Coppens <[email protected]>
+ *
+ * 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 __filltool_h__
+#define __filltool_h__
+
+#include <qpoint.h>
+
+#include "kis_point.h"
+#include "kis_tool_paint.h"
+
+class KisPainter;
+class QWidget;
+class QLabel;
+class QCheckBox;
+class KIntNumInput;
+class KActionCollection;
+
+class KisToolFill : public KisToolPaint {
+
+ typedef KisToolPaint super;
+ Q_OBJECT
+
+public:
+
+ KisToolFill();
+ virtual ~KisToolFill();
+
+ virtual void setup(KActionCollection *collection);
+ virtual enumToolType toolType() { return TOOL_FILL; }
+ virtual Q_UINT32 priority() { return 0; }
+
+ virtual void update(KisCanvasSubject *subject);
+
+ virtual void buttonPress(KisButtonPressEvent*);
+ virtual void buttonRelease(KisButtonReleaseEvent*);
+
+ bool flood(int startX, int startY);
+
+ virtual QWidget* createOptionWidget(QWidget* parent);
+
+public slots:
+ virtual void slotSetThreshold(int);
+ virtual void slotSetUsePattern(bool);
+ virtual void slotSetSampleMerged(bool);
+ virtual void slotSetFillSelection(bool);
+
+private:
+ KisPoint m_startPos;
+ int m_threshold;
+ Q_INT32 m_depth;
+ KisLayerSP m_lay;
+ Q_UINT8* m_oldColor, *m_color;
+ KisPainter *m_painter;
+ KisCanvasSubject *m_subject;
+ KisImageSP m_currentImage;
+ bool *m_map, m_unmerged, m_usePattern, m_fillOnlySelection;
+ KisSelectionSP m_selection;
+
+ QLabel *m_lbThreshold;
+ KIntNumInput *m_slThreshold;
+ QCheckBox *m_checkUsePattern;
+ QCheckBox *m_checkSampleMerged;
+ QCheckBox *m_checkFillSelection;
+ bool m_wasPressed; // use for preventing bug:133148
+};
+
+
+#include "kis_tool_factory.h"
+
+class KisToolFillFactory : public KisToolFactory {
+ typedef KisToolFactory super;
+public:
+ KisToolFillFactory() : super() {};
+ virtual ~KisToolFillFactory(){};
+
+ virtual KisTool * createTool(KActionCollection * ac) {
+ KisToolFill * t = new KisToolFill();
+ Q_CHECK_PTR(t);
+ t->setup(ac);
+ return t;
+ }
+ virtual KisID id() { return KisID("fill", i18n("Fill Tool")); }
+
+};
+
+
+
+
+#endif //__filltool_h__
+
diff --git a/krita/plugins/tools/defaulttools/kis_tool_gradient.cc b/krita/plugins/tools/defaulttools/kis_tool_gradient.cc
new file mode 100644
index 00000000..6c35de4e
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_gradient.cc
@@ -0,0 +1,309 @@
+/*
+ * kis_tool_gradient.cc - part of Krita
+ *
+ * Copyright (c) 2000 John Califf
+ * Copyright (c) 2002 Patrick Julien <[email protected]>
+ * Copyright (c) 2003 Boudewijn Rempt <[email protected]>
+ * Copyright (c) 2004 Adrian Page <[email protected]>
+ *
+ * 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 <qpainter.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qcheckbox.h>
+
+#include <kdebug.h>
+#include <kaction.h>
+#include <kcommand.h>
+#include <klocale.h>
+#include <knuminput.h>
+
+#include "kis_button_press_event.h"
+#include "kis_button_release_event.h"
+#include "kis_canvas_subject.h"
+#include "kis_cmb_composite.h"
+#include "kis_cursor.h"
+#include "kis_double_widget.h"
+#include "kis_gradient_painter.h"
+#include "kis_move_event.h"
+#include "kis_painter.h"
+#include "kis_progress_display_interface.h"
+#include "kis_tool_gradient.h"
+#include "kis_undo_adapter.h"
+#include "kis_canvas.h"
+#include "kis_canvas_painter.h"
+
+KisToolGradient::KisToolGradient()
+ : super(i18n("Gradient")),
+ m_dragging( false )
+{
+ setName("tool_gradient");
+ setCursor(KisCursor::load("tool_gradient_cursor.png", 6, 6));
+
+ m_startPos = KisPoint(0, 0);
+ m_endPos = KisPoint(0, 0);
+
+ m_reverse = false;
+ m_shape = KisGradientPainter::GradientShapeLinear;
+ m_repeat = KisGradientPainter::GradientRepeatNone;
+ m_antiAliasThreshold = 0.2;
+}
+
+KisToolGradient::~KisToolGradient()
+{
+}
+
+void KisToolGradient::update(KisCanvasSubject *subject)
+{
+ m_subject = subject;
+ super::update(m_subject);
+}
+
+void KisToolGradient::paint(KisCanvasPainter& gc)
+{
+ if (m_dragging)
+ paintLine(gc);
+}
+
+void KisToolGradient::paint(KisCanvasPainter& gc, const QRect&)
+{
+ if (m_dragging)
+ paintLine(gc);
+}
+
+void KisToolGradient::buttonPress(KisButtonPressEvent *e)
+{
+ if (!m_subject || !m_subject->currentImg()) {
+ return;
+ }
+
+ if (e->button() == QMouseEvent::LeftButton) {
+ m_dragging = true;
+ m_startPos = e->pos();
+ m_endPos = e->pos();
+ }
+}
+
+void KisToolGradient::move(KisMoveEvent *e)
+{
+ if (m_dragging) {
+ if (m_startPos != m_endPos) {
+ paintLine();
+ }
+
+ if ((e->state() & Qt::ShiftButton) == Qt::ShiftButton) {
+ m_endPos = straightLine(e->pos());
+ }
+ else {
+ m_endPos = e->pos();
+ }
+
+ paintLine();
+ }
+}
+
+void KisToolGradient::buttonRelease(KisButtonReleaseEvent *e)
+{
+ if (m_dragging && e->button() == QMouseEvent::LeftButton) {
+
+ KisCanvasController *controller = m_subject->canvasController();
+ KisImageSP img = m_subject->currentImg();
+
+ m_dragging = false;
+
+ if (m_startPos == m_endPos) {
+ controller->updateCanvas();
+ m_dragging = false;
+ return;
+ }
+
+ if ((e->state() & Qt::ShiftButton) == Qt::ShiftButton) {
+ m_endPos = straightLine(e->pos());
+ }
+ else {
+ m_endPos = e->pos();
+ }
+
+ KisPaintDeviceSP device;
+
+ if (img && (device = img->activeDevice())) {
+
+ KisGradientPainter painter(device);
+
+ if (img->undo()) painter.beginTransaction(i18n("Gradient"));
+
+ painter.setPaintColor(m_subject->fgColor());
+ painter.setGradient(*(m_subject->currentGradient()));
+ painter.setOpacity(m_opacity);
+ painter.setCompositeOp(m_compositeOp);
+
+ KisProgressDisplayInterface *progress = m_subject->progressDisplay();
+
+ if (progress) {
+ progress->setSubject(&painter, true, true);
+ }
+
+ bool painted = painter.paintGradient(m_startPos, m_endPos, m_shape, m_repeat, m_antiAliasThreshold, m_reverse, 0, 0, m_subject->currentImg()->width(), m_subject->currentImg()->height());
+
+ if (painted) {
+ // does whole thing at moment
+ device->setDirty(painter.dirtyRect());
+
+ notifyModified();
+
+ if (img->undo()) {
+ img->undoAdapter()->addCommand(painter.endTransaction());
+ }
+ }
+
+ /* remove remains of the line drawn while moving */
+ if (controller->kiscanvas()) {
+ controller->kiscanvas()->update();
+ }
+
+ }
+ }
+}
+
+KisPoint KisToolGradient::straightLine(KisPoint point)
+{
+ KisPoint comparison = point - m_startPos;
+ KisPoint result;
+
+ if ( fabs(comparison.x()) > fabs(comparison.y())) {
+ result.setX(point.x());
+ result.setY(m_startPos.y());
+ } else {
+ result.setX( m_startPos.x() );
+ result.setY( point.y() );
+ }
+
+ return result;
+}
+
+void KisToolGradient::paintLine()
+{
+ if (m_subject) {
+ KisCanvasController *controller = m_subject->canvasController();
+ KisCanvas *canvas = controller->kiscanvas();
+ KisCanvasPainter gc(canvas);
+
+ paintLine(gc);
+ }
+}
+
+void KisToolGradient::paintLine(KisCanvasPainter& gc)
+{
+ if (m_subject) {
+ KisCanvasController *controller = m_subject->canvasController();
+
+ KisPoint start = controller->windowToView(m_startPos);
+ KisPoint end = controller->windowToView(m_endPos);
+
+ RasterOp op = gc.rasterOp();
+ QPen old = gc.pen();
+ QPen pen(Qt::SolidLine);
+
+ gc.setRasterOp(Qt::NotROP);
+ gc.setPen(pen);
+ gc.drawLine(start.floorQPoint(), end.floorQPoint());
+ gc.setRasterOp(op);
+ gc.setPen(old);
+ }
+}
+
+QWidget* KisToolGradient::createOptionWidget(QWidget* parent)
+{
+ QWidget *widget = super::createOptionWidget(parent);
+ Q_CHECK_PTR(widget);
+
+ m_lbShape = new QLabel(i18n("Shape:"), widget);
+ m_lbRepeat = new QLabel(i18n("Repeat:"), widget);
+
+ m_ckReverse = new QCheckBox(i18n("Reverse"), widget, "reverse_check");
+ connect(m_ckReverse, SIGNAL(toggled(bool)), this, SLOT(slotSetReverse(bool)));
+
+ m_cmbShape = new QComboBox(false, widget, "shape_combo");
+ connect(m_cmbShape, SIGNAL(activated(int)), this, SLOT(slotSetShape(int)));
+ m_cmbShape->insertItem(i18n("Linear"));
+ m_cmbShape->insertItem(i18n("Bi-Linear"));
+ m_cmbShape->insertItem(i18n("Radial"));
+ m_cmbShape->insertItem(i18n("Square"));
+ m_cmbShape->insertItem(i18n("Conical"));
+ m_cmbShape->insertItem(i18n("Conical Symmetric"));
+
+ m_cmbRepeat = new QComboBox(false, widget, "repeat_combo");
+ connect(m_cmbRepeat, SIGNAL(activated(int)), this, SLOT(slotSetRepeat(int)));
+ m_cmbRepeat->insertItem(i18n("None"));
+ m_cmbRepeat->insertItem(i18n("Forwards"));
+ m_cmbRepeat->insertItem(i18n("Alternating"));
+
+ addOptionWidgetOption(m_cmbShape, m_lbShape);
+
+ addOptionWidgetOption(m_cmbRepeat, m_lbRepeat);
+
+ addOptionWidgetOption(m_ckReverse);
+
+ m_lbAntiAliasThreshold = new QLabel(i18n("Anti-alias threshold:"), widget);
+
+ m_slAntiAliasThreshold = new KDoubleNumInput(widget, "threshold_slider");
+ m_slAntiAliasThreshold->setRange( 0, 1);
+ m_slAntiAliasThreshold->setValue(m_antiAliasThreshold);
+ connect(m_slAntiAliasThreshold, SIGNAL(valueChanged(double)), this, SLOT(slotSetAntiAliasThreshold(double)));
+
+ addOptionWidgetOption(m_slAntiAliasThreshold, m_lbAntiAliasThreshold);
+
+ return widget;
+}
+
+void KisToolGradient::slotSetShape(int shape)
+{
+ m_shape = static_cast<KisGradientPainter::enumGradientShape>(shape);
+}
+
+void KisToolGradient::slotSetRepeat(int repeat)
+{
+ m_repeat = static_cast<KisGradientPainter::enumGradientRepeat>(repeat);
+}
+
+void KisToolGradient::slotSetReverse(bool state)
+{
+ m_reverse = state;
+}
+
+void KisToolGradient::slotSetAntiAliasThreshold(double value)
+{
+ m_antiAliasThreshold = value;
+}
+
+void KisToolGradient::setup(KActionCollection *collection)
+{
+ m_action = static_cast<KRadioAction *>(collection->action(name()));
+
+ if (m_action == 0) {
+ m_action = new KRadioAction(i18n("&Gradient"),
+ "tool_gradient", Qt::Key_G, this,
+ SLOT(activate()), collection,
+ name());
+ m_action->setToolTip(i18n("Draw a gradient"));
+ m_action->setExclusiveGroup("tools");
+ m_ownAction = true;
+ }
+}
+
+#include "kis_tool_gradient.moc"
+
diff --git a/krita/plugins/tools/defaulttools/kis_tool_gradient.h b/krita/plugins/tools/defaulttools/kis_tool_gradient.h
new file mode 100644
index 00000000..c80529e3
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_gradient.h
@@ -0,0 +1,123 @@
+/*
+ * kis_tool_line.h - part of Krayon
+ *
+ * Copyright (c) 2000 John Califf <[email protected]>
+ * Copyright (c) 2002 Patrick Julien <[email protected]>
+ * Copyright (c) 2004 Boudewijn Rempt <[email protected]>
+ * Copyright (c) 2004 Adrian Page <[email protected]>
+ *
+ * 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_TOOL_GRADIENT_H_
+#define KIS_TOOL_GRADIENT_H_
+
+#include "kis_tool_paint.h"
+
+#include "kis_global.h"
+#include "kis_types.h"
+#include "kis_gradient_painter.h"
+#include "kis_tool_factory.h"
+
+class KIntNumInput;
+class KDoubleNumInput;
+
+class KisCmbComposite;
+class KisPainter;
+
+class QLabel;
+class QPoint;
+class QWidget;
+class QCheckBox;
+
+
+
+class KisToolGradient : public KisToolPaint {
+
+ Q_OBJECT
+ typedef KisToolPaint super;
+
+public:
+ KisToolGradient();
+ virtual ~KisToolGradient();
+
+ virtual void setup(KActionCollection *collection);
+ virtual enumToolType toolType() { return TOOL_FILL; }
+ virtual Q_UINT32 priority() { return 1; }
+
+ virtual void update(KisCanvasSubject *subject);
+
+ virtual void buttonPress(KisButtonPressEvent *event);
+ virtual void move(KisMoveEvent *event);
+ virtual void buttonRelease(KisButtonReleaseEvent *event);
+
+ virtual void paint(KisCanvasPainter& gc);
+ virtual void paint(KisCanvasPainter& gc, const QRect& rc);
+
+ QWidget* createOptionWidget(QWidget* parent);
+
+public slots:
+ void slotSetShape(int);
+ void slotSetRepeat(int);
+ void slotSetReverse(bool);
+ void slotSetAntiAliasThreshold(double);
+
+private:
+ void paintLine();
+ void paintLine(KisCanvasPainter& gc);
+
+ KisPoint straightLine(KisPoint point);
+
+ bool m_dragging;
+
+ KisPoint m_startPos;
+ KisPoint m_endPos;
+
+ KisCanvasSubject *m_subject;
+
+ KisGradientPainter::enumGradientShape m_shape;
+ KisGradientPainter::enumGradientRepeat m_repeat;
+
+ bool m_reverse;
+ double m_antiAliasThreshold;
+
+ QLabel *m_lbShape;
+ QLabel *m_lbRepeat;
+ QCheckBox *m_ckReverse;
+ QComboBox *m_cmbShape;
+ QComboBox *m_cmbRepeat;
+ QLabel *m_lbAntiAliasThreshold;
+ KDoubleNumInput *m_slAntiAliasThreshold;
+};
+
+class KisToolGradientFactory : public KisToolFactory {
+ typedef KisToolFactory super;
+public:
+ KisToolGradientFactory() : super() {};
+ virtual ~KisToolGradientFactory(){};
+
+ virtual KisTool * createTool(KActionCollection * ac) {
+ KisTool * t = new KisToolGradient();
+ Q_CHECK_PTR(t);
+ t->setup(ac);
+ return t;
+ }
+ virtual KisID id() { return KisID("gradient", i18n("Gradient Tool")); }
+};
+
+
+
+#endif //KIS_TOOL_GRADIENT_H_
+
diff --git a/krita/plugins/tools/defaulttools/kis_tool_line.cc b/krita/plugins/tools/defaulttools/kis_tool_line.cc
new file mode 100644
index 00000000..cbdf5448
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_line.cc
@@ -0,0 +1,254 @@
+/*
+ * kis_tool_line.cc - part of Krayon
+ *
+ * Copyright (c) 2000 John Califf
+ * Copyright (c) 2002 Patrick Julien <[email protected]>
+ * Copyright (c) 2003 Boudewijn Rempt <[email protected]>
+ *
+ * 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 <qpainter.h>
+#include <qlayout.h>
+#include <qwidget.h>
+
+#include <kdebug.h>
+#include <kaction.h>
+#include <kcommand.h>
+#include <klocale.h>
+
+#include "kis_cursor.h"
+#include "kis_painter.h"
+#include "kis_tool_line.h"
+#include "kis_button_press_event.h"
+#include "kis_button_release_event.h"
+#include "kis_move_event.h"
+#include "kis_paintop_registry.h"
+#include "kis_canvas_subject.h"
+#include "kis_undo_adapter.h"
+#include "kis_canvas.h"
+#include "kis_canvas_painter.h"
+#include "kis_cursor.h"
+#include "kis_layer.h"
+
+KisToolLine::KisToolLine()
+ : super(i18n("Line")),
+ m_dragging( false )
+{
+ setName("tool_line");
+ setCursor(KisCursor::load("tool_line_cursor.png", 6, 6));
+
+ m_painter = 0;
+ m_currentImage = 0;
+ m_startPos = KisPoint(0, 0);
+ m_endPos = KisPoint(0, 0);
+}
+
+KisToolLine::~KisToolLine()
+{
+}
+
+void KisToolLine::update(KisCanvasSubject *subject)
+{
+ m_subject = subject;
+ m_currentImage = subject->currentImg();
+
+ super::update(m_subject);
+}
+
+
+void KisToolLine::paint(KisCanvasPainter& gc)
+{
+ if (m_dragging)
+ paintLine(gc, QRect());
+}
+
+void KisToolLine::paint(KisCanvasPainter& gc, const QRect& rc)
+{
+ if (m_dragging)
+ paintLine(gc, rc);
+}
+
+void KisToolLine::buttonPress(KisButtonPressEvent *e)
+{
+ if (!m_subject || !m_currentImage) return;
+
+ if (!m_subject->currentBrush()) return;
+
+ if (e->button() == QMouseEvent::LeftButton) {
+ m_dragging = true;
+ //KisCanvasController *controller = m_subject->canvasController();
+ m_startPos = e->pos(); //controller->windowToView(e->pos());
+ m_endPos = e->pos(); //controller->windowToView(e->pos());
+ }
+}
+
+void KisToolLine::move(KisMoveEvent *e)
+{
+ if (m_dragging) {
+ if (m_startPos != m_endPos)
+ paintLine();
+ //KisCanvasController *controller = m_subject->canvasController();
+
+ if (e->state() & Qt::AltButton) {
+ KisPoint trans = e->pos() - m_endPos;
+ m_startPos += trans;
+ m_endPos += trans;
+ } else if (e->state() & Qt::ShiftButton)
+ m_endPos = straightLine(e->pos());
+ else
+ m_endPos = e->pos();//controller->windowToView(e->pos());
+ paintLine();
+ }
+}
+
+void KisToolLine::buttonRelease(KisButtonReleaseEvent *e)
+{
+ if (m_dragging && e->button() == QMouseEvent::LeftButton) {
+ m_dragging = false;
+ KisCanvasController *controller = m_subject->canvasController();
+ KisImageSP img = m_subject->currentImg();
+
+ if (m_startPos == m_endPos) {
+ controller->updateCanvas();
+ m_dragging = false;
+ return;
+ }
+
+ if ((e->state() & Qt::ShiftButton) == Qt::ShiftButton) {
+ m_endPos = straightLine(e->pos());
+ }
+ else {
+ m_endPos = e->pos();
+ }
+
+ KisPaintDeviceSP device;
+ if (m_currentImage &&
+ (device = m_currentImage->activeDevice()) &&
+ m_subject &&
+ m_subject->currentBrush())
+ {
+ delete m_painter;
+ m_painter = new KisPainter( device );
+ Q_CHECK_PTR(m_painter);
+
+ if (m_currentImage->undo()) m_painter->beginTransaction(i18n("Line"));
+
+ m_painter->setPaintColor(m_subject->fgColor());
+ m_painter->setBrush(m_subject->currentBrush());
+ m_painter->setOpacity(m_opacity);
+ m_painter->setCompositeOp(m_compositeOp);
+ KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), m_painter);
+ m_painter->setPaintOp(op); // Painter takes ownership
+ m_painter->paintLine(m_startPos, PRESSURE_DEFAULT, 0, 0, m_endPos, PRESSURE_DEFAULT, 0, 0);
+ device->setDirty( m_painter->dirtyRect() );
+ notifyModified();
+
+ /* remove remains of the line drawn while moving */
+ if (controller->kiscanvas()) {
+ controller->kiscanvas()->update();
+ }
+
+ if (m_currentImage->undo() && m_painter) {
+ m_currentImage->undoAdapter()->addCommand(m_painter->endTransaction());
+ }
+ delete m_painter;
+ m_painter = 0;
+ } else {
+ if (m_painter)
+ controller->updateCanvas(m_painter->dirtyRect()); // Removes the last remaining line.
+ }
+ }
+
+}
+
+KisPoint KisToolLine::straightLine(KisPoint point)
+{
+ KisPoint comparison = point - m_startPos;
+ KisPoint result;
+
+ if ( fabs(comparison.x()) > fabs(comparison.y())) {
+ result.setX(point.x());
+ result.setY(m_startPos.y());
+ } else {
+ result.setX( m_startPos.x() );
+ result.setY( point.y() );
+ }
+
+ return result;
+}
+
+void KisToolLine::paintLine()
+{
+ if (m_subject) {
+ KisCanvasController *controller = m_subject->canvasController();
+ KisCanvas *canvas = controller->kiscanvas();
+ KisCanvasPainter gc(canvas);
+ QRect rc;
+
+ paintLine(gc, rc);
+ }
+}
+
+void KisToolLine::paintLine(KisCanvasPainter& gc, const QRect&)
+{
+ if (m_subject) {
+ KisCanvasController *controller = m_subject->canvasController();
+ RasterOp op = gc.rasterOp();
+ QPen old = gc.pen();
+ QPen pen(Qt::SolidLine);
+ KisPoint start;
+ KisPoint end;
+
+// Q_ASSERT(controller);
+ start = controller->windowToView(m_startPos);
+ end = controller->windowToView(m_endPos);
+// start.setX(start.x() - controller->horzValue());
+// start.setY(start.y() - controller->vertValue());
+// end.setX(end.x() - controller->horzValue());
+// end.setY(end.y() - controller->vertValue());
+// end.setX((end.x() - start.x()));
+// end.setY((end.y() - start.y()));
+// start *= m_subject->zoomFactor();
+// end *= m_subject->zoomFactor();
+ gc.setRasterOp(Qt::NotROP);
+ gc.setPen(pen);
+ gc.drawLine(start.floorQPoint(), end.floorQPoint());
+ gc.setRasterOp(op);
+ gc.setPen(old);
+ }
+}
+
+void KisToolLine::setup(KActionCollection *collection)
+{
+ m_action = static_cast<KRadioAction *>(collection->action(name()));
+
+ if (m_action == 0) {
+ m_action = new KRadioAction(i18n("&Line"),
+ "tool_line", Qt::Key_L, this,
+ SLOT(activate()), collection,
+ name());
+ m_action->setToolTip(i18n("Draw a line"));
+ m_action->setExclusiveGroup("tools");
+ m_ownAction = true;
+ }
+}
+
+QString KisToolLine::quickHelp() const {
+ return i18n("Alt+Drag will move the origin of the currently displayed line around, Shift+Drag will force you to draw straight lines");
+}
+
+#include "kis_tool_line.moc"
+
diff --git a/krita/plugins/tools/defaulttools/kis_tool_line.h b/krita/plugins/tools/defaulttools/kis_tool_line.h
new file mode 100644
index 00000000..8a84a819
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_line.h
@@ -0,0 +1,99 @@
+/*
+ * kis_tool_line.h - part of Krayon
+ *
+ * Copyright (c) 2000 John Califf <[email protected]>
+ * Copyright (c) 2002 Patrick Julien <[email protected]>
+ * Copyright (c) 2004 Boudewijn Rempt <[email protected]>
+ *
+ * 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_TOOL_LINE_H_
+#define KIS_TOOL_LINE_H_
+
+#include "kis_tool_paint.h"
+
+#include "kis_global.h"
+#include "kis_types.h"
+#include "kis_tool_factory.h"
+
+class KisBrush;
+class KisPainter;
+
+class QPoint;
+class QWidget;
+
+
+class KisToolLine : public KisToolPaint {
+
+ Q_OBJECT
+ typedef KisToolPaint super;
+
+ public:
+ KisToolLine();
+ virtual ~KisToolLine();
+
+ virtual void setup(KActionCollection *collection);
+ virtual enumToolType toolType() { return TOOL_SHAPE; }
+ virtual Q_UINT32 priority() { return 1; }
+ virtual void update(KisCanvasSubject *subject);
+
+ virtual void buttonPress(KisButtonPressEvent *event);
+ virtual void move(KisMoveEvent *event);
+ virtual void buttonRelease(KisButtonReleaseEvent *event);
+
+ virtual void paint(KisCanvasPainter& gc);
+ virtual void paint(KisCanvasPainter& gc, const QRect& rc);
+
+ virtual QString quickHelp() const;
+
+ private:
+ void paintLine();
+ void paintLine(KisCanvasPainter& gc, const QRect& rc);
+
+ KisPoint straightLine(KisPoint point);
+
+
+ bool m_dragging;
+
+ KisPoint m_startPos;
+ KisPoint m_endPos;
+
+ KisCanvasSubject *m_subject;
+ KisImageSP m_currentImage;
+ KisPainter *m_painter;
+};
+
+
+class KisToolLineFactory : public KisToolFactory {
+ typedef KisToolFactory super;
+public:
+ KisToolLineFactory() : super() {};
+ virtual ~KisToolLineFactory(){};
+
+ virtual KisTool * createTool(KActionCollection * ac) {
+ KisTool * t = new KisToolLine();
+ Q_CHECK_PTR(t);
+ t->setup(ac);
+ return t;
+ }
+ virtual KisID id() { return KisID("line", i18n("Line Tool")); }
+};
+
+
+
+
+#endif //KIS_TOOL_LINE_H_
+
diff --git a/krita/plugins/tools/defaulttools/kis_tool_move.cc b/krita/plugins/tools/defaulttools/kis_tool_move.cc
new file mode 100644
index 00000000..810bda37
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_move.cc
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 1999 Matthias Elter <[email protected]>
+ * 1999 Michael Koch <[email protected]>
+ * 2002 Patrick Julien <[email protected]>
+ * 2004 Boudewijn Rempt <[email protected]>
+ *
+ * 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 <stdlib.h>
+#include <qpoint.h>
+#include <kaction.h>
+#include <klocale.h>
+#include <qcolor.h>
+#include "kis_canvas_subject.h"
+#include "kis_cursor.h"
+#include "kis_image.h"
+#include "kis_paint_device.h"
+#include "kis_tool_move.h"
+#include "kis_tool_move.moc"
+#include "kis_button_press_event.h"
+#include "kis_button_release_event.h"
+#include "kis_move_event.h"
+#include "kis_selection.h"
+#include "kis_selection_manager.h"
+#include "kis_layer.h"
+
+KisToolMove::KisToolMove()
+ : super(i18n("Move Tool"))
+ , m_subject( 0 )
+ , m_keyEvent( 0 )
+{
+ setName("tool_move");
+
+ setCursor(KisCursor::moveCursor());
+ m_repeatTimer = new QTimer(this);
+ connect( m_repeatTimer, SIGNAL( timeout() ), this, SLOT( slotMove() ) );
+}
+
+KisToolMove::~KisToolMove()
+{
+}
+
+void KisToolMove::update(KisCanvasSubject *subject)
+{
+ m_subject = subject;
+ m_strategy.reset(subject);
+ super::update(subject);
+}
+
+void KisToolMove::buttonPress(KisButtonPressEvent *e)
+{
+ if (m_subject && e->button() == QMouseEvent::LeftButton) {
+ QPoint pos = e->pos().floorQPoint();
+ KisImageSP img = m_subject->currentImg();
+ KisLayerSP dev;
+
+ if (!img || !(dev = img->activeLayer()))
+ return;
+
+ m_strategy.startDrag(pos);
+ }
+}
+
+void KisToolMove::move(KisMoveEvent *e)
+{
+ if (m_subject && e->state() == QMouseEvent::LeftButton) {
+ QPoint pos = e->pos().floorQPoint();
+ if((e->state() & Qt::AltButton) || (e->state() & Qt::ControlButton)) {
+ if(fabs(pos.x() - m_dragStart.x()) > fabs(pos.y() - m_dragStart.y()))
+ pos.setY(m_dragStart.y());
+ else
+ pos.setX(m_dragStart.x());
+ }
+ m_strategy.drag(pos);
+ }
+}
+
+void KisToolMove::buttonRelease(KisButtonReleaseEvent *e)
+{
+ if (m_subject && e->button() == QMouseEvent::LeftButton) {
+ m_strategy.endDrag(e->pos().floorQPoint());
+ }
+}
+
+void KisToolMove::setup(KActionCollection *collection)
+{
+ m_action = static_cast<KRadioAction *>(collection->action(name()));
+
+ if (m_action == 0) {
+ m_action = new KRadioAction(i18n("&Move"),
+ "tool_move",
+ Qt::SHIFT+Qt::Key_V,
+ this,
+ SLOT(activate()),
+ collection,
+ name());
+ m_action->setToolTip(i18n("Move"));
+ m_action->setExclusiveGroup("tools");
+ m_ownAction = true;
+ }
+}
+
+
+void KisToolMove::keyPress( QKeyEvent *e )
+{
+ m_keyEvent = e;
+
+ if (m_subject) {
+
+ KisImageSP img = m_subject->currentImg();
+ KisLayerSP dev;
+
+ if (!img || !(dev = img->activeLayer()))
+ return;
+
+ m_dragStart = QPoint( 0, 0 );
+ m_strategy.startDrag( m_dragStart );
+ m_steps = 1;
+ m_repeatTimer->start(200);
+
+ }
+}
+
+void KisToolMove::keyRelease(QKeyEvent *)
+{
+ m_repeatTimer->stop();
+
+ if ( m_subject && m_keyEvent) {
+
+ if ( m_keyEvent->key() == Qt::Key_Left ) {
+ m_strategy.endDrag(QPoint( -m_steps, 0 ));
+ }
+ else if ( m_keyEvent->key() == Qt::Key_Right ) {
+ m_strategy.endDrag(QPoint(m_steps, 0) );
+ }
+ else if ( m_keyEvent->key() == Qt::Key_Up ) {
+ m_strategy.endDrag(QPoint(0, -m_steps) );
+ }
+ else if ( m_keyEvent->key() == Qt::Key_Down ) {
+ m_strategy.endDrag(QPoint(0, m_steps) );
+ }
+ }
+ m_steps = 0;
+ m_keyEvent = 0;
+
+}
+
+void KisToolMove::slotMove()
+{
+ if (m_subject && m_keyEvent) {
+
+ if ( m_keyEvent->key() == Qt::Key_Left ) {
+ m_strategy.drag(QPoint(-m_steps, 0) );
+ }
+ else if ( m_keyEvent->key() == Qt::Key_Right ) {
+ m_strategy.drag(QPoint(m_steps, 0) );
+ }
+ else if ( m_keyEvent->key() == Qt::Key_Up ) {
+ m_strategy.drag(QPoint(0, -m_steps) );
+ }
+ else if ( m_keyEvent->key() == Qt::Key_Down ) {
+ m_strategy.drag(QPoint(0, m_steps) );
+ }
+
+ ++m_steps;
+ }
+
+}
diff --git a/krita/plugins/tools/defaulttools/kis_tool_move.h b/krita/plugins/tools/defaulttools/kis_tool_move.h
new file mode 100644
index 00000000..128a9661
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_move.h
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 1999 Matthias Elter <[email protected]>
+ * 1999 Michael Koch <[email protected]>
+ * 2003 Patrick Julien <[email protected]>
+ *
+ * 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_TOOL_MOVE_H_
+#define KIS_TOOL_MOVE_H_
+
+#include <qtimer.h>
+
+#include "kis_strategy_move.h"
+#include "kis_tool_non_paint.h"
+#include "kis_tool_factory.h"
+
+class QTimer;
+
+class KisToolMove : public KisToolNonPaint {
+
+ typedef KisToolNonPaint super;
+ Q_OBJECT
+
+public:
+ KisToolMove();
+ virtual ~KisToolMove();
+
+public:
+ virtual void update(KisCanvasSubject *subject);
+
+public:
+ virtual void setup(KActionCollection *collection);
+ virtual enumToolType toolType() { return TOOL_TRANSFORM; }
+ virtual Q_UINT32 priority() { return 2; }
+
+ virtual void buttonPress(KisButtonPressEvent *e);
+ virtual void move(KisMoveEvent *e);
+ virtual void buttonRelease(KisButtonReleaseEvent *e);
+ virtual void keyPress(QKeyEvent *e);
+ virtual void keyRelease(QKeyEvent *e);
+
+private slots:
+
+ void slotMove();
+
+private:
+
+ KisCanvasSubject *m_subject;
+ KisStrategyMove m_strategy;
+ QPoint m_dragStart;
+ QTimer * m_repeatTimer;
+ QKeyEvent * m_keyEvent;
+ int m_steps;
+};
+
+
+class KisToolMoveFactory : public KisToolFactory {
+ typedef KisToolFactory super;
+public:
+ KisToolMoveFactory() : super() {};
+ virtual ~KisToolMoveFactory(){};
+
+ virtual KisTool * createTool(KActionCollection * ac) {
+ KisTool * t = new KisToolMove();
+ Q_CHECK_PTR(t);
+ t->setup(ac);
+ return t;
+ }
+ virtual KisID id() { return KisID("move", i18n("Move Tool")); }
+};
+
+
+
+#endif // KIS_TOOL_MOVE_H_
+
diff --git a/krita/plugins/tools/defaulttools/kis_tool_pan.cc b/krita/plugins/tools/defaulttools/kis_tool_pan.cc
new file mode 100644
index 00000000..56da211d
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_pan.cc
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2004 Adrian Page <[email protected]>
+ *
+ * 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 <kaction.h>
+#include <klocale.h>
+
+#include "kis_canvas_controller.h"
+#include "kis_canvas_subject.h"
+#include "kis_cursor.h"
+#include "kis_tool_pan.h"
+#include "kis_button_press_event.h"
+#include "kis_button_release_event.h"
+#include "kis_move_event.h"
+
+KisToolPan::KisToolPan()
+ : super(i18n("Pan Tool"))
+{
+ setName("tool_pan");
+ m_subject = 0;
+ m_dragging = false;
+ m_openHandCursor = KisCursor::openHandCursor();
+ m_closedHandCursor = KisCursor::closedHandCursor();
+ setCursor(m_openHandCursor);
+}
+
+KisToolPan::~KisToolPan()
+{
+}
+
+void KisToolPan::update(KisCanvasSubject *subject)
+{
+ m_subject = subject;
+ super::update(m_subject);
+}
+
+void KisToolPan::buttonPress(KisButtonPressEvent *e)
+{
+ if (m_subject && !m_dragging && e->button() == Qt::LeftButton) {
+ KisCanvasController *controller = m_subject->canvasController();
+
+ m_origScrollX = controller->horzValue();
+ m_origScrollY = controller->vertValue();
+ m_dragPos = controller->windowToView(e->pos());
+ m_dragging = true;
+ setCursor(m_closedHandCursor);
+ }
+}
+
+void KisToolPan::move(KisMoveEvent *e)
+{
+ if (m_subject && m_dragging) {
+ KisCanvasController *controller = m_subject->canvasController();
+
+ KisPoint currPos = controller->windowToView(e->pos());
+ KisPoint delta = currPos - m_dragPos;
+ controller->scrollTo(m_origScrollX - delta.floorX(), m_origScrollY - delta.floorY());
+ }
+}
+
+void KisToolPan::buttonRelease(KisButtonReleaseEvent *e)
+{
+ if (m_subject && m_dragging && e->button() == Qt::LeftButton) {
+ setCursor(m_openHandCursor);
+ m_dragging = false;
+ }
+}
+
+void KisToolPan::setup(KActionCollection *collection)
+{
+ m_action = static_cast<KRadioAction *>(collection->action(name()));
+
+ if (m_action == 0) {
+ m_action = new KRadioAction(i18n("&Pan"), "tool_pan", Qt::SHIFT+Qt::Key_H, this, SLOT(activate()), collection, name());
+ m_action->setToolTip(i18n("Pan"));
+ m_action->setExclusiveGroup("tools");
+ m_ownAction = true;
+ }
+}
+
+#include "kis_tool_pan.moc"
+
diff --git a/krita/plugins/tools/defaulttools/kis_tool_pan.h b/krita/plugins/tools/defaulttools/kis_tool_pan.h
new file mode 100644
index 00000000..d0f37669
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_pan.h
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2004 Adrian Page <[email protected]>
+ *
+ * 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_TOOL_PAN_H_
+#define KIS_TOOL_PAN_H_
+
+#include "kis_point.h"
+#include "kis_tool_non_paint.h"
+#include "kis_tool_factory.h"
+#include <koffice_export.h>
+
+class KisCanvasSubject;
+class KisPoint;
+
+class KRITATOOL_EXPORT KisToolPan : public KisToolNonPaint
+{
+
+ typedef KisToolNonPaint super;
+ Q_OBJECT
+
+public:
+ KisToolPan();
+ virtual ~KisToolPan();
+
+ virtual void update(KisCanvasSubject *subject);
+
+ virtual void setup(KActionCollection *collection);
+ virtual enumToolType toolType() { return TOOL_VIEW; }
+ virtual Q_UINT32 priority() { return 1; }
+
+ virtual void buttonPress(KisButtonPressEvent *e);
+ virtual void move(KisMoveEvent *e);
+ virtual void buttonRelease(KisButtonReleaseEvent *e);
+
+ virtual bool wantsAutoScroll() const { return false; }
+
+private:
+ KisCanvasSubject *m_subject;
+ KisPoint m_dragPos;
+ Q_INT32 m_origScrollX;
+ Q_INT32 m_origScrollY;
+ bool m_dragging;
+ QCursor m_openHandCursor;
+ QCursor m_closedHandCursor;
+};
+
+class KisToolPanFactory : public KisToolFactory {
+ typedef KisToolFactory super;
+public:
+ KisToolPanFactory() : super() {};
+ virtual ~KisToolPanFactory(){};
+
+ virtual KisTool * createTool(KActionCollection * ac) {
+ KisTool * t = new KisToolPan();
+ Q_CHECK_PTR(t);
+ t->setup(ac);
+ return t;
+ }
+ virtual KisID id() { return KisID("pan", i18n("Pan Tool")); }
+};
+
+
+#endif // KIS_TOOL_PAN_H_
+
diff --git a/krita/plugins/tools/defaulttools/kis_tool_rectangle.cc b/krita/plugins/tools/defaulttools/kis_tool_rectangle.cc
new file mode 100644
index 00000000..13b81c7f
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_rectangle.cc
@@ -0,0 +1,187 @@
+/*
+ * kis_tool_rectangle.cc - part of Krita
+ *
+ * Copyright (c) 2000 John Califf <[email protected]>
+ * Copyright (c) 2002 Patrick Julien <[email protected]>
+ * Copyright (c) 2004 Boudewijn Rempt <[email protected]>
+ * Copyright (c) 2004 Clarence Dang <[email protected]>
+ *
+ * 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 <qpainter.h>
+
+#include <kaction.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+#include "kis_button_press_event.h"
+#include "kis_button_release_event.h"
+#include "kis_canvas_controller.h"
+#include "kis_canvas_subject.h"
+#include "kis_move_event.h"
+#include "kis_painter.h"
+#include "kis_paintop_registry.h"
+#include "kis_tool_rectangle.h"
+#include "kis_undo_adapter.h"
+#include "kis_canvas.h"
+#include "kis_canvas_painter.h"
+#include "kis_cursor.h"
+#include "kis_layer.h"
+
+KisToolRectangle::KisToolRectangle()
+ : super(i18n ("Rectangle")),
+ m_dragging (false),
+ m_currentImage (0)
+{
+ setName("tool_rectangle");
+ setCursor(KisCursor::load("tool_rectangle_cursor.png", 6, 6));
+}
+
+KisToolRectangle::~KisToolRectangle()
+{
+}
+
+void KisToolRectangle::update (KisCanvasSubject *subject)
+{
+ super::update (subject);
+ if (m_subject)
+ m_currentImage = m_subject->currentImg ();
+}
+
+void KisToolRectangle::buttonPress(KisButtonPressEvent *event)
+{
+ if (m_currentImage && event->button() == LeftButton) {
+ m_dragging = true;
+ m_dragStart = m_dragCenter = m_dragEnd = event->pos();
+ draw(m_dragStart, m_dragEnd);
+ }
+}
+
+void KisToolRectangle::move(KisMoveEvent *event)
+{
+ if (m_dragging) {
+ // erase old lines on canvas
+ draw(m_dragStart, m_dragEnd);
+ // move (alt) or resize rectangle
+ if (event->state() & Qt::AltButton) {
+ KisPoint trans = event->pos() - m_dragEnd;
+ m_dragStart += trans;
+ m_dragEnd += trans;
+ } else {
+ KisPoint diag = event->pos() - (event->state() & Qt::ControlButton
+ ? m_dragCenter : m_dragStart);
+ // square?
+ if (event->state() & Qt::ShiftButton) {
+ double size = QMAX(fabs(diag.x()), fabs(diag.y()));
+ double w = diag.x() < 0 ? -size : size;
+ double h = diag.y() < 0 ? -size : size;
+ diag = KisPoint(w, h);
+ }
+
+ // resize around center point?
+ if (event->state() & Qt::ControlButton) {
+ m_dragStart = m_dragCenter - diag;
+ m_dragEnd = m_dragCenter + diag;
+ } else {
+ m_dragEnd = m_dragStart + diag;
+ }
+ }
+ // draw new lines on canvas
+ draw(m_dragStart, m_dragEnd);
+ m_dragCenter = KisPoint((m_dragStart.x() + m_dragEnd.x()) / 2,
+ (m_dragStart.y() + m_dragEnd.y()) / 2);
+ }
+}
+
+void KisToolRectangle::buttonRelease(KisButtonReleaseEvent *event)
+{
+ if (!m_subject)
+ return;
+
+ if (!m_currentImage)
+ return;
+
+ KisPaintDeviceSP device = m_currentImage->activeDevice ();
+ if (!device) return;
+
+ if (m_dragging && event->button() == LeftButton) {
+ // erase old lines on canvas
+ draw(m_dragStart, m_dragEnd);
+ m_dragging = false;
+
+ if (m_dragStart == m_dragEnd)
+ return;
+
+ if (!m_currentImage)
+ return;
+
+
+ KisPainter painter (device);
+ if (m_currentImage->undo()) painter.beginTransaction (i18n ("Rectangle"));
+
+ painter.setPaintColor(m_subject->fgColor());
+ painter.setBackgroundColor(m_subject->bgColor());
+ painter.setFillStyle(fillStyle());
+ painter.setBrush(m_subject->currentBrush());
+ painter.setPattern(m_subject->currentPattern());
+ painter.setOpacity(m_opacity);
+ painter.setCompositeOp(m_compositeOp);
+ KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp(m_subject->currentPaintop(), m_subject->currentPaintopSettings(), &painter);
+ painter.setPaintOp(op);
+
+ painter.paintRect(m_dragStart, m_dragEnd, PRESSURE_DEFAULT/*event->pressure()*/, event->xTilt(), event->yTilt());
+ device->setDirty( painter.dirtyRect() );
+ notifyModified();
+
+ if (m_currentImage->undo()) {
+ m_currentImage->undoAdapter()->addCommand(painter.endTransaction());
+ }
+ }
+}
+
+void KisToolRectangle::draw(const KisPoint& start, const KisPoint& end )
+{
+ if (!m_subject)
+ return;
+
+ KisCanvasController *controller = m_subject->canvasController ();
+ KisCanvas *canvas = controller->kiscanvas();
+ KisCanvasPainter p (canvas);
+
+ p.setRasterOp (Qt::NotROP);
+ p.drawRect (QRect (controller->windowToView (start).floorQPoint(), controller->windowToView (end).floorQPoint()));
+ p.end ();
+}
+
+void KisToolRectangle::setup(KActionCollection *collection)
+{
+ m_action = static_cast<KRadioAction *>(collection->action(name()));
+
+ if (m_action == 0) {
+ m_action = new KRadioAction(i18n("&Rectangle"),
+ "tool_rectangle",
+ Qt::Key_F6,
+ this,
+ SLOT(activate()),
+ collection,
+ name());
+ m_action->setToolTip(i18n("Draw a rectangle"));
+ m_action->setExclusiveGroup("tools");
+ m_ownAction = true;
+ }
+}
+
+#include "kis_tool_rectangle.moc"
diff --git a/krita/plugins/tools/defaulttools/kis_tool_rectangle.h b/krita/plugins/tools/defaulttools/kis_tool_rectangle.h
new file mode 100644
index 00000000..d9f1bf21
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_rectangle.h
@@ -0,0 +1,95 @@
+/*
+ * kis_tool_rectangle.h - part of KImageShop^WKrayon^WKrita
+ *
+ * Copyright (c) 1999 Michael Koch <[email protected]>
+ * Copyright (c) 2002 Patrick Julien <[email protected]>
+ * Copyright (c) 2004 Boudewijn Rempt <[email protected]>
+ * Copyright (c) 2004 Clarence Dang <[email protected]>
+ *
+ * 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_TOOL_RECTANGLE_H__
+#define __KIS_TOOL_RECTANGLE_H__
+
+#include <qrect.h>
+
+#include "kis_tool_shape.h"
+#include "kis_types.h"
+#include "kis_tool_factory.h"
+#include "kis_point.h"
+
+class QPainter;
+class KisPainter;
+
+class KisToolRectangle : public KisToolShape {
+
+ typedef KisToolShape super;
+ Q_OBJECT
+
+public:
+ KisToolRectangle();
+ virtual ~KisToolRectangle();
+
+ //
+ // KisCanvasObserver interface
+ //
+
+ virtual void update (KisCanvasSubject *subject);
+
+ //
+ // KisToolPaint interface
+ //
+
+ virtual void setup(KActionCollection *collection);
+ virtual enumToolType toolType() { return TOOL_SHAPE; }
+ virtual Q_UINT32 priority() { return 2; }
+ virtual void buttonPress(KisButtonPressEvent *event);
+ virtual void move(KisMoveEvent *event);
+ virtual void buttonRelease(KisButtonReleaseEvent *event);
+
+protected:
+ virtual void draw(const KisPoint&, const KisPoint&);
+
+protected:
+ int m_lineThickness;
+
+ KisPoint m_dragCenter;
+ KisPoint m_dragStart;
+ KisPoint m_dragEnd;
+ QRect m_final_lines;
+
+ bool m_dragging;
+ KisImageSP m_currentImage;
+};
+
+class KisToolRectangleFactory : public KisToolFactory {
+ typedef KisToolFactory super;
+public:
+ KisToolRectangleFactory() : super() {};
+ virtual ~KisToolRectangleFactory(){};
+
+ virtual KisTool * createTool(KActionCollection * ac) {
+ KisTool * t = new KisToolRectangle();
+ Q_CHECK_PTR(t);
+ t->setup(ac);
+ return t;
+ }
+ virtual KisID id() { return KisID("rectangle", i18n("Rectangle Tool")); }
+};
+
+
+#endif // __KIS_TOOL_RECTANGLE_H__
+
diff --git a/krita/plugins/tools/defaulttools/kis_tool_text.cc b/krita/plugins/tools/defaulttools/kis_tool_text.cc
new file mode 100644
index 00000000..b75f1b1b
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_text.cc
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2004 Bart Coppens <[email protected]>
+ *
+ * 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 <qfont.h>
+#include <qrect.h>
+#include <qimage.h>
+#include <qlayout.h>
+#include <qwidget.h>
+#include <qstring.h>
+#include <qpixmap.h>
+#include <qpainter.h>
+#include <qpushbutton.h>
+#include <qfontmetrics.h>
+#include <qhbox.h>
+
+#include <kaction.h>
+#include <kinputdialog.h>
+#include <klocale.h>
+#include <kfontdialog.h>
+#include <ksqueezedtextlabel.h>
+
+#include <qcolor.h>
+
+#include "kis_point.h"
+#include "kis_image.h"
+#include "kis_layer.h"
+#include "kis_group_layer.h"
+#include "kis_paint_layer.h"
+#include "kis_cursor.h"
+#include "kis_tool_text.h"
+#include "kis_paint_device.h"
+#include "kis_canvas_subject.h"
+#include "kis_button_press_event.h"
+#include "kis_button_release_event.h"
+#include "kis_color.h"
+#include "kis_undo_adapter.h"
+
+KisToolText::KisToolText()
+ : super(i18n("Text"))
+ , m_wasPressed( false )
+ , m_windowIsBeingShown( false )
+{
+ setName("tool_text");
+ m_subject = 0;
+ setCursor(KisCursor::load("tool_text_cursor.png", 6, 6));
+}
+
+KisToolText::~KisToolText()
+{
+}
+
+void KisToolText::update(KisCanvasSubject *subject)
+{
+ m_subject = subject;
+ super::update(subject);
+}
+
+void KisToolText::buttonPress(KisButtonPressEvent *e)
+{
+ if (m_subject && e->button() == QMouseEvent::LeftButton) {
+ m_wasPressed = true;
+ }
+}
+
+void KisToolText::buttonRelease(KisButtonReleaseEvent *e)
+{
+ if ( m_windowIsBeingShown ) return;
+
+ if (m_subject && e->button() == QMouseEvent::LeftButton) {
+ if(!m_wasPressed) return;
+ m_wasPressed = false;
+ KisImageSP img = m_subject->currentImg();
+
+ m_windowIsBeingShown = true;
+ bool ok;
+ QString text = KInputDialog::getText(i18n("Font Tool"), i18n("Enter text:"),
+ QString::null, &ok);
+ if (!ok) {
+ m_windowIsBeingShown = false;
+ return;
+ }
+
+ KisUndoAdapter *undoAdapter = img->undoAdapter();
+ if (undoAdapter) {
+ undoAdapter->beginMacro(i18n("Text"));
+ }
+
+ QFontMetrics metrics(m_font);
+ QRect boundingRect = metrics.boundingRect(text).normalize();
+ int xB = - boundingRect.x();
+ int yB = - boundingRect.y();
+
+ if (boundingRect.x() < 0 || boundingRect.y() < 0)
+ boundingRect.moveBy(- boundingRect.x(), - boundingRect.y());
+
+ QPixmap pixels(boundingRect.width(), boundingRect.height());
+ {
+ QPainter paint(&pixels);
+ paint.fillRect(boundingRect, Qt::white);
+ paint.setFont(m_font);
+ paint.setBrush(QBrush(Qt::black));
+ paint.drawText(xB, yB, text);
+ }
+ QImage image = pixels.convertToImage();
+
+ Q_INT32 height = boundingRect.height();
+ Q_INT32 width = boundingRect.width();
+ KisPaintLayer *layer = new KisPaintLayer(img, '"' + text + '"', OPACITY_OPAQUE);
+ KisGroupLayerSP parent = img->rootLayer();
+ if (img->activeLayer())
+ parent = img->activeLayer()->parent();
+ img->addLayer(layer, parent, img->activeLayer());
+ for (int y = 0; y < height; y++) {
+ for (int x = 0; x < width; x++) {
+ QRgb pixel = image.pixel(x, y);
+ // use the 'blackness' as alpha :)
+ Q_UINT8 alpha = 255 - qRed(pixel) * OPACITY_OPAQUE / 255;
+ QColor c = m_subject->fgColor().toQColor();
+ layer->paintDevice()->setPixel(x, y, c, alpha);
+ }
+ }
+
+ layer->setOpacity(m_opacity);
+ layer->setCompositeOp(m_compositeOp);
+
+ layer->setVisible(false);
+ Q_INT32 x = QMAX(0, static_cast<int>(e->x() - width/2));
+ Q_INT32 y = QMAX(0, static_cast<int>(e->y() - height/2));
+ layer->setX(x);
+ layer->setY(y);
+ layer->setVisible(true);
+ layer->setDirty();
+
+ if (undoAdapter) {
+ undoAdapter->endMacro();
+ }
+
+ m_windowIsBeingShown = false;
+ }
+}
+
+void KisToolText::setFont() {
+ KFontDialog::getFont( m_font, false/*, QWidget* parent! */ );
+ m_lbFontName->setText(QString(m_font.family() + ", %1").arg(m_font.pointSize()));
+}
+
+QWidget* KisToolText::createOptionWidget(QWidget* parent)
+{
+ QWidget *widget = super::createOptionWidget(parent);
+
+ m_lbFont = new QLabel(i18n("Font: "), widget);
+
+ QHBox *fontBox = new QHBox(widget);
+ m_lbFontName = new KSqueezedTextLabel(QString(m_font.family() + ", %1")
+ .arg(m_font.pointSize()), fontBox);
+ m_btnMoreFonts = new QPushButton("...", fontBox);
+
+ connect(m_btnMoreFonts, SIGNAL(released()), this, SLOT(setFont()));
+
+ addOptionWidgetOption(fontBox, m_lbFont);
+
+ return widget;
+}
+
+void KisToolText::setup(KActionCollection *collection)
+{
+ m_action = static_cast<KRadioAction *>(collection->action(name()));
+
+ if (m_action == 0) {
+ m_action = new KRadioAction(i18n("T&ext"),
+ "tool_text",
+ Qt::SHIFT+Qt::Key_T,
+ this,
+ SLOT(activate()),
+ collection,
+ name());
+ m_action->setExclusiveGroup("tools");
+ m_action->setToolTip(i18n("Text"));
+ m_ownAction = true;
+ }
+}
+
+#include "kis_tool_text.moc"
diff --git a/krita/plugins/tools/defaulttools/kis_tool_text.h b/krita/plugins/tools/defaulttools/kis_tool_text.h
new file mode 100644
index 00000000..b7bc857c
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_text.h
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2004 Bart Coppens <[email protected]>
+ *
+ * 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_TOOL_TEXT_H_
+#define KIS_TOOL_TEXT_H_
+
+#include "kis_tool_paint.h"
+
+#include "kis_tool_factory.h"
+
+class QFont;
+class QLabel;
+class QWidget;
+class QPushButton;
+class KSqueezedTextLabel;
+
+
+
+class KisToolText : public KisToolPaint {
+ typedef KisToolPaint super;
+ Q_OBJECT
+
+public:
+ KisToolText();
+ virtual ~KisToolText();
+
+ virtual void update(KisCanvasSubject *subject);
+ virtual void setup(KActionCollection *collection);
+ virtual enumToolType toolType() { return TOOL_FILL; }
+ virtual Q_UINT32 priority() { return 2; }
+ virtual void buttonPress(KisButtonPressEvent*);
+ virtual void buttonRelease(KisButtonReleaseEvent *e);
+
+ virtual QWidget* createOptionWidget(QWidget* parent);
+public slots:
+ virtual void setFont();
+
+private:
+ KisCanvasSubject *m_subject;
+ QFont m_font;
+ QLabel *m_lbFont;
+ KSqueezedTextLabel *m_lbFontName;
+ QPushButton *m_btnMoreFonts;
+ bool m_wasPressed; // use for preventing bug:136151
+ bool m_windowIsBeingShown;
+};
+
+
+class KisToolTextFactory : public KisToolFactory {
+ typedef KisToolFactory super;
+public:
+ KisToolTextFactory() : super() {};
+ virtual ~KisToolTextFactory(){};
+
+ virtual KisTool * createTool(KActionCollection * ac) {
+ KisTool * t = new KisToolText();
+ Q_CHECK_PTR(t);
+ t->setup(ac);
+ return t;
+ }
+ virtual KisID id() { return KisID("text", i18n("Text Tool")); }
+};
+
+
+#endif // KIS_TOOL_TEXT_H_
diff --git a/krita/plugins/tools/defaulttools/kis_tool_zoom.cc b/krita/plugins/tools/defaulttools/kis_tool_zoom.cc
new file mode 100644
index 00000000..a5567f83
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_zoom.cc
@@ -0,0 +1,191 @@
+/*
+ * Copyright (c) 1999 Matthias Elter <[email protected]>
+ * Copyright (c) 2002 Patrick Julien <[email protected]>
+ *
+ * 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 <kaction.h>
+#include <klocale.h>
+#include <kapplication.h>
+
+#include "kis_image.h"
+#include "kis_paint_device.h"
+#include "kis_paint_layer.h"
+#include "kis_canvas_controller.h"
+#include "kis_canvas_subject.h"
+#include "kis_canvas.h"
+#include "kis_canvas_painter.h"
+#include "kis_cursor.h"
+#include "kis_button_press_event.h"
+#include "kis_button_release_event.h"
+#include "kis_move_event.h"
+#include "kis_tool_zoom.h"
+
+
+KisToolZoom::KisToolZoom()
+ : super(i18n("Zoom Tool"))
+{
+ setName("tool_zoom");
+ m_subject = 0;
+ m_dragging = false;
+ m_startPos = QPoint(0, 0);
+ m_endPos = QPoint(0, 0);
+ m_plusCursor = KisCursor::load("tool_zoom_plus_cursor.png", 8, 8);
+ m_minusCursor = KisCursor::load("tool_zoom_minus_cursor.png", 8, 8);
+ setCursor(m_plusCursor);
+ connect(&m_timer, SIGNAL(timeout()), SLOT(slotTimer()));
+}
+
+KisToolZoom::~KisToolZoom()
+{
+}
+
+void KisToolZoom::update(KisCanvasSubject *subject)
+{
+ m_subject = subject;
+ super::update(m_subject);
+}
+
+void KisToolZoom::paint(KisCanvasPainter& gc)
+{
+ if (m_dragging)
+ paintOutline(gc, QRect());
+}
+
+void KisToolZoom::paint(KisCanvasPainter& gc, const QRect& rc)
+{
+ if (m_dragging)
+ paintOutline(gc, rc);
+}
+
+void KisToolZoom::buttonPress(KisButtonPressEvent *e)
+{
+ if (m_subject && m_subject->currentImg() && !m_dragging) {
+ if (e->button() == Qt::LeftButton) {
+ m_startPos = e->pos().floorQPoint();
+ m_endPos = e->pos().floorQPoint();
+ m_dragging = true;
+ }
+ }
+}
+
+void KisToolZoom::move(KisMoveEvent *e)
+{
+ if (m_subject && m_dragging) {
+ if (m_startPos != m_endPos)
+ paintOutline();
+
+ m_endPos = e->pos().floorQPoint();
+ paintOutline();
+ }
+}
+
+void KisToolZoom::buttonRelease(KisButtonReleaseEvent *e)
+{
+ if (m_subject && m_dragging && e->button() == Qt::LeftButton) {
+
+ KisCanvasController *controller = m_subject->canvasController();
+ m_endPos = e->pos().floorQPoint();
+ m_dragging = false;
+
+ QPoint delta = m_endPos - m_startPos;
+
+ if (sqrt(delta.x() * delta.x() + delta.y() * delta.y()) < 10) {
+ if (e->state() & Qt::ControlButton) {
+ controller->zoomOut(m_endPos.x(), m_endPos.y());
+ } else {
+ controller->zoomIn(m_endPos.x(), m_endPos.y());
+ }
+ } else {
+ controller->zoomTo(QRect(m_startPos, m_endPos));
+ }
+ }
+}
+
+void KisToolZoom::activate()
+{
+ super::activate();
+ m_timer.start(50);
+}
+
+void KisToolZoom::deactivate()
+{
+ m_timer.stop();
+}
+
+void KisToolZoom::slotTimer()
+{
+#if KDE_IS_VERSION(3,4,0)
+ int state = kapp->keyboardMouseState() & (Qt::ShiftButton|Qt::ControlButton|Qt::AltButton);
+#else
+ int state = kapp->keyboardModifiers() & (KApplication::ShiftModifier
+ |KApplication::ControlModifier|KApplication::Modifier1);
+#endif
+
+ if (state & Qt::ControlButton) {
+ m_subject->canvasController()->setCanvasCursor(m_minusCursor);
+ } else {
+ m_subject->canvasController()->setCanvasCursor(m_plusCursor);
+ }
+}
+
+void KisToolZoom::paintOutline()
+{
+ if (m_subject) {
+ KisCanvasController *controller = m_subject->canvasController();
+ KisCanvas *canvas = controller->kiscanvas();
+ KisCanvasPainter gc(canvas);
+ QRect rc;
+
+ paintOutline(gc, rc);
+ }
+}
+
+void KisToolZoom::paintOutline(KisCanvasPainter& gc, const QRect&)
+{
+ if (m_subject) {
+ KisCanvasController *controller = m_subject->canvasController();
+ RasterOp op = gc.rasterOp();
+ QPen old = gc.pen();
+ QPen pen(Qt::DotLine);
+ QPoint start;
+ QPoint end;
+
+ Q_ASSERT(controller);
+ start = controller->windowToView(m_startPos);
+ end = controller->windowToView(m_endPos);
+
+ gc.setRasterOp(Qt::NotROP);
+ gc.setPen(pen);
+ gc.drawRect(QRect(start, end));
+ gc.setRasterOp(op);
+ gc.setPen(old);
+ }
+}
+
+void KisToolZoom::setup(KActionCollection *collection)
+{
+ m_action = static_cast<KRadioAction *>(collection->action(name()));
+
+ if (m_action == 0) {
+ m_action = new KRadioAction(i18n("&Zoom"), "tool_zoom", Qt::Key_Z, this, SLOT(activate()), collection, name());
+ m_action->setToolTip(i18n("Zoom"));
+ m_action->setExclusiveGroup("tools");
+ m_ownAction = true;
+ }
+}
+
+#include "kis_tool_zoom.moc"
diff --git a/krita/plugins/tools/defaulttools/kis_tool_zoom.h b/krita/plugins/tools/defaulttools/kis_tool_zoom.h
new file mode 100644
index 00000000..235c3a74
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kis_tool_zoom.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 1999 Matthias Elter <[email protected]>
+ * Copyright (c) 2002 Patrick Julien <[email protected]>
+ * Copyright (c) 2004 Boudewijn Rempt <[email protected]>
+ *
+ * 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_ZOOM_TOOL_H_
+#define KIS_ZOOM_TOOL_H_
+
+#include <qtimer.h>
+
+#include "kis_tool_non_paint.h"
+
+#include "kis_tool_factory.h"
+
+class KisCanvasSubject;
+
+class KisToolZoom : public KisToolNonPaint {
+
+ typedef KisToolNonPaint super;
+ Q_OBJECT
+
+public:
+ KisToolZoom();
+ virtual ~KisToolZoom();
+
+public:
+ virtual void update(KisCanvasSubject *subject);
+
+public:
+ virtual void setup(KActionCollection *collection);
+ virtual enumToolType toolType() { return TOOL_VIEW; }
+ virtual Q_UINT32 priority() { return 2; }
+
+ virtual void buttonPress(KisButtonPressEvent *e);
+ virtual void move(KisMoveEvent *e);
+ virtual void buttonRelease(KisButtonReleaseEvent *e);
+
+ virtual void paint(KisCanvasPainter& gc);
+ virtual void paint(KisCanvasPainter& gc, const QRect& rc);
+
+private:
+ void paintOutline();
+ void paintOutline(KisCanvasPainter& gc, const QRect& rc);
+
+
+public slots:
+
+ void activate();
+ void deactivate();
+
+
+private slots:
+ void slotTimer();
+
+private:
+ KisCanvasSubject *m_subject;
+ QPoint m_startPos;
+ QPoint m_endPos;
+ bool m_dragging;
+ QCursor m_plusCursor;
+ QCursor m_minusCursor;
+ QTimer m_timer;
+};
+
+
+class KisToolZoomFactory : public KisToolFactory {
+ typedef KisToolFactory super;
+public:
+ KisToolZoomFactory() : super() {};
+ virtual ~KisToolZoomFactory(){};
+
+ virtual KisTool * createTool(KActionCollection * ac) {
+ KisTool * t = new KisToolZoom();
+ Q_CHECK_PTR(t);
+ t->setup(ac);
+ return t;
+ }
+ virtual KisID id() { return KisID("zoom", i18n("Zoom Tool")); }
+};
+
+
+#endif // KIS_ZOOM_TOOL_H_
diff --git a/krita/plugins/tools/defaulttools/kritadefaulttools.desktop b/krita/plugins/tools/defaulttools/kritadefaulttools.desktop
new file mode 100644
index 00000000..79c94c17
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/kritadefaulttools.desktop
@@ -0,0 +1,56 @@
+[Desktop Entry]
+Name=Default Tools
+Name[bg]=Инструменти по подразбиране
+Name[br]=Ostilhoù dre ziouer
+Name[ca]=Eines per defecte
+Name[cy]=Offer Rhagosodol
+Name[da]=Standardværktøjer
+Name[de]=Standardwerkzeuge
+Name[el]=Προκαθορισμένα εργαλεία
+Name[eo]=Aprioraj Iloj
+Name[es]=Herramientas predefinidas
+Name[et]=Vaiketööriistad
+Name[eu]=Tresna lehenetsiak
+Name[fa]=ابزارهای پیش‌فرض
+Name[fi]=Oletustyökalut
+Name[fr]=Outils par défaut
+Name[fy]=Standert ark
+Name[ga]=Uirlisí Réamhshocraithe
+Name[gl]=Ferramentas Predefinidas
+Name[he]=כלים המוגדרים כברירת מחדל
+Name[hi]=डिफ़ॉल्ट औज़ार
+Name[hr]=Zadani alati
+Name[hu]=Alapértelmezett eszközök
+Name[is]=Sjálfgefin tól
+Name[it]=Strumenti predefiniti
+Name[ja]=標準ツール
+Name[km]=ឧបករណ៍​លំនាំដើម
+Name[lt]=Numatyti įrankiai
+Name[lv]=Noklusējuma rīks
+Name[ms]=Alat Piawai
+Name[nb]=Standardverktøy
+Name[nds]=Standardwarktüüch
+Name[ne]=पूर्वनिर्धारित उपकरणहरू
+Name[nl]=Standaardgereedschappen
+Name[nn]=Standardverktøy
+Name[pl]=Domyślne narzędzia
+Name[pt]=Ferramentas Predefinidas
+Name[pt_BR]=Ferramentas Padrão
+Name[ru]=Стандартный инструментарий
+Name[se]=Standárdreaiddut
+Name[sk]=Štandardné nástroje
+Name[sl]=Privzeta orodja
+Name[sr]=Подразумевани алати
+Name[sr@Latn]=Podrazumevani alati
+Name[sv]=Standardverktyg
+Name[ta]=முன்னிருப்பு கருவிகள்
+Name[tr]=Öntanımlı Araçlar
+Name[uk]=Типові інструменти
+Name[uz]=Andoza vositalar
+Name[uz@cyrillic]=Андоза воситалар
+Name[zh_CN]=默认工具
+Name[zh_TW]=預設工具
+ServiceTypes=Krita/Tool
+Type=Service
+X-KDE-Library=kritadefaulttools
+X-Krita-Version=2
diff --git a/krita/plugins/tools/defaulttools/openhand_cursor.xpm b/krita/plugins/tools/defaulttools/openhand_cursor.xpm
new file mode 100644
index 00000000..607879d5
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/openhand_cursor.xpm
@@ -0,0 +1,28 @@
+/* XPM */
+static char *openhand_cursor[]={
+"22 22 3 1",
+". c None",
+"# c #000000",
+"a c #ffffff",
+"......................",
+"..........##..........",
+".........#aa###.......",
+".......###aa#aa#......",
+"......#aa#aa#aa##.....",
+"......#aa#aa#aa#a#....",
+"......#aa#aa#aa#aa#...",
+"..###.#aa#aa#aa#aa#...",
+"..#aa##aaaaaaaa#aa#...",
+"..#aaa#aaaaaaaaaaa#...",
+"...#aa#aaaaaaaaaaa#...",
+"....#a#aaaaaaaaaaa#...",
+"....#aaaaaaaaaaaaa#...",
+".....#aaaaaaaaaaaa#...",
+".....#aaaaaaaaaaa#....",
+"......#aaaaaaaaaa#....",
+"......#aaaaaaaaaa#....",
+".......#aaaaaaaa#.....",
+".......#aaaaaaaa#.....",
+".......##########.....",
+"......................",
+"......................"};
diff --git a/krita/plugins/tools/defaulttools/tool_color_fill.png b/krita/plugins/tools/defaulttools/tool_color_fill.png
new file mode 100644
index 00000000..4f5b4ecf
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_color_fill.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_colorpicker.png b/krita/plugins/tools/defaulttools/tool_colorpicker.png
new file mode 100644
index 00000000..d69b6e82
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_colorpicker.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_duplicate.png b/krita/plugins/tools/defaulttools/tool_duplicate.png
new file mode 100644
index 00000000..bf4ab7b0
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_duplicate.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_duplicate_cursor.png b/krita/plugins/tools/defaulttools/tool_duplicate_cursor.png
new file mode 100644
index 00000000..d71cdf60
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_duplicate_cursor.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_ellipse.png b/krita/plugins/tools/defaulttools/tool_ellipse.png
new file mode 100644
index 00000000..310932d4
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_ellipse.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_ellipse_cursor.png b/krita/plugins/tools/defaulttools/tool_ellipse_cursor.png
new file mode 100644
index 00000000..55e0c67e
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_ellipse_cursor.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_fill_cursor.png b/krita/plugins/tools/defaulttools/tool_fill_cursor.png
new file mode 100644
index 00000000..7ad5888e
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_fill_cursor.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_freehand.png b/krita/plugins/tools/defaulttools/tool_freehand.png
new file mode 100644
index 00000000..c5c90de0
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_freehand.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_freehand_cursor.png b/krita/plugins/tools/defaulttools/tool_freehand_cursor.png
new file mode 100644
index 00000000..a48b7e34
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_freehand_cursor.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_gradient.png b/krita/plugins/tools/defaulttools/tool_gradient.png
new file mode 100644
index 00000000..5ef05ad1
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_gradient.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_gradient_cursor.png b/krita/plugins/tools/defaulttools/tool_gradient_cursor.png
new file mode 100644
index 00000000..3cb25ae0
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_gradient_cursor.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_line.png b/krita/plugins/tools/defaulttools/tool_line.png
new file mode 100644
index 00000000..23c53e86
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_line.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_line_cursor.png b/krita/plugins/tools/defaulttools/tool_line_cursor.png
new file mode 100644
index 00000000..2f750ec4
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_line_cursor.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_move.png b/krita/plugins/tools/defaulttools/tool_move.png
new file mode 100644
index 00000000..e123f910
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_move.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_pan.png b/krita/plugins/tools/defaulttools/tool_pan.png
new file mode 100644
index 00000000..7ba6970e
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_pan.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_rectangle.png b/krita/plugins/tools/defaulttools/tool_rectangle.png
new file mode 100644
index 00000000..7a7027fb
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_rectangle.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_rectangle_cursor.png b/krita/plugins/tools/defaulttools/tool_rectangle_cursor.png
new file mode 100644
index 00000000..93a17d5a
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_rectangle_cursor.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_text.png b/krita/plugins/tools/defaulttools/tool_text.png
new file mode 100644
index 00000000..7e208364
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_text.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_text_cursor.png b/krita/plugins/tools/defaulttools/tool_text_cursor.png
new file mode 100644
index 00000000..df52c660
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_text_cursor.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_zoom.png b/krita/plugins/tools/defaulttools/tool_zoom.png
new file mode 100644
index 00000000..73f326eb
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_zoom.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_zoom_minus_cursor.png b/krita/plugins/tools/defaulttools/tool_zoom_minus_cursor.png
new file mode 100644
index 00000000..21b992c8
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_zoom_minus_cursor.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/tool_zoom_plus_cursor.png b/krita/plugins/tools/defaulttools/tool_zoom_plus_cursor.png
new file mode 100644
index 00000000..072cea1c
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/tool_zoom_plus_cursor.png
Binary files differ
diff --git a/krita/plugins/tools/defaulttools/wdgcolorpicker.ui b/krita/plugins/tools/defaulttools/wdgcolorpicker.ui
new file mode 100644
index 00000000..4a26c53f
--- /dev/null
+++ b/krita/plugins/tools/defaulttools/wdgcolorpicker.ui
@@ -0,0 +1,167 @@
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
+<class>ColorPickerOptionsWidget</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>ColorPickerOptionsWidget</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>263</width>
+ <height>307</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Color Picker</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <widget class="QComboBox">
+ <item>
+ <property name="text">
+ <string>Sample All Visible Layers</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Current Layer</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>cmbSources</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>200</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>200</width>
+ <height>32767</height>
+ </size>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>cbUpdateCurrentColour</cstring>
+ </property>
+ <property name="text">
+ <string>Update current color</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>cbPalette</cstring>
+ </property>
+ <property name="text">
+ <string>Add to palette:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <property name="name">
+ <cstring>cmbPalette</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>cbNormaliseValues</cstring>
+ </property>
+ <property name="text">
+ <string>Show colors as percentages</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Sample radius:</string>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>radius</cstring>
+ </property>
+ <property name="maxValue">
+ <number>9</number>
+ </property>
+ <property name="minValue">
+ <number>1</number>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QListView">
+ <column>
+ <property name="text">
+ <string>Channel</string>
+ </property>
+ <property name="clickable">
+ <bool>false</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Value</string>
+ </property>
+ <property name="clickable">
+ <bool>false</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>listViewChannels</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="selectionMode">
+ <enum>NoSelection</enum>
+ </property>
+ </widget>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>