diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-26 00:29:37 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-06-26 00:29:37 +0000 |
commit | 2785103a6bd4de55bd26d79e34d0fdd4b329a73a (patch) | |
tree | c2738b1095bfdb263da27bc1391403d829522a14 /krita/plugins/tools/defaulttools | |
parent | f008adb5a77e094eaf6abf3fc0f36958e66896a5 (diff) | |
download | koffice-2785103a6bd4de55bd26d79e34d0fdd4b329a73a.tar.gz koffice-2785103a6bd4de55bd26d79e34d0fdd4b329a73a.zip |
Remove krita* in preparation for name switch from Krita to Chalk
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238361 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'krita/plugins/tools/defaulttools')
53 files changed, 0 insertions, 4184 deletions
diff --git a/krita/plugins/tools/defaulttools/Makefile.am b/krita/plugins/tools/defaulttools/Makefile.am deleted file mode 100644 index f6bf3894..00000000 --- a/krita/plugins/tools/defaulttools/Makefile.am +++ /dev/null @@ -1,83 +0,0 @@ -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) $(LIB_QT) -lkdecore -lkdeui -lkjs -lkdefx -lkio -lkparts -L../../../../krita/kritacolor/.libs -lkritacolor -L../../../../krita/core/.libs -lkritaimage \ - -L../../../../krita/ui/.libs -lkritaui -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 deleted file mode 100644 index b3d98f85..00000000 --- a/krita/plugins/tools/defaulttools/closedhand_cursor.xpm +++ /dev/null @@ -1,28 +0,0 @@ -/* 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 deleted file mode 100644 index a281a52c..00000000 --- a/krita/plugins/tools/defaulttools/default_tools.cc +++ /dev/null @@ -1,88 +0,0 @@ -/* - * default_tools.cc -- Part of Krita - * - * Copyright (c) 2004 Boudewijn Rempt (boud@valdyas.org) - * - * 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 <tqpoint.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(TQObject *tqparent, const char *name, const TQStringList &) - : KParts::Plugin(tqparent, name) -{ - setInstance(DefaultToolsFactory::instance()); - - if ( tqparent->inherits("KisToolRegistry") ) - { - KisToolRegistry * r = dynamic_cast<KisToolRegistry*>(tqparent); - - 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 deleted file mode 100644 index b4c6d4de..00000000 --- a/krita/plugins/tools/defaulttools/default_tools.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2003 Boudewijn Rempt (boud@valdyas.org) - * - * 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 - TQ_OBJECT -public: - DefaultTools(TQObject *tqparent, const char *name, const TQStringList &); - 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 deleted file mode 100644 index 3a931bfb..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_brush.cc +++ /dev/null @@ -1,167 +0,0 @@ -/* - * kis_tool_brush.cc - part of Krita - * - * Copyright (c) 2003-2004 Boudewijn Rempt <boud@valdyas.org> - * - * 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 <tqevent.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqwidget.h> -#include <tqtimer.h> -#include <tqpushbutton.h> -#include <tqpainter.h> -#include <tqrect.h> -#include <tqcheckbox.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 TQTimer(this); - Q_CHECK_PTR(m_timer); - - connect(m_timer, TQT_SIGNAL(timeout()), this, TQT_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", TQt::Key_B, this, - TQT_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(TQEvent */*e*/) { - m_subject->canvasController()->kiscanvas()->update(); // remove the outline -} - - -void KisToolBrush::slotSetPaintingMode( int mode ) -{ - if (mode == TQButton::On) { - // Direct painting - m_paintIncremental = true; - } - else { - m_paintIncremental = false; - } -} - - -TQWidget* KisToolBrush::createOptionWidget(TQWidget* tqparent) -{ - TQWidget *widget = super::createOptionWidget(tqparent); - m_chkDirect = new TQCheckBox(i18n("Paint direct"), widget, "chkDirect"); - m_chkDirect->setChecked(true); - connect(m_chkDirect, TQT_SIGNAL(stateChanged(int)), this, TQT_SLOT(slotSetPaintingMode(int))); - - m_optionLayout = new TQGridLayout(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 deleted file mode 100644 index a23e8d12..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_brush.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2003-2004 Boudewijn Rempt <boud@valdyas.org> - * - * 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 TQTimer; -class KisPoint; -class TQHBoxLayout; -class TQPainter; -class TQRect; -class TQCheckBox; -class TQGridLayout; - -class KRITACORE_EXPORT KisToolBrush : public KisToolFreehand { - Q_OBJECT - TQ_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 TQ_UINT32 priority() { return 0; } - TQWidget* createOptionWidget(TQWidget* tqparent); - -protected: - - virtual void initPaint(KisEvent *e); - virtual void endPaint(); - virtual void move(KisMoveEvent *e); - virtual void leave(TQEvent *e); - -private slots: - - void timeoutPaint(); - void slotSetPaintingMode( int mode ); - -private: - - TQ_INT32 m_rate; - TQTimer * m_timer; - TQGridLayout* m_optionLayout; - TQCheckBox * 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 deleted file mode 100644 index 77020342..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_colorpicker.cc +++ /dev/null @@ -1,298 +0,0 @@ -/* - * Copyright (c) 1999 Matthias Elter <me@kde.org> - * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> - * - * 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 <tqpoint.h> -#include <tqlayout.h> -#include <tqcheckbox.h> -#include <tqcombobox.h> -#include <tqlistview.h> -#include <tqspinbox.h> - -#include <kaction.h> -#include <klocale.h> -#include <tqcolor.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() != TQMouseEvent::LeftButton && e->button() != TQMouseEvent::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; - } - } - - TQPoint pos = TQPoint(e->pos().floorX(), e->pos().floorY()); - - if (!img->bounds().tqcontains(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(); - - TQ_UINT8* data = new TQ_UINT8[pixelSize]; - TQ_UINT8** pixels = new TQ_UINT8*[counts[m_radius]]; - TQ_UINT8* weights = new TQ_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 TQ_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 TQ_UINT8** cpixels = const_cast<const TQ_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() == TQMouseEvent::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.toTQColor(); - // 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.").tqarg(palette->filename()), i18n("Palette")); - } - } - } -} - -void KisToolColorPicker::displayPickedColor() -{ - if (m_pickedColor.data() && m_optionsWidget) { - - TQValueVector<KisChannelInfo *> channels = m_pickedColor.colorSpace()->channels(); - m_optionsWidget->listViewChannels->clear(); - - for (int i = channels.count() - 1; i >= 0 ; --i) { - TQString channelValueText; - - if (m_normaliseValues) { - channelValueText = i18n("%1%").tqarg(m_pickedColor.colorSpace()->normalisedChannelValueText(m_pickedColor.data(), i)); - } else { - channelValueText = m_pickedColor.colorSpace()->channelValueText(m_pickedColor.data(), i); - } - - m_optionsWidget->listViewChannels->insertItem(new TQListViewItem(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", TQt::Key_P, this, TQT_SLOT(activate()), collection, name()); - m_action->setToolTip(i18n("Color picker")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -TQWidget* KisToolColorPicker::createOptionWidget(TQWidget* tqparent) -{ - m_optionsWidget = new ColorPickerOptionsWidget(tqparent); - - 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, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotSetUpdateColor(bool))); - connect(m_optionsWidget->cbNormaliseValues, TQT_SIGNAL(toggled(bool)), TQT_SLOT(slotSetNormaliseValues(bool))); - connect(m_optionsWidget->cbPalette, TQT_SIGNAL(toggled(bool)), - TQT_SLOT(slotSetAddPalette(bool))); - connect(m_optionsWidget->radius, TQT_SIGNAL(valueChanged(int)), - TQT_SLOT(slotChangeRadius(int))); - - KisResourceServerBase* srv = KisResourceServerRegistry::instance()->get("PaletteServer"); - - if (!srv) { - return m_optionsWidget; - } - - TQValueList<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, TQT_SIGNAL(resourceAdded(KisResource*)), this, TQT_SLOT(slotAddPalette(KisResource*))); - - return m_optionsWidget; -} - -TQWidget* 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 deleted file mode 100644 index ab59ef17..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_colorpicker.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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 "tqvaluevector.h" - -class ColorPickerOptionsWidget; -class KisResource; -class KisPalette; - -class KisToolColorPicker : public KisToolNonPaint { - - Q_OBJECT - TQ_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 TQWidget* createOptionWidget(TQWidget* tqparent); - virtual TQWidget* optionWidget(); - virtual enumToolType toolType() { return TOOL_FILL; } - virtual TQ_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; - TQValueVector<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 deleted file mode 100644 index bd03245d..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_duplicate.cc +++ /dev/null @@ -1,255 +0,0 @@ -/* - * kis_tool_duplicate.cc - part of Krita - * - * Copyright (c) 2004 Cyrille Berger <cberger@cberger.net> - * - * 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 <tqbitmap.h> -#include <tqcheckbox.h> -#include <tqpainter.h> -#include <tqlabel.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(TQPoint(-1,-1)) -{ - setName("tool_duplicate"); - m_subject = 0; - setCursor(KisCursor::load("tool_duplicate_cursor.png", 5, 5)); -} - -KisToolDuplicate::~KisToolDuplicate() -{ -} - -void KisToolDuplicate::activate() -{ - m_position = TQPoint(-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 != TQPoint(-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", TQt::Key_C, this, - TQT_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 != TQPoint(-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 == TQPoint(-1,-1) ) - return; - - TQPoint 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())); - TQRect r = TQRect(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.floorTQPoint(); - } - - }else { - srcPos = painter()->duplicateOffset().floorTQPoint(); - } - } else { - if(m_isOffsetNotUptodate) - srcPos = e->pos().floorTQPoint() - m_position.floorTQPoint(); - else - srcPos = m_offset.floorTQPoint(); - } - - TQ_INT32 x; - TQ_INT32 y; - - // like KisPaintOp::splitCoordinate - x = (TQ_INT32)((e->x() < 0) ? e->x() - 1 : e->x()); - y = (TQ_INT32)((e->y() < 0) ? e->y() - 1 : e->y()); - srcPos = TQPoint(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 != TQPoint(-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); - } -} - -TQString 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."); -} - -TQWidget* KisToolDuplicate::createOptionWidget(TQWidget* tqparent) -{ - TQWidget* widget = KisToolPaint::createOptionWidget(tqparent); - m_healing = new TQCheckBox(widget); - m_healing->setChecked( false); - addOptionWidgetOption(m_healing, new TQLabel(i18n("Healing"), widget )); - m_healingRadius = new KIntNumInput(widget); - - KisBrush *brush = m_subject->currentBrush(); - int healingradius = 20; - if( brush ) - { - healingradius = 2 * TQMAX(brush->width(),brush->height()); - } - - m_healingRadius->setValue( healingradius ); - addOptionWidgetOption(m_healingRadius, new TQLabel(i18n("Healing radius"), widget )); - m_perspectiveCorrection = new TQCheckBox(widget); - addOptionWidgetOption(m_perspectiveCorrection, new TQLabel(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 deleted file mode 100644 index 2201badd..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_duplicate.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * kis_tool_duplicate.h - part of Krita - * - * Copyright (c) 2004 Cyrille Berger <cberger@cberger.net> - * - * 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 TQCheckBox; -class KIntNumInput; - -class KisToolDuplicate : public KisToolFreehand { - - typedef KisToolFreehand super; - Q_OBJECT - TQ_OBJECT - -public: - KisToolDuplicate(); - virtual ~KisToolDuplicate(); - - virtual void setup(KActionCollection *collection); - virtual enumToolType toolType() { return TOOL_FREEHAND; } - virtual TQ_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 TQString quickHelp() const; - virtual TQWidget* createOptionWidget(TQWidget* tqparent); - -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; - TQCheckBox* m_healing; - KIntNumInput* m_healingRadius; - TQCheckBox* 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 deleted file mode 100644 index bae8ae04..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_ellipse.cc +++ /dev/null @@ -1,186 +0,0 @@ -/* - * kis_tool_ellipse.cc - part of Krayon - * - * Copyright (c) 2000 John Califf <jcaliff@compuzone.net> - * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> - * Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org> - * Copyright (c) 2004 Clarence Dang <dang@kde.org> - * - * 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 <tqpainter.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() & TQt::AltButton) { - KisPoint trans = event->pos() - m_dragEnd; - m_dragStart += trans; - m_dragEnd += trans; - } else { - KisPoint diag = event->pos() - (event->state() & TQt::ControlButton - ? m_dragCenter : m_dragStart); - // circle? - if (event->state() & TQt::ShiftButton) { - double size = TQMAX(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() & TQt::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 (TQt::NotROP); - p.drawEllipse (TQRect (controller->windowToView (start).floorTQPoint(), controller->windowToView (end).floorTQPoint())); - p.end (); -} - -void KisToolEllipse::setup(KActionCollection *collection) -{ - m_action = static_cast<KRadioAction *>(collection->action(name())); - - if (m_action == 0) { - KShortcut shortcut(TQt::Key_Plus); - shortcut.append(KShortcut(TQt::Key_F7)); - m_action = new KRadioAction(i18n("&Ellipse"), - "tool_ellipse", - shortcut, - this, - TQT_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 deleted file mode 100644 index 4f79fbd6..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_ellipse.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * kis_tool_ellipse.h - part of Krayon - * - * Copyright (c) 2000 John Califf <jcaliff@compuzone.net> - * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> - * Copyright (c) 2004 Clarence Dang <dang@kde.org> - * - * 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 - TQ_OBJECT - -public: - KisToolEllipse(); - virtual ~KisToolEllipse(); - - // - // KisCanvasObserver interface - // - - virtual void update (KisCanvasSubject *subject); - - // - // KisToolPaint interface - // - - virtual void setup(KActionCollection *collection); - virtual TQ_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 deleted file mode 100644 index 6e2ae99c..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_fill.cc +++ /dev/null @@ -1,233 +0,0 @@ -/* - * kis_tool_fill.cc - part of Krayon - * - * Copyright (c) 2000 John Califf <jcaliff@compuzone.net> - * Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org> - * Copyright (c) 2004 Bart Coppens <kde@bartcoppens.be> - * - * 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 <tqlabel.h> -#include <tqlayout.h> -#include <tqcheckbox.h> - -#include <tqcolor.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) { - TQRect 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() != TQMouseEvent::LeftButton) return; - if(!m_wasPressed) return; - m_wasPressed = false; - int x, y; - x = m_startPos.floorX(); - y = m_startPos.floorY(); - if (!m_currentImage->bounds().tqcontains(x, y)) { - return; - } - flood(x, y); - notifyModified(); -} - -TQWidget* KisToolFill::createOptionWidget(TQWidget* tqparent) -{ - TQWidget *widget = super::createOptionWidget(tqparent); - - m_lbThreshold = new TQLabel(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, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotSetThreshold(int))); - - m_checkUsePattern = new TQCheckBox(i18n("Use pattern"), widget); - m_checkUsePattern->setChecked(m_usePattern); - connect(m_checkUsePattern, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotSetUsePattern(bool))); - - m_checkSampleMerged = new TQCheckBox(i18n("Limit to current layer"), widget); - m_checkSampleMerged->setChecked(m_unmerged); - connect(m_checkSampleMerged, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotSetSampleMerged(bool))); - - m_checkFillSelection = new TQCheckBox(i18n("Fill entire selection"), widget); - m_checkFillSelection->setChecked(m_fillOnlySelection); - connect(m_checkFillSelection, TQT_SIGNAL(toggled(bool)), this, TQT_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", - TQt::Key_F, - this, - TQT_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 deleted file mode 100644 index 411d711e..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_fill.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - * kis_tool_fill.h - part of Krayon^Krita - * - * Copyright (c) 2004 Bart Coppens <kde@bartcoppens.be> - * - * 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 <tqpoint.h> - -#include "kis_point.h" -#include "kis_tool_paint.h" - -class KisPainter; -class TQWidget; -class TQLabel; -class TQCheckBox; -class KIntNumInput; -class KActionCollection; - -class KisToolFill : public KisToolPaint { - - typedef KisToolPaint super; - Q_OBJECT - TQ_OBJECT - -public: - - KisToolFill(); - virtual ~KisToolFill(); - - virtual void setup(KActionCollection *collection); - virtual enumToolType toolType() { return TOOL_FILL; } - virtual TQ_UINT32 priority() { return 0; } - - virtual void update(KisCanvasSubject *subject); - - virtual void buttonPress(KisButtonPressEvent*); - virtual void buttonRelease(KisButtonReleaseEvent*); - - bool flood(int startX, int startY); - - virtual TQWidget* createOptionWidget(TQWidget* tqparent); - -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; - TQ_INT32 m_depth; - KisLayerSP m_lay; - TQ_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; - - TQLabel *m_lbThreshold; - KIntNumInput *m_slThreshold; - TQCheckBox *m_checkUsePattern; - TQCheckBox *m_checkSampleMerged; - TQCheckBox *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 deleted file mode 100644 index 20ea5aa1..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_gradient.cc +++ /dev/null @@ -1,309 +0,0 @@ -/* - * kis_tool_gradient.cc - part of Krita - * - * Copyright (c) 2000 John Califf - * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> - * Copyright (c) 2003 Boudewijn Rempt <boud@valdyas.org> - * Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com> - * - * 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 <tqpainter.h> -#include <tqlabel.h> -#include <tqlayout.h> -#include <tqcheckbox.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_tqshape = 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 TQRect&) -{ - if (m_dragging) - paintLine(gc); -} - -void KisToolGradient::buttonPress(KisButtonPressEvent *e) -{ - if (!m_subject || !m_subject->currentImg()) { - return; - } - - if (e->button() == TQMouseEvent::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() & TQt::ShiftButton) == TQt::ShiftButton) { - m_endPos = straightLine(e->pos()); - } - else { - m_endPos = e->pos(); - } - - paintLine(); - } -} - -void KisToolGradient::buttonRelease(KisButtonReleaseEvent *e) -{ - if (m_dragging && e->button() == TQMouseEvent::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() & TQt::ShiftButton) == TQt::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_tqshape, 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(); - TQPen old = gc.pen(); - TQPen pen(TQt::SolidLine); - - gc.setRasterOp(TQt::NotROP); - gc.setPen(pen); - gc.drawLine(start.floorTQPoint(), end.floorTQPoint()); - gc.setRasterOp(op); - gc.setPen(old); - } -} - -TQWidget* KisToolGradient::createOptionWidget(TQWidget* tqparent) -{ - TQWidget *widget = super::createOptionWidget(tqparent); - Q_CHECK_PTR(widget); - - m_lbShape = new TQLabel(i18n("Shape:"), widget); - m_lbRepeat = new TQLabel(i18n("Repeat:"), widget); - - m_ckReverse = new TQCheckBox(i18n("Reverse"), widget, "reverse_check"); - connect(m_ckReverse, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotSetReverse(bool))); - - m_cmbShape = new TQComboBox(false, widget, "tqshape_combo"); - connect(m_cmbShape, TQT_SIGNAL(activated(int)), this, TQT_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 TQComboBox(false, widget, "repeat_combo"); - connect(m_cmbRepeat, TQT_SIGNAL(activated(int)), this, TQT_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 TQLabel(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, TQT_SIGNAL(valueChanged(double)), this, TQT_SLOT(slotSetAntiAliasThreshold(double))); - - addOptionWidgetOption(m_slAntiAliasThreshold, m_lbAntiAliasThreshold); - - return widget; -} - -void KisToolGradient::slotSetShape(int tqshape) -{ - m_tqshape = static_cast<KisGradientPainter::enumGradientShape>(tqshape); -} - -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", TQt::Key_G, this, - TQT_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 deleted file mode 100644 index 59d78ad3..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_gradient.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * kis_tool_line.h - part of Krayon - * - * Copyright (c) 2000 John Califf <jcaliff@comuzone.net> - * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> - * Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org> - * Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com> - * - * 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 TQLabel; -class TQPoint; -class TQWidget; -class TQCheckBox; - - - -class KisToolGradient : public KisToolPaint { - - Q_OBJECT - TQ_OBJECT - typedef KisToolPaint super; - -public: - KisToolGradient(); - virtual ~KisToolGradient(); - - virtual void setup(KActionCollection *collection); - virtual enumToolType toolType() { return TOOL_FILL; } - virtual TQ_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 TQRect& rc); - - TQWidget* createOptionWidget(TQWidget* tqparent); - -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_tqshape; - KisGradientPainter::enumGradientRepeat m_repeat; - - bool m_reverse; - double m_antiAliasThreshold; - - TQLabel *m_lbShape; - TQLabel *m_lbRepeat; - TQCheckBox *m_ckReverse; - TQComboBox *m_cmbShape; - TQComboBox *m_cmbRepeat; - TQLabel *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 deleted file mode 100644 index a335f918..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_line.cc +++ /dev/null @@ -1,254 +0,0 @@ -/* - * kis_tool_line.cc - part of Krayon - * - * Copyright (c) 2000 John Califf - * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> - * Copyright (c) 2003 Boudewijn Rempt <boud@valdyas.org> - * - * 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 <tqpainter.h> -#include <tqlayout.h> -#include <tqwidget.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, TQRect()); -} - -void KisToolLine::paint(KisCanvasPainter& gc, const TQRect& 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() == TQMouseEvent::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() & TQt::AltButton) { - KisPoint trans = e->pos() - m_endPos; - m_startPos += trans; - m_endPos += trans; - } else if (e->state() & TQt::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() == TQMouseEvent::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() & TQt::ShiftButton) == TQt::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); - TQRect rc; - - paintLine(gc, rc); - } -} - -void KisToolLine::paintLine(KisCanvasPainter& gc, const TQRect&) -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - RasterOp op = gc.rasterOp(); - TQPen old = gc.pen(); - TQPen pen(TQt::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(TQt::NotROP); - gc.setPen(pen); - gc.drawLine(start.floorTQPoint(), end.floorTQPoint()); - 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", TQt::Key_L, this, - TQT_SLOT(activate()), collection, - name()); - m_action->setToolTip(i18n("Draw a line")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - -TQString 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 deleted file mode 100644 index 4ce0ff38..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_line.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * kis_tool_line.h - part of Krayon - * - * Copyright (c) 2000 John Califf <jcaliff@comuzone.net> - * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> - * Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org> - * - * 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 TQPoint; -class TQWidget; - - -class KisToolLine : public KisToolPaint { - - Q_OBJECT - TQ_OBJECT - typedef KisToolPaint super; - - public: - KisToolLine(); - virtual ~KisToolLine(); - - virtual void setup(KActionCollection *collection); - virtual enumToolType toolType() { return TOOL_SHAPE; } - virtual TQ_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 TQRect& rc); - - virtual TQString quickHelp() const; - - private: - void paintLine(); - void paintLine(KisCanvasPainter& gc, const TQRect& 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 deleted file mode 100644 index 643c29c8..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_move.cc +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 1999 Matthias Elter <me@kde.org> - * 1999 Michael Koch <koch@kde.org> - * 2002 Patrick Julien <freak@codepimps.org> - * 2004 Boudewijn Rempt <boud@valdyas.org> - * - * 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 <tqpoint.h> -#include <kaction.h> -#include <klocale.h> -#include <tqcolor.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 TQTimer(this); - connect( m_repeatTimer, TQT_SIGNAL( timeout() ), this, TQT_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() == TQMouseEvent::LeftButton) { - TQPoint pos = e->pos().floorTQPoint(); - 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() == TQMouseEvent::LeftButton) { - TQPoint pos = e->pos().floorTQPoint(); - if((e->state() & TQt::AltButton) || (e->state() & TQt::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() == TQMouseEvent::LeftButton) { - m_strategy.endDrag(e->pos().floorTQPoint()); - } -} - -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", - TQt::SHIFT+TQt::Key_V, - this, - TQT_SLOT(activate()), - collection, - name()); - m_action->setToolTip(i18n("Move")); - m_action->setExclusiveGroup("tools"); - m_ownAction = true; - } -} - - -void KisToolMove::keyPress( TQKeyEvent *e ) -{ - m_keyEvent = e; - - if (m_subject) { - - KisImageSP img = m_subject->currentImg(); - KisLayerSP dev; - - if (!img || !(dev = img->activeLayer())) - return; - - m_dragStart = TQPoint( 0, 0 ); - m_strategy.startDrag( m_dragStart ); - m_steps = 1; - m_repeatTimer->start(200); - - } -} - -void KisToolMove::keyRelease(TQKeyEvent *) -{ - m_repeatTimer->stop(); - - if ( m_subject && m_keyEvent) { - - if ( m_keyEvent->key() == TQt::Key_Left ) { - m_strategy.endDrag(TQPoint( -m_steps, 0 )); - } - else if ( m_keyEvent->key() == TQt::Key_Right ) { - m_strategy.endDrag(TQPoint(m_steps, 0) ); - } - else if ( m_keyEvent->key() == TQt::Key_Up ) { - m_strategy.endDrag(TQPoint(0, -m_steps) ); - } - else if ( m_keyEvent->key() == TQt::Key_Down ) { - m_strategy.endDrag(TQPoint(0, m_steps) ); - } - } - m_steps = 0; - m_keyEvent = 0; - -} - -void KisToolMove::slotMove() -{ - if (m_subject && m_keyEvent) { - - if ( m_keyEvent->key() == TQt::Key_Left ) { - m_strategy.drag(TQPoint(-m_steps, 0) ); - } - else if ( m_keyEvent->key() == TQt::Key_Right ) { - m_strategy.drag(TQPoint(m_steps, 0) ); - } - else if ( m_keyEvent->key() == TQt::Key_Up ) { - m_strategy.drag(TQPoint(0, -m_steps) ); - } - else if ( m_keyEvent->key() == TQt::Key_Down ) { - m_strategy.drag(TQPoint(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 deleted file mode 100644 index 274cc3c7..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_move.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 1999 Matthias Elter <me@kde.org> - * 1999 Michael Koch <koch@kde.org> - * 2003 Patrick Julien <freak@codepimps.org> - * - * 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 <tqtimer.h> - -#include "kis_strategy_move.h" -#include "kis_tool_non_paint.h" -#include "kis_tool_factory.h" - -class TQTimer; - -class KisToolMove : public KisToolNonPaint { - - typedef KisToolNonPaint super; - Q_OBJECT - TQ_OBJECT - -public: - KisToolMove(); - virtual ~KisToolMove(); - -public: - virtual void update(KisCanvasSubject *subject); - -public: - virtual void setup(KActionCollection *collection); - virtual enumToolType toolType() { return TOOL_TRANSFORM; } - virtual TQ_UINT32 priority() { return 2; } - - virtual void buttonPress(KisButtonPressEvent *e); - virtual void move(KisMoveEvent *e); - virtual void buttonRelease(KisButtonReleaseEvent *e); - virtual void keyPress(TQKeyEvent *e); - virtual void keyRelease(TQKeyEvent *e); - -private slots: - - void slotMove(); - -private: - - KisCanvasSubject *m_subject; - KisStrategyMove m_strategy; - TQPoint m_dragStart; - TQTimer * m_repeatTimer; - TQKeyEvent * 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 deleted file mode 100644 index f7a92dcb..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_pan.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com> - * - * 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", TQt::SHIFT+TQt::Key_H, this, TQT_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 deleted file mode 100644 index 36ed9dcc..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_pan.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2004 Adrian Page <adrian@pagenet.plus.com> - * - * 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 - TQ_OBJECT - -public: - KisToolPan(); - virtual ~KisToolPan(); - - virtual void update(KisCanvasSubject *subject); - - virtual void setup(KActionCollection *collection); - virtual enumToolType toolType() { return TOOL_VIEW; } - virtual TQ_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; - TQ_INT32 m_origScrollX; - TQ_INT32 m_origScrollY; - bool m_dragging; - TQCursor m_openHandCursor; - TQCursor 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 deleted file mode 100644 index 741b5051..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_rectangle.cc +++ /dev/null @@ -1,187 +0,0 @@ -/* - * kis_tool_rectangle.cc - part of Krita - * - * Copyright (c) 2000 John Califf <jcaliff@compuzone.net> - * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> - * Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org> - * Copyright (c) 2004 Clarence Dang <dang@k.org> - * - * 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 <tqpainter.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() & TQt::AltButton) { - KisPoint trans = event->pos() - m_dragEnd; - m_dragStart += trans; - m_dragEnd += trans; - } else { - KisPoint diag = event->pos() - (event->state() & TQt::ControlButton - ? m_dragCenter : m_dragStart); - // square? - if (event->state() & TQt::ShiftButton) { - double size = TQMAX(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() & TQt::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 (TQt::NotROP); - p.drawRect (TQRect (controller->windowToView (start).floorTQPoint(), controller->windowToView (end).floorTQPoint())); - 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", - TQt::Key_F6, - this, - TQT_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 deleted file mode 100644 index cc6c0853..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_rectangle.h +++ /dev/null @@ -1,96 +0,0 @@ -/* - * kis_tool_rectangle.h - part of KImageShop^WKrayon^WKrita - * - * Copyright (c) 1999 Michael Koch <koch@kde.org> - * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> - * Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org> - * Copyright (c) 2004 Clarence Dang <dang@kde.org> - * - * 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 <tqrect.h> - -#include "kis_tool_shape.h" -#include "kis_types.h" -#include "kis_tool_factory.h" -#include "kis_point.h" - -class TQPainter; -class KisPainter; - -class KisToolRectangle : public KisToolShape { - - typedef KisToolShape super; - Q_OBJECT - TQ_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 TQ_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; - TQRect 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 deleted file mode 100644 index 853ff322..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_text.cc +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright (c) 2004 Bart Coppens <kde@bartcoppens.be> - * - * 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 <tqfont.h> -#include <tqrect.h> -#include <tqimage.h> -#include <tqlayout.h> -#include <tqwidget.h> -#include <tqstring.h> -#include <tqpixmap.h> -#include <tqpainter.h> -#include <tqpushbutton.h> -#include <tqfontmetrics.h> -#include <tqhbox.h> - -#include <kaction.h> -#include <kinputdialog.h> -#include <klocale.h> -#include <kfontdialog.h> -#include <ksqueezedtextlabel.h> - -#include <tqcolor.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() == TQMouseEvent::LeftButton) { - m_wasPressed = true; - } -} - -void KisToolText::buttonRelease(KisButtonReleaseEvent *e) -{ - if ( m_windowIsBeingShown ) return; - - if (m_subject && e->button() == TQMouseEvent::LeftButton) { - if(!m_wasPressed) return; - m_wasPressed = false; - KisImageSP img = m_subject->currentImg(); - - m_windowIsBeingShown = true; - bool ok; - TQString text = KInputDialog::getText(i18n("Font Tool"), i18n("Enter text:"), - TQString(), &ok); - if (!ok) { - m_windowIsBeingShown = false; - return; - } - - KisUndoAdapter *undoAdapter = img->undoAdapter(); - if (undoAdapter) { - undoAdapter->beginMacro(i18n("Text")); - } - - TQFontMetrics metrics(m_font); - TQRect 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()); - - TQPixmap pixels(boundingRect.width(), boundingRect.height()); - { - TQPainter paint(&pixels); - paint.fillRect(boundingRect, TQt::white); - paint.setFont(m_font); - paint.setBrush(TQBrush(TQt::black)); - paint.drawText(xB, yB, text); - } - TQImage image = pixels.convertToImage(); - - TQ_INT32 height = boundingRect.height(); - TQ_INT32 width = boundingRect.width(); - KisPaintLayer *layer = new KisPaintLayer(img, '"' + text + '"', OPACITY_OPAQUE); - KisGroupLayerSP tqparent = img->rootLayer(); - if (img->activeLayer()) - tqparent = img->activeLayer()->tqparent(); - img->addLayer(layer, tqparent, img->activeLayer()); - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - TQRgb pixel = image.pixel(x, y); - // use the 'blackness' as alpha :) - TQ_UINT8 alpha = 255 - tqRed(pixel) * OPACITY_OPAQUE / 255; - TQColor c = m_subject->fgColor().toTQColor(); - layer->paintDevice()->setPixel(x, y, c, alpha); - } - } - - layer->setOpacity(m_opacity); - layer->setCompositeOp(m_compositeOp); - - layer->setVisible(false); - TQ_INT32 x = TQMAX(0, static_cast<int>(e->x() - width/2)); - TQ_INT32 y = TQMAX(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/*, TQWidget* tqparent! */ ); - m_lbFontName->setText(TQString(m_font.family() + ", %1").tqarg(m_font.pointSize())); -} - -TQWidget* KisToolText::createOptionWidget(TQWidget* tqparent) -{ - TQWidget *widget = super::createOptionWidget(tqparent); - - m_lbFont = new TQLabel(i18n("Font: "), widget); - - TQHBox *fontBox = new TQHBox(widget); - m_lbFontName = new KSqueezedTextLabel(TQString(m_font.family() + ", %1") - .tqarg(m_font.pointSize()), fontBox); - m_btnMoreFonts = new TQPushButton("...", fontBox); - - connect(m_btnMoreFonts, TQT_SIGNAL(released()), this, TQT_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", - TQt::SHIFT+TQt::Key_T, - this, - TQT_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 deleted file mode 100644 index b2aa7e18..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_text.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2004 Bart Coppens <kde@bartcoppens.be> - * - * 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 TQFont; -class TQLabel; -class TQWidget; -class TQPushButton; -class KSqueezedTextLabel; - - - -class KisToolText : public KisToolPaint { - typedef KisToolPaint super; - Q_OBJECT - TQ_OBJECT - -public: - KisToolText(); - virtual ~KisToolText(); - - virtual void update(KisCanvasSubject *subject); - virtual void setup(KActionCollection *collection); - virtual enumToolType toolType() { return TOOL_FILL; } - virtual TQ_UINT32 priority() { return 2; } - virtual void buttonPress(KisButtonPressEvent*); - virtual void buttonRelease(KisButtonReleaseEvent *e); - - virtual TQWidget* createOptionWidget(TQWidget* tqparent); -public slots: - virtual void setFont(); - -private: - KisCanvasSubject *m_subject; - TQFont m_font; - TQLabel *m_lbFont; - KSqueezedTextLabel *m_lbFontName; - TQPushButton *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 deleted file mode 100644 index f866e5e2..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_zoom.cc +++ /dev/null @@ -1,191 +0,0 @@ -/* - * Copyright (c) 1999 Matthias Elter <me@kde.org> - * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> - * - * 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 = TQPoint(0, 0); - m_endPos = TQPoint(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, TQT_SIGNAL(timeout()), TQT_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, TQRect()); -} - -void KisToolZoom::paint(KisCanvasPainter& gc, const TQRect& 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().floorTQPoint(); - m_endPos = e->pos().floorTQPoint(); - m_dragging = true; - } - } -} - -void KisToolZoom::move(KisMoveEvent *e) -{ - if (m_subject && m_dragging) { - if (m_startPos != m_endPos) - paintOutline(); - - m_endPos = e->pos().floorTQPoint(); - paintOutline(); - } -} - -void KisToolZoom::buttonRelease(KisButtonReleaseEvent *e) -{ - if (m_subject && m_dragging && e->button() == Qt::LeftButton) { - - KisCanvasController *controller = m_subject->canvasController(); - m_endPos = e->pos().floorTQPoint(); - m_dragging = false; - - TQPoint delta = m_endPos - m_startPos; - - if (sqrt(delta.x() * delta.x() + delta.y() * delta.y()) < 10) { - if (e->state() & TQt::ControlButton) { - controller->zoomOut(m_endPos.x(), m_endPos.y()); - } else { - controller->zoomIn(m_endPos.x(), m_endPos.y()); - } - } else { - controller->zoomTo(TQRect(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() & (TQt::ShiftButton|TQt::ControlButton|TQt::AltButton); -#else - int state = kapp->keyboardModifiers() & (KApplication::ShiftModifier - |KApplication::ControlModifier|KApplication::Modifier1); -#endif - - if (state & TQt::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); - TQRect rc; - - paintOutline(gc, rc); - } -} - -void KisToolZoom::paintOutline(KisCanvasPainter& gc, const TQRect&) -{ - if (m_subject) { - KisCanvasController *controller = m_subject->canvasController(); - RasterOp op = gc.rasterOp(); - TQPen old = gc.pen(); - TQPen pen(TQt::DotLine); - TQPoint start; - TQPoint end; - - Q_ASSERT(controller); - start = controller->windowToView(m_startPos); - end = controller->windowToView(m_endPos); - - gc.setRasterOp(TQt::NotROP); - gc.setPen(pen); - gc.drawRect(TQRect(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", TQt::Key_Z, this, TQT_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 deleted file mode 100644 index 3faa5bf1..00000000 --- a/krita/plugins/tools/defaulttools/kis_tool_zoom.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 1999 Matthias Elter <me@kde.org> - * Copyright (c) 2002 Patrick Julien <freak@codepimps.org> - * Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org> - * - * 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 <tqtimer.h> - -#include "kis_tool_non_paint.h" - -#include "kis_tool_factory.h" - -class KisCanvasSubject; - -class KisToolZoom : public KisToolNonPaint { - - typedef KisToolNonPaint super; - Q_OBJECT - TQ_OBJECT - -public: - KisToolZoom(); - virtual ~KisToolZoom(); - -public: - virtual void update(KisCanvasSubject *subject); - -public: - virtual void setup(KActionCollection *collection); - virtual enumToolType toolType() { return TOOL_VIEW; } - virtual TQ_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 TQRect& rc); - -private: - void paintOutline(); - void paintOutline(KisCanvasPainter& gc, const TQRect& rc); - - -public slots: - - void activate(); - void deactivate(); - - -private slots: - void slotTimer(); - -private: - KisCanvasSubject *m_subject; - TQPoint m_startPos; - TQPoint m_endPos; - bool m_dragging; - TQCursor m_plusCursor; - TQCursor m_minusCursor; - TQTimer 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 deleted file mode 100644 index 79c94c17..00000000 --- a/krita/plugins/tools/defaulttools/kritadefaulttools.desktop +++ /dev/null @@ -1,56 +0,0 @@ -[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 deleted file mode 100644 index 607879d5..00000000 --- a/krita/plugins/tools/defaulttools/openhand_cursor.xpm +++ /dev/null @@ -1,28 +0,0 @@ -/* 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 Binary files differdeleted file mode 100644 index fdbe9ae5..00000000 --- a/krita/plugins/tools/defaulttools/tool_color_fill.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_colorpicker.png b/krita/plugins/tools/defaulttools/tool_colorpicker.png Binary files differdeleted file mode 100644 index 06164f7e..00000000 --- a/krita/plugins/tools/defaulttools/tool_colorpicker.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_duplicate.png b/krita/plugins/tools/defaulttools/tool_duplicate.png Binary files differdeleted file mode 100644 index 1710cf5d..00000000 --- a/krita/plugins/tools/defaulttools/tool_duplicate.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_duplicate_cursor.png b/krita/plugins/tools/defaulttools/tool_duplicate_cursor.png Binary files differdeleted file mode 100644 index 31418815..00000000 --- a/krita/plugins/tools/defaulttools/tool_duplicate_cursor.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_ellipse.png b/krita/plugins/tools/defaulttools/tool_ellipse.png Binary files differdeleted file mode 100644 index a8ac0bd1..00000000 --- a/krita/plugins/tools/defaulttools/tool_ellipse.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_ellipse_cursor.png b/krita/plugins/tools/defaulttools/tool_ellipse_cursor.png Binary files differdeleted file mode 100644 index b97f215b..00000000 --- a/krita/plugins/tools/defaulttools/tool_ellipse_cursor.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_fill_cursor.png b/krita/plugins/tools/defaulttools/tool_fill_cursor.png Binary files differdeleted file mode 100644 index 66691cb1..00000000 --- a/krita/plugins/tools/defaulttools/tool_fill_cursor.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_freehand.png b/krita/plugins/tools/defaulttools/tool_freehand.png Binary files differdeleted file mode 100644 index c313410d..00000000 --- a/krita/plugins/tools/defaulttools/tool_freehand.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_freehand_cursor.png b/krita/plugins/tools/defaulttools/tool_freehand_cursor.png Binary files differdeleted file mode 100644 index 194bb200..00000000 --- a/krita/plugins/tools/defaulttools/tool_freehand_cursor.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_gradient.png b/krita/plugins/tools/defaulttools/tool_gradient.png Binary files differdeleted file mode 100644 index a45075a8..00000000 --- a/krita/plugins/tools/defaulttools/tool_gradient.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_gradient_cursor.png b/krita/plugins/tools/defaulttools/tool_gradient_cursor.png Binary files differdeleted file mode 100644 index fd20079a..00000000 --- a/krita/plugins/tools/defaulttools/tool_gradient_cursor.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_line.png b/krita/plugins/tools/defaulttools/tool_line.png Binary files differdeleted file mode 100644 index 49f6fe2b..00000000 --- a/krita/plugins/tools/defaulttools/tool_line.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_line_cursor.png b/krita/plugins/tools/defaulttools/tool_line_cursor.png Binary files differdeleted file mode 100644 index 66ec6b05..00000000 --- a/krita/plugins/tools/defaulttools/tool_line_cursor.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_move.png b/krita/plugins/tools/defaulttools/tool_move.png Binary files differdeleted file mode 100644 index 386224ed..00000000 --- a/krita/plugins/tools/defaulttools/tool_move.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_pan.png b/krita/plugins/tools/defaulttools/tool_pan.png Binary files differdeleted file mode 100644 index c45a9c69..00000000 --- a/krita/plugins/tools/defaulttools/tool_pan.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_rectangle.png b/krita/plugins/tools/defaulttools/tool_rectangle.png Binary files differdeleted file mode 100644 index 4da56ecd..00000000 --- a/krita/plugins/tools/defaulttools/tool_rectangle.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_rectangle_cursor.png b/krita/plugins/tools/defaulttools/tool_rectangle_cursor.png Binary files differdeleted file mode 100644 index 0dba614b..00000000 --- a/krita/plugins/tools/defaulttools/tool_rectangle_cursor.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_text.png b/krita/plugins/tools/defaulttools/tool_text.png Binary files differdeleted file mode 100644 index c1683fc0..00000000 --- a/krita/plugins/tools/defaulttools/tool_text.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_text_cursor.png b/krita/plugins/tools/defaulttools/tool_text_cursor.png Binary files differdeleted file mode 100644 index e241beaf..00000000 --- a/krita/plugins/tools/defaulttools/tool_text_cursor.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_zoom.png b/krita/plugins/tools/defaulttools/tool_zoom.png Binary files differdeleted file mode 100644 index 10689553..00000000 --- a/krita/plugins/tools/defaulttools/tool_zoom.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_zoom_minus_cursor.png b/krita/plugins/tools/defaulttools/tool_zoom_minus_cursor.png Binary files differdeleted file mode 100644 index 7089eaf3..00000000 --- a/krita/plugins/tools/defaulttools/tool_zoom_minus_cursor.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/tool_zoom_plus_cursor.png b/krita/plugins/tools/defaulttools/tool_zoom_plus_cursor.png Binary files differdeleted file mode 100644 index 52c59b45..00000000 --- a/krita/plugins/tools/defaulttools/tool_zoom_plus_cursor.png +++ /dev/null diff --git a/krita/plugins/tools/defaulttools/wdgcolorpicker.ui b/krita/plugins/tools/defaulttools/wdgcolorpicker.ui deleted file mode 100644 index a2b9d7d3..00000000 --- a/krita/plugins/tools/defaulttools/wdgcolorpicker.ui +++ /dev/null @@ -1,167 +0,0 @@ -<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> -<class>ColorPickerOptionsWidget</class> -<widget class="TQWidget"> - <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="TQComboBox"> - <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="tqminimumSize"> - <size> - <width>200</width> - <height>0</height> - </size> - </property> - <property name="tqmaximumSize"> - <size> - <width>200</width> - <height>32767</height> - </size> - </property> - </widget> - <widget class="TQCheckBox"> - <property name="name"> - <cstring>cbUpdateCurrentColour</cstring> - </property> - <property name="text"> - <string>Update current color</string> - </property> - </widget> - <widget class="TQLayoutWidget"> - <property name="name"> - <cstring>tqlayout2</cstring> - </property> - <hbox> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="TQCheckBox"> - <property name="name"> - <cstring>cbPalette</cstring> - </property> - <property name="text"> - <string>Add to palette:</string> - </property> - </widget> - <widget class="TQComboBox"> - <property name="name"> - <cstring>cmbPalette</cstring> - </property> - </widget> - </hbox> - </widget> - <widget class="TQCheckBox"> - <property name="name"> - <cstring>cbNormaliseValues</cstring> - </property> - <property name="text"> - <string>Show colors as percentages</string> - </property> - </widget> - <widget class="TQLayoutWidget"> - <property name="name"> - <cstring>tqlayout1</cstring> - </property> - <hbox> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="TQLabel"> - <property name="name"> - <cstring>textLabel1</cstring> - </property> - <property name="text"> - <string>Sample radius:</string> - </property> - </widget> - <widget class="TQSpinBox"> - <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="TQListView"> - <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> -<tqlayoutdefaults spacing="6" margin="11"/> -</UI> |