Krita Source Code Documentation
Loading...
Searching...
No Matches
DefaultTool Class Reference

#include <DefaultTool.h>

+ Inheritance diagram for DefaultTool:

Classes

class  MoveGradientHandleInteractionFactory
 
class  MoveMeshGradientHandleInteractionFactory
 

Public Types

enum  CanvasResource { HotPosition = 1410100299 }
 

Public Slots

void activate (const QSet< KoShape * > &shapes) override
 
void deactivate () override
 
- Public Slots inherited from KoToolBase
virtual void activate (const QSet< KoShape * > &shapes)
 
virtual void deactivate ()
 
virtual void documentResourceChanged (int key, const QVariant &res)
 
virtual void repaintDecorations ()
 
virtual void requestRedoDuringStroke ()
 
virtual void requestStrokeCancellation ()
 
virtual void requestStrokeEnd ()
 
virtual void requestUndoDuringStroke ()
 
void setStatusText (const QString &statusText)
 
void updateOptionsWidgetIcons ()
 

Signals

void meshgradientHandleSelected (KoShapeMeshGradientHandles::Handle)
 
- Signals inherited from KoToolBase
void activateTool (const QString &id)
 
void cursorChanged (const QCursor &cursor)
 
void selectionChanged (bool hasSelection)
 
void statusTextChanged (const QString &statusText)
 
void textModeChanged (bool inTextMode)
 

Public Member Functions

void copy () const override
 reimplemented
 
QRectF decorationsRect () const override
 
 DefaultTool (KoCanvasBase *canvas, bool connectToSelectedShapesProxy=false)
 
void deleteSelection () override
 reimplemented
 
void deselect () override
 reimplemented
 
void explicitUserStrokeEndRequest () override
 explicitUserStrokeEndRequest is called by the input manager when the user presses Enter key or any equivalent. This callback comes before requestStrokeEnd(), which comes from a different source.
 
KoFlake::SelectionHandle handleAt (const QPointF &point, bool *innerHandleMeaning=0)
 
void keyPressEvent (QKeyEvent *event) override
 
void mouseDoubleClickEvent (KoPointerEvent *event) override
 
void mouseMoveEvent (KoPointerEvent *event) override
 
void mousePressEvent (KoPointerEvent *event) override
 
void mouseReleaseEvent (KoPointerEvent *event) override
 
void paint (QPainter &painter, const KoViewConverter &converter) override
 
bool paste () override
 reimplemented
 
QMenu * popupActionsMenu () override
 
bool selectAll () override
 reimplemented
 
KoToolSelectionselection () override
 reimplemented
 
KoSvgTextShapetryFetchCurrentShapeManagerOwnerTextShape () const
 
bool updateTextContourMode ()
 
bool wantsAutoScroll () const override
 
 ~DefaultTool () override
 
- Public Member Functions inherited from KoInteractionTool
void keyPressEvent (QKeyEvent *event) override
 
void keyReleaseEvent (QKeyEvent *event) override
 
 KoInteractionTool (KoCanvasBase *canvas)
 
void mouseMoveEvent (KoPointerEvent *event) override
 
void mousePressEvent (KoPointerEvent *event) override
 
void mouseReleaseEvent (KoPointerEvent *event) override
 
void paint (QPainter &painter, const KoViewConverter &converter) override
 
 ~KoInteractionTool () override
 
- Public Member Functions inherited from KoToolBase
QAction * action (const QString &name) const
 
KoCanvasBasecanvas () const
 Returns the canvas the tool is working on.
 
QCursor cursor () const
 return the last emitted cursor
 
virtual void customMoveEvent (KoPointerEvent *event)
 
virtual void customPressEvent (KoPointerEvent *event)
 
virtual void customReleaseEvent (KoPointerEvent *event)
 
virtual void cut ()
 
int decorationThickness () const
 decorationThickness The minimum thickness for tool decoration lines, this is derived from the screen magnification, thus the HiDPI settings. Note: to use this effectively, also set the pen to isCosmetic(true);
 
virtual void dragLeaveEvent (QDragLeaveEvent *event)
 
virtual void dragMoveEvent (QDragMoveEvent *event, const QPointF &point)
 
virtual void dropEvent (QDropEvent *event, const QPointF &point)
 
KoToolFactoryBasefactory () const
 
virtual void focusInEvent (QFocusEvent *event)
 
virtual void focusOutEvent (QFocusEvent *event)
 
virtual bool hasSelection ()
 
virtual void inputMethodEvent (QInputMethodEvent *event)
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const
 
bool isInTextMode () const
 
bool isOpacityPresetMode () const
 
 KoToolBase (KoCanvasBase *canvas)
 
bool maskSyntheticEvents () const
 
virtual void mouseTripleClickEvent (KoPointerEvent *event)
 
QList< QPointer< QWidget > > optionWidgets ()
 
virtual KisPopupWidgetInterfacepopupWidget ()
 
Q_INVOKABLE QString toolId () const
 
 ~KoToolBase () override
 

Protected Slots

void updateActions ()
 Update actions on selection change.
 

Protected Member Functions

void addTransformActions (QMenu *menu) const
 
QList< QPointer< QWidget > > createOptionWidgets () override
 
KoInteractionStrategycreateStrategy (KoPointerEvent *event) override
 
virtual bool isValidForCurrentLayer () const
 
virtual KoSelectionkoSelection () const
 
virtual KoShapeManagershapeManager () const
 
virtual void updateDistinctiveActions (const QList< KoShape * > &editableShapes)
 
- Protected Member Functions inherited from KoInteractionTool
void addInteractionFactory (KoInteractionStrategyFactory *factory)
 
void cancelCurrentStrategy ()
 Cancels the current strategy and deletes it.
 
KoInteractionStrategycreateStrategyBase (KoPointerEvent *event)
 
KoInteractionStrategycurrentStrategy ()
 
bool hasInteractionFactory (const QString &id)
 
 KoInteractionTool (KoInteractionToolPrivate &dd)
 
void removeInteractionFactory (const QString &id)
 
bool tryUseCustomCursor ()
 
- Protected Member Functions inherited from KoToolBase
virtual QWidget * createOptionWidget ()
 
int grabSensitivity () const
 Convenience function to get the current grab sensitivity.
 
qreal handleDocRadius () const
 
QRectF handleGrabRect (const QPointF &position) const
 
QRectF handlePaintRect (const QPointF &position) const
 
int handleRadius () const
 Convenience function to get the current handle radius.
 
bool isActivated () const
 
 KoToolBase (KoToolBasePrivate &dd)
 
KoPointerEventlastDeliveredPointerEvent () const
 
void setAbstractResource (KoAbstractCanvasResourceInterfaceSP abstractResource)
 
void setConverter (KoDerivedResourceConverterSP converter)
 
void setIsOpacityPresetMode (bool value)
 
void setMaskSyntheticEvents (bool value)
 
void setTextMode (bool value)
 
QHash< int, KoAbstractCanvasResourceInterfaceSPtoolAbstractResources ()
 
QHash< int, KoDerivedResourceConverterSPtoolConverters ()
 
void useCursor (const QCursor &cursor)
 

Protected Attributes

QScopedPointer< QMenu > m_contextMenu
 
- Protected Attributes inherited from KoToolBase
KoToolBasePrivated_ptr
 

Private Slots

void selectionAlign (int _align)
 
void selectionBooleanOp (int booleanOp)
 
void selectionBringToFront ()
 
void selectionDistribute (int _distribute)
 
void selectionGroup ()
 
void selectionMoveDown ()
 
void selectionMoveUp ()
 
void selectionSendToBack ()
 
void selectionSplitShapes ()
 
void selectionTransform (int transformAction)
 
void selectionUngroup ()
 
void slotActivateEditFillGradient (bool value)
 
void slotActivateEditFillMeshGradient (bool value)
 
void slotActivateEditStrokeGradient (bool value)
 
void slotAddShapesToFlow ()
 
void slotChangeTextType (int index)
 
void slotPutTextOnPath ()
 
void slotRemoveShapesFromFlow ()
 
void slotReorderFlowShapes (int type)
 
void slotResetMeshGradientState ()
 
void slotSubtractShapesFromFlow ()
 
void slotToggleFlowShapeType ()
 

Private Member Functions

void addMappedAction (KisSignalMapper *mapper, const QString &actionId, int type)
 
void canvasResourceChanged (int key, const QVariant &res) override
 
QRectF handlesSize ()
 Returns selection rectangle adjusted by handle proximity threshold.
 
bool moveSelection (int direction, Qt::KeyboardModifiers modifiers)
 
void recalcSelectionBox (KoSelection *selection)
 
qreal rotationOfHandle (KoFlake::SelectionHandle handle, bool useEdgeRotation)
 Returns rotation angle of given handle of the current selection.
 
void selectionReorder (KoShapeReorderCommand::MoveShapeType order)
 
void setupActions ()
 
void updateCursor ()
 

Private Attributes

KisSignalMapperm_alignSignalsMapper {0}
 
qreal m_angle
 
KisSignalMapperm_booleanSignalsMapper {0}
 
QScopedPointer< SelectionDecoratorm_decorator
 
KisSignalMapperm_distributeSignalsMapper {0}
 
KoFlake::AnchorPosition m_hotPosition
 
KoShapeMeshGradientHandles::Handle m_hoveredMeshHandle
 
KoFlake::SelectionHandle m_lastHandle
 
QPointF m_lastPoint
 
bool m_mouseWasInsideHandles
 
QCursor m_rotateCursors [8]
 
KoShapeMeshGradientHandles::Handle m_selectedMeshHandle
 
QPointF m_selectionBox [8]
 
KoToolSelectionm_selectionHandler
 
QPolygonF m_selectionOutline
 
QCursor m_shearCursors [8]
 
QCursor m_sizeCursors [8]
 
DefaultToolTabbedWidgetm_tabbedOptionWidget
 
KisSignalMapperm_textFlowSignalsMapper {0}
 
QScopedPointer< KoSvgTextShapeOutlineHelperm_textOutlineHelper
 
DefaultToolTextPropertiesInterfacem_textPropertyInterface {0}
 
KisSignalMapperm_textTypeSignalsMapper {0}
 
KisSignalMapperm_transformSignalsMapper {0}
 

Friends

class SelectionHandler
 
class SelectionInteractionStrategy
 

Detailed Description

The default tool (associated with the arrow icon) implements the default interactions you have with flake objects.
The tool provides scaling, moving, selecting, rotation and soon skewing of any number of shapes.

Note that the implementation of those different strategies are delegated to the InteractionStrategy class and its subclasses.

Definition at line 41 of file DefaultTool.h.

Member Enumeration Documentation

◆ CanvasResource

Enumerator
HotPosition 

Definition at line 53 of file DefaultTool.h.

53 {
54 HotPosition = 1410100299
55 };

Constructor & Destructor Documentation

◆ DefaultTool()

DefaultTool::DefaultTool ( KoCanvasBase * canvas,
bool connectToSelectedShapesProxy = false )
explicit

Constructor for basic interaction tool where user actions are translated and handled by interaction strategies of type KoInteractionStrategy.

Parameters
canvasthe canvas this tool will be working for.

Definition at line 422 of file DefaultTool.cpp.

431{
432 setupActions();
433
434 QPixmap rotatePixmap, shearPixmap;
435 rotatePixmap.load(":/cursor_rotate.png");
436 Q_ASSERT(!rotatePixmap.isNull());
437 shearPixmap.load(":/cursor_shear.png");
438 Q_ASSERT(!shearPixmap.isNull());
439
440 m_rotateCursors[0] = QCursor(rotatePixmap.transformed(QTransform().rotate(45)));
441 m_rotateCursors[1] = QCursor(rotatePixmap.transformed(QTransform().rotate(90)));
442 m_rotateCursors[2] = QCursor(rotatePixmap.transformed(QTransform().rotate(135)));
443 m_rotateCursors[3] = QCursor(rotatePixmap.transformed(QTransform().rotate(180)));
444 m_rotateCursors[4] = QCursor(rotatePixmap.transformed(QTransform().rotate(225)));
445 m_rotateCursors[5] = QCursor(rotatePixmap.transformed(QTransform().rotate(270)));
446 m_rotateCursors[6] = QCursor(rotatePixmap.transformed(QTransform().rotate(315)));
447 m_rotateCursors[7] = QCursor(rotatePixmap);
448 /*
449 m_rotateCursors[0] = QCursor(Qt::RotateNCursor);
450 m_rotateCursors[1] = QCursor(Qt::RotateNECursor);
451 m_rotateCursors[2] = QCursor(Qt::RotateECursor);
452 m_rotateCursors[3] = QCursor(Qt::RotateSECursor);
453 m_rotateCursors[4] = QCursor(Qt::RotateSCursor);
454 m_rotateCursors[5] = QCursor(Qt::RotateSWCursor);
455 m_rotateCursors[6] = QCursor(Qt::RotateWCursor);
456 m_rotateCursors[7] = QCursor(Qt::RotateNWCursor);
457 */
458 m_shearCursors[0] = QCursor(shearPixmap);
459 m_shearCursors[1] = QCursor(shearPixmap.transformed(QTransform().rotate(45)));
460 m_shearCursors[2] = QCursor(shearPixmap.transformed(QTransform().rotate(90)));
461 m_shearCursors[3] = QCursor(shearPixmap.transformed(QTransform().rotate(135)));
462 m_shearCursors[4] = QCursor(shearPixmap.transformed(QTransform().rotate(180)));
463 m_shearCursors[5] = QCursor(shearPixmap.transformed(QTransform().rotate(225)));
464 m_shearCursors[6] = QCursor(shearPixmap.transformed(QTransform().rotate(270)));
465 m_shearCursors[7] = QCursor(shearPixmap.transformed(QTransform().rotate(315)));
466 m_sizeCursors[0] = Qt::SizeVerCursor;
467 m_sizeCursors[1] = Qt::SizeBDiagCursor;
468 m_sizeCursors[2] = Qt::SizeHorCursor;
469 m_sizeCursors[3] = Qt::SizeFDiagCursor;
470 m_sizeCursors[4] = Qt::SizeVerCursor;
471 m_sizeCursors[5] = Qt::SizeBDiagCursor;
472 m_sizeCursors[6] = Qt::SizeHorCursor;
473 m_sizeCursors[7] = Qt::SizeFDiagCursor;
474
475 if (connectToSelectedShapesProxy) {
476 connect(canvas->selectedShapesProxy(), SIGNAL(selectionChanged()), this, SLOT(updateActions()));
477
478 connect(canvas->selectedShapesProxy(), SIGNAL(selectionChanged()), this, SLOT(repaintDecorations()));
479 connect(canvas->selectedShapesProxy(), SIGNAL(selectionChanged()), m_textPropertyInterface, SLOT(slotSelectionChanged()));
480 connect(canvas->selectedShapesProxy(), SIGNAL(selectionContentChanged()), this, SLOT(repaintDecorations()));
481 }
482
483 m_textOutlineHelper->setDrawBoundingRect(false);
484 m_textOutlineHelper->setDrawShapeOutlines(true);
485}
KoFlake::SelectionHandle m_lastHandle
bool m_mouseWasInsideHandles
KoFlake::AnchorPosition m_hotPosition
void updateActions()
Update actions on selection change.
QCursor m_shearCursors[8]
QCursor m_sizeCursors[8]
DefaultToolTabbedWidget * m_tabbedOptionWidget
friend class SelectionHandler
DefaultToolTextPropertiesInterface * m_textPropertyInterface
QScopedPointer< KoSvgTextShapeOutlineHelper > m_textOutlineHelper
QCursor m_rotateCursors[8]
void setupActions()
KoToolSelection * m_selectionHandler
virtual KoSelectedShapesProxy * selectedShapesProxy() const =0
selectedShapesProxy() is a special interface for keeping a persistent connections to selectionChanged...
KoInteractionTool(KoCanvasBase *canvas)
The KoSvgTextShapeOutlineHelper class helper class that draws the text outlines and contour mode butt...
KoCanvasBase * canvas() const
Returns the canvas the tool is working on.
void selectionChanged(bool hasSelection)
virtual void repaintDecorations()
@ TopLeft
Definition KoFlake.h:86
@ NoHandle
Value to indicate no handle.
Definition KoFlake.h:64
Interface to interact with the text property manager.

