From 698569f8428ca088f764d704034a1330517b98c0 Mon Sep 17 00:00:00 2001 From: tpearson Date: Sun, 26 Jun 2011 00:41:16 +0000 Subject: Finish rebranding of Krita as Chalk git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238363 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- chalk/plugins/tools/selectiontools/Makefile.am | 56 + .../selectiontools/chalkselectiontools.desktop | 52 + .../selectiontools/kis_tool_move_selection.cc | 223 +++ .../tools/selectiontools/kis_tool_move_selection.h | 75 + .../tools/selectiontools/kis_tool_select_brush.cc | 168 ++ .../tools/selectiontools/kis_tool_select_brush.h | 83 + .../selectiontools/kis_tool_select_contiguous.cc | 234 +++ .../selectiontools/kis_tool_select_contiguous.h | 95 + .../selectiontools/kis_tool_select_elliptical.cc | 321 ++++ .../selectiontools/kis_tool_select_elliptical.h | 99 + .../tools/selectiontools/kis_tool_select_eraser.cc | 156 ++ .../tools/selectiontools/kis_tool_select_eraser.h | 82 + .../selectiontools/kis_tool_select_outline.cc | 295 +++ .../tools/selectiontools/kis_tool_select_outline.h | 101 + .../selectiontools/kis_tool_select_polygonal.cc | 315 ++++ .../selectiontools/kis_tool_select_polygonal.h | 106 ++ .../selectiontools/kis_tool_select_rectangular.cc | 323 ++++ .../selectiontools/kis_tool_select_rectangular.h | 95 + .../tools/selectiontools/selection_tools.cc | 77 + .../plugins/tools/selectiontools/selection_tools.h | 44 + .../tools/selectiontools/tool_brush_selection.png | Bin 0 -> 1052 bytes .../tools/selectiontools/tool_brush_selection.svg | 827 ++++++++ .../selectiontools/tool_brush_selection_cursor.png | Bin 0 -> 339 bytes .../selectiontools/tool_contiguous_selection.png | Bin 0 -> 836 bytes .../tool_contiguous_selection_cursor.png | Bin 0 -> 321 bytes .../selectiontools/tool_elliptical_selection.png | Bin 0 -> 703 bytes .../selectiontools/tool_elliptical_selection.svg | 256 +++ .../tool_elliptical_selection_cursor.png | Bin 0 -> 296 bytes .../tools/selectiontools/tool_eraser_selection.png | Bin 0 -> 1087 bytes .../tools/selectiontools/tool_eraser_selection.svg | 1993 ++++++++++++++++++++ .../tool_eraser_selection_cursor.png | Bin 0 -> 341 bytes .../selectiontools/tool_outline_selection.png | Bin 0 -> 556 bytes .../selectiontools/tool_outline_selection.svg | 329 ++++ .../tool_outline_selection_cursor.png | Bin 0 -> 359 bytes .../selectiontools/tool_polygonal_selection.png | Bin 0 -> 576 bytes .../selectiontools/tool_polygonal_selection.svg | 364 ++++ .../tool_polygonal_selection_cursor.png | Bin 0 -> 433 bytes .../tools/selectiontools/tool_rect_selection.png | Bin 0 -> 523 bytes .../tools/selectiontools/tool_rect_selection.svg | 191 ++ .../tool_rectangular_selection_cursor.png | Bin 0 -> 224 bytes 40 files changed, 6960 insertions(+) create mode 100644 chalk/plugins/tools/selectiontools/Makefile.am create mode 100644 chalk/plugins/tools/selectiontools/chalkselectiontools.desktop create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_move_selection.cc create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_move_selection.h create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_brush.cc create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_brush.h create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_contiguous.cc create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_contiguous.h create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.cc create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.h create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_eraser.cc create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_eraser.h create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_outline.cc create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_outline.h create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_polygonal.cc create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_polygonal.h create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.cc create mode 100644 chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.h create mode 100644 chalk/plugins/tools/selectiontools/selection_tools.cc create mode 100644 chalk/plugins/tools/selectiontools/selection_tools.h create mode 100644 chalk/plugins/tools/selectiontools/tool_brush_selection.png create mode 100644 chalk/plugins/tools/selectiontools/tool_brush_selection.svg create mode 100644 chalk/plugins/tools/selectiontools/tool_brush_selection_cursor.png create mode 100644 chalk/plugins/tools/selectiontools/tool_contiguous_selection.png create mode 100644 chalk/plugins/tools/selectiontools/tool_contiguous_selection_cursor.png create mode 100644 chalk/plugins/tools/selectiontools/tool_elliptical_selection.png create mode 100644 chalk/plugins/tools/selectiontools/tool_elliptical_selection.svg create mode 100644 chalk/plugins/tools/selectiontools/tool_elliptical_selection_cursor.png create mode 100644 chalk/plugins/tools/selectiontools/tool_eraser_selection.png create mode 100644 chalk/plugins/tools/selectiontools/tool_eraser_selection.svg create mode 100644 chalk/plugins/tools/selectiontools/tool_eraser_selection_cursor.png create mode 100644 chalk/plugins/tools/selectiontools/tool_outline_selection.png create mode 100644 chalk/plugins/tools/selectiontools/tool_outline_selection.svg create mode 100644 chalk/plugins/tools/selectiontools/tool_outline_selection_cursor.png create mode 100644 chalk/plugins/tools/selectiontools/tool_polygonal_selection.png create mode 100644 chalk/plugins/tools/selectiontools/tool_polygonal_selection.svg create mode 100644 chalk/plugins/tools/selectiontools/tool_polygonal_selection_cursor.png create mode 100644 chalk/plugins/tools/selectiontools/tool_rect_selection.png create mode 100644 chalk/plugins/tools/selectiontools/tool_rect_selection.svg create mode 100644 chalk/plugins/tools/selectiontools/tool_rectangular_selection_cursor.png (limited to 'chalk/plugins/tools/selectiontools') diff --git a/chalk/plugins/tools/selectiontools/Makefile.am b/chalk/plugins/tools/selectiontools/Makefile.am new file mode 100644 index 00000000..dc0ad90e --- /dev/null +++ b/chalk/plugins/tools/selectiontools/Makefile.am @@ -0,0 +1,56 @@ +kde_services_DATA = chalkselectiontools.desktop + +# all_includes must remain last! +INCLUDES = -I$(srcdir)/../../../sdk \ + -I$(srcdir)/../../../core \ + -I$(srcdir)/../../../chalkcolor/ \ + -I$(srcdir)/../../../ui \ + -I$/../../../ui \ + $(KOFFICE_INCLUDES) \ + $(all_includes) + +chalkselectiontools_la_SOURCES = kis_tool_move_selection.cc \ + kis_tool_select_brush.cc kis_tool_select_contiguous.cc kis_tool_select_elliptical.cc \ + kis_tool_select_eraser.cc kis_tool_select_outline.cc kis_tool_select_polygonal.cc \ + kis_tool_select_rectangular.cc selection_tools.cc + +# Install this plugin in the KDE modules directory +kde_module_LTLIBRARIES = chalkselectiontools.la + +noinst_HEADERS = \ + selection_tools.h \ + kis_tool_select_outline.h \ + kis_tool_select_polygonal.h \ + kis_tool_select_rectangular.h \ + kis_tool_select_brush.h \ + kis_tool_select_eraser.h \ + kis_tool_select_contiguous.h \ + kis_tool_select_elliptical.h + + +chalkselectiontools_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN) $(LIB_QT) -lkdecore -lkdeui -lkjs -lkdefx -lkio -lkparts -L../../../../chalk/chalkcolor/.libs -lchalkcolor -L../../../../chalk/core/.libs -lchalkimage \ + -L../../../../chalk/ui/.libs -lchalkui +chalkselectiontools_la_LIBADD = ../../../libchalkcommon.la + +chalkselectiontools_la_METASOURCES = AUTO + +KDE_OPTIONS = nofinal + +chalkpics_DATA = \ + tool_rect_selection.png \ + tool_eraser_selection.png \ + tool_brush_selection.png \ + tool_contiguous_selection.png \ + tool_elliptical_selection.png \ + tool_outline_selection.png \ + tool_polygonal_selection.png \ + tool_rectangular_selection_cursor.png \ + tool_eraser_selection_cursor.png \ + tool_brush_selection_cursor.png \ + tool_contiguous_selection_cursor.png \ + tool_elliptical_selection_cursor.png \ + tool_outline_selection_cursor.png \ + tool_polygonal_selection_cursor.png + +chalkpicsdir = $(kde_datadir)/chalk/pics + diff --git a/chalk/plugins/tools/selectiontools/chalkselectiontools.desktop b/chalk/plugins/tools/selectiontools/chalkselectiontools.desktop new file mode 100644 index 00000000..72a7f217 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/chalkselectiontools.desktop @@ -0,0 +1,52 @@ +[Desktop Entry] +Name=Selection Tools +Name[bg]=Инструмент за маркиране +Name[br]=Ostilhoù choazh +Name[ca]=Eines de selecció +Name[cy]=Offer Detholi +Name[da]=Markeringsværktøj +Name[de]=Auswahlwerkzeuge +Name[el]=Εργαλεία επιλογής +Name[eo]=Elektado-iloj +Name[es]=Herramientas de selección +Name[et]=Valikutööriistad +Name[eu]=Hautapen-tresnak +Name[fa]=ابزارهای گزینش +Name[fi]=Valintatyökalut +Name[fr]=Outils de sélection +Name[fy]=Seleksje-ark +Name[ga]=Uirlisí Roghnúcháin +Name[gl]=Ferramentas de Selección +Name[he]=כלי בחירה +Name[hu]=Kiválasztó eszközök +Name[is]=Valtól +Name[it]=Strumenti di selezione +Name[ja]=選択ツール +Name[km]=ឧបករណ៍​ជ្រើស​ +Name[lt]=Pažymėjimo įrankiai +Name[lv]=Izvēles rīki +Name[ms]=Alat Pemilihan +Name[nb]=Velgeverktøy +Name[nds]=Utwahlwarktüüch +Name[ne]=चयन उपकरण +Name[nl]=Selectiegereedschappen +Name[nn]=Veljeverktøy +Name[pl]=Narzędzia wyboru +Name[pt]=Ferramentas de Selecção +Name[pt_BR]=Ferramentas de Seleção +Name[ru]=Инструменты выделения +Name[se]=Válljenreaiddut +Name[sk]=Štetec výberu +Name[sl]=Orodja za izbiro +Name[sr]=Алати за избор +Name[sr@Latn]=Alati za izbor +Name[sv]=Markeringsverktyg +Name[uk]=Засоби виділення +Name[uz]=Tanlash vositalari +Name[uz@cyrillic]=Танлаш воситалари +Name[zh_CN]=选择工具 +Name[zh_TW]=選取區工具 +ServiceTypes=Chalk/Tool +Type=Service +X-KDE-Library=chalkselectiontools +X-Chalk-Version=2 diff --git a/chalk/plugins/tools/selectiontools/kis_tool_move_selection.cc b/chalk/plugins/tools/selectiontools/kis_tool_move_selection.cc new file mode 100644 index 00000000..b7b123d7 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_move_selection.cc @@ -0,0 +1,223 @@ +/* + * Copyright (c) 2006 Cyrille Berger + * + * 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 "kis_tool_move_selection.h" + +#include +#include +#include +#include +#include +#include +#include "kis_canvas_subject.h" +#include "kis_cursor.h" +#include "kis_image.h" +#include "kis_layer.h" +#include "kis_paint_layer.h" +#include "kis_paint_device.h" +#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_undo_adapter.h" + +class KisSelectionOffsetCommand : public KNamedCommand { + typedef KNamedCommand super; + +public: + KisSelectionOffsetCommand(KisSelectionSP layer, const TQPoint& oldpos, const TQPoint& newpos); + virtual ~KisSelectionOffsetCommand(); + + virtual void execute(); + virtual void unexecute(); + +private: + void moveTo(const TQPoint& pos); + +private: + KisSelectionSP m_layer; + TQPoint m_oldPos; + TQPoint m_newPos; +}; + + KisSelectionOffsetCommand::KisSelectionOffsetCommand(KisSelectionSP layer, const TQPoint& oldpos, const TQPoint& newpos) : + super(i18n("Move Layer")) + { + m_layer = layer; + m_oldPos = oldpos; + m_newPos = newpos; + + } + + KisSelectionOffsetCommand::~KisSelectionOffsetCommand() + { + } + + void KisSelectionOffsetCommand::execute() + { + moveTo(m_newPos); + } + + void KisSelectionOffsetCommand::unexecute() + { + moveTo(m_oldPos); + } + + void KisSelectionOffsetCommand::moveTo(const TQPoint& pos) + { + if (m_layer->undoAdapter()) { + m_layer->undoAdapter()->setUndo(false); + } + + m_layer->setX(pos.x()); + m_layer->setY(pos.y()); + + m_layer->tqparentPaintDevice()->setDirty(); + + if (m_layer->undoAdapter()) { + m_layer->undoAdapter()->setUndo(true); + } + } + + +KisToolMoveSelection::KisToolMoveSelection() + : super(i18n("Move Selection Tool")) +{ + setName("tool_move_selection"); + m_subject = 0; + setCursor(KisCursor::moveCursor()); +} + +KisToolMoveSelection::~KisToolMoveSelection() +{ +} + +void KisToolMoveSelection::update(KisCanvasSubject *subject) +{ + m_subject = subject; + super::update(subject); + m_dragging = false; +} + +void KisToolMoveSelection::buttonPress(KisButtonPressEvent *e) +{ + m_dragging = false; + if (m_subject && e->button() == Qt::LeftButton) { + TQPoint pos = e->pos().floorTQPoint(); + KisImageSP img = m_subject->currentImg(); + KisPaintLayerSP lay; + + if (!img || !(lay = dynamic_cast( img->activeLayer().data() ))) + return; + + m_dragStart = pos; + + if ( !lay->visible() || !lay->paintDevice()->hasSelection()) + return; + KisSelectionSP sel = lay->paintDevice()->selection(); + + m_dragging = true; + m_dragStart.setX(pos.x()); + m_dragStart.setY(pos.y()); + m_layerStart.setX(sel->getX()); + m_layerStart.setY(sel->getY()); + m_layerPosition = m_layerStart; + + } +} + +void KisToolMoveSelection::move(KisMoveEvent *e) +{ + if (m_subject && m_dragging) { + 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()); + } + + KisImageSP img = m_subject->currentImg(); + KisPaintLayerSP lay = dynamic_cast(m_subject->currentImg()->activeLayer().data()); + if(!lay) return; + KisSelectionSP sel = lay->paintDevice()->selection(); + + TQRect rc; + + pos -= m_dragStart; // convert to delta + rc = sel->selectedRect(); + sel->setX(sel->getX() + pos.x()); + sel->setY(sel->getY() + pos.y()); + rc = rc.unite(sel->selectedRect()); + + m_layerPosition = TQPoint(sel->getX(), sel->getY()); + m_dragStart = e->pos().floorTQPoint(); + + lay->paintDevice()->setDirty(rc); + } + +} + +void KisToolMoveSelection::buttonRelease(KisButtonReleaseEvent *e) +{ + if (m_subject && e->button() == Qt::LeftButton && m_dragging) { + m_dragging = false; + KisImageSP img = m_subject->currentImg(); + if(!img) return; + KisPaintLayerSP lay = dynamic_cast(img->activeLayer().data()); + + if (lay->paintDevice()->hasSelection()) { + KisSelectionSP dev = lay->paintDevice()->selection(); + m_dragging = false; + + if (img->undo()) { + KCommand *cmd = new KisSelectionOffsetCommand( dev, m_layerStart, m_layerPosition); + Q_CHECK_PTR(cmd); + KisUndoAdapter *adapter = img->undoAdapter(); + if (adapter) { + adapter->addCommand(cmd); + } else { + delete cmd; + } + } + img->setModified(); + lay->setDirty(); + } + } +} + +void KisToolMoveSelection::setup(KActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new KRadioAction(i18n("&Move selection"), + "tool_move", + TQt::SHIFT+TQt::Key_V, + this, + TQT_SLOT(activate()), + collection, + name()); + m_action->setToolTip(i18n("Move the selection")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +#include "kis_tool_move_selection.moc" diff --git a/chalk/plugins/tools/selectiontools/kis_tool_move_selection.h b/chalk/plugins/tools/selectiontools/kis_tool_move_selection.h new file mode 100644 index 00000000..60d73a9b --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_move_selection.h @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2006 Cyrille Berger + * + * 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 "kis_tool_non_paint.h" +#include "kis_tool_factory.h" + +// XXX: Moving is not nearly smooth enough! +class KisToolMoveSelection : public KisToolNonPaint { + + typedef KisToolNonPaint super; + Q_OBJECT + TQ_OBJECT + +public: + KisToolMoveSelection(); + virtual ~KisToolMoveSelection(); + +public: + virtual void update(KisCanvasSubject *subject); + +public: + virtual void setup(KActionCollection *collection); + virtual enumToolType toolType() { return TOOL_SELECT; } + virtual TQ_UINT32 priority() { return 10; } + + virtual void buttonPress(KisButtonPressEvent *e); + virtual void move(KisMoveEvent *e); + virtual void buttonRelease(KisButtonReleaseEvent *e); + +private: + KisCanvasSubject *m_subject; + TQPoint m_dragStart; + TQPoint m_layerStart; + TQPoint m_layerPosition; + bool m_dragging; +}; + + +class KisToolMoveSelectionFactory : public KisToolFactory { + typedef KisToolFactory super; +public: + KisToolMoveSelectionFactory() : super() {}; + virtual ~KisToolMoveSelectionFactory(){}; + + virtual KisTool * createTool(KActionCollection * ac) { + KisTool * t = new KisToolMoveSelection(); + Q_CHECK_PTR(t); + t->setup(ac); + return t; + } + virtual KisID id() { return KisID("moveselection", i18n("Move Selection Tool")); } +}; + + + +#endif // KIS_TOOL_MOVE_H_ + diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_brush.cc b/chalk/plugins/tools/selectiontools/kis_tool_select_brush.cc new file mode 100644 index 00000000..ff5242d6 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_brush.cc @@ -0,0 +1,168 @@ +/* + * kis_tool_select_brush.cc - part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "kis_brush.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_cmb_composite.h" +#include "kis_cursor.h" +#include "kis_doc.h" +#include "kis_paintop.h" +#include "kis_paintop_registry.h" +#include "kis_move_event.h" +#include "kis_painter.h" +#include "kis_selection.h" +#include "kis_tool_select_brush.h" +#include "kis_types.h" +#include "kis_layer.h" +#include "kis_view.h" +#include "kis_selection_options.h" +#include "kis_selected_transaction.h" + +KisToolSelectBrush::KisToolSelectBrush() + : super(i18n("SelectBrush")) +{ + setName("tool_select_brush"); + m_optWidget = 0; + setCursor(KisCursor::load("tool_brush_selection_cursor.png", 5, 5)); + m_paintOnSelection = true; +} + +KisToolSelectBrush::~KisToolSelectBrush() +{ +} + +void KisToolSelectBrush::activate() +{ + super::activate(); + + if (!m_optWidget) + return; + + m_optWidget->slotActivated(); +} + +void KisToolSelectBrush::initPaint(KisEvent* /*e*/) +{ + if (!m_currentImage || !m_currentImage->activeDevice()) return; + + m_mode = PAINT; + m_dragDist = 0; + + // Create painter + KisPaintDeviceSP dev = m_currentImage->activeDevice(); + if (m_painter) + delete m_painter; + bool hasSelection = dev->hasSelection(); + if (m_currentImage->undo()) m_transaction = new KisSelectedTransaction(i18n("Selection Brush"), dev); + if(! hasSelection) + { + dev->selection()->clear(); + dev->emitSelectionChanged(); + } + KisSelectionSP selection = dev->selection(); + + m_target = selection; + m_painter = new KisPainter(selection.data()); + Q_CHECK_PTR(m_painter); + m_painter->setPaintColor(KisColor(TQt::black, selection->colorSpace())); + m_painter->setBrush(m_subject->currentBrush()); + m_painter->setOpacity(OPACITY_OPAQUE);//m_subject->fgColor().colorSpace()->intensity8(m_subject->fgColor().data())); + m_painter->setCompositeOp(COMPOSITE_OVER); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp("paintbrush", 0, painter()); + painter()->setPaintOp(op); // And now the painter owns the op and will destroy it. + + // Set the cursor -- ideally. this should be a tqmask created from the brush, + // now that X11 can handle colored cursors. +#if 0 + // Setting cursors has no effect until the tool is selected again; this + // should be fixed. + setCursor(KisCursor::brushCursor()); +#endif +} + +void KisToolSelectBrush::endPaint() +{ + m_mode = HOVER; + if (m_currentImage && m_currentImage->activeLayer()) { + if (m_currentImage->undo() && m_painter) { + // If painting in mouse release, make sure painter + // is destructed or end()ed + m_currentImage->undoAdapter()->addCommand(m_transaction); + } + delete m_painter; + m_painter = 0; + if (m_currentImage->activeDevice()) + m_currentImage->activeDevice()->emitSelectionChanged(); + notifyModified(); + } +} + + +void KisToolSelectBrush::setup(KActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new KRadioAction(i18n("&Selection Brush"), + "tool_brush_selection", "Ctrl+Shift+B", this, + TQT_SLOT(activate()), collection, + name()); + Q_CHECK_PTR(m_action); + m_action->setToolTip(i18n("Paint a selection")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +TQWidget* KisToolSelectBrush::createOptionWidget(TQWidget* tqparent) +{ + Q_UNUSED(tqparent); + // Commented out due to the fact that this doesn't actually work if you change the action +#if 0 + m_optWidget = new KisSelectionOptions(tqparent, m_subject); + Q_CHECK_PTR(m_optWidget); + m_optWidget->setCaption(i18n("Selection Brush")); + + TQVBoxLayout * l = dynamic_cast(m_optWidget->tqlayout()); + l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); + + return m_optWidget; +#endif + return 0; +} + +TQWidget* KisToolSelectBrush::optionWidget() +{ + return m_optWidget; +} + +#include "kis_tool_select_brush.moc" diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_brush.h b/chalk/plugins/tools/selectiontools/kis_tool_select_brush.h new file mode 100644 index 00000000..374050f6 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_brush.h @@ -0,0 +1,83 @@ +/* + * kis_tool_select_brush.h - part of Chalk + * + * Copyright (c) 2003-2004 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KIS_TOOL_SELECT_BRUSH_H_ +#define KIS_TOOL_SELECT_BRUSH_H_ + +#include +#include +#include + +class TQWidget; +class KisPoint; +class KisSelectedTransaction; +class KisSelectionOptions; + +/** + * The selection brush creates a selection by painting with the current + * brush tqshape. Not sure what kind of an icon could represent this... + * Depends a bit on how we're going to visualize selections. + */ +class KisToolSelectBrush : public KisToolFreehand { + Q_OBJECT + TQ_OBJECT + typedef KisToolFreehand super; + +public: + KisToolSelectBrush(); + virtual ~KisToolSelectBrush(); + + virtual void setup(KActionCollection *collection); + virtual TQ_UINT32 priority() { return 1; } + virtual enumToolType toolType() { return TOOL_SELECT; } + virtual TQWidget* createOptionWidget(TQWidget* tqparent); + virtual TQWidget* optionWidget(); + +public slots: + virtual void activate(); + +protected: + + virtual void initPaint(KisEvent *e); + virtual void endPaint(); + +private: + KisSelectionOptions * m_optWidget; + KisSelectedTransaction *m_transaction; +}; + +class KisToolSelectBrushFactory : public KisToolFactory { + typedef KisToolFactory super; +public: + KisToolSelectBrushFactory() : super() {}; + virtual ~KisToolSelectBrushFactory(){}; + + virtual KisTool * createTool(KActionCollection * ac) { + KisTool * t = new KisToolSelectBrush(); + Q_CHECK_PTR(t); + t->setup(ac); + return t; + } + virtual KisID id() { return KisID("brushselect", i18n("Brush Select Tool")); } +}; + + +#endif // KIS_TOOL_SELECT_BRUSH_H_ + diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_contiguous.cc b/chalk/plugins/tools/selectiontools/kis_tool_select_contiguous.cc new file mode 100644 index 00000000..c4c908fc --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_contiguous.cc @@ -0,0 +1,234 @@ +/* + * kis_tool_select_contiguous - part of Krayon^WChalk + * + * Copyright (c) 1999 Michael Koch + * Copyright (c) 2002 Patrick Julien + * Copyright (c) 2004 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "kis_tool_select_contiguous.h" + +KisToolSelectContiguous::KisToolSelectContiguous() : super(i18n("Contiguous Select")) +{ + setName("tool_select_contiguous"); + m_subject = 0; + m_optWidget = 0; + m_fuzziness = 20; + m_sampleMerged = false; + m_selectAction = SELECTION_ADD; + + setCursor(KisCursor::load("tool_contiguous_selection_cursor.png", 6, 6)); +} + +KisToolSelectContiguous::~KisToolSelectContiguous() +{ +} + +void KisToolSelectContiguous::activate() +{ + super::activate(); + + if (!m_optWidget) + return; + + m_optWidget->slotActivated(); +} + +void KisToolSelectContiguous::buttonPress(KisButtonPressEvent * e) +{ + if (m_subject) { + + KisImageSP img; + KisPaintDeviceSP dev; + TQPoint pos; + + if (e->button() != Qt::LeftButton && e->button() != Qt::RightButton) + return; + + if (!(img = m_subject->currentImg())) + return; + + dev = img->activeDevice(); + + if (!dev || !img->activeLayer()->visible()) + return; + + TQApplication::setOverrideCursor(KisCursor::waitCursor()); + + pos = TQPoint(e->pos().floorX(), e->pos().floorY()); + + KisFillPainter fillpainter(dev); + fillpainter.setFillThreshold(m_fuzziness); + fillpainter.setSampleMerged(m_sampleMerged); + KisSelectionSP selection = fillpainter.createFloodSelection(pos.x(), pos.y()); + KisSelectedTransaction *t = 0; + if (img->undo()) t = new KisSelectedTransaction(i18n("Contiguous Area Selection"), dev); + + if (!dev->hasSelection()) { + dev->selection()->clear(); + if(m_selectAction==SELECTION_SUBTRACT) + selection->invert(); + } + + switch (m_selectAction) { + case SELECTION_SUBTRACT: + dev->subtractSelection(selection); + break; + case SELECTION_ADD: + default: + dev->addSelection(selection); + break; + + } + + dev->setDirty(selection->selectedRect()); // A bit too wide, but that's not that bad + dev->emitSelectionChanged(); + + + if (img->undo()) + img->undoAdapter()->addCommand(t); + + TQApplication::restoreOverrideCursor(); + } + +} + +void KisToolSelectContiguous::setup(KActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new KRadioAction(i18n("&Contiguous Area Selection"), + "tool_contiguous_selection" , + 0, + this, + TQT_SLOT(activate()), + collection, + name()); + Q_CHECK_PTR(m_action); + m_action->setToolTip(i18n("Select a contiguous area")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +void KisToolSelectContiguous::update(KisCanvasSubject *subject) +{ + super::update(subject); + m_subject = subject; +} + +void KisToolSelectContiguous::slotSetFuzziness(int fuzziness) +{ + m_fuzziness = fuzziness; +} + + +void KisToolSelectContiguous::slotSetAction(int action) +{ + if (action >= SELECTION_ADD && action <= SELECTION_SUBTRACT) + m_selectAction =(enumSelectionMode)action; +// XXX: Fix cursors when then are done. +// switch(m_selectAction) { +// case SELECTION_ADD: +// m_subject->setCanvasCursor(KisCursor::pickerPlusCursor()); +// break; +// case SELECTION_SUBTRACT: +// m_subject->setCanvasCursor(KisCursor::pickerMinusCursor()); +// }; +} + + +TQWidget* KisToolSelectContiguous::createOptionWidget(TQWidget* tqparent) +{ + m_optWidget = new KisSelectionOptions(tqparent, m_subject); + Q_CHECK_PTR(m_optWidget); + m_optWidget->setCaption(i18n("Contiguous Area Selection")); + + TQVBoxLayout * l = dynamic_cast(m_optWidget->tqlayout()); + l->setSpacing( 6 ); + + connect (m_optWidget, TQT_SIGNAL(actionChanged(int)), this, TQT_SLOT(slotSetAction(int))); + + TQHBoxLayout * hbox = new TQHBoxLayout(l); + Q_CHECK_PTR(hbox); + + TQLabel * lbl = new TQLabel(i18n("Fuzziness: "), m_optWidget); + hbox->addWidget(lbl); + + KIntNumInput * input = new KIntNumInput(m_optWidget, "fuzziness"); + Q_CHECK_PTR(input); + + input->setRange(0, 200, 10, true); + input->setValue(20); + hbox->addWidget(input); + connect(input, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotSetFuzziness(int))); + + TQCheckBox* samplemerged = new TQCheckBox(i18n("Sample merged"), m_optWidget); + l->addWidget( samplemerged ); + samplemerged->setChecked(m_sampleMerged); + connect(samplemerged, TQT_SIGNAL(stateChanged(int)), + this, TQT_SLOT(slotSetSampleMerged(int))); + + l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); + + return m_optWidget; +} + +TQWidget* KisToolSelectContiguous::optionWidget() +{ + return m_optWidget; +} + +void KisToolSelectContiguous::slotSetSampleMerged(int state) +{ + if (state == TQButton::NoChange) + return; + m_sampleMerged = (state == TQButton::On); +} + +#include "kis_tool_select_contiguous.moc" diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_contiguous.h b/chalk/plugins/tools/selectiontools/kis_tool_select_contiguous.h new file mode 100644 index 00000000..e4beb6b7 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_contiguous.h @@ -0,0 +1,95 @@ +/* + * kis_tool_select_contiguous.h - part of KImageShop^WKrayon^Chalk + * + * Copyright (c) 1999 Michael Koch + * 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_SELECT_CONTIGUOUS_H__ +#define __KIS_TOOL_SELECT_CONTIGUOUS_H__ + +#include +#include +#include +#include + +class KisCanvasSubject; +class TQWidget; +class TQVBoxLayout; +class TQCheckBox; +class KisSelectionOptions; + +/** + * The 'magic wand' selection tool -- in fact just + * a floodfill that only creates a selection. + */ +class KisToolSelectContiguous : public KisToolNonPaint { + + typedef KisToolNonPaint super; + Q_OBJECT + TQ_OBJECT + +public: + KisToolSelectContiguous(); + virtual ~KisToolSelectContiguous(); + +public: + virtual void update(KisCanvasSubject *subject); + + virtual void setup(KActionCollection *collection); + virtual TQ_UINT32 priority() { return 7; } + virtual enumToolType toolType() { return TOOL_SELECT; }; + + virtual TQWidget* createOptionWidget(TQWidget* tqparent); + virtual TQWidget* optionWidget(); + + virtual void buttonPress(KisButtonPressEvent *event); + +public slots: + virtual void slotSetFuzziness(int); + virtual void slotSetAction(int); + virtual void slotSetSampleMerged(int); + virtual void activate(); + + +private: + KisCanvasSubject *m_subject; + KisSelectionOptions * m_optWidget; + + int m_fuzziness; + enumSelectionMode m_selectAction; + bool m_sampleMerged; +}; + +class KisToolSelectContiguousFactory : public KisToolFactory { + typedef KisToolFactory super; +public: + KisToolSelectContiguousFactory() : super() {}; + virtual ~KisToolSelectContiguousFactory(){}; + + virtual KisTool * createTool(KActionCollection * ac) { + KisTool * t = new KisToolSelectContiguous(); + Q_CHECK_PTR(t); + t->setup(ac); + return t; + } + virtual KisID id() { return KisID("contiguousselect", i18n("Contiguous Select Tool")); } +}; + + +#endif //__KIS_TOOL_SELECT_CONTIGUOUS_H__ + diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.cc b/chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.cc new file mode 100644 index 00000000..efdae2f3 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.cc @@ -0,0 +1,321 @@ +/* + * kis_tool_select_elliptical.cc -- part of Chalk + * + * 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 +#include +#include +#include + +#include +#include +#include +#include + +#include "kis_autobrush_resource.h" +#include "kis_canvas_controller.h" +#include "kis_canvas_subject.h" +#include "kis_cursor.h" +#include "kis_image.h" +#include "kis_painter.h" +#include "kis_tool_select_elliptical.h" +#include "kis_layer.h" +#include "kis_undo_adapter.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_move_event.h" +#include "kis_selection.h" +#include "kis_selection_options.h" +#include "kis_selected_transaction.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" + +KisToolSelectElliptical::KisToolSelectElliptical() + : super(i18n("Elliptical Select")) +{ + setName("tool_select_elliptical"); + setCursor(KisCursor::load("tool_elliptical_selection_cursor.png", 6, 6)); + + m_subject = 0; + m_selecting = false; + m_centerPos = KisPoint(0, 0); + m_startPos = KisPoint(0, 0); + m_endPos = KisPoint(0, 0); + m_optWidget = 0; + m_selectAction = SELECTION_ADD; +} + +KisToolSelectElliptical::~KisToolSelectElliptical() +{ +} + +void KisToolSelectElliptical::activate() +{ + super::activate(); + + if (!m_optWidget) + return; + + m_optWidget->slotActivated(); +} + +void KisToolSelectElliptical::update(KisCanvasSubject *subject) +{ + m_subject = subject; + super::update(m_subject); +} + +void KisToolSelectElliptical::paint(KisCanvasPainter& gc) +{ + if (m_selecting) + paintOutline(gc, TQRect()); +} + +void KisToolSelectElliptical::paint(KisCanvasPainter& gc, const TQRect& rc) +{ + if (m_selecting) + paintOutline(gc, rc); +} + +void KisToolSelectElliptical::clearSelection() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisImageSP img = m_subject->currentImg(); + + Q_ASSERT(controller); + +// if (img && img->floatingSelection().data() != 0) { +// img->unsetFloatingSelection(); +// controller->canvas()->update(); +// } + + m_startPos = KisPoint(0, 0); + m_endPos = KisPoint(0, 0); + m_selecting = false; + } +} + +void KisToolSelectElliptical::buttonPress(KisButtonPressEvent *e) +{ + if (m_subject) { + KisImageSP img = m_subject->currentImg(); + + if (img && img->activeDevice() && e->button() == Qt::LeftButton) { + clearSelection(); + m_startPos = m_endPos = m_centerPos = e->pos(); + m_selecting = true; + paintOutline(); + } + } +} + +void KisToolSelectElliptical::move(KisMoveEvent *e) +{ + if (m_subject && m_selecting) { + paintOutline(); + // move (alt) or resize ellipse + if (e->state() & TQt::AltButton) { + KisPoint trans = e->pos() - m_endPos; + m_startPos += trans; + m_endPos += trans; + } else { + KisPoint diag = e->pos() - (e->state() & TQt::ControlButton + ? m_centerPos : m_startPos); + // circle? + if (e->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 (e->state() & TQt::ControlButton) { + m_startPos = m_centerPos - diag; + m_endPos = m_centerPos + diag; + } else { + m_endPos = m_startPos + diag; + } + } + paintOutline(); + m_centerPos = KisPoint((m_startPos.x() + m_endPos.x()) / 2, + (m_startPos.y() + m_endPos.y()) / 2); + } +} + +void KisToolSelectElliptical::buttonRelease(KisButtonReleaseEvent *e) +{ + if (m_subject && m_selecting && e->button() == Qt::LeftButton) { + + paintOutline(); + + if (m_startPos == m_endPos) { + clearSelection(); + } else { + TQApplication::setOverrideCursor(KisCursor::waitCursor()); + KisImageSP img = m_subject->currentImg(); + + if (!img) + return; + + if (m_endPos.y() < 0) + m_endPos.setY(0); + + if (m_endPos.y() > img->height()) + m_endPos.setY(img->height()); + + if (m_endPos.x() < 0) + m_endPos.setX(0); + + if (m_endPos.x() > img->width()) + m_endPos.setX(img->width()); + + if (img && img->activeDevice()) { + KisPaintDeviceSP dev = img->activeDevice(); + KisSelectedTransaction *t = 0; + if (img->undo()) t = new KisSelectedTransaction(i18n("Elliptical Selection"), dev); + + bool hasSelection = dev->hasSelection(); + if(! hasSelection) + { + dev->selection()->clear(); + if(m_selectAction==SELECTION_SUBTRACT) + dev->selection()->invert(); + } + TQRect rc( m_startPos.floorTQPoint(), m_endPos.floorTQPoint()); + rc = rc.normalize(); + + KisSelectionSP tmpSel = new KisSelection(dev); + KisAutobrushCircleShape tqshape(rc.width(),rc.height(), 1, 1); + TQ_UINT8 value; + for (int y = 0; y <= rc.height(); y++) + for (int x = 0; x <= rc.width(); x++) + { + value = MAX_SELECTED - tqshape.valueAt(x,y); + tmpSel->setSelected( x+rc.x(), y+rc.y(), value); + } + switch(m_selectAction) + { + case SELECTION_ADD: + dev->addSelection(tmpSel); + break; + case SELECTION_SUBTRACT: + dev->subtractSelection(tmpSel); + break; + } + + if(hasSelection) { + dev->setDirty(rc); + dev->emitSelectionChanged(rc); + } else { + dev->setDirty(); + dev->emitSelectionChanged(); + } + + if (img->undo()) + img->undoAdapter()->addCommand(t); + + TQApplication::restoreOverrideCursor(); + } + } + m_selecting = false; + } +} + +void KisToolSelectElliptical::paintOutline() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + TQRect rc; + + paintOutline(gc, rc); + } +} + +void KisToolSelectElliptical::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).floorTQPoint(); + end = controller->windowToView(m_endPos).floorTQPoint(); + + gc.setRasterOp(TQt::NotROP); + gc.setPen(pen); + gc.drawEllipse(TQRect(start, end)); + gc.setRasterOp(op); + gc.setPen(old); + } +} + +void KisToolSelectElliptical::slotSetAction(int action) { + if (action >= SELECTION_ADD && action <= SELECTION_SUBTRACT) + m_selectAction =(enumSelectionMode)action; +} + +void KisToolSelectElliptical::setup(KActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new KRadioAction(i18n("&Elliptical Selection"), + "tool_elliptical_selection" , + TQt::Key_J, + this, + TQT_SLOT(activate()), + collection, + name()); + Q_CHECK_PTR(m_action); + m_action->setToolTip(i18n("Select an elliptical area")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +TQWidget* KisToolSelectElliptical::createOptionWidget(TQWidget* tqparent) +{ + m_optWidget = new KisSelectionOptions(tqparent, m_subject); + Q_CHECK_PTR(m_optWidget); + m_optWidget->setCaption(i18n("Elliptical Selection")); + + connect (m_optWidget, TQT_SIGNAL(actionChanged(int)), this, TQT_SLOT(slotSetAction(int))); + + TQVBoxLayout * l = dynamic_cast(m_optWidget->tqlayout()); + l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); + + return m_optWidget; +} + +TQWidget* KisToolSelectElliptical::optionWidget() +{ + return m_optWidget; +} + + + +#include "kis_tool_select_elliptical.moc" diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.h b/chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.h new file mode 100644 index 00000000..f0d1a039 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_elliptical.h @@ -0,0 +1,99 @@ +/* + * kis_tool_select_elliptical.h - part of Krayon^WChalk + * + * Copyright (c) 2000 John Califf + * Copyright (c) 2002 Patrick Julien + * Copyright (c) 2004 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __KIS_TOOL_SELECT_ELLIPTICAL_H__ +#define __KIS_TOOL_SELECT_ELLIPTICAL_H__ + +#include + +#include "kis_point.h" +#include "kis_selection.h" +#include "kis_tool_factory.h" +#include "kis_tool_non_paint.h" + +class KisSelectionOptions; + +class KisToolSelectElliptical : public KisToolNonPaint { + + typedef KisToolNonPaint super; + Q_OBJECT + TQ_OBJECT + +public: + KisToolSelectElliptical(); + virtual ~KisToolSelectElliptical(); + + virtual void update(KisCanvasSubject *subject); + + virtual void setup(KActionCollection *collection); + virtual TQ_UINT32 priority() { return 4; } + virtual TQWidget * createOptionWidget(TQWidget* tqparent); + virtual TQWidget* optionWidget(); + virtual enumToolType toolType() { return TOOL_SELECT; } + + virtual void paint(KisCanvasPainter& gc); + virtual void paint(KisCanvasPainter& gc, const TQRect& rc); + virtual void buttonPress(KisButtonPressEvent *e); + virtual void move(KisMoveEvent *e); + virtual void buttonRelease(KisButtonReleaseEvent *e); + +public slots: + virtual void slotSetAction(int); + virtual void activate(); + + +private: + void clearSelection(); + void paintOutline(); + void paintOutline(KisCanvasPainter& gc, const TQRect& rc); + +private: + KisCanvasSubject *m_subject; + KisPoint m_centerPos; + KisPoint m_startPos; + KisPoint m_endPos; + bool m_selecting; + KisSelectionOptions * m_optWidget; + enumSelectionMode m_selectAction; +}; + +class KisToolSelectEllipticalFactory : public KisToolFactory { + typedef KisToolFactory super; +public: + KisToolSelectEllipticalFactory() : super() {}; + virtual ~KisToolSelectEllipticalFactory(){}; + + virtual KisTool * createTool(KActionCollection * ac) { + KisTool * t = new KisToolSelectElliptical(); + Q_CHECK_PTR(t); + t->setup(ac); + return t; + } + virtual KisID id() { return KisID("ellipticalselect", i18n("Elliptical Select Tool")); } +}; + + + + + +#endif //__KIS_TOOL_SELECT_ELLIPTICAL_H__ + diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_eraser.cc b/chalk/plugins/tools/selectiontools/kis_tool_select_eraser.cc new file mode 100644 index 00000000..58a7778c --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_eraser.cc @@ -0,0 +1,156 @@ +/* + * kis_tool_select_brush.cc - part of Chalk + * + * Copyright (c) 2004 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "kis_brush.h" +#include "kis_layer.h" +#include "kis_paintop.h" +#include "kis_paintop_registry.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_cmb_composite.h" +#include "kis_cursor.h" +#include "kis_doc.h" +#include "kis_move_event.h" +#include "kis_painter.h" +#include "kis_selection.h" +#include "kis_tool_select_eraser.h" +#include "kis_types.h" +#include "kis_view.h" +#include "kis_selection_options.h" + +KisToolSelectEraser::KisToolSelectEraser() + : super(i18n("SelectEraser")) +{ + setName("tool_select_eraser"); + setCursor(KisCursor::load("tool_eraser_selection_cursor.png", 5, 5)); + m_optWidget = 0; + m_paintOnSelection = true; +} + +KisToolSelectEraser::~KisToolSelectEraser() +{ +} + +void KisToolSelectEraser::activate() +{ + super::activate(); + + if (!m_optWidget) + return; + + m_optWidget->slotActivated(); +} + +void KisToolSelectEraser::initPaint(KisEvent */*e*/) +{ + if (!m_currentImage || !m_currentImage->activeDevice()) return; + + m_mode = PAINT; + m_dragDist = 0; + + // Create painter + KisPaintDeviceSP dev = m_currentImage->activeDevice(); + + if (dev == 0) return; + + if (m_painter) + delete m_painter; + if(! dev->hasSelection()) + { + dev->selection()->clear(); + dev->emitSelectionChanged(); + } + KisSelectionSP selection = dev->selection(); + + m_target = selection; + m_painter = new KisPainter(selection.data()); + Q_CHECK_PTR(m_painter); + m_painter->beginTransaction(i18n("Selection Eraser")); + m_painter->setPaintColor(KisColor(TQt::white, selection->colorSpace())); + m_painter->setBrush(m_subject->currentBrush()); + m_painter->setOpacity(OPACITY_OPAQUE); + m_painter->setCompositeOp(COMPOSITE_ERASE); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp("eraser", 0, painter()); + painter()->setPaintOp(op); // And now the painter owns the op and will destroy it. + + // Set the cursor -- ideally. this should be a tqmask created from the brush, + // now that X11 can handle colored cursors. +#if 0 + // Setting cursors has no effect until the tool is selected again; this + // should be fixed. + setCursor(KisCursor::eraserCursor()); +#endif +} + +void KisToolSelectEraser::endPaint() { + super::endPaint(); + if (m_currentImage && m_currentImage->activeDevice()) + m_currentImage->activeDevice()->emitSelectionChanged(); +} +void KisToolSelectEraser::setup(KActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new KRadioAction(i18n("Selection &Eraser"), + "tool_eraser_selection", "Ctrl+Shift+E", this, + TQT_SLOT(activate()), collection, + name()); + Q_CHECK_PTR(m_action); + m_action->setToolTip(i18n("Erase parts of a selection")); + m_action->setExclusiveGroup("tools"); + m_ownAction = true; + } +} + +TQWidget* KisToolSelectEraser::createOptionWidget(TQWidget* tqparent) +{ + Q_UNUSED(tqparent); + // Commented out due to the fact that this doesn't actually work if you change the action +#if 0 + m_optWidget = new KisSelectionOptions(tqparent, m_subject); + Q_CHECK_PTR(m_optWidget); + m_optWidget->setCaption(i18n("Selection Eraser")); + + TQVBoxLayout * l = dynamic_cast(m_optWidget->tqlayout()); + l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); + + return m_optWidget; +#endif + return 0; +} + +TQWidget* KisToolSelectEraser::optionWidget() +{ + return m_optWidget; +} + +#include "kis_tool_select_eraser.moc" + diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_eraser.h b/chalk/plugins/tools/selectiontools/kis_tool_select_eraser.h new file mode 100644 index 00000000..85bd5509 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_eraser.h @@ -0,0 +1,82 @@ +/* + * kis_tool_select_eraser.h - part of Chalk + * + * Copyright (c) 2003-2004 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef KIS_TOOL_SELECT_ERASER_H_ +#define KIS_TOOL_SELECT_ERASER_H_ + +#include +#include + +class KisPoint; +class KisSelectionOptions; + + +/** + * The selection eraser makes a selection smaller by painting with the + * current eraser tqshape. Not sure what kind of an icon could represent + * this... Depends a bit on how we're going to visualize selections. + */ +class KisToolSelectEraser : public KisToolFreehand { + Q_OBJECT + TQ_OBJECT + typedef KisToolFreehand super; + +public: + KisToolSelectEraser(); + virtual ~KisToolSelectEraser(); + + virtual void setup(KActionCollection *collection); + virtual TQ_UINT32 priority() { return 2; } + virtual enumToolType toolType() { return TOOL_SELECT; } + virtual TQWidget* createOptionWidget(TQWidget* tqparent); + virtual TQWidget* optionWidget(); + +public slots: + virtual void activate(); + +protected: + + virtual void initPaint(KisEvent *e); + virtual void endPaint(); +private: + KisSelectionOptions * m_optWidget; + +}; + + +class KisToolSelectEraserFactory : public KisToolFactory { + typedef KisToolFactory super; +public: + KisToolSelectEraserFactory() : super() {}; + virtual ~KisToolSelectEraserFactory(){}; + + virtual KisTool * createTool(KActionCollection * ac) { + KisTool * t = new KisToolSelectEraser(); + Q_CHECK_PTR(t); + t->setup(ac); + return t; + } + virtual KisID id() { return KisID("eraserselect", i18n("Eraser Select Tool")); } +}; + + + +#endif // KIS_TOOL_SELECT_ERASER_H_ + diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_outline.cc b/chalk/plugins/tools/selectiontools/kis_tool_select_outline.cc new file mode 100644 index 00000000..b81762fb --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_outline.cc @@ -0,0 +1,295 @@ +/* + * kis_tool_select_freehand.h - part of Krayon^WChalk + * + * Copyright (c) 2000 John Califf + * Copyright (c) 2002 Patrick Julien + * Copyright (c) 2004 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "kis_selected_transaction.h" +#include "kis_painter.h" +#include "kis_paintop_registry.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" + +KisToolSelectOutline::KisToolSelectOutline() + : super(i18n("Select Outline")) +{ + setName("tool_select_outline"); + setCursor(KisCursor::load("tool_outline_selection_cursor.png", 5, 5)); + + m_subject = 0; + m_dragging = false; + m_optWidget = 0; + m_selectAction = SELECTION_ADD; +} + +KisToolSelectOutline::~KisToolSelectOutline() +{ +} + +void KisToolSelectOutline::activate() +{ + super::activate(); + + if (!m_optWidget) + return; + + m_optWidget->slotActivated(); +} + +void KisToolSelectOutline::update (KisCanvasSubject *subject) +{ + m_subject = subject; + super::update(m_subject); +} + +void KisToolSelectOutline::buttonPress(KisButtonPressEvent *event) +{ + if (event->button() == Qt::LeftButton) { + m_dragging = true; + + m_dragStart = event->pos(); + m_dragEnd = event->pos(); + m_points.clear(); + m_points.append(m_dragStart); + } +} + +void KisToolSelectOutline::move(KisMoveEvent *event) +{ + if (m_dragging) { + m_dragStart = m_dragEnd; + m_dragEnd = event->pos(); + m_points.append (m_dragEnd); + // draw new lines on canvas + draw(); + } +} + +void KisToolSelectOutline::buttonRelease(KisButtonReleaseEvent *event) +{ + if (!m_subject) + return; + + if (m_dragging && event->button() == Qt::LeftButton) { + m_dragging = false; + deactivate(); + + KisImageSP img = m_subject->currentImg(); + + if (img && img->activeDevice()) { + TQApplication::setOverrideCursor(KisCursor::waitCursor()); + KisPaintDeviceSP dev = img->activeDevice(); + bool hasSelection = dev->hasSelection(); + KisSelectedTransaction *t = 0; + if (img->undo()) t = new KisSelectedTransaction(i18n("Outline Selection"), dev); + KisSelectionSP selection = dev->selection(); + + if (!hasSelection) { + selection->clear(); + } + + KisPainter painter(selection.data()); + + painter.setPaintColor(KisColor(TQt::black, selection->colorSpace())); + painter.setFillStyle(KisPainter::FillStyleForegroundColor); + painter.setStrokeStyle(KisPainter::StrokeStyleNone); + painter.setBrush(m_subject->currentBrush()); + painter.setOpacity(OPACITY_OPAQUE); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp("paintbrush", 0, &painter); + painter.setPaintOp(op); // And now the painter owns the op and will destroy it. + + switch (m_selectAction) { + case SELECTION_ADD: + painter.setCompositeOp(COMPOSITE_OVER); + break; + case SELECTION_SUBTRACT: + painter.setCompositeOp(COMPOSITE_SUBTRACT); + break; + default: + break; + } + + painter.paintPolygon(m_points); + + + if(hasSelection) { + TQRect dirty(painter.dirtyRect()); + dev->setDirty(dirty); + dev->emitSelectionChanged(dirty); + } else { + dev->setDirty(); + dev->emitSelectionChanged(); + } + + if (img->undo()) + img->undoAdapter()->addCommand(t); + + TQApplication::restoreOverrideCursor(); + } + + m_points.clear(); + } +} + +void KisToolSelectOutline::paint(KisCanvasPainter& gc) +{ + draw(gc); +} + +void KisToolSelectOutline::paint(KisCanvasPainter& gc, const TQRect&) +{ + draw(gc); +} + +void KisToolSelectOutline::draw() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + + draw(gc); + } +} + +void KisToolSelectOutline::draw(KisCanvasPainter& gc) +{ + if (!m_subject) + return; + + if (m_dragging && !m_points.empty()) { + TQPen pen(TQt::white, 0, TQt::DotLine); + + gc.setPen(pen); + gc.setRasterOp(TQt::XorROP); + + KisCanvasController *controller = m_subject->canvasController(); + KisPoint start, end; + TQPoint startPos; + TQPoint endPos; + + startPos = controller->windowToView(m_dragStart.floorTQPoint()); + endPos = controller->windowToView(m_dragEnd.floorTQPoint()); + gc.drawLine(startPos, endPos); + } +} + +void KisToolSelectOutline::deactivate() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + + TQPen pen(TQt::white, 0, TQt::DotLine); + + gc.setPen(pen); + gc.setRasterOp(TQt::XorROP); + + KisPoint start, end; + TQPoint startPos; + TQPoint endPos; + + for (KisPointVector::iterator it = m_points.begin(); it != m_points.end(); ++it) { + + if (it == m_points.begin()) + { + start = (*it); + } else { + end = (*it); + + startPos = controller->windowToView(start.floorTQPoint()); + endPos = controller->windowToView(end.floorTQPoint()); + + gc.drawLine(startPos, endPos); + + start = end; + } + } + } +} + +void KisToolSelectOutline::setup(KActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new KRadioAction(i18n("&Outline Selection"), + "tool_outline_selection", + 0, + this, + TQT_SLOT(activate()), + collection, + name()); + Q_CHECK_PTR(m_action); + m_action->setExclusiveGroup("tools"); + m_action->setToolTip(i18n("Select an outline")); + m_ownAction = true; + } +} + + +TQWidget* KisToolSelectOutline::createOptionWidget(TQWidget* tqparent) +{ + m_optWidget = new KisSelectionOptions(tqparent, m_subject); + Q_CHECK_PTR(m_optWidget); + m_optWidget->setCaption(i18n("Outline Selection")); + + connect (m_optWidget, TQT_SIGNAL(actionChanged(int)), this, TQT_SLOT(slotSetAction(int))); + + TQVBoxLayout * l = dynamic_cast(m_optWidget->tqlayout()); + l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); + + return m_optWidget; +} + +TQWidget* KisToolSelectOutline::optionWidget() +{ + return m_optWidget; +} + +void KisToolSelectOutline::slotSetAction(int action) { + if (action >= SELECTION_ADD && action <= SELECTION_SUBTRACT) + m_selectAction =(enumSelectionMode)action; +} + +#include "kis_tool_select_outline.moc" + diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_outline.h b/chalk/plugins/tools/selectiontools/kis_tool_select_outline.h new file mode 100644 index 00000000..74ecab78 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_outline.h @@ -0,0 +1,101 @@ +/* + * kis_tool_select_freehand.h - part of Krayon^WChalk + * + * Copyright (c) 2000 John Califf + * Copyright (c) 2002 Patrick Julien + * Copyright (c) 2004 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __selecttoolfreehand_h__ +#define __selecttoolfreehand_h__ + +#include +#include + +#include "kis_point.h" +#include "kis_tool_non_paint.h" +#include "kis_tool_factory.h" +#include "kis_selection.h" + +class KisSelectionOptions; + +class KisToolSelectOutline : public KisToolNonPaint { + + typedef KisToolNonPaint super; + Q_OBJECT + TQ_OBJECT +public: + KisToolSelectOutline(); + virtual ~KisToolSelectOutline(); + + virtual void update (KisCanvasSubject *subject); + + virtual void setup(KActionCollection *collection); + virtual TQ_UINT32 priority() { return 6; } + virtual enumToolType toolType() { return TOOL_SELECT; } + + virtual void buttonPress(KisButtonPressEvent *event); + virtual void move(KisMoveEvent *event); + virtual void buttonRelease(KisButtonReleaseEvent *event); + + TQWidget* createOptionWidget(TQWidget* tqparent); + virtual TQWidget* optionWidget(); + +public slots: + virtual void slotSetAction(int); + virtual void activate(); + void deactivate(); + +protected: + virtual void paint(KisCanvasPainter& gc); + virtual void paint(KisCanvasPainter& gc, const TQRect& rc); + void draw(KisCanvasPainter& gc); + void draw(); + + +protected: + KisPoint m_dragStart; + KisPoint m_dragEnd; + + bool m_dragging; +private: + typedef TQValueVector KisPointVector; + KisCanvasSubject *m_subject; + KisPointVector m_points; + KisSelectionOptions * m_optWidget; + enumSelectionMode m_selectAction; +}; + + +class KisToolSelectOutlineFactory : public KisToolFactory { + typedef KisToolFactory super; +public: + KisToolSelectOutlineFactory() : super() {}; + virtual ~KisToolSelectOutlineFactory(){}; + + virtual KisTool * createTool(KActionCollection * ac) { + KisTool * t = new KisToolSelectOutline(); + Q_CHECK_PTR(t); + t->setup(ac); + return t; + } + virtual KisID id() { return KisID("selectoutline", i18n("Select Outline tool")); } +}; + + +#endif //__selecttoolfreehand_h__ + diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_polygonal.cc b/chalk/plugins/tools/selectiontools/kis_tool_select_polygonal.cc new file mode 100644 index 00000000..7bac7cc3 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_polygonal.cc @@ -0,0 +1,315 @@ +/* + * kis_tool_select_polygonal.h - part of Krayon^WChalk + * + * Copyright (c) 2000 John Califf + * Copyright (c) 2002 Patrick Julien + * Copyright (c) 2004 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "kis_selected_transaction.h" +#include "kis_painter.h" +#include "kis_paintop_registry.h" +#include "kis_canvas.h" +#include "kis_canvas_painter.h" + +KisToolSelectPolygonal::KisToolSelectPolygonal() + : super(i18n("Select Polygonal")) +{ + setName("tool_select_polygonal"); + setCursor(KisCursor::load("tool_polygonal_selection_cursor.png", 6, 6)); + + m_subject = 0; + m_dragging = false; + m_optWidget = 0; + m_selectAction = SELECTION_ADD; +} + +KisToolSelectPolygonal::~KisToolSelectPolygonal() +{ +} + +void KisToolSelectPolygonal::activate() +{ + m_points.clear(); + super::activate(); + + if (!m_optWidget) + return; + + m_optWidget->slotActivated(); +} + +void KisToolSelectPolygonal::deactivate() +{ + draw(); + m_points.clear(); + m_dragging = false; +} + + +void KisToolSelectPolygonal::update (KisCanvasSubject *subject) +{ + m_subject = subject; + super::update(m_subject); +} + +void KisToolSelectPolygonal::buttonPress(KisButtonPressEvent *event) +{ + if (event->button() == Qt::LeftButton) { + m_dragging = true; + + if (m_points.isEmpty()) + { + m_dragStart = event->pos(); + m_dragEnd = event->pos(); + m_points.append(m_dragStart); + } else { + m_dragStart = m_dragEnd; + m_dragEnd = event->pos(); + draw(); + } + } else if (event->button() == Qt::LeftButton && event->state() == ShiftButton) { + finish(); + } +} + + +void KisToolSelectPolygonal::doubleClick( KisDoubleClickEvent * ) +{ + finish(); +} + +void KisToolSelectPolygonal::finish() +{ + // erase old lines on canvas + draw(); + m_dragging = false; + + KisImageSP img = m_subject->currentImg(); + + if (img && img->activeDevice()) { + TQApplication::setOverrideCursor(KisCursor::waitCursor()); + KisPaintDeviceSP dev = img->activeDevice(); + + bool hasSelection = dev->hasSelection(); + KisSelectedTransaction *t = 0; + if (img->undo()) t = new KisSelectedTransaction(i18n("Polygonal Selection"), dev); + KisSelectionSP selection = dev->selection(); + + if (!hasSelection) + { + selection->clear(); + } + + KisPainter painter(selection.data()); + painter.setPaintColor(KisColor(TQt::black, selection->colorSpace())); + painter.setFillStyle(KisPainter::FillStyleForegroundColor); + painter.setStrokeStyle(KisPainter::StrokeStyleNone); + painter.setBrush(m_subject->currentBrush()); + painter.setOpacity(OPACITY_OPAQUE); + KisPaintOp * op = KisPaintOpRegistry::instance()->paintOp("paintbrush", 0, &painter); + painter.setPaintOp(op); // And now the painter owns the op and will destroy it. + + switch(m_selectAction) + { + case SELECTION_ADD: + painter.setCompositeOp(COMPOSITE_OVER); + break; + case SELECTION_SUBTRACT: + painter.setCompositeOp(COMPOSITE_SUBTRACT); + break; + default: + break; + } + + painter.paintPolygon(m_points); + + if(hasSelection) { + TQRect rect(painter.dirtyRect()); + dev->setDirty(rect); + dev->emitSelectionChanged(rect); + } else { + dev->setDirty(); + dev->emitSelectionChanged(); + } + + if (img->undo()) img->undoAdapter()->addCommand(t); + + TQApplication::restoreOverrideCursor(); + } + + m_points.clear(); + +} + +void KisToolSelectPolygonal::move(KisMoveEvent *event) +{ + if (m_dragging) { + // erase old lines on canvas + draw(); + // get current mouse position + m_dragEnd = event->pos(); + // draw new lines on canvas + draw(); + } +} + +void KisToolSelectPolygonal::buttonRelease(KisButtonReleaseEvent *event) +{ + if (!m_subject) + return; + + if (m_dragging && event->button() == Qt::LeftButton) { + m_dragging = false; + m_points.append (m_dragEnd); + } + + if (m_dragging && event->button() == Qt::RightButton) { + + } +} + +void KisToolSelectPolygonal::paint(KisCanvasPainter& gc) +{ + draw(gc); +} + +void KisToolSelectPolygonal::paint(KisCanvasPainter& gc, const TQRect&) +{ + draw(gc); +} + +void KisToolSelectPolygonal::draw() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + + draw(gc); + } +} + +void KisToolSelectPolygonal::draw(KisCanvasPainter& gc) +{ + if (!m_subject) + return; + + TQPen pen(TQt::white, 0, TQt::DotLine); + + gc.setPen(pen); + gc.setRasterOp(TQt::XorROP); + + KisCanvasController *controller = m_subject->canvasController(); + KisPoint start, end; + TQPoint startPos; + TQPoint endPos; + + if (m_dragging) { + startPos = controller->windowToView(m_dragStart.floorTQPoint()); + endPos = controller->windowToView(m_dragEnd.floorTQPoint()); + gc.drawLine(startPos, endPos); + } else { + for (KisPointVector::iterator it = m_points.begin(); it != m_points.end(); ++it) { + + if (it == m_points.begin()) + { + start = (*it); + } else { + end = (*it); + + startPos = controller->windowToView(start.floorTQPoint()); + endPos = controller->windowToView(end.floorTQPoint()); + + gc.drawLine(startPos, endPos); + + start = end; + } + } + } +} + + +void KisToolSelectPolygonal::setup(KActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new KRadioAction(i18n("&Polygonal Selection"), + "tool_polygonal_selection" , + 0, + this, + TQT_SLOT(activate()), + collection, + name()); + Q_CHECK_PTR(m_action); + m_action->setExclusiveGroup("tools"); + m_action->setToolTip(i18n("Select a polygonal area")); + m_ownAction = true; + } +} + + +TQWidget* KisToolSelectPolygonal::createOptionWidget(TQWidget* tqparent) +{ + m_optWidget = new KisSelectionOptions(tqparent, m_subject); + Q_CHECK_PTR(m_optWidget); + m_optWidget->setCaption(i18n("Polygonal Selection")); + + connect (m_optWidget, TQT_SIGNAL(actionChanged(int)), this, TQT_SLOT(slotSetAction(int))); + + TQVBoxLayout * l = dynamic_cast(m_optWidget->tqlayout()); + l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); + + return m_optWidget; +} + +TQWidget* KisToolSelectPolygonal::optionWidget() +{ + return m_optWidget; +} + +void KisToolSelectPolygonal::slotSetAction(int action) { + if (action >= SELECTION_ADD && action <= SELECTION_SUBTRACT) + m_selectAction =(enumSelectionMode)action; +} + + + +#include "kis_tool_select_polygonal.moc" diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_polygonal.h b/chalk/plugins/tools/selectiontools/kis_tool_select_polygonal.h new file mode 100644 index 00000000..65a32ee6 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_polygonal.h @@ -0,0 +1,106 @@ +/* + * kis_tool_select_polygonal.h - part of Krayon^WChalk + * + * Copyright (c) 2000 John Califf + * Copyright (c) 2002 Patrick Julien + * Copyright (c) 2004 Boudewijn Rempt + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#ifndef __selecttoolpolygonal_h__ +#define __selecttoolpolygonal_h__ + +#include "kis_point.h" +#include "kis_tool_non_paint.h" +#include "kis_tool_factory.h" +#include "kis_selection.h" + +class KisSelectionOptions; + +class KisToolSelectPolygonal : public KisToolNonPaint { + + typedef KisToolNonPaint super; + Q_OBJECT + TQ_OBJECT +public: + KisToolSelectPolygonal(); + virtual ~KisToolSelectPolygonal(); + + // + // KisCanvasObserver interface + // + + virtual void update (KisCanvasSubject *subject); + + // + // KisToolPaint interface + // + + virtual void setup(KActionCollection *collection); + virtual TQ_UINT32 priority() { return 5; } + virtual enumToolType toolType() { return TOOL_SELECT; } + virtual void buttonPress(KisButtonPressEvent *event); + virtual void move(KisMoveEvent *event); + virtual void buttonRelease(KisButtonReleaseEvent *event); + virtual void doubleClick(KisDoubleClickEvent * event); + + void finish(); + TQWidget* createOptionWidget(TQWidget* tqparent); + virtual TQWidget* optionWidget(); + +public slots: + virtual void slotSetAction(int); + virtual void activate(); + void deactivate(); + +protected: + virtual void paint(KisCanvasPainter& gc); + virtual void paint(KisCanvasPainter& gc, const TQRect& rc); + void draw(KisCanvasPainter& gc); + void draw(); + +protected: + KisPoint m_dragStart; + KisPoint m_dragEnd; + + bool m_dragging; +private: + typedef TQValueVector KisPointVector; + KisCanvasSubject *m_subject; + KisPointVector m_points; + KisSelectionOptions * m_optWidget; + enumSelectionMode m_selectAction; +}; + + +class KisToolSelectPolygonalFactory : public KisToolFactory { + typedef KisToolFactory super; +public: + KisToolSelectPolygonalFactory() : super() {}; + virtual ~KisToolSelectPolygonalFactory(){}; + + virtual KisTool * createTool(KActionCollection * ac) { + KisTool * t = new KisToolSelectPolygonal(); + Q_CHECK_PTR(t); + t->setup(ac); + return t; + } + virtual KisID id() { return KisID("polygonalselect", i18n("Polygonal Select Tool")); } +}; + + +#endif //__selecttoolpolygonal_h__ + diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.cc b/chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.cc new file mode 100644 index 00000000..aa7052af --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.cc @@ -0,0 +1,323 @@ + +/* + * kis_tool_select_rectangular.cc -- part of Chalk + * + * Copyright (c) 1999 Michael Koch + * 2001 John Califf + * 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. + */ + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "kis_canvas_controller.h" +#include "kis_canvas_subject.h" +#include "kis_cursor.h" +#include "kis_image.h" +#include "kis_painter.h" +#include "kis_layer.h" +#include "kis_tool_select_rectangular.h" +#include "kis_undo_adapter.h" +#include "kis_button_press_event.h" +#include "kis_button_release_event.h" +#include "kis_move_event.h" +#include "kis_selection.h" +#include "kis_selection_options.h" +#include +#include "kis_canvas.h" +#include "kis_canvas_painter.h" + +KisToolSelectRectangular::KisToolSelectRectangular() + : super(i18n("Rectangular Select Tool")) +{ + setName("tool_select_rectangular"); + setCursor(KisCursor::load("tool_rectangular_selection_cursor.png", 6, 6)); + m_subject = 0; + m_selecting = false; + m_centerPos = KisPoint(0, 0); + m_startPos = KisPoint(0, 0); + m_endPos = KisPoint(0, 0); + m_optWidget = 0; + m_selectAction = SELECTION_ADD; +} + +KisToolSelectRectangular::~KisToolSelectRectangular() +{ +} + +void KisToolSelectRectangular::activate() +{ + super::activate(); + + if (!m_optWidget) + return; + + m_optWidget->slotActivated(); +} + +void KisToolSelectRectangular::update(KisCanvasSubject *subject) +{ + m_subject = subject; + super::update(m_subject); +} + +void KisToolSelectRectangular::paint(KisCanvasPainter& gc) +{ + if (m_selecting) + paintOutline(gc, TQRect()); +} + +void KisToolSelectRectangular::paint(KisCanvasPainter& gc, const TQRect& rc) +{ + if (m_selecting) + paintOutline(gc, rc); +} + +void KisToolSelectRectangular::clearSelection() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisImageSP img = m_subject->currentImg(); + + Q_ASSERT(controller); + + m_centerPos = KisPoint(0, 0); + m_startPos = KisPoint(0, 0); + m_endPos = KisPoint(0, 0); + m_selecting = false; + } +} + +void KisToolSelectRectangular::buttonPress(KisButtonPressEvent *e) +{ + if (m_subject) { + KisImageSP img = m_subject->currentImg(); + + if (img && img->activeDevice() && e->button() == Qt::LeftButton) { + clearSelection(); + m_startPos = m_endPos = m_centerPos = e->pos(); + m_selecting = true; + } + } +} + +void KisToolSelectRectangular::move(KisMoveEvent *e) +{ + if (m_subject && m_selecting) { + paintOutline(); + // move (alt) or resize rectangle + if (e->state() & TQt::AltButton) { + KisPoint trans = e->pos() - m_endPos; + m_startPos += trans; + m_endPos += trans; + } else { + KisPoint diag = e->pos() - (e->state() & TQt::ControlButton + ? m_centerPos : m_startPos); + // square? + if (e->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 (e->state() & TQt::ControlButton) { + m_startPos = m_centerPos - diag; + m_endPos = m_centerPos + diag; + } else { + m_endPos = m_startPos + diag; + } + } + paintOutline(); + m_centerPos = KisPoint((m_startPos.x() + m_endPos.x()) / 2, + (m_startPos.y() + m_endPos.y()) / 2); + } +} + +void KisToolSelectRectangular::buttonRelease(KisButtonReleaseEvent *e) +{ + if (m_subject && m_selecting && e->button() == Qt::LeftButton) { + + paintOutline(); + + if (m_startPos == m_endPos) { + clearSelection(); + } else { + KisImageSP img = m_subject->currentImg(); + + if (!img) + return; + + if (m_endPos.y() < 0) + m_endPos.setY(0); + + if (m_endPos.y() > img->height()) + m_endPos.setY(img->height()); + + if (m_endPos.x() < 0) + m_endPos.setX(0); + + if (m_endPos.x() > img->width()) + m_endPos.setX(img->width()); + if (img && img->activeDevice()) { + + TQApplication::setOverrideCursor(KisCursor::waitCursor()); + KisPaintDeviceSP dev = img->activeDevice(); + bool hasSelection = dev->hasSelection(); + + KisSelectedTransaction *t = 0; + if (img->undo()) t = new KisSelectedTransaction(i18n("Rectangular Selection"), dev); + KisSelectionSP selection = dev->selection(); + TQRect rc(m_startPos.floorTQPoint(), m_endPos.floorTQPoint()); + rc = rc.normalize(); + + // We don't want the border of the 'rectangle' to be included in our selection + rc.setSize(rc.size() - TQSize(1,1)); + + if(! hasSelection) + { + selection->clear(); + if(m_selectAction==SELECTION_SUBTRACT) + selection->invert(); + } + + KisSelectionSP tmpSel = new KisSelection(dev); + tmpSel->select(rc); + switch(m_selectAction) + { + case SELECTION_ADD: + dev->addSelection(tmpSel); + break; + case SELECTION_SUBTRACT: + dev->subtractSelection(tmpSel); + break; + default: + break; + } + + + if(hasSelection) { + dev->setDirty(rc); + dev->emitSelectionChanged(rc); + } else { + dev->setDirty(); + dev->emitSelectionChanged(); + } + + if (img->undo()) + img->undoAdapter()->addCommand(t); + + KisCanvasController *controller = m_subject -> canvasController(); + controller -> kiscanvas() -> update(); + + TQApplication::restoreOverrideCursor(); + } + } + + m_selecting = false; + } +} + +void KisToolSelectRectangular::paintOutline() +{ + if (m_subject) { + KisCanvasController *controller = m_subject->canvasController(); + KisCanvas *canvas = controller->kiscanvas(); + KisCanvasPainter gc(canvas); + TQRect rc; + + paintOutline(gc, rc); + } +} + +void KisToolSelectRectangular::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.floorTQPoint()); + end = controller->windowToView(m_endPos.floorTQPoint()); + + gc.setRasterOp(TQt::NotROP); + gc.setPen(pen); + gc.drawRect(TQRect(start, end)); + gc.setRasterOp(op); + gc.setPen(old); + } +} + +void KisToolSelectRectangular::slotSetAction(int action) { + if (action >= SELECTION_ADD && action <= SELECTION_SUBTRACT) + m_selectAction =(enumSelectionMode)action; +} + +void KisToolSelectRectangular::setup(KActionCollection *collection) +{ + m_action = static_cast(collection->action(name())); + + if (m_action == 0) { + m_action = new KRadioAction(i18n("&Rectangular Selection"), + "tool_rect_selection", + TQt::Key_R, + this, + TQT_SLOT(activate()), + collection, + name()); + Q_CHECK_PTR(m_action); + m_action->setExclusiveGroup("tools"); + m_action->setToolTip(i18n("Select a rectangular area")); + m_ownAction = true; + } +} + +TQWidget* KisToolSelectRectangular::createOptionWidget(TQWidget* tqparent) +{ + m_optWidget = new KisSelectionOptions(tqparent, m_subject); + Q_CHECK_PTR(m_optWidget); + m_optWidget->setCaption(i18n("Rectangular Selection")); + + connect (m_optWidget, TQT_SIGNAL(actionChanged(int)), this, TQT_SLOT(slotSetAction(int))); + + TQVBoxLayout * l = dynamic_cast(m_optWidget->tqlayout()); + l->addItem(new TQSpacerItem(1, 1, TQSizePolicy::Fixed, TQSizePolicy::Expanding)); + + return m_optWidget; +} + +TQWidget* KisToolSelectRectangular::optionWidget() +{ + return m_optWidget; +} + + + + +#include "kis_tool_select_rectangular.moc" diff --git a/chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.h b/chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.h new file mode 100644 index 00000000..eb286cca --- /dev/null +++ b/chalk/plugins/tools/selectiontools/kis_tool_select_rectangular.h @@ -0,0 +1,95 @@ +/* + * kis_tool_select_rectangular.h - part of Chalk + * + * Copyright (c) 1999 Michael Koch + * 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_SELECT_RECTANGULAR_H_ +#define KIS_TOOL_SELECT_RECTANGULAR_H_ + +#include "kis_point.h" +#include "kis_tool_non_paint.h" +#include "kis_selection.h" +#include "kis_tool_factory.h" + +class KisSelectionOptions; + +class KisToolSelectRectangular : public KisToolNonPaint { + + typedef KisToolNonPaint super; + Q_OBJECT + TQ_OBJECT + +public: + KisToolSelectRectangular(); + virtual ~KisToolSelectRectangular(); + + virtual void update(KisCanvasSubject *subject); + + virtual void setup(KActionCollection *collection); + virtual TQ_UINT32 priority() { return 3; } + virtual enumToolType toolType() { return TOOL_SELECT; } + virtual TQWidget * createOptionWidget(TQWidget* tqparent); + virtual TQWidget* optionWidget(); + + virtual void paint(KisCanvasPainter& gc); + virtual void paint(KisCanvasPainter& gc, const TQRect& rc); + virtual void buttonPress(KisButtonPressEvent *e); + virtual void move(KisMoveEvent *e); + virtual void buttonRelease(KisButtonReleaseEvent *e); + +public slots: + virtual void slotSetAction(int); + virtual void activate(); + + +private: + void clearSelection(); + void paintOutline(); + void paintOutline(KisCanvasPainter& gc, const TQRect& rc); + +private: + KisCanvasSubject *m_subject; + KisPoint m_centerPos; + KisPoint m_startPos; + KisPoint m_endPos; + bool m_selecting; + KisSelectionOptions * m_optWidget; + enumSelectionMode m_selectAction; + +}; + +class KisToolSelectRectangularFactory : public KisToolFactory { + typedef KisToolFactory super; +public: + KisToolSelectRectangularFactory() : super() {}; + virtual ~KisToolSelectRectangularFactory(){}; + + virtual KisTool * createTool(KActionCollection * ac) { + KisTool * t = new KisToolSelectRectangular(); + t->setup(ac); + Q_CHECK_PTR(t); + return t; + } + virtual KisID id() { return KisID("rectangularselect", i18n("Rectangular Select Tool")); } +}; + + + +#endif // KIS_TOOL_SELECT_RECTANGULAR_H_ + diff --git a/chalk/plugins/tools/selectiontools/selection_tools.cc b/chalk/plugins/tools/selectiontools/selection_tools.cc new file mode 100644 index 00000000..db4df1ab --- /dev/null +++ b/chalk/plugins/tools/selectiontools/selection_tools.cc @@ -0,0 +1,77 @@ +/* + * selection_tools.cc -- Part of Chalk + * + * 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 +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "selection_tools.h" + +#include "kis_tool_select_outline.h" +#include "kis_tool_select_polygonal.h" +#include "kis_tool_select_rectangular.h" +#include "kis_tool_select_contiguous.h" +#include "kis_tool_select_elliptical.h" +#include "kis_tool_select_eraser.h" +#include "kis_tool_select_brush.h" +#include "kis_tool_move_selection.h" + +typedef KGenericFactory SelectionToolsFactory; +K_EXPORT_COMPONENT_FACTORY( chalkselectiontools, SelectionToolsFactory( "chalk" ) ) + + +SelectionTools::SelectionTools(TQObject *tqparent, const char *name, const TQStringList &) + : KParts::Plugin(tqparent, name) +{ + setInstance(SelectionToolsFactory::instance()); + + if ( tqparent->inherits("KisToolRegistry") ) + { + KisToolRegistry * r = dynamic_cast(tqparent); + r->add(new KisToolSelectOutlineFactory()); + r->add(new KisToolSelectPolygonalFactory()); + r->add(new KisToolSelectRectangularFactory()); + r->add(new KisToolSelectBrushFactory()); + r->add(new KisToolSelectContiguousFactory()); + r->add(new KisToolSelectEllipticalFactory()); + r->add(new KisToolSelectEraserFactory()); + r->add(new KisToolMoveSelectionFactory()); + } +} + +SelectionTools::~SelectionTools() +{ +} + +#include "selection_tools.moc" diff --git a/chalk/plugins/tools/selectiontools/selection_tools.h b/chalk/plugins/tools/selectiontools/selection_tools.h new file mode 100644 index 00000000..2e448e3e --- /dev/null +++ b/chalk/plugins/tools/selectiontools/selection_tools.h @@ -0,0 +1,44 @@ +/* + * 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 SELECTION_TOOLS_H_ +#define SELECTION_TOOLS_H_ + +#include + +/** + * A module wrapper around Chalk's selection 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 Chalk. 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 SelectionTools : public KParts::Plugin +{ + Q_OBJECT + TQ_OBJECT +public: + SelectionTools(TQObject *tqparent, const char *name, const TQStringList &); + virtual ~SelectionTools(); + +}; + +#endif // SELECTION_TOOLS_H_ diff --git a/chalk/plugins/tools/selectiontools/tool_brush_selection.png b/chalk/plugins/tools/selectiontools/tool_brush_selection.png new file mode 100644 index 00000000..3d1bba3f Binary files /dev/null and b/chalk/plugins/tools/selectiontools/tool_brush_selection.png differ diff --git a/chalk/plugins/tools/selectiontools/tool_brush_selection.svg b/chalk/plugins/tools/selectiontools/tool_brush_selection.svg new file mode 100644 index 00000000..228a411f --- /dev/null +++ b/chalk/plugins/tools/selectiontools/tool_brush_selection.svg @@ -0,0 +1,827 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/chalk/plugins/tools/selectiontools/tool_brush_selection_cursor.png b/chalk/plugins/tools/selectiontools/tool_brush_selection_cursor.png new file mode 100644 index 00000000..96929d8f Binary files /dev/null and b/chalk/plugins/tools/selectiontools/tool_brush_selection_cursor.png differ diff --git a/chalk/plugins/tools/selectiontools/tool_contiguous_selection.png b/chalk/plugins/tools/selectiontools/tool_contiguous_selection.png new file mode 100644 index 00000000..fcc8f36d Binary files /dev/null and b/chalk/plugins/tools/selectiontools/tool_contiguous_selection.png differ diff --git a/chalk/plugins/tools/selectiontools/tool_contiguous_selection_cursor.png b/chalk/plugins/tools/selectiontools/tool_contiguous_selection_cursor.png new file mode 100644 index 00000000..0e3572cd Binary files /dev/null and b/chalk/plugins/tools/selectiontools/tool_contiguous_selection_cursor.png differ diff --git a/chalk/plugins/tools/selectiontools/tool_elliptical_selection.png b/chalk/plugins/tools/selectiontools/tool_elliptical_selection.png new file mode 100644 index 00000000..ad585848 Binary files /dev/null and b/chalk/plugins/tools/selectiontools/tool_elliptical_selection.png differ diff --git a/chalk/plugins/tools/selectiontools/tool_elliptical_selection.svg b/chalk/plugins/tools/selectiontools/tool_elliptical_selection.svg new file mode 100644 index 00000000..31ff66f4 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/tool_elliptical_selection.svg @@ -0,0 +1,256 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/chalk/plugins/tools/selectiontools/tool_elliptical_selection_cursor.png b/chalk/plugins/tools/selectiontools/tool_elliptical_selection_cursor.png new file mode 100644 index 00000000..5e02f87b Binary files /dev/null and b/chalk/plugins/tools/selectiontools/tool_elliptical_selection_cursor.png differ diff --git a/chalk/plugins/tools/selectiontools/tool_eraser_selection.png b/chalk/plugins/tools/selectiontools/tool_eraser_selection.png new file mode 100644 index 00000000..ffe2e440 Binary files /dev/null and b/chalk/plugins/tools/selectiontools/tool_eraser_selection.png differ diff --git a/chalk/plugins/tools/selectiontools/tool_eraser_selection.svg b/chalk/plugins/tools/selectiontools/tool_eraser_selection.svg new file mode 100644 index 00000000..9c147c1b --- /dev/null +++ b/chalk/plugins/tools/selectiontools/tool_eraser_selection.svg @@ -0,0 +1,1993 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/chalk/plugins/tools/selectiontools/tool_eraser_selection_cursor.png b/chalk/plugins/tools/selectiontools/tool_eraser_selection_cursor.png new file mode 100644 index 00000000..e6b01060 Binary files /dev/null and b/chalk/plugins/tools/selectiontools/tool_eraser_selection_cursor.png differ diff --git a/chalk/plugins/tools/selectiontools/tool_outline_selection.png b/chalk/plugins/tools/selectiontools/tool_outline_selection.png new file mode 100644 index 00000000..ca1cb1d1 Binary files /dev/null and b/chalk/plugins/tools/selectiontools/tool_outline_selection.png differ diff --git a/chalk/plugins/tools/selectiontools/tool_outline_selection.svg b/chalk/plugins/tools/selectiontools/tool_outline_selection.svg new file mode 100644 index 00000000..2795dc86 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/tool_outline_selection.svg @@ -0,0 +1,329 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/chalk/plugins/tools/selectiontools/tool_outline_selection_cursor.png b/chalk/plugins/tools/selectiontools/tool_outline_selection_cursor.png new file mode 100644 index 00000000..10ef65fe Binary files /dev/null and b/chalk/plugins/tools/selectiontools/tool_outline_selection_cursor.png differ diff --git a/chalk/plugins/tools/selectiontools/tool_polygonal_selection.png b/chalk/plugins/tools/selectiontools/tool_polygonal_selection.png new file mode 100644 index 00000000..eda50984 Binary files /dev/null and b/chalk/plugins/tools/selectiontools/tool_polygonal_selection.png differ diff --git a/chalk/plugins/tools/selectiontools/tool_polygonal_selection.svg b/chalk/plugins/tools/selectiontools/tool_polygonal_selection.svg new file mode 100644 index 00000000..441dc125 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/tool_polygonal_selection.svg @@ -0,0 +1,364 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/chalk/plugins/tools/selectiontools/tool_polygonal_selection_cursor.png b/chalk/plugins/tools/selectiontools/tool_polygonal_selection_cursor.png new file mode 100644 index 00000000..6bf000a7 Binary files /dev/null and b/chalk/plugins/tools/selectiontools/tool_polygonal_selection_cursor.png differ diff --git a/chalk/plugins/tools/selectiontools/tool_rect_selection.png b/chalk/plugins/tools/selectiontools/tool_rect_selection.png new file mode 100644 index 00000000..7cb658c8 Binary files /dev/null and b/chalk/plugins/tools/selectiontools/tool_rect_selection.png differ diff --git a/chalk/plugins/tools/selectiontools/tool_rect_selection.svg b/chalk/plugins/tools/selectiontools/tool_rect_selection.svg new file mode 100644 index 00000000..824bcc78 --- /dev/null +++ b/chalk/plugins/tools/selectiontools/tool_rect_selection.svg @@ -0,0 +1,191 @@ + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/chalk/plugins/tools/selectiontools/tool_rectangular_selection_cursor.png b/chalk/plugins/tools/selectiontools/tool_rectangular_selection_cursor.png new file mode 100644 index 00000000..548d8ace Binary files /dev/null and b/chalk/plugins/tools/selectiontools/tool_rectangular_selection_cursor.png differ -- cgit v1.2.1