--Boundary-00=_17tf/5UM2qlKGdC Content-Type: multipart/signed; charset="us-ascii"; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="Boundary-02=_47tf/Szu3DuLimG"; name=" " Content-Transfer-Encoding: 7bit --Boundary-02=_47tf/Szu3DuLimG Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline Attached diff adds preliminary support for wacom tablets to Krita (easy, ju= st=20 added QTabletEvent handling). Todo is making Krita aware that it now has=20 three active tools: stylus, eraser and pointer, and lots of other things,.= =20 but the basic event routing is present. And I've added a new tool, one that actually does something to an image,=20 namely adding red spots. The spots vary in size and transparency with the pressure of the pen, so I know that it works, too. Since I don't have CVS=20 access, I've attached the files implementing this tool-let separately. In the interests of full disclosure I have to add that, while, yes, I am a= =20 programmer, been at it for twenty-two years now, since I was twelve, and=20 yes,I have a few languages under my belt, but C++ is new for me. I only=20 started reading _Accelerated C++_ a week ago. There's probably much to laug= h=20 at in this code. But I've been having fun :-). Anyway, I'm off for a beer now. =2D-=20 Boudewijn Rempt | http://www.valdyas.org/index2.html --Boundary-02=_47tf/Szu3DuLimG Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux) iD8DBQA/ft74daCcgCmN5d8RAiLnAKCgdv6Dae4x2dFDTGHo9otsh2tAzACgvBQM bnmpiJyMHJdflFzl5+Bl6Pk= =uTsF -----END PGP SIGNATURE----- --Boundary-02=_47tf/Szu3DuLimG-- --Boundary-00=_17tf/5UM2qlKGdC Content-Type: text/x-diff; charset="us-ascii"; name="krita_tablet+test_tool.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="krita_tablet+test_tool.diff" ? .cdtproject ? .project ? core/kis_view.cc.flc ? tools/Makefile.flc ? tools/kis_tool_airbrush.loT ? tools/kis_tool_colorchanger.loT ? tools/kis_tool_ellipse.loT ? tools/kis_tool_eraser.loT ? tools/kis_tool_fill.loT ? tools/kis_tool_line.loT ? tools/kis_tool_paint.cc ? tools/kis_tool_paint.h ? tools/kis_tool_pen.loT ? tools/kis_tool_polygon.loT ? tools/kis_tool_polyline.loT ? tools/kis_tool_rectangle.loT ? tools/kis_tool_select_contiguous.loT ? tools/kis_tool_select_elliptical.loT ? tools/kis_tool_select_freehand.loT ? tools/kis_tool_select_polygonal.loT ? tools/kis_tool_stamp.loT ? tools/kis_tool_test.cc ? tools/kis_tool_test.h Index: krita.rc =================================================================== RCS file: /home/kdecvs/kde/koffice/krita/krita.rc,v retrieving revision 1.37 diff -u -3 -u -p -r1.37 krita.rc --- krita.rc 8 Jan 2003 03:30:50 -0000 1.37 +++ krita.rc 4 Oct 2003 14:47:07 -0000 @@ -117,6 +117,7 @@ + C&olor @@ -233,6 +234,7 @@ + Index: core/kis_painter.cc =================================================================== RCS file: /home/kdecvs/kde/koffice/krita/core/kis_painter.cc,v retrieving revision 1.49 diff -u -3 -u -p -r1.49 kis_painter.cc --- core/kis_painter.cc 17 Mar 2003 20:10:17 -0000 1.49 +++ core/kis_painter.cc 4 Oct 2003 14:47:07 -0000 @@ -136,7 +136,7 @@ namespace { if (m_tiles.count(tileNo) == 0) { tile -> shareRef(); - m_tiles[tileNo] = tile; + m_tiles[tileNo] = tile; } } } @@ -607,16 +607,19 @@ void KisPainter::fillRect(Q_INT32 x1, Q_ switch (m_device -> image() -> imgType()) { case IMAGE_TYPE_GREY: case IMAGE_TYPE_GREYA: + kdDebug() << "GREY.\n"; src[PIXEL_GRAY] = upscale(c.R()); src[PIXEL_GRAY_ALPHA] = opacity; break; case IMAGE_TYPE_INDEXED: case IMAGE_TYPE_INDEXEDA: + kdDebug() << "INDEXED.\n"; src[PIXEL_INDEXED] = upscale(c.R()); src[PIXEL_INDEXED_ALPHA] = opacity; break; case IMAGE_TYPE_RGB: case IMAGE_TYPE_RGBA: + kdDebug() << "RGBA.\n"; src[PIXEL_RED] = upscale(c.R()); src[PIXEL_GREEN] = upscale(c.G()); src[PIXEL_BLUE] = upscale(c.B()); @@ -624,6 +627,7 @@ void KisPainter::fillRect(Q_INT32 x1, Q_ break; case IMAGE_TYPE_CMYK: case IMAGE_TYPE_CMYKA: + kdDebug() << "CMYKA.\n"; src[PIXEL_CYAN] = upscale(c.C()); src[PIXEL_MAGENTA] = upscale(c.M()); src[PIXEL_YELLOW] = upscale(c.Y()); @@ -636,7 +640,8 @@ void KisPainter::fillRect(Q_INT32 x1, Q_ } stride = m_device -> image() -> depth(); - ydiff = y1 - TILE_HEIGHT * (y1 / TILE_HEIGHT); + + ydiff = y1 - TILE_HEIGHT * (y1 / TILE_HEIGHT); if (m_transaction) { tc = new KisTileCommand(m_transaction -> name(), m_device, x1, y1, w, h); @@ -655,7 +660,7 @@ void KisPainter::fillRect(Q_INT32 x1, Q_ if (!(tile = tm -> tile(x, y, TILEMODE_WRITE))) continue; - + if (xmod > tile -> width()) continue; Index: core/kis_tool.h =================================================================== RCS file: /home/kdecvs/kde/koffice/krita/core/kis_tool.h,v retrieving revision 1.33 diff -u -3 -u -p -r1.33 kis_tool.h --- core/kis_tool.h 7 Mar 2003 22:05:53 -0000 1.33 +++ core/kis_tool.h 4 Oct 2003 14:47:07 -0000 @@ -49,6 +49,8 @@ public: virtual void mousePress(QMouseEvent *e) = 0; virtual void mouseMove(QMouseEvent *e) = 0; virtual void mouseRelease(QMouseEvent *e) = 0; + // XXX: attempt add pre-emptively adding tablet events. + virtual void tabletEvent(QTabletEvent *e) = 0; virtual void keyPress(QKeyEvent *e) = 0; virtual void keyRelease(QKeyEvent *e) = 0; Index: core/kis_tool_factory.cc =================================================================== RCS file: /home/kdecvs/kde/koffice/krita/core/kis_tool_factory.cc,v retrieving revision 1.14 diff -u -3 -u -p -r1.14 kis_tool_factory.cc --- core/kis_tool_factory.cc 17 Mar 2003 20:10:17 -0000 1.14 +++ core/kis_tool_factory.cc 4 Oct 2003 14:47:07 -0000 @@ -21,18 +21,14 @@ #include "kis_tool_factory.h" // tools + + +// Non-working tools (Re-ordered because I became confused). #if 0 #include "kis_tool_select_freehand.h" -#endif -#include "kis_tool_select_rectangular.h" -#if 0 #include "kis_tool_select_polygonal.h" #include "kis_tool_select_elliptical.h" #include "kis_tool_select_contiguous.h" -#endif -#include "kis_tool_move.h" -#include "kis_tool_zoom.h" -#if 0 #include "kis_tool_brush.h" #include "kis_tool_airbrush.h" #include "kis_tool_pen.h" @@ -41,24 +37,28 @@ #include "kis_tool_polygon.h" #include "kis_tool_rectangle.h" #include "kis_tool_ellipse.h" -#endif -#include "kis_tool_colorpicker.h" -#if 0 #include "kis_tool_colorchanger.h" #include "kis_tool_eraser.h" #include "kis_tool_fill.h" #include "kis_tool_stamp.h" #endif +// Working tools -- note that the 'paste' tool is added in the KisView, not here. +#include "kis_tool_select_rectangular.h" +#include "kis_tool_move.h" +#include "kis_tool_zoom.h" +#include "kis_tool_colorpicker.h" +#include "kis_tool_test.h" + /* * toolFactory * * Load every know tool, and make it available to the KisView. Hopefully, someday - * these tools will be parts, so we can discover which tools are available at runtime + * these tools will be parts, so we can discover which tools are available at runtime * instead of compile time. * * The doc becomes the parent of these tools, so you don't need to delete them. When - * the doc is destroyed, they will get automatically deleted. In other words, to be + * the doc is destroyed, they will get automatically deleted. In other words, to be * safe, you should store the vector returned by this function inside the parent. This * way, nobody will use this vector after the parent dies. */ @@ -78,6 +78,12 @@ vKisToolSP toolFactory(KisView *view, Ki tools.push_back(new EraserTool(doc, brush)); #endif + // My test tool to put some pixels down. Note that + // the non-working painting tools had a canvas, and a brush, + // those don't exist here anymore. So, how is this going to work? + // How am I going to get something to paint on? + tools.push_back(new KisToolTest(view, doc) ); + tools.push_back(new KisToolColorPicker(view, doc)); #if 0 Index: core/kis_view.cc =================================================================== RCS file: /home/kdecvs/kde/koffice/krita/core/kis_view.cc,v retrieving revision 1.214 diff -u -3 -u -p -r1.214 kis_view.cc --- core/kis_view.cc 26 Aug 2003 23:53:44 -0000 1.214 +++ core/kis_view.cc 4 Oct 2003 14:47:08 -0000 @@ -439,7 +439,7 @@ void KisView::setupActions() m_imgMergeLinked = new KAction(i18n("Merge &Linked Layers"), 0, this, SLOT(merge_linked_layers()), actionCollection(), "merge_linked_layers"); // setting actions - (void)new KAction(i18n("Paint Offset..."), "paint_offet", this, SLOT(setPaintOffset()), actionCollection(), "paint_offset"); + (void)new KAction(i18n("Paint Offset..."), "paint_offset", this, SLOT(setPaintOffset()), actionCollection(), "paint_offset"); m_sidebarToggle = new KToggleAction(i18n("Show/Hide Sidebar"), "ok", 0, this, SLOT(showSidebar()), actionCollection(), "show_sidebar"); m_floatsidebarToggle = new KToggleAction(i18n("Dock/Undock Sidebar"), "attach", 0, this, SLOT(floatSidebar()), actionCollection(), "float_sidebar"); m_lsidebarToggle = new KToggleAction(i18n("Left/Right Sidebar"), "view_right", 0, this, SLOT(placeSidebarLeft()), actionCollection(), "left_sidebar"); @@ -754,14 +754,14 @@ void KisView::layerUpdateGUI(bool enable { KisImageSP img = currentImg(); KisLayerSP layer; - Q_INT32 nlayers; - Q_INT32 layerPos; + Q_INT32 nlayers = 0; + Q_INT32 layerPos = 0; if (img) { layer = img -> activeLayer(); nlayers = img -> nlayers(); } - + if (layer) layerPos = img -> index(layer); @@ -832,7 +832,7 @@ void KisView::paste_into() KisImageSP img = currentImg(); Q_ASSERT(!QApplication::clipboard() -> image().isNull()); - + if (img) { KisSelectionSP selection = m_doc -> clipboardSelection(); KisLayerSP layer = m_doc -> layerAdd(img, img -> nextLayerName(), selection); @@ -867,7 +867,7 @@ void KisView::removeSelection() m_doc -> beginMacro(i18n("Remove Selection")); img -> unsetSelection(true); ur = rc; - + if (parent -> x() || parent -> y()) rc.moveBy(-parent -> x(), -parent -> y()); @@ -978,7 +978,7 @@ void KisView::selectAll() if (img) { KisPaintDeviceSP dev; - + img -> unsetSelection(); dev = img -> activeDevice(); @@ -1591,7 +1591,7 @@ void KisView::placeSidebarLeft() */ void KisView::preferences() { - // PreferencesDialog::editPreferences(); +// PreferencesDialog::editPreferences(); } Q_INT32 KisView::docWidth() const @@ -1697,6 +1697,8 @@ void KisView::print(KPrinter& printer) void KisView::setupTools() { m_toolSet = toolFactory(this, m_doc); + // Why is the paste tool local to the view, + // instead of added by the toolfactory? m_paste = new KisToolPaste(this, m_doc); m_toolSet.push_back(m_paste); m_paste -> setup(); @@ -1758,7 +1760,7 @@ void KisView::canvasGotMousePressEvent(Q return; } } - } + } if (m_tool) { Q_INT32 x = static_cast((e -> pos().x() - canvasXOffset() + horzValue() * zoom()) / zoom()); @@ -1820,6 +1822,30 @@ void KisView::canvasGotMouseReleaseEvent } } +void KisView::canvasGotTabletEvent(QTabletEvent *e) +{ + KisImageSP img = currentImg(); + if (img ) { + if ( m_tool ) { + // Compute offset between screen coordinates and (zoomed) canvas coordinates. + Q_INT32 x = static_cast((e -> pos().x() - canvasXOffset() + horzValue() * zoom()) / zoom()); + Q_INT32 y = static_cast((e -> pos().y() - canvasYOffset() + vertValue() * zoom()) / zoom()); + // Synthesize a new tablet event. + // Pity I haven't got a tablet that's got tilt, too + QTabletEvent ev(e -> type(), + QPoint(x, y), + e -> globalPos(), + e -> device(), + e -> pressure(), + e -> xTilt(), + e -> yTilt(), + e -> uniqueId()); + + m_tool->tabletEvent( &ev ); + } + } +} + void KisView::canvasGotEnterEvent(QEvent *e) { if (m_tool) @@ -1918,7 +1944,7 @@ void KisView::layerProperties() if (layer) { KisPaintPropertyDlg dlg(layer -> name(), QPoint(layer -> x(), layer -> y()), layer -> opacity()); - if (dlg.exec() == QDialog::Accepted) { + if (dlg.exec() == QDialog::Accepted) { QPoint pt = dlg.getPosition(); bool changed = layer -> name() != dlg.getName(); @@ -2161,6 +2187,7 @@ void KisView::setupCanvas() QObject::connect(m_canvas, SIGNAL(mousePressed(QMouseEvent*)), this, SLOT(canvasGotMousePressEvent(QMouseEvent*))); QObject::connect(m_canvas, SIGNAL(mouseMoved(QMouseEvent*)), this, SLOT(canvasGotMouseMoveEvent(QMouseEvent*))); QObject::connect(m_canvas, SIGNAL(mouseReleased(QMouseEvent*)), this, SLOT(canvasGotMouseReleaseEvent(QMouseEvent*))); + QObject::connect(m_canvas, SIGNAL(gotTabletEvent(QTabletEvent*)), this, SLOT(canvasGotTabletEvent(QTabletEvent*))); QObject::connect(m_canvas, SIGNAL(gotPaintEvent(QPaintEvent*)), this, SLOT(canvasGotPaintEvent(QPaintEvent*))); QObject::connect(m_canvas, SIGNAL(gotEnterEvent(QEvent*)), this, SLOT(canvasGotEnterEvent(QEvent*))); QObject::connect(m_canvas, SIGNAL(gotLeaveEvent(QEvent*)), this, SLOT(canvasGotLeaveEvent(QEvent*))); @@ -2330,7 +2357,7 @@ void KisView::layerToImage() if (img) { KisSelectionSP selection = img -> selection(); KisLayerSP layer; - + if (selection) layer = selection.data(); else @@ -2455,7 +2482,7 @@ bool KisView::eventFilter(QObject *o, QE if (!img) return super::eventFilter(o, e); - + mgr = img -> guides(); if (e -> type() == QEvent::MouseMove) { @@ -2463,7 +2490,7 @@ bool KisView::eventFilter(QObject *o, QE KisGuideSP gd; if (m_currentGuide == 0 && flag) { - // No guide is being edited and moving mouse over the canvas. + // No guide is being edited and moving mouse over the canvas. // Create a new guide. enterEvent(0); eraseGuides(); Index: core/kis_view.h =================================================================== RCS file: /home/kdecvs/kde/koffice/krita/core/kis_view.h,v retrieving revision 1.101 diff -u -3 -u -p -r1.101 kis_view.h --- core/kis_view.h 7 Mar 2003 22:05:53 -0000 1.101 +++ core/kis_view.h 4 Oct 2003 14:47:09 -0000 @@ -177,6 +177,7 @@ private slots: void canvasGotMousePressEvent(QMouseEvent *e); void canvasGotMouseMoveEvent(QMouseEvent *e); void canvasGotMouseReleaseEvent(QMouseEvent *e); + void canvasGotTabletEvent(QTabletEvent *e); void canvasGotPaintEvent(QPaintEvent *e); void canvasGotEnterEvent(QEvent *e); void canvasGotLeaveEvent(QEvent *e); Index: tools/Makefile.am =================================================================== RCS file: /home/kdecvs/kde/koffice/krita/tools/Makefile.am,v retrieving revision 1.41 diff -u -3 -u -p -r1.41 Makefile.am --- tools/Makefile.am 7 Dec 2002 04:27:35 -0000 1.41 +++ tools/Makefile.am 4 Oct 2003 14:47:09 -0000 @@ -3,8 +3,7 @@ INCLUDES = -I$(srcdir)/../core -I$(srcdi noinst_LTLIBRARIES = libkistools.la -libkistools_la_SOURCES = kis_tool_non_paint.cc kis_tool_colorpicker.cc kis_tool_move.cc kis_tool_select_rectangular.cc \ - kis_tool_paste.cc kis_tool_zoom.cc +libkistools_la_SOURCES = kis_tool_paint.cc kis_tool_non_paint.cc kis_tool_colorpicker.cc kis_tool_move.cc kis_tool_select_rectangular.cc kis_tool_paste.cc kis_tool_zoom.cc kis_tool_test.cc #kis_tool_brush.cc # # kis_tool_select_freehand.cc kis_tool_select_rectangular.cc kis_tool_select_polygonal.cc Index: tools/kis_tool_ellipse.cc =================================================================== RCS file: /home/kdecvs/kde/koffice/krita/tools/kis_tool_ellipse.cc,v retrieving revision 1.21 diff -u -3 -u -p -r1.21 kis_tool_ellipse.cc --- tools/kis_tool_ellipse.cc 17 Mar 2003 20:10:18 -0000 1.21 +++ tools/kis_tool_ellipse.cc 4 Oct 2003 14:47:09 -0000 @@ -31,7 +31,8 @@ #include "kis_tool_ellipse.h" #include "kis_dlg_toolopts.h" -EllipseTool::EllipseTool(KisDoc *doc, KisCanvas *canvas) : super(doc, canvas) +EllipseTool::EllipseTool(KisDoc *doc, KisCanvas *canvas) : + super(doc, canvas) { m_doc = doc; m_dragging = false; Index: tools/kis_tool_non_paint.cc =================================================================== RCS file: /home/kdecvs/kde/koffice/krita/tools/kis_tool_non_paint.cc,v retrieving revision 1.6 diff -u -3 -u -p -r1.6 kis_tool_non_paint.cc --- tools/kis_tool_non_paint.cc 17 Mar 2003 20:10:18 -0000 1.6 +++ tools/kis_tool_non_paint.cc 4 Oct 2003 14:47:09 -0000 @@ -15,6 +15,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "kdebug.h" #include "kis_tool_memento.h" #include "kis_tool_non_paint.h" #include "kis_view.h" @@ -65,6 +66,17 @@ void KisToolNonPaint::mouseRelease(QMous { } +void KisToolNonPaint::tabletEvent(QTabletEvent *e) +{ +// kdDebug() << "received tablet event at position (" +// << e->pos().x() +// << ", " +// << e->pos().y() +// << ")" +// << endl; +} + + void KisToolNonPaint::keyPress(QKeyEvent *) { } Index: tools/kis_tool_non_paint.h =================================================================== RCS file: /home/kdecvs/kde/koffice/krita/tools/kis_tool_non_paint.h,v retrieving revision 1.5 diff -u -3 -u -p -r1.5 kis_tool_non_paint.h --- tools/kis_tool_non_paint.h 7 Mar 2003 22:05:54 -0000 1.5 +++ tools/kis_tool_non_paint.h 4 Oct 2003 14:47:09 -0000 @@ -27,6 +27,7 @@ class QEvent; class QKeyEvent; class QPaintEvent; class QMouseEvent; +class QTabletEvent; class QRect; class KDialog; class KisDoc; @@ -52,6 +53,7 @@ public: virtual void mousePress(QMouseEvent *e); virtual void mouseMove(QMouseEvent *e); virtual void mouseRelease(QMouseEvent *e); + virtual void tabletEvent(QTabletEvent *e); virtual void keyPress(QKeyEvent *e); virtual void keyRelease(QKeyEvent *e); virtual KDialog *options(); Index: tools/kis_tool_rectangle.h =================================================================== RCS file: /home/kdecvs/kde/koffice/krita/tools/kis_tool_rectangle.h,v retrieving revision 1.17 diff -u -3 -u -p -r1.17 kis_tool_rectangle.h --- tools/kis_tool_rectangle.h 7 Mar 2003 22:05:54 -0000 1.17 +++ tools/kis_tool_rectangle.h 4 Oct 2003 14:47:09 -0000 @@ -34,8 +34,8 @@ class KisDoc; class KisPainter; class KisView; -class RectangleTool : public KisTool { - typedef KisTool super; +class RectangleTool : public KisToolInterface { + typedef KisToolInterface super; public: RectangleTool(KisDoc *doc, KisCanvas *canvas); Index: tools/kis_tool_select_rectangular.cc =================================================================== RCS file: /home/kdecvs/kde/koffice/krita/tools/kis_tool_select_rectangular.cc,v retrieving revision 1.39 diff -u -3 -u -p -r1.39 kis_tool_select_rectangular.cc --- tools/kis_tool_select_rectangular.cc 17 Mar 2003 20:10:18 -0000 1.39 +++ tools/kis_tool_select_rectangular.cc 4 Oct 2003 14:47:09 -0000 @@ -140,7 +140,7 @@ void KisToolRectangularSelect::mouseRele if (!img) return; - + m_startPos = m_view -> viewToWindow(m_startPos); m_endPos = e -> pos(); @@ -215,7 +215,7 @@ void KisToolRectangularSelect::setup() { KToggleAction *toggle; - toggle = new KToggleAction(i18n("&Rectangular Select"), "rectangular", 0, this, + toggle = new KToggleAction(i18n("&Rectangular Select"), "rectangular", 0, this, SLOT(activateSelf()), m_view -> actionCollection(), "tool_select_rectangular"); toggle -> setExclusiveGroup("tools"); } Index: ui/kis_canvas.cc =================================================================== RCS file: /home/kdecvs/kde/koffice/krita/ui/kis_canvas.cc,v retrieving revision 1.8 diff -u -3 -u -p -r1.8 kis_canvas.cc --- ui/kis_canvas.cc 17 Mar 2003 20:10:19 -0000 1.8 +++ ui/kis_canvas.cc 4 Oct 2003 14:47:09 -0000 @@ -57,6 +57,11 @@ void KisCanvas::mouseMoveEvent(QMouseEve emit mouseMoved(e); } +void KisCanvas::tabletEvent( QTabletEvent *e ) +{ + emit gotTabletEvent( e ); +} + void KisCanvas::enterEvent(QEvent *e) { emit gotEnterEvent(e); Index: ui/kis_canvas.h =================================================================== RCS file: /home/kdecvs/kde/koffice/krita/ui/kis_canvas.h,v retrieving revision 1.7 diff -u -3 -u -p -r1.7 kis_canvas.h --- ui/kis_canvas.h 7 Mar 2003 22:05:52 -0000 1.7 +++ ui/kis_canvas.h 4 Oct 2003 14:47:09 -0000 @@ -34,6 +34,7 @@ signals: void mousePressed(QMouseEvent*); void mouseMoved(QMouseEvent*); void mouseReleased(QMouseEvent*); + void gotTabletEvent(QTabletEvent*); void gotPaintEvent(QPaintEvent*); void gotEnterEvent(QEvent*); void gotLeaveEvent(QEvent*); @@ -46,6 +47,7 @@ protected: virtual void mousePressEvent(QMouseEvent *event); virtual void mouseReleaseEvent(QMouseEvent *event); virtual void mouseMoveEvent(QMouseEvent *event); + virtual void tabletEvent(QTabletEvent *event); virtual void enterEvent(QEvent *event ); virtual void leaveEvent(QEvent *event); virtual void wheelEvent(QWheelEvent *event); --Boundary-00=_17tf/5UM2qlKGdC Content-Type: text/x-c++src; charset="us-ascii"; name="kis_tool_paint.cc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kis_tool_paint.cc" /* * Copyright (c) 2003 Boudewijn Rempt * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "kdebug.h" #include "kis_tool_memento.h" #include "kis_tool_paint.h" #include "kis_view.h" KisToolPaint::KisToolPaint(KisView *view, KisDoc *doc) { m_view = view; m_doc = doc; } KisToolPaint::~KisToolPaint() { } void KisToolPaint::paint(QPainter&) { } void KisToolPaint::paint(QPainter&, const QRect&) { } void KisToolPaint::clear() { } void KisToolPaint::clear(const QRect&) { } void KisToolPaint::enter(QEvent *) { } void KisToolPaint::leave(QEvent *) { } void KisToolPaint::mousePress(QMouseEvent *) { } void KisToolPaint::mouseMove(QMouseEvent *) { } void KisToolPaint::mouseRelease(QMouseEvent *) { } void KisToolPaint::tabletEvent(QTabletEvent *e) { // kdDebug() << "received tablet event at position (" // << e->pos().x() // << ", " // << e->pos().y() // << ")" // << endl; } void KisToolPaint::keyPress(QKeyEvent *) { } void KisToolPaint::keyRelease(QKeyEvent *) { } KDialog *KisToolPaint::options() { return 0; } void KisToolPaint::save(KisToolMementoSP) { } void KisToolPaint::restore(KisToolMementoSP) { } void KisToolPaint::cursor(QWidget *w) const { if (w) w -> setCursor(m_cursor); } void KisToolPaint::setCursor(const QCursor& cursor) { m_cursor = cursor; } void KisToolPaint::activateSelf() { if (m_view) m_view -> activateTool(this); } void KisToolPaint::setup() { } void KisToolPaint::activate() { } #include "kis_tool_paint.moc" --Boundary-00=_17tf/5UM2qlKGdC Content-Type: text/x-chdr; charset="us-ascii"; name="kis_tool_paint.h" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kis_tool_paint.h" /* * Copyright (c) 2003 Boudewijn Rempt * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #if !defined KIS_TOOL_PAINT_H_ #define KIS_TOOL_PAINT_H_ #include #include "kis_global.h" #include "kis_types.h" #include "kis_tool.h" class QEvent; class QKeyEvent; class QPaintEvent; class QMouseEvent; class QTabletEvent; class QRect; class KDialog; class KisDoc; class KisView; class KisToolPaint : public KisToolInterface { Q_OBJECT typedef KisToolInterface super; public: KisToolPaint(KisView *view, KisDoc *doc); virtual ~KisToolPaint(); public: virtual void activate(); virtual void setup(); virtual void paint(QPainter& gc); virtual void paint(QPainter& gc, const QRect& rc); virtual void clear(); virtual void clear(const QRect& rc); virtual void enter(QEvent *e); virtual void leave(QEvent *e); virtual void mousePress(QMouseEvent *e); virtual void mouseMove(QMouseEvent *e); virtual void mouseRelease(QMouseEvent *e); virtual void tabletEvent(QTabletEvent *e); virtual void keyPress(QKeyEvent *e); virtual void keyRelease(QKeyEvent *e); virtual KDialog *options(); virtual void save(KisToolMementoSP memento); virtual void restore(KisToolMementoSP memento); virtual void cursor(QWidget *w) const; virtual void setCursor(const QCursor& cursor); public slots: virtual void activateSelf(); private: KisView *m_view; KisDoc *m_doc; QCursor m_cursor; }; #endif // KIS_TOOL_PAINT_H_ --Boundary-00=_17tf/5UM2qlKGdC Content-Type: text/x-c++src; charset="us-ascii"; name="kis_tool_test.cc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kis_tool_test.cc" /* * Copyright (c) 2003 Boudewijn Rempt * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #include #include #include #include #include #include "kis_painter.h" #include "kis_selection.h" #include "kis_doc.h" #include "kis_view.h" #include "kis_tool_test.h" namespace { class TestCmd : public KNamedCommand { typedef KNamedCommand super; public: TestCmd(KisImageSP owner); virtual ~TestCmd(); public: virtual void execute(); virtual void unexecute(); private: KisImageSP m_owner; }; TestCmd::TestCmd(KisImageSP owner ) : super(i18n("Testing 123")) { // At least we know on which image this command happened m_owner = owner; } TestCmd::~TestCmd() { } void TestCmd::execute() { // Redo the command } void TestCmd::unexecute() { // Undo the command } } KisToolTest::KisToolTest(KisView *view, KisDoc *doc) : super(view, doc) { m_view = view; m_doc = doc; } KisToolTest::~KisToolTest() { } void KisToolTest::mousePress(QMouseEvent *e) { Q_INT32 x = e->pos().x(); Q_INT32 y = e->pos().y(); kdDebug() << "mousePress: " << e->pos().x() << ", " << e->pos().y() << endl; KisImageSP img = m_view -> currentImg(); if (img) { KisPaintDeviceSP device = img -> activeDevice(); if (device) { kdDebug() << "Going to paint" << endl; KisPainter *p = new KisPainter(); p->begin(device); kdDebug() << "In the painter" << endl; p->fillRect( x, y, 10, 10, KoColor(QColor( "red" )) ); p->end(); //m_doc -> addCommand(new TestCmd(img)); device->anchor(); } } img -> invalidate(QRect( x, y, 10, 10 )); m_view -> updateCanvas(); kdDebug( "done painting" ); } void KisToolTest::tabletEvent(QTabletEvent *e) { Q_INT32 x = e->pos().x(); Q_INT32 y = e->pos().y(); kdDebug() << "tablet event: " << e->pos().x() << ", " << e->pos().y() << endl; KisImageSP img = m_view -> currentImg(); if (img) { KisPaintDeviceSP device = img -> activeDevice(); if (device) { kdDebug() << "Going to paint" << endl; KisPainter *p = new KisPainter(); p->begin(device); kdDebug() << "In the painter" << endl; if ( e->type() == QEvent::TabletPress ) { p->fillRect( x, y, e->pressure(), e->pressure(), KoColor(QColor( "red" )), e->pressure() ); p->end(); //m_doc -> addCommand(new TestCmd(img)); img -> invalidate(QRect( x, y, 10, 10 )); m_view -> updateCanvas(); device->anchor(); } } } e->accept(); kdDebug( "done painting" ); } void KisToolTest::setup() { KToggleAction *toggle; toggle = new KToggleAction(i18n("&Test"), "Test", 0, this, SLOT(activateSelf()), m_view -> actionCollection(), "tool_test"); toggle -> setExclusiveGroup("tools"); } --Boundary-00=_17tf/5UM2qlKGdC Content-Type: text/x-chdr; charset="us-ascii"; name="kis_tool_test.h" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kis_tool_test.h" /* * Copyright (c) 2003 Boudewijn Rempt * * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #if !defined KIS_TOOL_TEST_H_ #define KIS_TOOL_TEST_H_ #include #include "kis_tool.h" #include "kis_tool_paint.h" class KisToolTest : public KisToolPaint { typedef KisToolPaint super; public: KisToolTest(KisView *view, KisDoc *doc); virtual ~KisToolTest(); public: virtual void KisToolTest::setup(); virtual void mousePress(QMouseEvent *e); virtual void tabletEvent(QTabletEvent *e); private: KisView *m_view; KisDoc *m_doc; }; #endif // KIS_TOOL_TEST_H_ --Boundary-00=_17tf/5UM2qlKGdC Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ kimageshop mailing list kimageshop@mail.kde.org http://mail.kde.org/mailman/listinfo/kimageshop --Boundary-00=_17tf/5UM2qlKGdC--