References KoToolBase::canvas(), m_rotateCursors, m_shearCursors, m_sizeCursors, m_textOutlineHelper, m_textPropertyInterface, KoToolBase::repaintDecorations(), KoCanvasBase::selectedShapesProxy(), KoToolBase::selectionChanged(), setupActions(), and updateActions().

◆ ~DefaultTool()

DefaultTool::~DefaultTool ( )
override

Definition at line 487 of file DefaultTool.cpp.

488{
489}

Member Function Documentation

◆ activate

void DefaultTool::activate ( const QSet< KoShape * > & shapes)
overrideslot

Definition at line 1476 of file DefaultTool.cpp.

1477{
1478 KoToolBase::activate(shapes);
1479
1480 QAction *actionBringToFront = action("object_order_front");
1481 connect(actionBringToFront, SIGNAL(triggered()), this, SLOT(selectionBringToFront()), Qt::UniqueConnection);
1482
1483 QAction *actionRaise = action("object_order_raise");
1484 connect(actionRaise, SIGNAL(triggered()), this, SLOT(selectionMoveUp()), Qt::UniqueConnection);
1485
1486 QAction *actionLower = action("object_order_lower");
1487 connect(actionLower, SIGNAL(triggered()), this, SLOT(selectionMoveDown()));
1488
1489 QAction *actionSendToBack = action("object_order_back");
1490 connect(actionSendToBack, SIGNAL(triggered()), this, SLOT(selectionSendToBack()), Qt::UniqueConnection);
1491
1492 QAction *actionGroupBottom = action("object_group");
1493 connect(actionGroupBottom, SIGNAL(triggered()), this, SLOT(selectionGroup()), Qt::UniqueConnection);
1494
1495 QAction *actionUngroupBottom = action("object_ungroup");
1496 connect(actionUngroupBottom, SIGNAL(triggered()), this, SLOT(selectionUngroup()), Qt::UniqueConnection);
1497
1498 QAction *actionSplit = action("object_split");
1499 connect(actionSplit, SIGNAL(triggered()), this, SLOT(selectionSplitShapes()), Qt::UniqueConnection);
1500
1501 connect(m_alignSignalsMapper, SIGNAL(mapped(int)), SLOT(selectionAlign(int)));
1502 connect(m_distributeSignalsMapper, SIGNAL(mapped(int)), SLOT(selectionDistribute(int)));
1503 connect(m_transformSignalsMapper, SIGNAL(mapped(int)), SLOT(selectionTransform(int)));
1504 connect(m_booleanSignalsMapper, SIGNAL(mapped(int)), SLOT(selectionBooleanOp(int)));
1505 connect(m_textTypeSignalsMapper, SIGNAL(mapped(int)), SLOT(slotChangeTextType(int)));
1506 connect(m_textFlowSignalsMapper, SIGNAL(mapped(int)), SLOT(slotReorderFlowShapes(int)));
1507
1508 QAction *actionTextInside = action("add_shape_to_flow_area");
1509 connect(actionTextInside, SIGNAL(triggered()), this, SLOT(slotAddShapesToFlow()), Qt::UniqueConnection);
1510
1511 QAction *actionTextSubtract = action("subtract_shape_from_flow_area");
1512 connect(actionTextSubtract, SIGNAL(triggered()), this, SLOT(slotSubtractShapesFromFlow()), Qt::UniqueConnection);
1513
1514 QAction *actionTextOnPath = action("put_text_on_path");
1515 connect(actionTextOnPath, SIGNAL(triggered()), this, SLOT(slotPutTextOnPath()), Qt::UniqueConnection);
1516
1517 QAction *actionTextRemoveFlow = action("remove_shapes_from_text_flow");
1518 connect(actionTextRemoveFlow, SIGNAL(triggered()), this, SLOT(slotRemoveShapesFromFlow()), Qt::UniqueConnection);
1519
1520 QAction *actionTextFlowToggle = action("flow_shape_type_toggle");
1521 connect(actionTextFlowToggle, SIGNAL(triggered()), this, SLOT(slotToggleFlowShapeType()), Qt::UniqueConnection);
1522
1525 useCursor(Qt::ArrowCursor);
1527 updateActions();
1528
1529 const KisCanvas2 *canvas2 = qobject_cast<const KisCanvas2 *>(this->canvas());
1530 if (canvas2) {
1533 }
1534
1537 }
1538}
void selectionSendToBack()
KisSignalMapper * m_textTypeSignalsMapper
void selectionDistribute(int _distribute)
KisSignalMapper * m_booleanSignalsMapper
KisSignalMapper * m_distributeSignalsMapper
void slotRemoveShapesFromFlow()
void slotAddShapesToFlow()
void slotReorderFlowShapes(int type)
void selectionTransform(int transformAction)
void slotSubtractShapesFromFlow()
void slotPutTextOnPath()
void selectionGroup()
void selectionAlign(int _align)
void selectionMoveDown()
void slotToggleFlowShapeType()
void selectionBooleanOp(int booleanOp)
KisSignalMapper * m_alignSignalsMapper
KisSignalMapper * m_textFlowSignalsMapper
KisSignalMapper * m_transformSignalsMapper
void selectionBringToFront()
void selectionUngroup()
void slotChangeTextType(int index)
void selectionSplitShapes()
void selectionMoveUp()
KisViewManager * viewManager() const
void setTextPropertiesInterface(KoSvgTextPropertiesInterface *interface)
setTextPropertiesInterface set the text properties interface. This should be done on tool activation....
KisTextPropertiesManager * textPropertyManager() const
void useCursor(const QCursor &cursor)
virtual void activate(const QSet< KoShape * > &shapes)
QAction * action(const QString &name) const

References KoToolBase::action(), DefaultToolTabbedWidget::activate(), KoToolBase::activate(), KoToolBase::canvas(), m_alignSignalsMapper, m_booleanSignalsMapper, m_distributeSignalsMapper, m_lastHandle, m_mouseWasInsideHandles, m_tabbedOptionWidget, m_textFlowSignalsMapper, m_textPropertyInterface, m_textTypeSignalsMapper, m_transformSignalsMapper, KoFlake::NoHandle, KoToolBase::repaintDecorations(), selectionAlign(), selectionBooleanOp(), selectionBringToFront(), selectionDistribute(), selectionGroup(), selectionMoveDown(), selectionMoveUp(), selectionSendToBack(), selectionSplitShapes(), selectionTransform(), selectionUngroup(), KisTextPropertiesManager::setTextPropertiesInterface(), slotAddShapesToFlow(), slotChangeTextType(), slotPutTextOnPath(), slotRemoveShapesFromFlow(), slotReorderFlowShapes(), DefaultToolTextPropertiesInterface::slotSelectionChanged(), slotSubtractShapesFromFlow(), slotToggleFlowShapeType(), KisViewManager::textPropertyManager(), updateActions(), KoToolBase::useCursor(), and KisCanvas2::viewManager().

◆ addMappedAction()

void DefaultTool::addMappedAction ( KisSignalMapper * mapper,
const QString & actionId,
int type )
private

Definition at line 799 of file DefaultTool.cpp.

800{
801 QAction *a =action(actionId);
802 connect(a, SIGNAL(triggered()), mapper, SLOT(map()));
803 mapper->setMapping(a, commandType);
804}
void setMapping(QObject *sender, int id)

References KoToolBase::action(), and KisSignalMapper::setMapping().

◆ addTransformActions()

void DefaultTool::addTransformActions ( QMenu * menu) const
protected

Definition at line 2335 of file DefaultTool.cpp.

2335 {
2336 menu->addAction(action("object_transform_rotate_90_cw"));
2337 menu->addAction(action("object_transform_rotate_90_ccw"));
2338 menu->addAction(action("object_transform_rotate_180"));
2339 menu->addSeparator();
2340 menu->addAction(action("object_transform_mirror_horizontally"));
2341 menu->addAction(action("object_transform_mirror_vertically"));
2342 menu->addSeparator();
2343 menu->addAction(action("object_transform_reset"));
2344}

References KoToolBase::action().

◆ canvasResourceChanged()

void DefaultTool::canvasResourceChanged ( int key,
const QVariant & res )
overrideprivatevirtual

This method is called whenever a property in the resource provider associated with the canvas this tool belongs to changes. An example is currently selected foreground color.

Reimplemented from KoToolBase.

Definition at line 1977 of file DefaultTool.cpp.

1978{
1979 if (key == HotPosition) {
1982 }
1983}
AnchorPosition
Definition KoFlake.h:85

References HotPosition, m_hotPosition, and KoToolBase::repaintDecorations().

◆ copy()

void DefaultTool::copy ( ) const
overridevirtual

reimplemented

Reimplemented from KoToolBase.

Definition at line 1328 of file DefaultTool.cpp.

1329{
1330 // all the selected shapes, not only editable!
1332
1333 if (!shapes.isEmpty()) {
1334 KoDrag drag;
1335 drag.setSvg(shapes);
1336 drag.addToClipboard();
1337 }
1338}
virtual KoSelection * koSelection() const
bool setSvg(const QList< KoShape * > shapes)
Definition KoDrag.cpp:47
void addToClipboard()
Definition KoDrag.cpp:86
const QList< KoShape * > selectedShapes() const

References KoDrag::addToClipboard(), koSelection(), KoSelection::selectedShapes(), and KoDrag::setSvg().

◆ createOptionWidgets()

QList< QPointer< QWidget > > DefaultTool::createOptionWidgets ( )
overrideprotectedvirtual

Reimplemented from KoToolBase.

Reimplemented in ToolReferenceImages.

Definition at line 1946 of file DefaultTool.cpp.

1947{
1948 QList<QPointer<QWidget> > widgets;
1949
1951
1952 if (isActivated()) {
1954 }
1955 widgets.append(m_tabbedOptionWidget);
1956
1957 connect(m_tabbedOptionWidget,
1958 SIGNAL(sigSwitchModeEditFillGradient(bool)),
1959 SLOT(slotActivateEditFillGradient(bool)));
1960
1961 connect(m_tabbedOptionWidget,
1962 SIGNAL(sigSwitchModeEditStrokeGradient(bool)),
1963 SLOT(slotActivateEditStrokeGradient(bool)));
1964
1965 connect(m_tabbedOptionWidget,
1966 SIGNAL(sigSwitchModeEditFillGradient(bool)),
1968 // TODO: strokes!!
1969
1970 connect(m_tabbedOptionWidget,
1971 SIGNAL(sigMeshGradientResetted()),
1973
1974 return widgets;
1975}
void slotActivateEditStrokeGradient(bool value)
void slotActivateEditFillMeshGradient(bool value)
void slotActivateEditFillGradient(bool value)
void slotResetMeshGradientState()
bool isActivated() const

References DefaultToolTabbedWidget::activate(), KoToolBase::isActivated(), m_tabbedOptionWidget, slotActivateEditFillGradient(), slotActivateEditFillMeshGradient(), slotActivateEditStrokeGradient(), and slotResetMeshGradientState().

◆ createStrategy()

KoInteractionStrategy * DefaultTool::createStrategy ( KoPointerEvent * event)
overrideprotectedvirtual

Implements KoInteractionTool.

Definition at line 1985 of file DefaultTool.cpp.

1986{
1988 if (!selection) return nullptr;
1989
1990 bool insideSelection = false;
1991 KoFlake::SelectionHandle handle = handleAt(event->point, &insideSelection);
1992
1993 bool editableShape = !selection->selectedEditableShapes().isEmpty();
1994
1995 const bool selectMultiple = event->modifiers() & Qt::ShiftModifier;
1996 const bool selectNextInStack = event->modifiers() & Qt::ControlModifier;
1997 const bool avoidSelection = event->modifiers() & Qt::AltModifier;
1998
1999 if (selectNextInStack) {
2000 // change the hot selection position when middle clicking on a handle
2001 KoFlake::AnchorPosition newHotPosition = m_hotPosition;
2002 switch (handle) {
2004 newHotPosition = KoFlake::Top;
2005 break;
2007 newHotPosition = KoFlake::TopRight;
2008 break;
2010 newHotPosition = KoFlake::Right;
2011 break;
2013 newHotPosition = KoFlake::BottomRight;
2014 break;
2016 newHotPosition = KoFlake::Bottom;
2017 break;
2019 newHotPosition = KoFlake::BottomLeft;
2020 break;
2022 newHotPosition = KoFlake::Left;
2023 break;
2025 newHotPosition = KoFlake::TopLeft;
2026 break;
2027 case KoFlake::NoHandle:
2028 default:
2029 // check if we had hit the center point
2030 const KoViewConverter *converter = canvas()->viewConverter();
2031 QPointF pt = converter->documentToView(event->point);
2032
2033 // TODO: use calculated values instead!
2034 QPointF centerPt = converter->documentToView(selection->absolutePosition());
2035
2036 if (kisSquareDistance(pt, centerPt) < HANDLE_DISTANCE_SQ) {
2037 newHotPosition = KoFlake::Center;
2038 }
2039
2040 break;
2041 }
2042
2043 if (m_hotPosition != newHotPosition) {
2044 canvas()->resourceManager()->setResource(HotPosition, newHotPosition);
2045 return new NopInteractionStrategy(this);
2046 }
2047 }
2048
2049 if (!avoidSelection && editableShape) {
2050 // manipulation of selected shapes goes first
2051 if (handle != KoFlake::NoHandle) {
2052 // resizing or shearing only with left mouse button
2053 if (insideSelection) {
2054 bool forceUniformScaling = m_tabbedOptionWidget && m_tabbedOptionWidget->useUniformScaling();
2055 return new ShapeResizeStrategy(this, selection, event->point, handle, forceUniformScaling);
2056 }
2057
2058 if (handle == KoFlake::TopMiddleHandle || handle == KoFlake::RightMiddleHandle ||
2060
2061 return new ShapeShearStrategy(this, selection, event->point, handle);
2062 }
2063
2064 // rotating is allowed for right mouse button too
2065 if (handle == KoFlake::TopLeftHandle || handle == KoFlake::TopRightHandle ||
2067
2068 return new ShapeRotateStrategy(this, selection, event->point, event->buttons());
2069 }
2070 }
2071
2072 if (!selectMultiple && !selectNextInStack) {
2073
2074 if (insideSelection) {
2075 return new ShapeMoveStrategy(this, selection, event->point);
2076 }
2077 }
2078 }
2079
2080 KoShape *shape = shapeManager()->shapeAt(event->point, selectNextInStack ? KoFlake::NextUnselected : KoFlake::ShapeOnTop);
2081
2082 if (avoidSelection || (!shape && handle == KoFlake::NoHandle)) {
2083 if (!selectMultiple) {
2084 selection->deselectAll();
2085 }
2086 return new SelectionInteractionStrategy(this, event->point, false);
2087 }
2088
2089 if (selection->isSelected(shape)) {
2090 if (selectMultiple) {
2091 selection->deselect(shape);
2092 }
2093 } else if (handle == KoFlake::NoHandle) { // clicked on shape which is not selected
2094 if (!selectMultiple) {
2095 selection->deselectAll();
2096 }
2097 selection->select(shape);
2098 // tablet selection isn't precise and may lead to a move, preventing that
2099 if (event->isTabletEvent()) {
2100 return new NopInteractionStrategy(this);
2101 }
2102 return new ShapeMoveStrategy(this, selection, event->point);
2103 }
2104 return 0;
2105}
#define HANDLE_DISTANCE_SQ
KoFlake::SelectionHandle handleAt(const QPointF &point, bool *innerHandleMeaning=0)
friend class SelectionInteractionStrategy
KoToolSelection * selection() override
reimplemented
virtual KoShapeManager * shapeManager() const
virtual const KoViewConverter * viewConverter() const =0
QPointer< KoCanvasResourceProvider > resourceManager
Qt::MouseButtons buttons() const
return buttons pressed (see QMouseEvent::buttons());
bool isTabletEvent() const
QPointF point
The point in document coordinates.
KoShape * shapeAt(const QPointF &position, KoFlake::ShapeSelection selection=KoFlake::ShapeOnTop, bool omitHiddenShapes=true)
virtual QPointF documentToView(const QPointF &documentPoint) const
qreal kisSquareDistance(const QPointF &pt1, const QPointF &pt2)
Definition kis_global.h:194
@ ShapeOnTop
return the shape highest z-ordering, regardless of selection.
Definition KoFlake.h:74
@ NextUnselected
return the first unselected directly under a selected shape, or the top most one if nothing is select...
Definition KoFlake.h:73
@ Left
Definition KoFlake.h:89
@ Right
Definition KoFlake.h:91
@ Bottom
Definition KoFlake.h:93
@ BottomRight
Definition KoFlake.h:94
@ Top
Definition KoFlake.h:87
@ TopRight
Definition KoFlake.h:88
@ BottomLeft
Definition KoFlake.h:92
@ Center
Definition KoFlake.h:90
SelectionHandle
Enum determining which handle is meant, used in KoInteractionTool.
Definition KoFlake.h:55
@ BottomRightHandle
The handle that is at the bottom right of a selection.
Definition KoFlake.h:59
@ BottomLeftHandle
The handle that is at the bottom left of a selection.
Definition KoFlake.h:61
@ RightMiddleHandle
The handle that is at the right - center of a selection.
Definition KoFlake.h:58
@ TopRightHandle
The handle that is at the top - right of a selection.
Definition KoFlake.h:57
@ TopLeftHandle
The handle that is at the top left of a selection.
Definition KoFlake.h:63
@ LeftMiddleHandle
The handle that is at the left center of a selection.
Definition KoFlake.h:62
@ TopMiddleHandle
The handle that is at the top - center of a selection.
Definition KoFlake.h:56
@ BottomMiddleHandle
The handle that is at the bottom center of a selection.
Definition KoFlake.h:60

References KoFlake::Bottom, KoFlake::BottomLeft, KoFlake::BottomLeftHandle, KoFlake::BottomMiddleHandle, KoFlake::BottomRight, KoFlake::BottomRightHandle, KoPointerEvent::buttons(), KoToolBase::canvas(), KoFlake::Center, KoViewConverter::documentToView(), HANDLE_DISTANCE_SQ, handleAt(), HotPosition, KoPointerEvent::isTabletEvent(), kisSquareDistance(), koSelection(), KoFlake::Left, KoFlake::LeftMiddleHandle, m_hotPosition, m_tabbedOptionWidget, KoFlake::NextUnselected, KoFlake::NoHandle, KoPointerEvent::point, KoCanvasBase::resourceManager, KoFlake::Right, KoFlake::RightMiddleHandle, selection(), SelectionInteractionStrategy, KoShapeManager::shapeAt(), shapeManager(), KoFlake::ShapeOnTop, KoFlake::Top, KoFlake::TopLeft, KoFlake::TopLeftHandle, KoFlake::TopMiddleHandle, KoFlake::TopRight, KoFlake::TopRightHandle, DefaultToolTabbedWidget::useUniformScaling(), and KoCanvasBase::viewConverter().

◆ deactivate

void DefaultTool::deactivate ( )
overrideslot

Definition at line 1540 of file DefaultTool.cpp.

1541{
1543
1544 QAction *actionBringToFront = action("object_order_front");
1545 disconnect(actionBringToFront, 0, this, 0);
1546
1547 QAction *actionRaise = action("object_order_raise");
1548 disconnect(actionRaise, 0, this, 0);
1549
1550 QAction *actionLower = action("object_order_lower");
1551 disconnect(actionLower, 0, this, 0);
1552
1553 QAction *actionSendToBack = action("object_order_back");
1554 disconnect(actionSendToBack, 0, this, 0);
1555
1556 QAction *actionGroupBottom = action("object_group");
1557 disconnect(actionGroupBottom, 0, this, 0);
1558
1559 QAction *actionUngroupBottom = action("object_ungroup");
1560 disconnect(actionUngroupBottom, 0, this, 0);
1561
1562 QAction *actionSplit = action("object_split");
1563 disconnect(actionSplit, 0, this, 0);
1564
1565 disconnect(m_alignSignalsMapper, 0, this, 0);
1566 disconnect(m_distributeSignalsMapper, 0, this, 0);
1567 disconnect(m_transformSignalsMapper, 0, this, 0);
1568 disconnect(m_booleanSignalsMapper, 0, this, 0);
1569 disconnect(m_textTypeSignalsMapper, 0, this, 0);
1570 disconnect(m_textFlowSignalsMapper, 0, this, 0);
1571
1572 QAction *actionTextInside = action("add_shape_to_flow_area");
1573 disconnect(actionTextInside, 0, this, 0);
1574 QAction *actionTextSubtract = action("subtract_shape_from_flow_area");
1575 disconnect(actionTextSubtract, 0, this, 0);
1576 QAction *actionTextOnPath = action("put_text_on_path");
1577 disconnect(actionTextOnPath, 0, this, 0);
1578 QAction *actionTextRemoveFlow = action("remove_shapes_from_text_flow");
1579 disconnect(actionTextRemoveFlow, 0, this, 0);
1580 QAction *actionTextFlowToggle = action("flow_shape_type_toggle");
1581 disconnect(actionTextFlowToggle, 0, this, 0);
1582
1583 const KisCanvas2 *canvas2 = qobject_cast<const KisCanvas2 *>(this->canvas());
1584 if (canvas2) {
1587 }
1588
1591 }
1592}
virtual void deactivate()

References KoToolBase::action(), KoToolBase::canvas(), DefaultToolTextPropertiesInterface::clearSelection(), KoToolBase::deactivate(), DefaultToolTabbedWidget::deactivate(), m_alignSignalsMapper, m_booleanSignalsMapper, m_distributeSignalsMapper, m_tabbedOptionWidget, m_textFlowSignalsMapper, m_textPropertyInterface, m_textTypeSignalsMapper, m_transformSignalsMapper, KisTextPropertiesManager::setTextPropertiesInterface(), KisViewManager::textPropertyManager(), and KisCanvas2::viewManager().

◆ decorationsRect()

QRectF DefaultTool::decorationsRect ( ) const
overridevirtual

TODO: avoid cons_cast by implementing proper caching strategy inrecalcSelectionBox() and handlesSize()

Reimplemented from KoToolBase.

Definition at line 1309 of file DefaultTool.cpp.

1310{
1311 QRectF dirtyRect;
1312
1313 if (koSelection() && koSelection()->count() > 0) {
1317 dirtyRect = const_cast<DefaultTool*>(this)->handlesSize();
1318 }
1319
1320 if (canvas()->snapGuide()->isSnapping()) {
1321 dirtyRect |= canvas()->snapGuide()->boundingRect();
1322 }
1323 dirtyRect |= m_textOutlineHelper->decorationRect();
1324
1325 return dirtyRect;
1326}
QRectF handlesSize()
Returns selection rectangle adjusted by handle proximity threshold.
KoSnapGuide * snapGuide
QRectF boundingRect()
returns the bounding rect of the guide
bool isSnapping() const
returns if snapping is enabled

References KoSnapGuide::boundingRect(), KoToolBase::canvas(), handlesSize(), KoSnapGuide::isSnapping(), koSelection(), m_textOutlineHelper, and KoCanvasBase::snapGuide.

◆ deleteSelection()

void DefaultTool::deleteSelection ( )
overridevirtual

reimplemented

Reimplemented from KoToolBase.

Reimplemented in ToolReferenceImages.

Definition at line 1340 of file DefaultTool.cpp.

1341{
1342 QList<KoShape *> shapes;
1343 foreach (KoShape *s, koSelection()->selectedShapes()) {
1344 if (s->isGeometryProtected()) {
1345 continue;
1346 }
1347 shapes << s;
1348 }
1349 if (!shapes.empty()) {
1350 canvas()->addCommand(canvas()->shapeController()->removeShapes(shapes));
1351 }
1352}
virtual void addCommand(KUndo2Command *command)=0
bool isGeometryProtected() const
Definition KoShape.cpp:842

References KoCanvasBase::addCommand(), KoToolBase::canvas(), KoShape::isGeometryProtected(), and koSelection().

◆ deselect()

void DefaultTool::deselect ( )
overridevirtual

reimplemented

Reimplemented from KoToolBase.

Definition at line 1373 of file DefaultTool.cpp.

1374{
1375 Q_ASSERT(canvas());
1376 Q_ASSERT(canvas()->selectedShapesProxy());
1379}
virtual KoSelection * selection()=0
void deselectAll()
clear the selections list

References KoToolBase::canvas(), KoSelection::deselectAll(), KoToolBase::repaintDecorations(), KoCanvasBase::selectedShapesProxy(), and KoSelectedShapesProxy::selection().

◆ explicitUserStrokeEndRequest()

void DefaultTool::explicitUserStrokeEndRequest ( )
overridevirtual

explicitUserStrokeEndRequest is called by the input manager when the user presses Enter key or any equivalent. This callback comes before requestStrokeEnd(), which comes from a different source.

Reimplemented from KoToolBase.

Definition at line 2346 of file DefaultTool.cpp.

2347{
2349 QString tool = KoToolManager::instance()->preferredToolForSelection(shapes);
2350 QTimer::singleShot(0, [tool = std::move(tool)]() {
2352 });
2353}
const QList< KoShape * > selectedEditableShapesAndDelegates() const
void switchToolRequested(const QString &id)
QString preferredToolForSelection(const QList< KoShape * > &shapes)
static KoToolManager * instance()
Return the toolmanager singleton.

References KoToolManager::instance(), koSelection(), KoToolManager::preferredToolForSelection(), KoSelection::selectedEditableShapesAndDelegates(), and KoToolManager::switchToolRequested().

◆ handleAt()

KoFlake::SelectionHandle DefaultTool::handleAt ( const QPointF & point,
bool * innerHandleMeaning = 0 )

Returns which selection handle is at params point (or NoHandle if none).

Returns
which selection handle is at params point (or NoHandle if none).
Parameters
pointthe location (in pt) where we should look for a handle
innerHandleMeaningthis boolean is altered to true if the point is inside the selection rectangle and false if it is just outside. The value of innerHandleMeaning is undefined if the handle location is NoHandle

Definition at line 1388 of file DefaultTool.cpp.

1389{
1390 // check for handles in this order; meaning that when handles overlap the one on top is chosen
1391 static const KoFlake::SelectionHandle handleOrder[] = {
1401 };
1402
1403 const KoViewConverter *converter = canvas()->viewConverter();
1405
1406 if (!selection || !selection->count() || !converter) {
1407 return KoFlake::NoHandle;
1408 }
1409
1411
1412 if (innerHandleMeaning) {
1413 QPainterPath path;
1414 path.addPolygon(m_selectionOutline);
1415 *innerHandleMeaning = path.contains(point) || path.intersects(handlePaintRect(point));
1416 }
1417
1418 const QPointF viewPoint = converter->documentToView(point);
1419
1420 for (int i = 0; i < KoFlake::NoHandle; ++i) {
1421 KoFlake::SelectionHandle handle = handleOrder[i];
1422
1423 const QPointF handlePoint = converter->documentToView(m_selectionBox[handle]);
1424 const qreal distanceSq = kisSquareDistance(viewPoint, handlePoint);
1425
1426 // if just inside the outline
1427 if (distanceSq < HANDLE_DISTANCE_SQ) {
1428
1429 if (innerHandleMeaning) {
1430 if (distanceSq < INNER_HANDLE_DISTANCE_SQ) {
1431 *innerHandleMeaning = true;
1432 }
1433 }
1434
1435 return handle;
1436 }
1437 }
1438 return KoFlake::NoHandle;
1439}
#define INNER_HANDLE_DISTANCE_SQ
QPointF m_selectionBox[8]
void recalcSelectionBox(KoSelection *selection)
QPolygonF m_selectionOutline
QRectF handlePaintRect(const QPointF &position) const

References KoFlake::BottomLeftHandle, KoFlake::BottomMiddleHandle, KoFlake::BottomRightHandle, KoToolBase::canvas(), KoViewConverter::documentToView(), HANDLE_DISTANCE_SQ, KoToolBase::handlePaintRect(), INNER_HANDLE_DISTANCE_SQ, kisSquareDistance(), koSelection(), KoFlake::LeftMiddleHandle, m_selectionBox, m_selectionOutline, KoFlake::NoHandle, recalcSelectionBox(), KoFlake::RightMiddleHandle, selection(), KoFlake::TopLeftHandle, KoFlake::TopMiddleHandle, KoFlake::TopRightHandle, and KoCanvasBase::viewConverter().

◆ handlesSize()

QRectF DefaultTool::handlesSize ( )
private

Returns selection rectangle adjusted by handle proximity threshold.

Definition at line 1212 of file DefaultTool.cpp.

1213{
1215 if (!selection || !selection->count()) return QRectF();
1216
1218
1219 QRectF bound = m_selectionOutline.boundingRect();
1220
1221 // expansion Border
1222 if (!canvas() || !canvas()->viewConverter()) {
1223 return bound;
1224 }
1225
1226 QPointF border = canvas()->viewConverter()->viewToDocument(QPointF(HANDLE_DISTANCE, HANDLE_DISTANCE));
1227 bound.adjust(-border.x(), -border.y(), border.x(), border.y());
1228 return bound;
1229}
#define HANDLE_DISTANCE
virtual QPointF viewToDocument(const QPointF &viewPoint) const

References KoToolBase::canvas(), HANDLE_DISTANCE, koSelection(), m_selectionOutline, recalcSelectionBox(), selection(), KoCanvasBase::viewConverter(), and KoViewConverter::viewToDocument().

◆ isValidForCurrentLayer()

bool DefaultTool::isValidForCurrentLayer ( ) const
protectedvirtual

Reimplemented in ToolReferenceImages.

Definition at line 1149 of file DefaultTool.cpp.

1150{
1151 // if the currently active node has a shape manager, then it is
1152 // probably our client :)
1153
1154 KisCanvas2 *kisCanvas = static_cast<KisCanvas2 *>(canvas());
1155 return bool(kisCanvas->localShapeManager());
1156}
KoShapeManager * localShapeManager() const

References KoToolBase::canvas(), and KisCanvas2::localShapeManager().

◆ keyPressEvent()

void DefaultTool::keyPressEvent ( QKeyEvent * event)
overridevirtual

Called when a key is pressed. Implementors should call event->ignore() if they do not actually use the event. Default implementation ignores this event.

Parameters
eventstate and reason of this key press

Reimplemented from KoToolBase.

Definition at line 1290 of file DefaultTool.cpp.

1291{
1293 if (currentStrategy() == 0) {
1294 switch (event->key()) {
1295 case Qt::Key_Left:
1296 case Qt::Key_Right:
1297 case Qt::Key_Up:
1298 case Qt::Key_Down:
1299 if (moveSelection(event->key(), event->modifiers())) {
1300 event->accept();
1301 }
1302 break;
1303 default:
1304 return;
1305 }
1306 }
1307}
bool moveSelection(int direction, Qt::KeyboardModifiers modifiers)
void keyPressEvent(QKeyEvent *event) override
KoInteractionStrategy * currentStrategy()

References KoInteractionTool::currentStrategy(), KoInteractionTool::keyPressEvent(), and moveSelection().

◆ koSelection()

KoSelection * DefaultTool::koSelection ( ) const
protectedvirtual

Reimplemented in ToolReferenceImages.

Definition at line 1381 of file DefaultTool.cpp.

1382{
1383 Q_ASSERT(canvas());
1384 Q_ASSERT(canvas()->selectedShapesProxy());
1385 return canvas()->selectedShapesProxy()->selection();
1386}

References KoToolBase::canvas(), KoCanvasBase::selectedShapesProxy(), and KoSelectedShapesProxy::selection().

◆ meshgradientHandleSelected

void DefaultTool::meshgradientHandleSelected ( KoShapeMeshGradientHandles::Handle )
signal

◆ mouseDoubleClickEvent()

void DefaultTool::mouseDoubleClickEvent ( KoPointerEvent * event)
overridevirtual

Called when (one of) the mouse or stylus buttons is double clicked. Implementors should call event->ignore() if they do not actually use the event. Default implementation ignores this event.

Parameters
eventstate and reason of this mouse or stylus press

Reimplemented from KoToolBase.

Reimplemented in ToolReferenceImages.

Definition at line 1237 of file DefaultTool.cpp.

1238{
1240
1242 if (shape && selection && !selection->isSelected(shape)) {
1243
1244 if (!(event->modifiers() & Qt::ShiftModifier)) {
1245 selection->deselectAll();
1246 }
1247
1248 selection->select(shape);
1249 }
1250
1252}
void explicitUserStrokeEndRequest() override
explicitUserStrokeEndRequest is called by the input manager when the user presses Enter key or any eq...
Qt::KeyboardModifiers modifiers() const

References explicitUserStrokeEndRequest(), koSelection(), KoPointerEvent::modifiers(), KoPointerEvent::point, selection(), KoShapeManager::shapeAt(), shapeManager(), and KoFlake::ShapeOnTop.

◆ mouseMoveEvent()

void DefaultTool::mouseMoveEvent ( KoPointerEvent * event)
overridevirtual

Called when the mouse or stylus moved over the canvas. Implementors should call event->ignore() if they do not actually use the event.

Parameters
eventstate and reason of this mouse or stylus move

Implements KoToolBase.

Definition at line 1184 of file DefaultTool.cpp.

1185{
1187 if (currentStrategy() == 0 && koSelection() && koSelection()->count() > 0) {
1188 QRectF bound = handlesSize();
1189
1190 if (bound.contains(event->point)) {
1191 bool inside;
1192 KoFlake::SelectionHandle newDirection = handleAt(event->point, &inside);
1193
1194 if (inside != m_mouseWasInsideHandles || m_lastHandle != newDirection) {
1195 m_lastHandle = newDirection;
1196 m_mouseWasInsideHandles = inside;
1197 }
1198 } else {
1201
1202 // there used to be guides... :'''(
1203 }
1204 } else {
1205 // there used to be guides... :'''(
1206 }
1207
1208
1209 updateCursor();
1210}
void updateCursor()
void mouseMoveEvent(KoPointerEvent *event) override

References KoInteractionTool::currentStrategy(), handleAt(), handlesSize(), koSelection(), m_lastHandle, m_mouseWasInsideHandles, KoInteractionTool::mouseMoveEvent(), KoFlake::NoHandle, KoPointerEvent::point, and updateCursor().

◆ mousePressEvent()

void DefaultTool::mousePressEvent ( KoPointerEvent * event)
overridevirtual

Called when (one of) the mouse or stylus buttons is pressed. Implementors should call event->ignore() if they do not actually use the event.

Parameters
eventstate and reason of this mouse or stylus press

Implements KoToolBase.

Definition at line 1162 of file DefaultTool.cpp.

1163{
1164 // this tool only works on a vector layer right now, so give a warning if another layer type is trying to use it
1165 if (!isValidForCurrentLayer()) {
1166 KisCanvas2 *kiscanvas = static_cast<KisCanvas2 *>(canvas());
1167 kiscanvas->viewManager()->showFloatingMessage(
1168 i18n("This tool only works on vector layers. You probably want the move tool."),
1169 QIcon(), 2000, KisFloatingMessage::Medium, Qt::AlignCenter);
1170 return;
1171 }
1172
1173 if (KoSvgTextShape *shape = m_textOutlineHelper->contourModeButtonHovered(event->point)) {
1174 m_textOutlineHelper->toggleTextContourMode(shape);
1175 updateActions();
1176 event->accept();
1177 updateCursor();
1178 return;
1179 }
1181 updateCursor();
1182}
virtual bool isValidForCurrentLayer() const
void showFloatingMessage(const QString &message, const QIcon &icon, int timeout=4500, KisFloatingMessage::Priority priority=KisFloatingMessage::Medium, int alignment=Qt::AlignCenter|Qt::TextWordWrap)
shows a floating message in the top right corner of the canvas
void mousePressEvent(KoPointerEvent *event) override

References KoToolBase::canvas(), isValidForCurrentLayer(), m_textOutlineHelper, KisFloatingMessage::Medium, KoInteractionTool::mousePressEvent(), KoPointerEvent::point, KisViewManager::showFloatingMessage(), updateActions(), updateCursor(), and KisCanvas2::viewManager().

◆ mouseReleaseEvent()

void DefaultTool::mouseReleaseEvent ( KoPointerEvent * event)
overridevirtual

Called when (one of) the mouse or stylus buttons is released. Implementors should call event->ignore() if they do not actually use the event.

Parameters
eventstate and reason of this mouse or stylus release

Implements KoToolBase.

Definition at line 1231 of file DefaultTool.cpp.

1232{
1234 updateCursor();
1235}
void mouseReleaseEvent(KoPointerEvent *event) override

References KoInteractionTool::mouseReleaseEvent(), and updateCursor().

◆ moveSelection()

bool DefaultTool::moveSelection ( int direction,
Qt::KeyboardModifiers modifiers )
private

Definition at line 1254 of file DefaultTool.cpp.

1255{
1256 bool result = false;
1257
1258 qreal x = 0.0, y = 0.0;
1259 if (direction == Qt::Key_Left) {
1260 x = -5;
1261 } else if (direction == Qt::Key_Right) {
1262 x = 5;
1263 } else if (direction == Qt::Key_Up) {
1264 y = -5;
1265 } else if (direction == Qt::Key_Down) {
1266 y = 5;
1267 }
1268
1269 if (x != 0.0 || y != 0.0) { // actually move
1270
1271 if ((modifiers & Qt::ShiftModifier) != 0) {
1272 x *= 10;
1273 y *= 10;
1274 } else if ((modifiers & Qt::AltModifier) != 0) { // more precise
1275 x /= 5;
1276 y /= 5;
1277 }
1278
1280
1281 if (!shapes.isEmpty()) {
1282 canvas()->addCommand(new KoShapeMoveCommand(shapes, QPointF(x, y)));
1283 result = true;
1284 }
1285 }
1286
1287 return result;
1288}
const QList< KoShape * > selectedEditableShapes() const
The undo / redo command for shape moving.

References KoCanvasBase::addCommand(), KoToolBase::canvas(), koSelection(), and KoSelection::selectedEditableShapes().

◆ paint()

void DefaultTool::paint ( QPainter & painter,
const KoViewConverter & converter )
overridevirtual

Called by the canvas to paint any decorations that the tool deems needed. The painter has the top left of the canvas as its origin.

Parameters
painterused for painting the shape
converterto convert between internal and view coordinates.

Selection masks don't render the outline of the shapes, so we should do that explicitly when rendering them via selection

Implements KoToolBase.

Definition at line 1107 of file DefaultTool.cpp.

1108{
1110 if (selection) {
1111 m_decorator.reset(new SelectionDecorator(canvas()->resourceManager()));
1112
1113 {
1119 KisCanvas2 *kisCanvas = static_cast<KisCanvas2 *>(canvas());
1120 KisNodeSP node = kisCanvas->viewManager()->nodeManager()->activeNode();
1121 const bool isSelectionMask = node && node->inherits("KisSelectionMask");
1122 m_decorator->setForceShapeOutlines(isSelectionMask);
1123
1124
1125 }
1126
1127 m_decorator->setSelection(selection);
1128 m_decorator->setHandleRadius(handleRadius());
1129 m_decorator->setDecorationThickness(decorationThickness());
1130 m_decorator->setShowFillGradientHandles(hasInteractionFactory(EditFillGradientFactoryId));
1131 m_decorator->setShowStrokeFillGradientHandles(hasInteractionFactory(EditStrokeGradientFactoryId));
1132 m_decorator->setShowFillMeshGradientHandles(hasInteractionFactory(EditFillMeshGradientFactoryId));
1133 m_decorator->setCurrentMeshGradientHandles(m_selectedMeshHandle, m_hoveredMeshHandle);
1134 m_decorator->paint(painter, converter);
1135 }
1136
1137 m_textOutlineHelper->setHandleRadius(handleRadius());
1138 m_textOutlineHelper->setDecorationThickness(decorationThickness());
1139 m_textOutlineHelper->paint(&painter, converter);
1140
1141 KoInteractionTool::paint(painter, converter);
1142
1143 painter.save();
1144 painter.setTransform(converter.documentToView(), true);
1145 canvas()->snapGuide()->paint(painter, converter);
1146 painter.restore();
1147}
KoShapeMeshGradientHandles::Handle m_selectedMeshHandle
QScopedPointer< SelectionDecorator > m_decorator
KoShapeMeshGradientHandles::Handle m_hoveredMeshHandle
KisNodeSP activeNode()
Convenience function to get the active layer or mask.
KisNodeManager * nodeManager() const
The node manager handles everything about nodes.
bool hasInteractionFactory(const QString &id)
void paint(QPainter &painter, const KoViewConverter &converter) override
void paint(QPainter &painter, const KoViewConverter &converter)
paints the guide
int handleRadius() const
Convenience function to get the current handle radius.
int decorationThickness() const
decorationThickness The minimum thickness for tool decoration lines, this is derived from the screen ...
bool isSelectionMask(KisNodeSP node)

References KisNodeManager::activeNode(), KoToolBase::canvas(), KoToolBase::decorationThickness(), KoViewConverter::documentToView(), KoToolBase::handleRadius(), KoInteractionTool::hasInteractionFactory(), isSelectionMask(), koSelection(), m_decorator, m_hoveredMeshHandle, m_selectedMeshHandle, m_textOutlineHelper, KisViewManager::nodeManager(), KoSnapGuide::paint(), KoInteractionTool::paint(), selection(), KoCanvasBase::snapGuide, and KisCanvas2::viewManager().

◆ paste()

bool DefaultTool::paste ( )
overridevirtual

reimplemented

Reimplemented from KoToolBase.

Definition at line 1354 of file DefaultTool.cpp.

1355{
1356 // we no longer have to do anything as tool Proxy will do it for us
1357 return false;
1358}

◆ popupActionsMenu()

QMenu * DefaultTool::popupActionsMenu ( )
overridevirtual
Returns
a menu with context-aware actions for the current selection. If the returned value is null, no context menu is shown.

Reimplemented from KoToolBase.

Reimplemented in ToolReferenceImages.

Definition at line 2260 of file DefaultTool.cpp.

2261{
2262 if (m_contextMenu) {
2263 m_contextMenu->clear();
2264
2265 m_contextMenu->addSection(i18n("Vector Shape Actions"));
2266 m_contextMenu->addSeparator();
2267
2268 QMenu *transform = m_contextMenu->addMenu(i18n("Transform"));
2269
2270 transform->addAction(action("object_transform_rotate_90_cw"));
2271 transform->addAction(action("object_transform_rotate_90_ccw"));
2272 transform->addAction(action("object_transform_rotate_180"));
2273 transform->addSeparator();
2274 transform->addAction(action("object_transform_mirror_horizontally"));
2275 transform->addAction(action("object_transform_mirror_vertically"));
2276 transform->addSeparator();
2277 transform->addAction(action("object_transform_reset"));
2278
2279 if (action("object_unite")->isEnabled() ||
2280 action("object_intersect")->isEnabled() ||
2281 action("object_subtract")->isEnabled() ||
2282 action("object_split")->isEnabled()) {
2283
2284 QMenu *transform = m_contextMenu->addMenu(i18n("Logical Operations"));
2285 transform->addAction(action("object_unite"));
2286 transform->addAction(action("object_intersect"));
2287 transform->addAction(action("object_subtract"));
2288 transform->addAction(action("object_split"));
2289 }
2290
2291 m_contextMenu->addSeparator();
2292
2293 m_contextMenu->addAction(action("edit_cut"));
2294 m_contextMenu->addAction(action("edit_copy"));
2295 m_contextMenu->addAction(action("edit_paste"));
2296 m_contextMenu->addAction(action("paste_at"));
2297
2298 m_contextMenu->addSeparator();
2299
2300 m_contextMenu->addAction(action("object_order_front"));
2301 m_contextMenu->addAction(action("object_order_raise"));
2302 m_contextMenu->addAction(action("object_order_lower"));
2303 m_contextMenu->addAction(action("object_order_back"));
2304
2305 if (action("object_group")->isEnabled() || action("object_ungroup")->isEnabled()) {
2306 m_contextMenu->addSeparator();
2307 m_contextMenu->addAction(action("object_group"));
2308 m_contextMenu->addAction(action("object_ungroup"));
2309 }
2310 m_contextMenu->addSeparator();
2311 m_contextMenu->addAction(action("convert_shapes_to_vector_selection"));
2312
2313 m_contextMenu->addSeparator();
2314 QMenu *text = m_contextMenu->addMenu(i18n("Text"));
2315 text->addAction(action("add_shape_to_flow_area"));
2316 text->addAction(action("subtract_shape_from_flow_area"));
2317 text->addAction(action("put_text_on_path"));
2318 text->addSeparator();
2319 text->addAction(action("text_type_preformatted"));
2320 text->addAction(action("text_type_inline_wrap"));
2321 text->addAction(action("text_type_pre_positioned"));
2322 text->addSeparator();
2323 text->addAction(action("remove_shapes_from_text_flow"));
2324 text->addAction(action("flow_shape_type_toggle"));
2325 text->addSeparator();
2326 text->addAction(action("flow_shape_order_back"));
2327 text->addAction(action("flow_shape_order_earlier"));
2328 text->addAction(action("flow_shape_order_later"));
2329 text->addAction(action("flow_shape_order_front"));
2330 }
2331
2332 return m_contextMenu.data();
2333}
QScopedPointer< QMenu > m_contextMenu

References KoToolBase::action(), and m_contextMenu.

◆ recalcSelectionBox()

void DefaultTool::recalcSelectionBox ( KoSelection * selection)
private

Definition at line 1441 of file DefaultTool.cpp.

1442{
1444
1445 QTransform matrix = selection->absoluteTransformation();
1446 m_selectionOutline = matrix.map(QPolygonF(selection->outlineRect()));
1447 m_angle = 0.0;
1448
1449 QPolygonF outline = m_selectionOutline; //shorter name in the following :)
1450 m_selectionBox[KoFlake::TopMiddleHandle] = (outline.value(0) + outline.value(1)) / 2;
1451 m_selectionBox[KoFlake::TopRightHandle] = outline.value(1);
1452 m_selectionBox[KoFlake::RightMiddleHandle] = (outline.value(1) + outline.value(2)) / 2;
1453 m_selectionBox[KoFlake::BottomRightHandle] = outline.value(2);
1454 m_selectionBox[KoFlake::BottomMiddleHandle] = (outline.value(2) + outline.value(3)) / 2;
1455 m_selectionBox[KoFlake::BottomLeftHandle] = outline.value(3);
1456 m_selectionBox[KoFlake::LeftMiddleHandle] = (outline.value(3) + outline.value(0)) / 2;
1457 m_selectionBox[KoFlake::TopLeftHandle] = outline.value(0);
1458 if (selection->count() == 1) {
1459#if 0 // TODO detect mirroring
1461
1462 if (s->scaleX() < 0) { // vertically mirrored: swap left / right
1466 }
1467 if (s->scaleY() < 0) { // vertically mirrored: swap top / bottom
1471 }
1472#endif
1473 }
1474}
KoShape * firstSelectedShape() const
#define KIS_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:75

References KoFlake::BottomLeftHandle, KoFlake::BottomMiddleHandle, KoFlake::BottomRightHandle, KoSelection::firstSelectedShape(), KIS_ASSERT_RECOVER_RETURN, koSelection(), KoFlake::LeftMiddleHandle, m_angle, m_selectionBox, m_selectionOutline, KoFlake::RightMiddleHandle, selection(), KoFlake::TopLeftHandle, KoFlake::TopMiddleHandle, and KoFlake::TopRightHandle.

◆ rotationOfHandle()

qreal DefaultTool::rotationOfHandle ( KoFlake::SelectionHandle handle,
bool useEdgeRotation )
private

Returns rotation angle of given handle of the current selection.

Definition at line 870 of file DefaultTool.cpp.

871{
872 QPointF selectionCenter = koSelection()->absolutePosition();
873 QPointF direction;
874
875 switch (handle) {
877 if (useEdgeRotation) {
880 } else {
881 QPointF handlePosition = koSelection()->absolutePosition(KoFlake::TopLeft);
882 handlePosition += 0.5 * (koSelection()->absolutePosition(KoFlake::TopRight) - handlePosition);
883 direction = handlePosition - selectionCenter;
884 }
885 break;
887 direction = (QVector2D(koSelection()->absolutePosition(KoFlake::TopRight) - koSelection()->absolutePosition(KoFlake::TopLeft)).normalized() + QVector2D(koSelection()->absolutePosition(KoFlake::TopRight) - koSelection()->absolutePosition(KoFlake::BottomRight)).normalized()).toPointF();
888 break;
890 if (useEdgeRotation) {
893 } else {
894 QPointF handlePosition = koSelection()->absolutePosition(KoFlake::TopRight);
895 handlePosition += 0.5 * (koSelection()->absolutePosition(KoFlake::BottomRight) - handlePosition);
896 direction = handlePosition - selectionCenter;
897 }
898 break;
900 direction = (QVector2D(koSelection()->absolutePosition(KoFlake::BottomRight) - koSelection()->absolutePosition(KoFlake::BottomLeft)).normalized() + QVector2D(koSelection()->absolutePosition(KoFlake::BottomRight) - koSelection()->absolutePosition(KoFlake::TopRight)).normalized()).toPointF();
901 break;
903 if (useEdgeRotation) {
906 } else {
907 QPointF handlePosition = koSelection()->absolutePosition(KoFlake::BottomLeft);
908 handlePosition += 0.5 * (koSelection()->absolutePosition(KoFlake::BottomRight) - handlePosition);
909 direction = handlePosition - selectionCenter;
910 }
911 break;
913 direction = koSelection()->absolutePosition(KoFlake::BottomLeft) - selectionCenter;
914 direction = (QVector2D(koSelection()->absolutePosition(KoFlake::BottomLeft) - koSelection()->absolutePosition(KoFlake::BottomRight)).normalized() + QVector2D(koSelection()->absolutePosition(KoFlake::BottomLeft) - koSelection()->absolutePosition(KoFlake::TopLeft)).normalized()).toPointF();
915 break;
917 if (useEdgeRotation) {
920 } else {
921 QPointF handlePosition = koSelection()->absolutePosition(KoFlake::TopLeft);
922 handlePosition += 0.5 * (koSelection()->absolutePosition(KoFlake::BottomLeft) - handlePosition);
923 direction = handlePosition - selectionCenter;
924 }
925 break;
927 direction = koSelection()->absolutePosition(KoFlake::TopLeft) - selectionCenter;
928 direction = (QVector2D(koSelection()->absolutePosition(KoFlake::TopLeft) - koSelection()->absolutePosition(KoFlake::TopRight)).normalized() + QVector2D(koSelection()->absolutePosition(KoFlake::TopLeft) - koSelection()->absolutePosition(KoFlake::BottomLeft)).normalized()).toPointF();
929 break;
931 return 0.0;
932 break;
933 }
934
935 qreal rotation = atan2(direction.y(), direction.x()) * 180.0 / M_PI;
936
937 switch (handle) {
939 if (useEdgeRotation) {
940 rotation -= 0.0;
941 } else {
942 rotation -= 270.0;
943 }
944 break;
946 rotation -= 315.0;
947 break;
949 if (useEdgeRotation) {
950 rotation -= 90.0;
951 } else {
952 rotation -= 0.0;
953 }
954 break;
956 rotation -= 45.0;
957 break;
959 if (useEdgeRotation) {
960 rotation -= 180.0;
961 } else {
962 rotation -= 90.0;
963 }
964 break;
966 rotation -= 135.0;
967 break;
969 if (useEdgeRotation) {
970 rotation -= 270.0;
971 } else {
972 rotation -= 180.0;
973 }
974 break;
976 rotation -= 225.0;
977 break;
978 default:
979 ;
980 }
981
982 if (rotation < 0.0) {
983 rotation += 360.0;
984 }
985
986 return rotation;
987}
QPointF absolutePosition(KoFlake::AnchorPosition anchor=KoFlake::Center) const
Definition KoShape.cpp:568
#define M_PI
Definition kis_global.h:111
KRITAIMAGE_EXPORT qreal atan2(qreal y, qreal x)
atan2 replacement

References KoShape::absolutePosition(), KoFlake::BottomLeft, KoFlake::BottomLeftHandle, KoFlake::BottomMiddleHandle, KoFlake::BottomRight, KoFlake::BottomRightHandle, koSelection(), KoFlake::LeftMiddleHandle, M_PI, KoFlake::NoHandle, KoFlake::RightMiddleHandle, KoFlake::TopLeft, KoFlake::TopLeftHandle, KoFlake::TopMiddleHandle, KoFlake::TopRight, and KoFlake::TopRightHandle.

◆ selectAll()

bool DefaultTool::selectAll ( )
overridevirtual

reimplemented

Reimplemented from KoToolBase.

Definition at line 1360 of file DefaultTool.cpp.

1361{
1362 Q_ASSERT(canvas());
1363 Q_ASSERT(canvas()->selectedShapesProxy());
1364 Q_FOREACH(KoShape *shape, canvas()->shapeManager()->shapes()) {
1365 if (!shape->isSelectable()) continue;
1367 }
1369
1370 return true;
1371}
void select(KoShape *shape)
bool isSelectable() const
Definition KoShape.cpp:832

References KoToolBase::canvas(), KoShape::isSelectable(), KoToolBase::repaintDecorations(), KoSelection::select(), KoCanvasBase::selectedShapesProxy(), KoSelectedShapesProxy::selection(), and shapeManager().

◆ selection()

KoToolSelection * DefaultTool::selection ( )
overridevirtual

reimplemented

Reimplemented from KoToolBase.

Definition at line 2255 of file DefaultTool.cpp.

2256{
2257 return m_selectionHandler;
2258}

References m_selectionHandler.

◆ selectionAlign

void DefaultTool::selectionAlign ( int _align)
privateslot

Definition at line 1858 of file DefaultTool.cpp.

1859{
1861 static_cast<KoShapeAlignCommand::Align>(_align);
1862
1864 if (!selection) return;
1865
1866 QList<KoShape *> editableShapes = selection->selectedEditableShapes();
1867 if (editableShapes.isEmpty()) {
1868 return;
1869 }
1870
1871 // TODO add an option to the widget so that one can align to the page
1872 // with multiple selected shapes too
1873
1874 QRectF bb;
1875
1876 // single selected shape is automatically aligned to document rect
1877 if (editableShapes.count() == 1) {
1878 if (!canvas()->resourceManager()->hasResource(KoCanvasResource::PageSize)) {
1879 return;
1880 }
1881 bb = QRectF(QPointF(0, 0), canvas()->resourceManager()->sizeResource(KoCanvasResource::PageSize));
1882 } else {
1883 bb = KoShape::absoluteOutlineRect(editableShapes);
1884 }
1885
1886 KoShapeAlignCommand *cmd = new KoShapeAlignCommand(editableShapes, align, bb);
1887 canvas()->addCommand(cmd);
1888}
The undo / redo command for aligning shapes.
Align
The different alignment options for this command.
QRectF absoluteOutlineRect() const
Definition KoShape.cpp:319
@ PageSize
The size of the (current) page in postscript points.

References KoShape::absoluteOutlineRect(), KoCanvasBase::addCommand(), KoToolBase::canvas(), koSelection(), KoCanvasResource::PageSize, and selection().

◆ selectionBooleanOp

void DefaultTool::selectionBooleanOp ( int booleanOp)
privateslot

Definition at line 1730 of file DefaultTool.cpp.

1731{
1733 if (!selection) return;
1734
1735 QList<KoShape *> editableShapes = selection->selectedEditableShapes();
1736 if (editableShapes.isEmpty()) {
1737 return;
1738 }
1739
1740 QVector<QPainterPath> srcOutlines;
1741 QPainterPath dstOutline;
1742 KUndo2MagicString actionName = kundo2_noi18n("BUG: boolean action name");
1743
1744 // TODO: implement a reference shape selection dialog!
1745 const int referenceShapeIndex = 0;
1746 KoShape *referenceShape = editableShapes[referenceShapeIndex];
1747
1748 KisCanvas2 *kisCanvas = static_cast<KisCanvas2 *>(canvas());
1750 const QTransform booleanWorkaroundTransform =
1752
1753 Q_FOREACH (KoShape *shape, editableShapes) {
1754 srcOutlines <<
1755 booleanWorkaroundTransform.map(
1756 shape->absoluteTransformation().map(
1757 shape->outline()));
1758 }
1759
1760 if (booleanOp == BooleanUnion) {
1761 Q_FOREACH (const QPainterPath &path, srcOutlines) {
1762 dstOutline |= path;
1763 }
1764 actionName = kundo2_i18n("Unite Shapes");
1765 } else if (booleanOp == BooleanIntersection) {
1766 for (int i = 0; i < srcOutlines.size(); i++) {
1767 if (i == 0) {
1768 dstOutline = srcOutlines[i];
1769 } else {
1770 dstOutline &= srcOutlines[i];
1771 }
1772 }
1773
1774 // there is a bug in Qt, sometimes it leaves the resulting
1775 // outline open, so just close it explicitly.
1776 dstOutline.closeSubpath();
1777
1778 actionName = kundo2_i18n("Intersect Shapes");
1779
1780 } else if (booleanOp == BooleanSubtraction) {
1781 for (int i = 0; i < srcOutlines.size(); i++) {
1782 dstOutline = srcOutlines[referenceShapeIndex];
1783 if (i != referenceShapeIndex) {
1784 dstOutline -= srcOutlines[i];
1785 }
1786 }
1787
1788 actionName = kundo2_i18n("Subtract Shapes");
1789 }
1790
1791 dstOutline = booleanWorkaroundTransform.inverted().map(dstOutline);
1792
1793 KoShape *newShape = 0;
1794
1795 if (!dstOutline.isEmpty()) {
1796 newShape = KoPathShape::createShapeFromPainterPath(dstOutline);
1797 }
1798
1799 KUndo2Command *cmd = new KUndo2Command(actionName);
1800
1801 new KoKeepShapesSelectedCommand(editableShapes, {}, canvas()->selectedShapesProxy(), false, cmd);
1802
1803 QList<KoShape*> newSelectedShapes;
1804
1805 if (newShape) {
1806 newShape->setBackground(referenceShape->background());
1807 newShape->setStroke(referenceShape->stroke());
1808 newShape->setZIndex(referenceShape->zIndex());
1809
1810 KoShapeContainer *parent = referenceShape->parent();
1811 canvas()->shapeController()->addShapeDirect(newShape, parent, cmd);
1812
1813 newSelectedShapes << newShape;
1814 }
1815
1816 canvas()->shapeController()->removeShapes(editableShapes, cmd);
1817
1818 new KoKeepShapesSelectedCommand({}, newSelectedShapes, canvas()->selectedShapesProxy(), true, cmd);
1819
1820 canvas()->addCommand(cmd);
1821}
KisImageWSP image() const
QPointer< KoShapeController > shapeController
static KoPathShape * createShapeFromPainterPath(const QPainterPath &path)
Creates path shape from given QPainterPath.
void setZIndex(qint16 zIndex)
Definition KoShape.cpp:782
virtual QPainterPath outline() const
Definition KoShape.cpp:554
virtual KoShapeStrokeModelSP stroke() const
Definition KoShape.cpp:885
KoShapeContainer * parent() const
Definition KoShape.cpp:857
virtual void setStroke(KoShapeStrokeModelSP stroke)
Definition KoShape.cpp:899
QTransform absoluteTransformation() const
Definition KoShape.cpp:330
virtual void setBackground(QSharedPointer< KoShapeBackground > background)
Definition KoShape.cpp:746
virtual QSharedPointer< KoShapeBackground > background() const
Definition KoShape.cpp:754
qint16 zIndex() const
Definition KoShape.cpp:524
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
KUndo2MagicString kundo2_i18n(const char *text)
KUndo2MagicString kundo2_noi18n(const QString &text)
ChildIterator< value_type, is_const > parent(const ChildIterator< value_type, is_const > &it)
Definition KisForest.h:327
QTransform pathShapeBooleanSpaceWorkaround(KisImageSP image)

References KoShape::absoluteTransformation(), KoCanvasBase::addCommand(), KoShape::background(), KoToolBase::canvas(), KoPathShape::createShapeFromPainterPath(), KisCanvas2::image(), KIS_SAFE_ASSERT_RECOVER_RETURN, koSelection(), kundo2_i18n(), kundo2_noi18n(), KoShape::outline(), KoShape::parent(), KritaUtils::pathShapeBooleanSpaceWorkaround(), KoCanvasBase::selectedShapesProxy(), selection(), KoShape::setBackground(), KoShape::setStroke(), KoShape::setZIndex(), KoCanvasBase::shapeController, KoShape::stroke(), and KoShape::zIndex().

◆ selectionBringToFront

void DefaultTool::selectionBringToFront ( )
privateslot

Definition at line 1908 of file DefaultTool.cpp.

1909{
1911}
void selectionReorder(KoShapeReorderCommand::MoveShapeType order)
@ BringToFront
Raise the selected shape to be on top of all shapes.

References KoShapeReorderCommand::BringToFront, and selectionReorder().

◆ selectionDistribute

void DefaultTool::selectionDistribute ( int _distribute)
privateslot

Definition at line 1890 of file DefaultTool.cpp.

1891{
1893 static_cast<KoShapeDistributeCommand::Distribute>(_distribute);
1894
1896 if (!selection) return;
1897
1898 QList<KoShape *> editableShapes = selection->selectedEditableShapes();
1899 if (editableShapes.size() < 3) {
1900 return;
1901 }
1902
1903 QRectF bb = KoShape::absoluteOutlineRect(editableShapes);
1904 KoShapeDistributeCommand *cmd = new KoShapeDistributeCommand(editableShapes, distribute, bb);
1905 canvas()->addCommand(cmd);
1906}
The undo / redo command for distributing shapes.
Distribute
The different options to distribute with this command.

References KoShape::absoluteOutlineRect(), KoCanvasBase::addCommand(), KoToolBase::canvas(), koSelection(), and selection().

◆ selectionGroup

void DefaultTool::selectionGroup ( )
privateslot

Definition at line 1594 of file DefaultTool.cpp.

1595{
1597 if (!selection) return;
1598
1599 QList<KoShape *> selectedShapes = selection->selectedEditableShapes();
1600 std::sort(selectedShapes.begin(), selectedShapes.end(), KoShape::compareShapeZIndex);
1601 if (selectedShapes.isEmpty()) return;
1602
1603 const int groupZIndex = selectedShapes.last()->zIndex();
1604
1605 KoShapeGroup *group = new KoShapeGroup();
1606 group->setZIndex(groupZIndex);
1607 // TODO what if only one shape is left?
1608 KUndo2Command *cmd = new KUndo2Command(kundo2_i18n("Group shapes"));
1609 new KoKeepShapesSelectedCommand(selectedShapes, {}, canvas()->selectedShapesProxy(), false, cmd);
1610 canvas()->shapeController()->addShapeDirect(group, 0, cmd);
1611 new KoShapeGroupCommand(group, selectedShapes, true, cmd);
1612 new KoKeepShapesSelectedCommand({}, {group}, canvas()->selectedShapesProxy(), true, cmd);
1613 canvas()->addCommand(cmd);
1614
1615 // update selection so we can ungroup immediately again
1616 selection->deselectAll();
1617 selection->select(group);
1618}
The undo / redo command for grouping shapes.
static bool compareShapeZIndex(KoShape *s1, KoShape *s2)
Definition KoShape.cpp:388

References KoCanvasBase::addCommand(), KoToolBase::canvas(), KoShape::compareShapeZIndex(), koSelection(), kundo2_i18n(), KoCanvasBase::selectedShapesProxy(), selection(), KoShape::setZIndex(), and KoCanvasBase::shapeController.

◆ selectionMoveDown

void DefaultTool::selectionMoveDown ( )
privateslot

Definition at line 1918 of file DefaultTool.cpp.

1919{
1921}
@ LowerShape
Lower the selected shape to the level that it is below the shape that is below it.

References KoShapeReorderCommand::LowerShape, and selectionReorder().

◆ selectionMoveUp

void DefaultTool::selectionMoveUp ( )
privateslot

Definition at line 1913 of file DefaultTool.cpp.

1914{
1916}
@ RaiseShape
raise the selected shape to the level that it is above the shape that is on top of it.

References KoShapeReorderCommand::RaiseShape, and selectionReorder().

◆ selectionReorder()

void DefaultTool::selectionReorder ( KoShapeReorderCommand::MoveShapeType order)
private

Definition at line 1928 of file DefaultTool.cpp.

1929{
1931 if (!selection) {
1932 return;
1933 }
1934
1935 QList<KoShape *> selectedShapes = selection->selectedEditableShapes();
1936 if (selectedShapes.isEmpty()) {
1937 return;
1938 }
1939
1940 KUndo2Command *cmd = KoShapeReorderCommand::createCommand(selectedShapes, shapeManager(), order);
1941 if (cmd) {
1942 canvas()->addCommand(cmd);
1943 }
1944}
static KoShapeReorderCommand * createCommand(const QList< KoShape * > &shapes, KoShapeManager *manager, MoveShapeType move, KUndo2Command *parent=0)

References KoCanvasBase::addCommand(), KoToolBase::canvas(), KoShapeReorderCommand::createCommand(), koSelection(), selection(), and shapeManager().

◆ selectionSendToBack

void DefaultTool::selectionSendToBack ( )
privateslot

Definition at line 1923 of file DefaultTool.cpp.

1924{
1926}
@ SendToBack
Lower the selected shape to be below all other shapes.

References selectionReorder(), and KoShapeReorderCommand::SendToBack.

◆ selectionSplitShapes

void DefaultTool::selectionSplitShapes ( )
privateslot

Definition at line 1823 of file DefaultTool.cpp.

1824{
1826 if (!selection) return;
1827
1828 QList<KoShape *> editableShapes = selection->selectedEditableShapes();
1829 if (editableShapes.isEmpty()) {
1830 return;
1831 }
1832
1833 KUndo2Command *cmd = new KUndo2Command(kundo2_i18n("Split Shapes"));
1834
1835 new KoKeepShapesSelectedCommand(editableShapes, {}, canvas()->selectedShapesProxy(), false, cmd);
1836 QList<KoShape*> newShapes;
1837
1838 Q_FOREACH (KoShape *shape, editableShapes) {
1839 KoPathShape *pathShape = dynamic_cast<KoPathShape*>(shape);
1840 if (!pathShape) return;
1841
1842 QList<KoPathShape*> splitShapes;
1843 if (pathShape->separate(splitShapes)) {
1844 QList<KoShape*> normalShapes = implicitCastList<KoShape*>(splitShapes);
1845
1846 KoShapeContainer *parent = shape->parent();
1847 canvas()->shapeController()->addShapesDirect(normalShapes, parent, cmd);
1848 canvas()->shapeController()->removeShape(shape, cmd);
1849 newShapes << normalShapes;
1850 }
1851 }
1852
1853 new KoKeepShapesSelectedCommand({}, newShapes, canvas()->selectedShapesProxy(), true, cmd);
1854
1855 canvas()->addCommand(cmd);
1856}
The position of a path point within a path shape.
Definition KoPathShape.h:63
bool separate(QList< KoPathShape * > &separatedPaths)
Creates separate path shapes, one for each existing subpath.

References KoCanvasBase::addCommand(), KoToolBase::canvas(), koSelection(), kundo2_i18n(), KoShape::parent(), KoCanvasBase::selectedShapesProxy(), selection(), KoPathShape::separate(), and KoCanvasBase::shapeController.

◆ selectionTransform

void DefaultTool::selectionTransform ( int transformAction)
privateslot

Definition at line 1652 of file DefaultTool.cpp.

1653{
1655 if (!selection) return;
1656
1657 QList<KoShape *> editableShapes = selection->selectedEditableShapes();
1658 if (editableShapes.isEmpty()) {
1659 return;
1660 }
1661
1662 QTransform applyTransform;
1663 bool shouldReset = false;
1664 KUndo2MagicString actionName = kundo2_noi18n("BUG: No transform action");
1665
1666
1667 switch (TransformActionType(transformAction)) {
1668 case TransformRotate90CW:
1669 applyTransform.rotate(90.0);
1670 actionName = kundo2_i18n("Rotate Object 90° CW");
1671 break;
1672 case TransformRotate90CCW:
1673 applyTransform.rotate(-90.0);
1674 actionName = kundo2_i18n("Rotate Object 90° CCW");
1675 break;
1676 case TransformRotate180:
1677 applyTransform.rotate(180.0);
1678 actionName = kundo2_i18n("Rotate Object 180°");
1679 break;
1680 case TransformMirrorX:
1681 applyTransform.scale(-1.0, 1.0);
1682 actionName = kundo2_i18n("Mirror Object Horizontally");
1683 break;
1684 case TransformMirrorY:
1685 applyTransform.scale(1.0, -1.0);
1686 actionName = kundo2_i18n("Mirror Object Vertically");
1687 break;
1688 case TransformReset:
1689 shouldReset = true;
1690 actionName = kundo2_i18n("Reset Object Transformations");
1691 break;
1692 }
1693
1694 if (!shouldReset && applyTransform.isIdentity()) return;
1695
1696 QList<QTransform> oldTransforms;
1697 QList<QTransform> newTransforms;
1698
1699 const QRectF outlineRect = KoShape::absoluteOutlineRect(editableShapes);
1700 const QPointF centerPoint = outlineRect.center();
1701 const QTransform centerTrans = QTransform::fromTranslate(centerPoint.x(), centerPoint.y());
1702 const QTransform centerTransInv = QTransform::fromTranslate(-centerPoint.x(), -centerPoint.y());
1703
1704 // we also add selection to the list of transformed shapes, so that its outline is updated correctly
1705 QList<KoShape*> transformedShapes = editableShapes;
1706 transformedShapes << selection;
1707
1708 Q_FOREACH (KoShape *shape, transformedShapes) {
1709 oldTransforms.append(shape->transformation());
1710
1711 QTransform t;
1712
1713 if (!shouldReset) {
1714 const QTransform world = shape->absoluteTransformation();
1715 t = world * centerTransInv * applyTransform * centerTrans * world.inverted() * shape->transformation();
1716 } else {
1717 const QPointF center = shape->outlineRect().center();
1718 const QPointF offset = shape->transformation().map(center) - center;
1719 t = QTransform::fromTranslate(offset.x(), offset.y());
1720 }
1721
1722 newTransforms.append(t);
1723 }
1724
1725 KoShapeTransformCommand *cmd = new KoShapeTransformCommand(transformedShapes, oldTransforms, newTransforms);
1726 cmd->setText(actionName);
1727 canvas()->addCommand(cmd);
1728}
void setText(const KUndo2MagicString &text)
virtual QRectF outlineRect() const
Definition KoShape.cpp:561
QTransform transformation() const
Returns the shapes local transformation matrix.
Definition KoShape.cpp:378

References KoShape::absoluteOutlineRect(), KoShape::absoluteTransformation(), KoCanvasBase::addCommand(), KoToolBase::canvas(), koSelection(), kundo2_i18n(), kundo2_noi18n(), KoShape::outlineRect(), selection(), KUndo2Command::setText(), and KoShape::transformation().

◆ selectionUngroup

void DefaultTool::selectionUngroup ( )
privateslot

Definition at line 1620 of file DefaultTool.cpp.

1621{
1623 if (!selection) return;
1624
1625 QList<KoShape *> selectedShapes = selection->selectedEditableShapes();
1626 std::sort(selectedShapes.begin(), selectedShapes.end(), KoShape::compareShapeZIndex);
1627
1628 KUndo2Command *cmd = 0;
1629 QList<KoShape*> newShapes;
1630
1631 // add a ungroup command for each found shape container to the macro command
1632 Q_FOREACH (KoShape *shape, selectedShapes) {
1633 KoShapeGroup *group = dynamic_cast<KoShapeGroup *>(shape);
1634 if (group) {
1635 if (!cmd) {
1636 cmd = new KUndo2Command(kundo2_i18n("Ungroup shapes"));
1637 new KoKeepShapesSelectedCommand(selectedShapes, {}, canvas()->selectedShapesProxy(), false, cmd);
1638 }
1639 newShapes << group->shapes();
1640 new KoShapeUngroupCommand(group, group->shapes(),
1641 group->parent() ? QList<KoShape *>() : shapeManager()->topLevelShapes(),
1642 cmd);
1643 canvas()->shapeController()->removeShape(group, cmd);
1644 }
1645 }
1646 if (cmd) {
1647 new KoKeepShapesSelectedCommand({}, newShapes, canvas()->selectedShapesProxy(), true, cmd);
1648 canvas()->addCommand(cmd);
1649 }
1650}
QList< KoShape * > shapes() const
The undo / redo command for ungrouping shapes.

References KoCanvasBase::addCommand(), KoToolBase::canvas(), KoShape::compareShapeZIndex(), koSelection(), kundo2_i18n(), KoShape::parent(), KoCanvasBase::selectedShapesProxy(), selection(), KoCanvasBase::shapeController, shapeManager(), KoShapeContainer::shapes(), and KoShapeManager::topLevelShapes().

◆ setupActions()

void DefaultTool::setupActions ( )
private

Definition at line 806 of file DefaultTool.cpp.

807{
809
816
818
823
828
830
831 addMappedAction(m_transformSignalsMapper, "object_transform_rotate_90_cw", TransformRotate90CW);
832 addMappedAction(m_transformSignalsMapper, "object_transform_rotate_90_ccw", TransformRotate90CCW);
833 addMappedAction(m_transformSignalsMapper, "object_transform_rotate_180", TransformRotate180);
834 addMappedAction(m_transformSignalsMapper, "object_transform_mirror_horizontally", TransformMirrorX);
835 addMappedAction(m_transformSignalsMapper, "object_transform_mirror_vertically", TransformMirrorY);
836 addMappedAction(m_transformSignalsMapper, "object_transform_reset", TransformReset);
837
839
840 addMappedAction(m_booleanSignalsMapper, "object_unite", BooleanUnion);
841 addMappedAction(m_booleanSignalsMapper, "object_intersect", BooleanIntersection);
842 addMappedAction(m_booleanSignalsMapper, "object_subtract", BooleanSubtraction);
843
848
849 if (!action("text_type_preformatted")->actionGroup()) {
850 QActionGroup *textTypeActions = new QActionGroup(this);
851 textTypeActions->addAction(action("text_type_preformatted"));
852 textTypeActions->addAction(action("text_type_inline_wrap"));
853 textTypeActions->addAction(action("text_type_pre_positioned"));
854 textTypeActions->setExclusive(false);
855 Q_FOREACH (QAction *a, textTypeActions->actions()) {
856 a->setCheckable(false);
857 }
858 }
859
861
866
867 m_contextMenu.reset(new QMenu());
868}
void addMappedAction(KisSignalMapper *mapper, const QString &actionId, int type)
The KisSignalMapper class bundles signals from identifiable senders.
@ VerticalCenterAlignment
Align centered vertically.
@ HorizontalLeftAlignment
Align left.
@ HorizontalCenterAlignment
Align Centered horizontally.
@ VerticalBottomAlignment
Align bottom.
@ HorizontalRightAlignment
Align Right.
@ HorizontalRightDistribution
Horizontal Right.
@ VerticalCenterDistribution
Vertical centered.
@ HorizontalGapsDistribution
Horizontal Gaps.
@ VerticalBottomDistribution
Vertical bottom.
@ HorizontalCenterDistribution
Horizontal centered.
@ HorizontalLeftDistribution
Horizontal Left.
@ PreformattedText
Text-on-Path falls under this or PrePositionedText depending on collapse of lines.
@ InlineWrap
Uses inline size to wrap and preserves spaces.

References KoToolBase::action(), addMappedAction(), KoSvgTextReorderShapeInsideCommand::BringToFront, KoShapeAlignCommand::HorizontalCenterAlignment, KoShapeDistributeCommand::HorizontalCenterDistribution, KoShapeDistributeCommand::HorizontalGapsDistribution, KoShapeAlignCommand::HorizontalLeftAlignment, KoShapeDistributeCommand::HorizontalLeftDistribution, KoShapeAlignCommand::HorizontalRightAlignment, KoShapeDistributeCommand::HorizontalRightDistribution, KoSvgTextShape::InlineWrap, m_alignSignalsMapper, m_booleanSignalsMapper, m_contextMenu, m_distributeSignalsMapper, m_textFlowSignalsMapper, m_textTypeSignalsMapper, m_transformSignalsMapper, KoSvgTextReorderShapeInsideCommand::MoveEarlier, KoSvgTextReorderShapeInsideCommand::MoveLater, KoSvgTextShape::PreformattedText, KoSvgTextShape::PrePositionedText, KoSvgTextReorderShapeInsideCommand::SendToBack, KoShapeAlignCommand::VerticalBottomAlignment, KoShapeDistributeCommand::VerticalBottomDistribution, KoShapeAlignCommand::VerticalCenterAlignment, KoShapeDistributeCommand::VerticalCenterDistribution, KoShapeDistributeCommand::VerticalGapsDistribution, KoShapeAlignCommand::VerticalTopAlignment, and KoShapeDistributeCommand::VerticalTopDistribution.

◆ shapeManager()

KoShapeManager * DefaultTool::shapeManager ( ) const
protectedvirtual

Reimplemented in ToolReferenceImages.

Definition at line 1158 of file DefaultTool.cpp.

1158 {
1159 return canvas()->shapeManager();
1160}
virtual KoShapeManager * shapeManager() const =0

References KoToolBase::canvas(), and KoCanvasBase::shapeManager().

◆ slotActivateEditFillGradient

void DefaultTool::slotActivateEditFillGradient ( bool value)
privateslot

Definition at line 491 of file DefaultTool.cpp.

492{
493 if (value) {
495 new MoveGradientHandleInteractionFactory(KoFlake::Fill,
496 1, EditFillGradientFactoryId, this));
497 } else {
498 removeInteractionFactory(EditFillGradientFactoryId);
499 }
501}
float value(const T *src, size_t ch)
void removeInteractionFactory(const QString &id)
void addInteractionFactory(KoInteractionStrategyFactory *factory)
@ Fill
Definition KoFlake.h:29

References KoInteractionTool::addInteractionFactory(), KoFlake::Fill, KoInteractionTool::removeInteractionFactory(), KoToolBase::repaintDecorations(), and value().

◆ slotActivateEditFillMeshGradient

void DefaultTool::slotActivateEditFillMeshGradient ( bool value)
privateslot

Definition at line 515 of file DefaultTool.cpp.

516{
517 if (value) {
519 m_tabbedOptionWidget, SLOT(slotMeshGradientHandleSelected(KoShapeMeshGradientHandles::Handle)));
521 new MoveMeshGradientHandleInteractionFactory(KoFlake::Fill, 1,
522 EditFillMeshGradientFactoryId, this));
523 } else {
525 m_tabbedOptionWidget, SLOT(slotMeshGradientHandleSelected(KoShapeMeshGradientHandles::Handle)));
526 removeInteractionFactory(EditFillMeshGradientFactoryId);
527 }
528}
void meshgradientHandleSelected(KoShapeMeshGradientHandles::Handle)

References KoInteractionTool::addInteractionFactory(), KoFlake::Fill, m_tabbedOptionWidget, meshgradientHandleSelected(), KoInteractionTool::removeInteractionFactory(), and value().

◆ slotActivateEditStrokeGradient

void DefaultTool::slotActivateEditStrokeGradient ( bool value)
privateslot

Definition at line 503 of file DefaultTool.cpp.

504{
505 if (value) {
507 new MoveGradientHandleInteractionFactory(KoFlake::StrokeFill,
508 0, EditStrokeGradientFactoryId, this));
509 } else {
510 removeInteractionFactory(EditStrokeGradientFactoryId);
511 }
513}
@ StrokeFill
Definition KoFlake.h:30

References KoInteractionTool::addInteractionFactory(), KoInteractionTool::removeInteractionFactory(), KoToolBase::repaintDecorations(), KoFlake::StrokeFill, and value().

◆ slotAddShapesToFlow

void DefaultTool::slotAddShapesToFlow ( )
privateslot

Definition at line 563 of file DefaultTool.cpp.

564{
565 KoSvgTextShape *textShape = nullptr;
566 QList<KoShape*> shapes;
568 if (!selection) return;
569
570 QList<KoShape *> selectedShapes = selection->selectedEditableShapes();
571 std::sort(selectedShapes.begin(), selectedShapes.end(), KoShape::compareShapeZIndex);
572 if (selectedShapes.isEmpty()) return;
573
574 Q_FOREACH(KoShape *shape, selectedShapes) {
575 KoSvgTextShape *text = dynamic_cast<KoSvgTextShape*>(shape);
576 KoPathShape *path = dynamic_cast<KoPathShape*>(shape);
577 if (text && !textShape) {
578 textShape = text;
579 } else if (path && path->isClosedSubpath(0)) {
580 shapes.append(shape);
581 }
582 }
583 if (!textShape) return;
584 if (shapes.isEmpty()) return;
585
586 KUndo2Command *parentCommand = new KUndo2Command(kundo2_i18n("Add shapes to text flow."));
587
588 if (textShape->textType() != KoSvgTextShape::InlineWrap) {
589 new KoSvgConvertTextTypeCommand(textShape, KoSvgTextShape::PreformattedText, 0, parentCommand);
590 }
591 KoSvgTextRemoveShapeCommand::removeContourShapesFromFlow(textShape, parentCommand, false, true);
592
593 new KoKeepShapesSelectedCommand(selectedShapes, {}, canvas()->selectedShapesProxy(), false, parentCommand);
594 Q_FOREACH(KoShape *shape, shapes) {
595 new KoSvgTextAddShapeCommand(textShape, shape, true, parentCommand);
596 }
597 new KoKeepShapesSelectedCommand({}, {textShape}, canvas()->selectedShapesProxy(), true, parentCommand);
598
599 canvas()->addCommand(parentCommand);
600 selection->deselectAll();
601 selection->select(textShape);
602}
The SvgConvertTextTypeCommand class This command allows textshapes to be converted between preformatt...
static void removeContourShapesFromFlow(KoSvgTextShape *textShape, KUndo2Command *parent, bool textInShape, bool textPaths)
removeContourShapesFromFlow Create a command to remove all contour shapes of a certain type from the ...
TextType textType() const
textType This enum gives an indication of what kind of text this shape is. The different text types a...

References KoCanvasBase::addCommand(), KoToolBase::canvas(), KoShape::compareShapeZIndex(), KoSvgTextShape::InlineWrap, koSelection(), kundo2_i18n(), KoSvgTextShape::PreformattedText, KoSvgTextRemoveShapeCommand::removeContourShapesFromFlow(), KoCanvasBase::selectedShapesProxy(), selection(), and KoSvgTextShape::textType().

◆ slotChangeTextType

void DefaultTool::slotChangeTextType ( int index)
privateslot

Definition at line 535 of file DefaultTool.cpp.

536{
538
539 if (shapes.isEmpty()) return;
540
542 KUndo2Command *parentCommand = new KUndo2Command();
543 bool convertableShape = false;
545 Q_FOREACH(KoShape *shape, shapes) {
546 KoSvgTextShape *textShape = dynamic_cast<KoSvgTextShape*>(shape);
547 if (textShape && textShape->textType() != type) {
548 KoSvgConvertTextTypeCommand *cmd = new KoSvgConvertTextTypeCommand(textShape, type, 0, parentCommand);
549 if (!convertableShape) {
550 convertableShape = true;
551 parentCommand->setText(cmd->text());
552 }
554 }
555 }
556
558 if (convertableShape) {
559 canvas()->addCommand(parentCommand);
560 }
561}
KUndo2MagicString text() const
@ TextInShape
Uses shape-inside to wrap and preserves spaces.

References KoCanvasBase::addCommand(), KoToolBase::canvas(), KisCommandUtils::FlipFlopCommand::FINALIZING, KisCommandUtils::FlipFlopCommand::INITIALIZING, KoSvgTextShape::InlineWrap, koSelection(), KoSvgTextRemoveShapeCommand::removeContourShapesFromFlow(), KoSelection::selectedShapes(), KoCanvasBase::selectedShapesProxy(), KUndo2Command::setText(), KUndo2Command::text(), KoSvgTextShape::TextInShape, and KoSvgTextShape::textType().

◆ slotPutTextOnPath

void DefaultTool::slotPutTextOnPath ( )
privateslot

This will always remove all previous text paths. While Krita's layout engine can handle multiple of them, the interaction hasn't been fully verified yet. So if someone implements multiple textpaths, they will also need to check if the cursor interaction makes sense.

We need to adjust the startOffset by the anchor/direction, because otherwise the text might be largely off the path. This isn't a problem when using cursor to set it, as the cursor-pos can be the startOffset position.

Definition at line 604 of file DefaultTool.cpp.

605{
606 KoSvgTextShape *textShape = nullptr;
607 KoPathShape *textPath = nullptr;
609 if (!selection) return;
610
611 QList<KoShape *> selectedShapes = selection->selectedEditableShapes();
612 std::sort(selectedShapes.begin(), selectedShapes.end(), KoShape::compareShapeZIndex);
613 if (selectedShapes.isEmpty()) return;
614
615 Q_FOREACH(KoShape *shape, selectedShapes) {
616 KoSvgTextShape *text = dynamic_cast<KoSvgTextShape*>(shape);
617 if (text && !textShape) {
618 textShape = text;
619 } else if (KoPathShape *path = dynamic_cast<KoPathShape*>(shape)){
620 textPath = path;
621 }
622 if (textShape && textPath) {
623 break;
624 }
625 }
626 if (!(textShape && textPath)) return;
627
628 KUndo2Command *parentCommand = new KUndo2Command(kundo2_i18n("Put Text On Path"));
629
630 new KoKeepShapesSelectedCommand(selectedShapes, {}, canvas()->selectedShapesProxy(), false, parentCommand);
632 new KoSvgConvertTextTypeCommand(textShape, KoSvgTextShape::PreformattedText, 0, parentCommand);
633 }
634
639 KoSvgTextRemoveShapeCommand::removeContourShapesFromFlow(textShape, parentCommand, true, true);
640 new KoSvgTextSetTextPathOnRangeCommand(textShape, textPath, 0, textShape->posForIndex(textShape->plainText().size()), parentCommand);
641
645 if ((textShape->direction() == KoSvgText::DirectionRightToLeft && anchor == KoSvgText::AnchorStart)
646 || (textShape->direction() == KoSvgText::DirectionLeftToRight && anchor == KoSvgText::AnchorEnd)) {
648 info.startOffset = 100.0;
649 info.startOffsetIsPercentage = true;
650 new KoSvgTextPathInfoChangeCommand(textShape, 0, info, parentCommand);
651 } else if (anchor == KoSvgText::AnchorMiddle) {
653 info.startOffset = 50.0;
654 info.startOffsetIsPercentage = true;
655 new KoSvgTextPathInfoChangeCommand(textShape, 0, info, parentCommand);
656 }
657
658 new KoKeepShapesSelectedCommand({}, {textShape}, canvas()->selectedShapesProxy(), true, parentCommand);
659
660 canvas()->addCommand(parentCommand);
661 selection->deselectAll();
662 selection->select(textShape);
663}
@ TextAnchorId
KoSvgText::TextAnchor.
QVariant propertyOrDefault(PropertyId id) const
KoSvgText::Direction direction() const
direction Whether the text is left to right or right to left.
int posForIndex(int index, bool firstIndex=false, bool skipSynthetic=false) const
posForIndex Get the cursor position for a given index in a string.
KoSvgTextProperties textProperties() const
TextAnchor
Where the text is anchored for SVG 1.1 text and 'inline-size'.
Definition KoSvgText.h:79
@ AnchorEnd
Anchor right for LTR, left for RTL.
Definition KoSvgText.h:82
@ AnchorStart
Anchor left for LTR, right for RTL.
Definition KoSvgText.h:80
@ AnchorMiddle
Anchor to the middle.
Definition KoSvgText.h:81
@ DirectionLeftToRight
Definition KoSvgText.h:49
@ DirectionRightToLeft
Definition KoSvgText.h:50

References KoCanvasBase::addCommand(), KoSvgText::AnchorEnd, KoSvgText::AnchorMiddle, KoSvgText::AnchorStart, KoToolBase::canvas(), KoShape::compareShapeZIndex(), KoSvgTextShape::direction(), KoSvgText::DirectionLeftToRight, KoSvgText::DirectionRightToLeft, koSelection(), kundo2_i18n(), KoSvgTextShape::plainText, KoSvgTextShape::posForIndex(), KoSvgTextShape::PreformattedText, KoSvgTextShape::PrePositionedText, KoSvgTextProperties::propertyOrDefault(), KoSvgTextRemoveShapeCommand::removeContourShapesFromFlow(), KoCanvasBase::selectedShapesProxy(), selection(), KoSvgText::TextOnPathInfo::startOffset, KoSvgText::TextOnPathInfo::startOffsetIsPercentage, KoSvgTextProperties::TextAnchorId, KoSvgTextShape::textProperties(), and KoSvgTextShape::textType().

◆ slotRemoveShapesFromFlow

void DefaultTool::slotRemoveShapesFromFlow ( )
privateslot

Definition at line 711 of file DefaultTool.cpp.

712{
714 if (!textShape) return;
716 if (!selection) return;
717
718 QList<KoShape *> selectedShapes = selection->selectedEditableShapes();
719 if (selectedShapes.isEmpty()) return;
720
721 KUndo2Command *parentCommand = new KUndo2Command(kundo2_i18n("Remove shapes from text flow."));
722
723 new KoKeepShapesSelectedCommand(selectedShapes, {}, canvas()->selectedShapesProxy(), false, parentCommand);
724 Q_FOREACH(KoShape *shape, selectedShapes) {
725 if (!textShape->shapeInContours(shape)) continue;
726 new KoSvgTextRemoveShapeCommand(textShape, shape, parentCommand);
727 }
728 new KoKeepShapesSelectedCommand({}, {selectedShapes}, canvas()->selectedShapesProxy(), true, parentCommand);
729
730 canvas()->addCommand(parentCommand);
731}
KoSvgTextShape * tryFetchCurrentShapeManagerOwnerTextShape() const
bool shapeInContours(KoShape *shape)
shapeInContours

References KoCanvasBase::addCommand(), KoToolBase::canvas(), koSelection(), kundo2_i18n(), KoCanvasBase::selectedShapesProxy(), selection(), KoSvgTextShape::shapeInContours(), and tryFetchCurrentShapeManagerOwnerTextShape().

◆ slotReorderFlowShapes

void DefaultTool::slotReorderFlowShapes ( int type)
privateslot

Definition at line 756 of file DefaultTool.cpp.

757{
759 if (!textShape) return;
761 if (!selection) return;
762
763 QList<KoShape *> selectedShapes = selection->selectedEditableShapes();
764 if (selectedShapes.isEmpty()) return;
765
766 KUndo2Command *parentCommand = new KUndo2Command();
768 parentCommand->setText(kundo2_i18n("Set Flow Shape as First"));
770 parentCommand->setText(kundo2_i18n("Decrease Flow Shape Index"));
772 parentCommand->setText(kundo2_i18n("Increase Flow Shape Index"));
773 } else {
774 parentCommand->setText(kundo2_i18n("Set Flow Shape as Last"));
775 }
776
777 QList<KoShape *> shapesInside;
778 Q_FOREACH(KoShape *shape, selectedShapes) {
779 if (!textShape->shapesInside().contains(shape)) continue;
780 shapesInside.append(shape);
781 }
782
783 if (!shapesInside.isEmpty()) {
784 new KoSvgTextReorderShapeInsideCommand(textShape, shapesInside, KoSvgTextReorderShapeInsideCommand::MoveShapeType(type), parentCommand);
785 canvas()->addCommand(parentCommand);
786 }
787}
The KoSvgTextReorderShapeInsideCommand class Within a text shape, the order of the shapes inside dete...
QList< KoShape * > shapesInside

References KoCanvasBase::addCommand(), KoSvgTextReorderShapeInsideCommand::BringToFront, KoToolBase::canvas(), koSelection(), kundo2_i18n(), KoSvgTextReorderShapeInsideCommand::MoveEarlier, KoSvgTextReorderShapeInsideCommand::MoveLater, selection(), KUndo2Command::setText(), KoSvgTextShape::shapesInside, and tryFetchCurrentShapeManagerOwnerTextShape().

◆ slotResetMeshGradientState

void DefaultTool::slotResetMeshGradientState ( )
privateslot

Definition at line 530 of file DefaultTool.cpp.

References m_selectedMeshHandle.

◆ slotSubtractShapesFromFlow

void DefaultTool::slotSubtractShapesFromFlow ( )
privateslot

Definition at line 665 of file DefaultTool.cpp.

666{
667 KoSvgTextShape *textShape = nullptr;
668 QList<KoShape*> shapes;
670 if (!selection) return;
671
672 QList<KoShape *> selectedShapes = selection->selectedEditableShapes();
673 std::sort(selectedShapes.begin(), selectedShapes.end(), KoShape::compareShapeZIndex);
674 if (selectedShapes.isEmpty()) return;
675
676 Q_FOREACH(KoShape *shape, selectedShapes) {
677 KoSvgTextShape *text = dynamic_cast<KoSvgTextShape*>(shape);
678 KoPathShape *path = dynamic_cast<KoPathShape*>(shape);
679 if (text && !textShape) {
680 textShape = text;
681 } else if (path && path->isClosedSubpath(0)) {
682 shapes.append(shape);
683 }
684 }
685 if (!textShape) return;
686 if (shapes.isEmpty()) return;
687
688 KUndo2Command *parentCommand = new KUndo2Command(kundo2_i18n("Subtract shapes from text flow."));
689
690 if (textShape->textType() == KoSvgTextShape::InlineWrap) {
691 new KoSvgConvertTextTypeCommand(textShape, KoSvgTextShape::PreformattedText, 0, parentCommand);
692 }
693 KoSvgTextRemoveShapeCommand::removeContourShapesFromFlow(textShape, parentCommand, false, true);
694
695 new KoKeepShapesSelectedCommand(selectedShapes, {}, canvas()->selectedShapesProxy(), false, parentCommand);
696 Q_FOREACH(KoShape *shape, shapes) {
697 new KoSvgTextAddShapeCommand(textShape, shape, false, parentCommand);
698 }
699 new KoKeepShapesSelectedCommand({}, {textShape}, canvas()->selectedShapesProxy(), true, parentCommand);
700
701 canvas()->addCommand(parentCommand);
702 selection->deselectAll();
703 selection->select(textShape);
704}

References KoCanvasBase::addCommand(), KoToolBase::canvas(), KoShape::compareShapeZIndex(), KoSvgTextShape::InlineWrap, koSelection(), kundo2_i18n(), KoSvgTextShape::PreformattedText, KoSvgTextRemoveShapeCommand::removeContourShapesFromFlow(), KoCanvasBase::selectedShapesProxy(), selection(), and KoSvgTextShape::textType().

◆ slotToggleFlowShapeType

void DefaultTool::slotToggleFlowShapeType ( )
privateslot

Definition at line 733 of file DefaultTool.cpp.

734{
736 if (!textShape) return;
738 if (!selection) return;
739
740 QList<KoShape *> selectedShapes = selection->selectedEditableShapes();
741 if (selectedShapes.isEmpty()) return;
742 KUndo2Command *parentCommand = new KUndo2Command(kundo2_i18n("Toggle Flow Shape Type"));
743
744 bool addToCanvas = false;
745 Q_FOREACH(KoShape *shape, selectedShapes) {
746 if (!textShape->shapesInside().contains(shape)
747 && !textShape->shapesSubtract().contains(shape)) continue;
748 addToCanvas = true;
749 new KoSvgTextFlipShapeContourTypeCommand(textShape, shape, parentCommand);
750 }
751 if (addToCanvas) {
752 canvas()->addCommand(parentCommand);
753 }
754}
QList< KoShape * > shapesSubtract

References KoCanvasBase::addCommand(), KoToolBase::canvas(), koSelection(), kundo2_i18n(), selection(), KoSvgTextShape::shapesInside, KoSvgTextShape::shapesSubtract, and tryFetchCurrentShapeManagerOwnerTextShape().

◆ tryFetchCurrentShapeManagerOwnerTextShape()

KoSvgTextShape * DefaultTool::tryFetchCurrentShapeManagerOwnerTextShape ( ) const

Definition at line 706 of file DefaultTool.cpp.

707{
708 return dynamic_cast<KoSvgTextShape*>(canvas()->currentShapeManagerOwnerShape());
709}
virtual KoShape * currentShapeManagerOwnerShape() const
the shape that owns the currently active shape manager

References KoToolBase::canvas(), and KoCanvasBase::currentShapeManagerOwnerShape().

◆ updateActions

void DefaultTool::updateActions ( )
protectedslot

Update actions on selection change.

Definition at line 2107 of file DefaultTool.cpp.

2108{
2109 QList<KoShape*> editableShapes;
2110
2111 if (koSelection()) {
2112 editableShapes = koSelection()->selectedEditableShapes();
2113 }
2114
2115 const bool hasEditableShapes = !editableShapes.isEmpty();
2116
2117 action("object_order_front")->setEnabled(hasEditableShapes);
2118 action("object_order_raise")->setEnabled(hasEditableShapes);
2119 action("object_order_lower")->setEnabled(hasEditableShapes);
2120 action("object_order_back")->setEnabled(hasEditableShapes);
2121
2122 action("object_transform_rotate_90_cw")->setEnabled(hasEditableShapes);
2123 action("object_transform_rotate_90_ccw")->setEnabled(hasEditableShapes);
2124 action("object_transform_rotate_180")->setEnabled(hasEditableShapes);
2125 action("object_transform_mirror_horizontally")->setEnabled(hasEditableShapes);
2126 action("object_transform_mirror_vertically")->setEnabled(hasEditableShapes);
2127 action("object_transform_reset")->setEnabled(hasEditableShapes);
2128
2129 const bool multipleSelected = editableShapes.size() > 1;
2130
2131 const bool alignmentEnabled =
2132 multipleSelected ||
2133 (!editableShapes.isEmpty() &&
2135
2136 action("object_align_horizontal_left")->setEnabled(alignmentEnabled);
2137 action("object_align_horizontal_center")->setEnabled(alignmentEnabled);
2138 action("object_align_horizontal_right")->setEnabled(alignmentEnabled);
2139 action("object_align_vertical_top")->setEnabled(alignmentEnabled);
2140 action("object_align_vertical_center")->setEnabled(alignmentEnabled);
2141 action("object_align_vertical_bottom")->setEnabled(alignmentEnabled);
2142
2143 const bool distributionEnabled = editableShapes.size() > 2;
2144
2145 action("object_distribute_horizontal_left")->setEnabled(distributionEnabled);
2146 action("object_distribute_horizontal_center")->setEnabled(distributionEnabled);
2147 action("object_distribute_horizontal_right")->setEnabled(distributionEnabled);
2148 action("object_distribute_horizontal_gaps")->setEnabled(distributionEnabled);
2149
2150 action("object_distribute_vertical_top")->setEnabled(distributionEnabled);
2151 action("object_distribute_vertical_center")->setEnabled(distributionEnabled);
2152 action("object_distribute_vertical_bottom")->setEnabled(distributionEnabled);
2153 action("object_distribute_vertical_gaps")->setEnabled(distributionEnabled);
2154
2155 /* Handling the text actions */
2156 bool textShape = false;
2157 bool otherShapes = false;
2158 bool filledShapes = false;
2159 bool shapesInside = false;
2161 const bool editFlowShapes = bool(currentTextShapeGroup);
2162 Q_FOREACH(KoShape *shape, editableShapes) {
2163 KoSvgTextShape *text = dynamic_cast<KoSvgTextShape *>(shape);
2164 if (text && !textShape) {
2165 textShape = true;
2166 } else {
2167 otherShapes = true;
2168 KoPathShape *path = dynamic_cast<KoPathShape*>(shape);
2169 filledShapes = filledShapes? filledShapes: (path && path->isClosedSubpath(0));
2170 if (editFlowShapes) {
2171 if (!shapesInside && currentTextShapeGroup->shapesInside().contains(shape)) {
2172 shapesInside = true;
2173 }
2174 }
2175 }
2176 if (textShape && otherShapes) break;
2177 }
2178 const bool editContours = textShape && otherShapes;
2179 const bool editFilledContours = textShape && filledShapes;
2180
2181 action("add_shape_to_flow_area")->setEnabled(editFilledContours);
2182 action("subtract_shape_from_flow_area")->setEnabled(editFilledContours);
2183 action("put_text_on_path")->setEnabled(editContours);
2184 action("remove_shapes_from_text_flow")->setEnabled(editFlowShapes);
2185 action("flow_shape_type_toggle")->setEnabled(editFlowShapes);
2186 action("flow_shape_order_back")->setEnabled(shapesInside);
2187 action("flow_shape_order_earlier")->setEnabled(shapesInside);
2188 action("flow_shape_order_later")->setEnabled(shapesInside);
2189 action("flow_shape_order_front")->setEnabled(shapesInside);
2190
2191 updateDistinctiveActions(editableShapes);
2192
2193 Q_EMIT selectionChanged(editableShapes.size());
2194}
virtual void updateDistinctiveActions(const QList< KoShape * > &editableShapes)

References KoToolBase::action(), KoToolBase::canvas(), koSelection(), KoCanvasResource::PageSize, KoCanvasBase::resourceManager, KoSelection::selectedEditableShapes(), KoToolBase::selectionChanged(), KoSvgTextShape::shapesInside, tryFetchCurrentShapeManagerOwnerTextShape(), and updateDistinctiveActions().

◆ updateCursor()

void DefaultTool::updateCursor ( )
private

Definition at line 989 of file DefaultTool.cpp.

990{
991 if (tryUseCustomCursor()) return;
992
993 QCursor cursor = Qt::ArrowCursor;
994
995 QString statusText;
996
998 if (selection && selection->count() > 0) { // has a selection
999 bool editable = !selection->selectedEditableShapes().isEmpty();
1000
1003 int rotOctant = 8 + int(8.5 + m_angle / 45);
1004
1005 bool rotateHandle = false;
1006 bool shearHandle = false;
1007 switch (m_lastHandle) {
1009 cursor = m_shearCursors[(0 + rotOctant) % 8];
1010 shearHandle = true;
1011 break;
1013 cursor = m_rotateCursors[(1 + rotOctant) % 8];
1014 rotateHandle = true;
1015 break;
1017 cursor = m_shearCursors[(2 + rotOctant) % 8];
1018 shearHandle = true;
1019 break;
1021 cursor = m_rotateCursors[(3 + rotOctant) % 8];
1022 rotateHandle = true;
1023 break;
1025 cursor = m_shearCursors[(4 + rotOctant) % 8];
1026 shearHandle = true;
1027 break;
1029 cursor = m_rotateCursors[(5 + rotOctant) % 8];
1030 rotateHandle = true;
1031 break;
1033 cursor = m_shearCursors[(6 + rotOctant) % 8];
1034 shearHandle = true;
1035 break;
1037 cursor = m_rotateCursors[(7 + rotOctant) % 8];
1038 rotateHandle = true;
1039 break;
1040 case KoFlake::NoHandle:
1041 cursor = Qt::ArrowCursor;
1042 break;
1043 }
1044 if (rotateHandle) {
1045 statusText = i18n("Left click rotates around center, right click around highlighted position.");
1046 }
1047 if (shearHandle) {
1048 statusText = i18n("Click and drag to shear selection.");
1049 }
1050
1051
1052 } else {
1053 statusText = i18n("Click and drag to resize selection.");
1055 int rotOctant = 8 + int(8.5 + m_angle / 45);
1056 bool cornerHandle = false;
1057 switch (m_lastHandle) {
1059 cursor = m_sizeCursors[(0 + rotOctant) % 8];
1060 break;
1062 cursor = m_sizeCursors[(1 + rotOctant) % 8];
1063 cornerHandle = true;
1064 break;
1066 cursor = m_sizeCursors[(2 + rotOctant) % 8];
1067 break;
1069 cursor = m_sizeCursors[(3 + rotOctant) % 8];
1070 cornerHandle = true;
1071 break;
1073 cursor = m_sizeCursors[(4 + rotOctant) % 8];
1074 break;
1076 cursor = m_sizeCursors[(5 + rotOctant) % 8];
1077 cornerHandle = true;
1078 break;
1080 cursor = m_sizeCursors[(6 + rotOctant) % 8];
1081 break;
1083 cursor = m_sizeCursors[(7 + rotOctant) % 8];
1084 cornerHandle = true;
1085 break;
1086 case KoFlake::NoHandle:
1087 cursor = Qt::SizeAllCursor;
1088 statusText = i18n("Click and drag to move selection.");
1089 break;
1090 }
1091 if (cornerHandle) {
1092 statusText = i18n("Click and drag to resize selection. Middle click to set highlighted position.");
1093 }
1094 }
1095 if (!editable) {
1096 cursor = Qt::ArrowCursor;
1097 }
1098 } else {
1099 // there used to be guides... :'''(
1100 }
1102 if (currentStrategy() == 0) {
1103 Q_EMIT statusTextChanged(statusText);
1104 }
1105}
qreal rotationOfHandle(KoFlake::SelectionHandle handle, bool useEdgeRotation)
Returns rotation angle of given handle of the current selection.
QCursor cursor() const
return the last emitted cursor
void statusTextChanged(const QString &statusText)

References KoFlake::BottomLeftHandle, KoFlake::BottomMiddleHandle, KoFlake::BottomRightHandle, KoInteractionTool::currentStrategy(), KoToolBase::cursor(), koSelection(), KoFlake::LeftMiddleHandle, m_angle, m_lastHandle, m_mouseWasInsideHandles, m_rotateCursors, m_shearCursors, m_sizeCursors, KoFlake::NoHandle, KoFlake::RightMiddleHandle, rotationOfHandle(), selection(), KoToolBase::statusTextChanged(), KoFlake::TopLeftHandle, KoFlake::TopMiddleHandle, KoFlake::TopRightHandle, KoInteractionTool::tryUseCustomCursor(), and KoToolBase::useCursor().

◆ updateDistinctiveActions()

void DefaultTool::updateDistinctiveActions ( const QList< KoShape * > & editableShapes)
protectedvirtual

Enable/disable actions specific to the tool (vector vs. reference images)

Reimplemented in ToolReferenceImages.

Definition at line 2196 of file DefaultTool.cpp.

2196 {
2197 const bool multipleSelected = editableShapes.size() > 1;
2198
2199 action("object_group")->setEnabled(multipleSelected);
2200
2201 action("object_unite")->setEnabled(multipleSelected);
2202 action("object_intersect")->setEnabled(multipleSelected);
2203 action("object_subtract")->setEnabled(multipleSelected);
2204
2205 bool hasShapesWithMultipleSegments = false;
2206 Q_FOREACH (KoShape *shape, editableShapes) {
2207 KoPathShape *pathShape = dynamic_cast<KoPathShape *>(shape);
2208 if (pathShape && pathShape->subpathCount() > 1) {
2209 hasShapesWithMultipleSegments = true;
2210 break;
2211 }
2212 }
2213 action("object_split")->setEnabled(hasShapesWithMultipleSegments);
2214
2215
2216 bool hasGroupShape = false;
2217 foreach (KoShape *shape, editableShapes) {
2218 if (dynamic_cast<KoShapeGroup *>(shape)) {
2219 hasGroupShape = true;
2220 break;
2221 }
2222 }
2223 action("object_ungroup")->setEnabled(hasGroupShape);
2224
2225 bool enablePreformatted = false;
2226 bool enablePrePositioned = false;
2227 bool enableInlineWrapped = false;
2228 bool text = false;
2229 Q_FOREACH (KoShape *shape, editableShapes) {
2230 KoSvgTextShape *textShape = dynamic_cast<KoSvgTextShape *>(shape);
2231 if (textShape) {
2232 text = true;
2233 if (textShape->textType() != KoSvgTextShape::PreformattedText && !enablePreformatted) {
2234 enablePreformatted = true;
2235 }
2236 if (textShape && textShape->textType() != KoSvgTextShape::PrePositionedText && !enablePrePositioned) {
2237 enablePrePositioned = true;
2238 }
2239 if (textShape && textShape->textType() != KoSvgTextShape::InlineWrap && !enableInlineWrapped) {
2240 enableInlineWrapped = true;
2241 }
2242 }
2243 }
2244 QActionGroup *group = action("text_type_preformatted")->actionGroup();
2245 if (group) {
2246 group->setEnabled(text);
2247 }
2248
2249 action("text_type_preformatted")->setEnabled(enablePreformatted);
2250 action("text_type_pre_positioned")->setEnabled(enablePrePositioned);
2251 action("text_type_inline_wrap")->setEnabled(enableInlineWrapped);
2252}
int subpathCount() const
Returns the number of subpaths in the path.

References KoToolBase::action(), KoSvgTextShape::InlineWrap, KoSvgTextShape::PreformattedText, KoSvgTextShape::PrePositionedText, KoPathShape::subpathCount(), and KoSvgTextShape::textType().

◆ updateTextContourMode()

bool DefaultTool::updateTextContourMode ( )

Definition at line 789 of file DefaultTool.cpp.

790{
791 return m_textOutlineHelper->updateTextContourMode();
792}

References m_textOutlineHelper.

◆ wantsAutoScroll()

bool DefaultTool::wantsAutoScroll ( ) const
overridevirtual

Return if dragging (moving with the mouse down) to the edge of a canvas should scroll the canvas (default is true).

Returns
if this tool wants mouse events to cause scrolling of canvas.

Reimplemented from KoToolBase.

Definition at line 794 of file DefaultTool.cpp.

795{
796 return true;
797}

Friends And Related Symbol Documentation

◆ SelectionHandler

friend class SelectionHandler
friend

Definition at line 209 of file DefaultTool.h.

◆ SelectionInteractionStrategy

friend class SelectionInteractionStrategy
friend

Definition at line 155 of file DefaultTool.h.

Member Data Documentation

◆ m_alignSignalsMapper

KisSignalMapper* DefaultTool::m_alignSignalsMapper {0}
private

Definition at line 213 of file DefaultTool.h.

213{0};

◆ m_angle

qreal DefaultTool::m_angle
private

Definition at line 207 of file DefaultTool.h.

◆ m_booleanSignalsMapper

KisSignalMapper* DefaultTool::m_booleanSignalsMapper {0}
private

Definition at line 216 of file DefaultTool.h.

216{0};

◆ m_contextMenu

QScopedPointer<QMenu> DefaultTool::m_contextMenu
protected

Definition at line 166 of file DefaultTool.h.

◆ m_decorator

QScopedPointer<SelectionDecorator> DefaultTool::m_decorator
private

Definition at line 197 of file DefaultTool.h.

◆ m_distributeSignalsMapper

KisSignalMapper* DefaultTool::m_distributeSignalsMapper {0}
private

Definition at line 214 of file DefaultTool.h.

214{0};

◆ m_hotPosition

KoFlake::AnchorPosition DefaultTool::m_hotPosition
private

Definition at line 191 of file DefaultTool.h.

◆ m_hoveredMeshHandle

KoShapeMeshGradientHandles::Handle DefaultTool::m_hoveredMeshHandle
private

Definition at line 201 of file DefaultTool.h.

◆ m_lastHandle

KoFlake::SelectionHandle DefaultTool::m_lastHandle
private

Definition at line 190 of file DefaultTool.h.

◆ m_lastPoint

QPointF DefaultTool::m_lastPoint
private

Definition at line 195 of file DefaultTool.h.

◆ m_mouseWasInsideHandles

bool DefaultTool::m_mouseWasInsideHandles
private

Definition at line 192 of file DefaultTool.h.

◆ m_rotateCursors

QCursor DefaultTool::m_rotateCursors[8]
private

Definition at line 205 of file DefaultTool.h.

◆ m_selectedMeshHandle

KoShapeMeshGradientHandles::Handle DefaultTool::m_selectedMeshHandle
private

Definition at line 200 of file DefaultTool.h.

◆ m_selectionBox

QPointF DefaultTool::m_selectionBox[8]
private

Definition at line 193 of file DefaultTool.h.

◆ m_selectionHandler

KoToolSelection* DefaultTool::m_selectionHandler
private

Definition at line 208 of file DefaultTool.h.

◆ m_selectionOutline

QPolygonF DefaultTool::m_selectionOutline
private

Definition at line 194 of file DefaultTool.h.

◆ m_shearCursors

QCursor DefaultTool::m_shearCursors[8]
private

Definition at line 206 of file DefaultTool.h.

◆ m_sizeCursors

QCursor DefaultTool::m_sizeCursors[8]
private

Definition at line 204 of file DefaultTool.h.

◆ m_tabbedOptionWidget

DefaultToolTabbedWidget* DefaultTool::m_tabbedOptionWidget
private

Definition at line 211 of file DefaultTool.h.

◆ m_textFlowSignalsMapper

KisSignalMapper* DefaultTool::m_textFlowSignalsMapper {0}
private

Definition at line 218 of file DefaultTool.h.

218{0};

◆ m_textOutlineHelper

QScopedPointer<KoSvgTextShapeOutlineHelper> DefaultTool::m_textOutlineHelper
private

Definition at line 198 of file DefaultTool.h.

◆ m_textPropertyInterface

DefaultToolTextPropertiesInterface* DefaultTool::m_textPropertyInterface {0}
private

Definition at line 220 of file DefaultTool.h.

220{0};

◆ m_textTypeSignalsMapper

KisSignalMapper* DefaultTool::m_textTypeSignalsMapper {0}
private

Definition at line 217 of file DefaultTool.h.

217{0};

◆ m_transformSignalsMapper

KisSignalMapper* DefaultTool::m_transformSignalsMapper {0}
private

Definition at line 215 of file DefaultTool.h.

215{0};

The documentation for this class was generated from the following files: