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

#include <kis_tool_lazy_brush.h>

+ Inheritance diagram for KisToolLazyBrush:

Classes

struct  Private
 

Public Slots

void activate (const QSet< KoShape * > &shapes) override
 
void deactivate () override
 
- Public Slots inherited from KisToolFreehand
void activate (const QSet< KoShape * > &shapes) override
 
void deactivate () override
 
- Public Slots inherited from KisToolPaint
void activate (const QSet< KoShape * > &shapes) override
 
void deactivate () override
 
- Public Slots inherited from KisTool
void activate (const QSet< KoShape * > &shapes) override
 
void canvasResourceChanged (int key, const QVariant &res) override
 
void deactivate () override
 
virtual void updateSettingsViews ()
 
- 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 ()
 

Public Member Functions

void activateAlternateAction (AlternateAction action) override
 
void activatePrimaryAction () override
 
void beginAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
void beginPrimaryAction (KoPointerEvent *event) override
 
void continueAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
void continuePrimaryAction (KoPointerEvent *event) override
 
QWidget * createOptionWidget () override
 
void deactivateAlternateAction (AlternateAction action) override
 
void deactivatePrimaryAction () override
 
void endAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
void endPrimaryAction (KoPointerEvent *event) override
 
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.
 
 KisToolLazyBrush (KoCanvasBase *canvas)
 
 ~KisToolLazyBrush () override
 
- Public Member Functions inherited from KisToolFreehand
int flags () const override
 
 KisToolFreehand (KoCanvasBase *canvas, const QCursor &cursor, const KUndo2MagicString &transactionText, bool useSavedSmoothing=true)
 
void mouseMoveEvent (KoPointerEvent *event) override
 
 ~KisToolFreehand () override
 
- Public Member Functions inherited from KisToolPaint
int flags () const override
 
 KisToolPaint (KoCanvasBase *canvas, const QCursor &cursor)
 
void mouseMoveEvent (KoPointerEvent *event) override
 
void mousePressEvent (KoPointerEvent *event) override
 
void mouseReleaseEvent (KoPointerEvent *event) override
 
KisPopupWidgetInterfacepopupWidget () override
 
 ~KisToolPaint () override
 
- Public Member Functions inherited from KisTool
virtual bool alternateActionSupportsHiResEvents (AlternateAction action) const
 
virtual void beginAlternateDoubleClickAction (KoPointerEvent *event, AlternateAction action)
 
virtual void beginPrimaryDoubleClickAction (KoPointerEvent *event)
 
void deleteSelection () override
 
bool isActive () const
 
 KisTool (KoCanvasBase *canvas, const QCursor &cursor)
 
void mouseDoubleClickEvent (KoPointerEvent *event) override
 
void mouseTripleClickEvent (KoPointerEvent *event) override
 
virtual void newActivationWithExternalSource (KisPaintDeviceSP externalSource)
 newActivationWithExternalSource Makes sure that the tool is active and starts a new stroke, which will be able to access the pixels from the specified external source.
 
KisTool::NodePaintAbility nodePaintAbility ()
 
 ~KisTool () override
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KoToolBase
QAction * action (const QString &name) const
 
KoCanvasBasecanvas () const
 Returns the canvas the tool is working on.
 
virtual void copy () const
 
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 ()
 
virtual QRectF decorationsRect () const
 
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 deselect ()
 deselect the tool should clear the selection if it has one.
 
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
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
 KoToolBase (KoCanvasBase *canvas)
 
bool maskSyntheticEvents () const
 
QList< QPointer< QWidget > > optionWidgets ()
 
virtual bool paste ()
 
virtual QMenu * popupActionsMenu ()
 
virtual bool selectAll ()
 selectAll select all data the tool can select.
 
virtual KoToolSelectionselection ()
 
Q_INVOKABLE QString toolId () const
 
 ~KoToolBase () override
 

Protected Slots

void resetCursorStyle () override
 
- Protected Slots inherited from KisToolFreehand
void explicitUpdateOutline ()
 
void resetCursorStyle () override
 
void setAssistant (bool assistant)
 
void setOnlyOneAssistantSnap (bool assistant)
 
void setSnapEraser (bool assistant)
 
void slotDoResizeBrush (qreal newSize)
 
- Protected Slots inherited from KisTool
virtual void resetCursorStyle ()
 

Private Slots

void slotCurrentNodeChanged (KisNodeSP node)
 

Private Member Functions

bool canCreateColorizeMask () const
 
bool colorizeMaskActive () const
 
bool shouldActivateKeyStrokes () const
 
void tryCreateColorizeMask ()
 
void tryDisableKeyStrokesOnMask ()
 

Private Attributes

const QScopedPointer< Privatem_d
 

Additional Inherited Members

- Public Types inherited from KisTool
enum  { FLAG_USES_CUSTOM_PRESET =0x01 , FLAG_USES_CUSTOM_COMPOSITEOP =0x02 , FLAG_USES_CUSTOM_SIZE =0x04 }
 
enum  AlternateAction {
  ChangeSize = AlternateChangeSize , ChangeSizeSnap = AlternateChangeSizeSnap , SampleFgNode = AlternateSampleFgNode , SampleBgNode = AlternateSampleBgNode ,
  SampleFgImage = AlternateSampleFgImage , SampleBgImage = AlternateSampleBgImage , Secondary = AlternateSecondary , Third = AlternateThird ,
  Fourth = AlternateFourth , Fifth = AlternateFifth , NONE = 10000
}
 
enum  NodePaintAbility {
  VECTOR , CLONE , PAINT , UNPAINTABLE ,
  MYPAINTBRUSH_UNPAINTABLE
}
 
enum  ToolAction {
  Primary , AlternateChangeSize , AlternateChangeSizeSnap , AlternateSampleFgNode ,
  AlternateSampleBgNode , AlternateSampleFgImage , AlternateSampleBgImage , AlternateSecondary ,
  AlternateThird , AlternateFourth , AlternateFifth , Alternate_NONE = 10000
}
 
- Signals inherited from KisToolPaint
void sigPaintingFinished ()
 
- Signals inherited from KisTool
void isActiveChanged (bool isActivated)
 
- 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)
 
- Static Public Member Functions inherited from KisTool
static AlternateAction actionToAlternateAction (ToolAction action)
 
- Public Attributes inherited from KisTool
KoColor currentBgColor
 
float currentExposure {1.0}
 
KoColor currentFgColor
 
KisFilterConfigurationSP currentGenerator
 
KoAbstractGradientSP currentGradient
 
KoPatternSP currentPattern
 
QCursor cursor
 
bool m_isActive {false}
 
ToolMode m_mode {HOVER_MODE}
 
QWidget * optionWidget {0}
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 
- Protected Types inherited from KisTool
enum  ToolMode : int {
  HOVER_MODE , PAINT_MODE , SECONDARY_PAINT_MODE , MIRROR_AXIS_SETUP_MODE ,
  GESTURE_MODE , PAN_MODE , OTHER , OTHER_1
}
 
- Protected Member Functions inherited from KisToolFreehand
virtual void doStroke (KoPointerEvent *event)
 
virtual void endStroke ()
 
KisOptimizedBrushOutline getOutlinePath (const QPointF &documentPos, const KoPointerEvent *event, KisPaintOpSettings::OutlineMode outlineMode) override
 
virtual void initStroke (KoPointerEvent *event)
 
KisPaintingInformationBuilderpaintingInformationBuilder () const
 
bool primaryActionSupportsHiResEvents () const override
 
void resetHelper (KisToolFreehandHelper *helper)
 
KisSmoothingOptionsSP smoothingOptions () const
 
bool supportsPaintingAssistants () const override
 
bool trySampleByPaintOp (KoPointerEvent *event, AlternateAction action)
 
bool wantsAutoScroll () const override
 
- Protected Member Functions inherited from KisToolPaint
void activateAlternateAction (AlternateAction action) override
 
void activatePrimaryAction () override
 
void addOptionWidgetLayout (QLayout *layout)
 Add the tool-specific layout to the default option widget layout.
 
virtual void addOptionWidgetOption (QWidget *control, QWidget *label=nullptr)
 Add a widget and a label to the current option widget layout.
 
void beginAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
void canvasResourceChanged (int key, const QVariant &v) override
 
void continueAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
QWidget * createOptionWidget () override
 
void deactivateAlternateAction (AlternateAction action) override
 
void deactivatePrimaryAction () override
 
void enableControl (QWidget *control, bool value)
 
void endAlternateAction (KoPointerEvent *event, AlternateAction action) override
 
bool isEraser () const
 
bool isOutlineEnabled () const
 
bool isOutlineVisible () const
 
void paint (QPainter &gc, const KoViewConverter &converter) override
 
virtual QString quickHelp () const
 
virtual void requestUpdateOutline (const QPointF &outlineDocPoint, const KoPointerEvent *event)
 
void setMode (ToolMode mode) override
 
void setOutlineEnabled (bool enabled)
 
void setOutlineVisible (bool visible)
 
void setSupportOutline (bool supportOutline)
 
void showControl (QWidget *control, bool value)
 
- Protected Member Functions inherited from KisTool
bool blockUntilOperationsFinished ()
 
void blockUntilOperationsFinishedForced ()
 
QPointF convertDocumentToWidget (const QPointF &pt)
 
QPoint convertToImagePixelCoordFloored (KoPointerEvent *e)
 
QPointF convertToPixelCoord (const QPointF &pt)
 
QPointF convertToPixelCoord (KoPointerEvent *e)
 
QPointF convertToPixelCoordAndAlignOnWidget (const QPointF &pt)
 
QPointF convertToPixelCoordAndSnap (const QPointF &pt, const QPointF &offset=QPointF())
 
QPointF convertToPixelCoordAndSnap (KoPointerEvent *e, const QPointF &offset=QPointF(), bool useModifiers=true)
 
QRectF convertToPt (const QRectF &rect)
 
qreal convertToPt (qreal value)
 
KoColor currentBgColor ()
 
KoColor currentFgColor ()
 
KisFilterConfigurationSP currentGenerator ()
 
KoAbstractGradientSP currentGradient ()
 
KisImageWSP currentImage ()
 
KisNodeSP currentNode () const
 
KisPaintOpPresetSP currentPaintOpPreset ()
 
KoPatternSP currentPattern ()
 
QCursor cursor () const
 
KisImageWSP image () const
 
virtual bool listeningToModifiers ()
 
virtual void listenToModifiers (bool listen)
 
virtual ToolMode mode () const
 
bool nodeEditable ()
 Checks checks if the current node is editable.
 
bool overrideCursorIfNotEditable ()
 Override the cursor appropriately if current node is not editable.
 
void paintToolOutline (QPainter *painter, const KisOptimizedBrushOutline &path)
 
KisOptimizedBrushOutline pixelToView (const KisOptimizedBrushOutline &path) const
 
QPainterPath pixelToView (const QPainterPath &pixelPath) const
 Convert a pixel path into a view path.
 
QPointF pixelToView (const QPoint &pixelCoord) const
 
QPointF pixelToView (const QPointF &pixelCoord) const
 Convert a floating point pixel coordinate into a view coordinate.
 
QPolygonF pixelToView (const QPolygonF &pixelPolygon) const
 Convert a pixel polygon into a view path.
 
QRectF pixelToView (const QRectF &pixelRect) const
 Convert a pixel rectangle into a view rectangle.
 
KisNodeList selectedNodes () const
 
bool selectionEditable ()
 Checks checks if the selection is editable, only applies to local selection as global selection is always editable.
 
void setCursor (const QCursor &cursor)
 
void updateCanvasPixelRect (const QRectF &pixelRect)
 Update the canvas for the given rectangle in image pixel coordinates.
 
void updateCanvasViewRect (const QRectF &viewRect)
 Update the canvas for the given rectangle in view coordinates.
 
QPointF viewToPixel (const QPointF &viewCoord) const
 
QPointF widgetCenterInWidgetPixels ()
 
- Protected Member Functions inherited from KoToolBase
virtual QList< QPointer< QWidget > > createOptionWidgets ()
 
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 inherited from KisToolFreehand
bool m_assistant {false}
 
bool m_eraser_snapping {false}
 
double m_magnetism {1.0}
 
bool m_only_one_assistant {true}
 
- Protected Attributes inherited from KisToolPaint
KisOptimizedBrushOutline m_currentOutline
 
QRectF m_oldColorPreviewUpdateRect
 
QRectF m_oldOutlineRect
 
QPointF m_outlineDocPoint
 
bool m_paintOutline {false}
 
- Protected Attributes inherited from KoToolBase
KoToolBasePrivated_ptr
 
- Properties inherited from KisTool
bool isActive
 

Detailed Description

Definition at line 26 of file kis_tool_lazy_brush.h.

Constructor & Destructor Documentation

◆ KisToolLazyBrush()

KisToolLazyBrush::KisToolLazyBrush ( KoCanvasBase * canvas)

Definition at line 45 of file kis_tool_lazy_brush.cpp.

47 KisCursor::load("tool_freehand_cursor.xpm", 2, 2),
48 kundo2_i18n("Colorize Mask Key Stroke")),
49 m_d(new Private)
50{
51 setObjectName("tool_lazybrush");
52}
static QCursor load(const QString &cursorName, int hotspotX=-1, int hotspotY=-1)
KisToolFreehand(KoCanvasBase *canvas, const QCursor &cursor, const KUndo2MagicString &transactionText, bool useSavedSmoothing=true)
const QScopedPointer< Private > m_d
KUndo2MagicString kundo2_i18n(const char *text)
KisCanvas2 * canvas

◆ ~KisToolLazyBrush()

KisToolLazyBrush::~KisToolLazyBrush ( )
override

Definition at line 54 of file kis_tool_lazy_brush.cpp.

55{
56}

Member Function Documentation

◆ activate

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

Definition at line 72 of file kis_tool_lazy_brush.cpp.

73{
74 KisCanvas2 * kiscanvas = dynamic_cast<KisCanvas2*>(canvas());
75 KIS_ASSERT(kiscanvas);
76 m_d->toolConnections.addUniqueConnection(
77 kiscanvas->viewManager()->canvasResourceProvider(), SIGNAL(sigNodeChanged(KisNodeSP)),
79
80
81 KisColorizeMask *mask = qobject_cast<KisColorizeMask*>(currentNode().data());
82 if (mask) {
84 }
85
87}
KisViewManager * viewManager() const
void regeneratePrefilteredDeviceIfNeeded()
void activate(const QSet< KoShape * > &shapes) override
void slotCurrentNodeChanged(KisNodeSP node)
KisCanvasResourceProvider * canvasResourceProvider()
#define KIS_ASSERT(cond)
Definition kis_assert.h:33
KisNodeSP currentNode() const
Definition kis_tool.cc:370

References KisToolFreehand::activate(), Private::canvas, KisViewManager::canvasResourceProvider(), KisTool::currentNode(), KIS_ASSERT, m_d, KisColorizeMask::regeneratePrefilteredDeviceIfNeeded(), slotCurrentNodeChanged(), and KisCanvas2::viewManager().

◆ activateAlternateAction()

void KisToolLazyBrush::activateAlternateAction ( KisTool::AlternateAction action)
overridevirtual

Reimplemented from KisToolFreehand.

Definition at line 224 of file kis_tool_lazy_brush.cpp.

225{
226 if (action == KisTool::Secondary && !m_d->activateMaskMode && !m_d->activatedActionLock) {
227 KisNodeSP node = currentNode();
228 if (!node) return;
229
230 m_d->activatedActionLock = true;
231 m_d->oldShowKeyStrokesValue =
234 true).toBool();
235
238 !m_d->oldShowKeyStrokesValue, image());
239
241
242 } else if (action == KisTool::Third && !m_d->activateMaskMode && !m_d->activatedActionLock) {
243 KisNodeSP node = currentNode();
244 if (!node) return;
245
246 m_d->activatedActionLock = true;
247 m_d->oldShowColoringValue =
250 true).toBool();
251
254 !m_d->oldShowColoringValue, image());
255
257
258 } else {
260 }
261}
static QVariant nodeProperty(KisNodeSP node, const KoID &id, const QVariant &defaultValue)
static void setNodePropertyAutoUndo(KisNodeSP node, const KoID &id, const QVariant &value, KisImageSP image)
void activateAlternateAction(AlternateAction action) override
QAction * action(const QString &name) const
virtual void activatePrimaryAction()
Definition kis_tool.cc:421
KisImageWSP image() const
Definition kis_tool.cc:332
@ Secondary
Definition kis_tool.h:141

References KoToolBase::action(), KisToolFreehand::activateAlternateAction(), KisTool::activatePrimaryAction(), KisLayerPropertiesIcons::colorizeEditKeyStrokes, KisLayerPropertiesIcons::colorizeShowColoring, KisTool::currentNode(), KisTool::image(), m_d, KisLayerPropertiesIcons::nodeProperty(), KisTool::Secondary, KisLayerPropertiesIcons::setNodePropertyAutoUndo(), and KisTool::Third.

◆ activatePrimaryAction()

void KisToolLazyBrush::activatePrimaryAction ( )
overridevirtual

Called by KisToolProxy when the primary action of the tool is going to be started now, that is when all the modifiers are pressed and the only thing left is just to press the mouse button. On coming of this callback the tool is supposed to prepare the cursor and/or the outline to show the user shat is going to happen next

Reimplemented from KisTool.

Definition at line 168 of file kis_tool_lazy_brush.cpp.

169{
173 m_d->activateMaskMode = true;
174 setOutlineVisible(false);
175 }
176}
static QCursor handCursor()
bool colorizeMaskActive() const
bool canCreateColorizeMask() const
void setOutlineVisible(bool visible)
void useCursor(const QCursor &cursor)

References KisTool::activatePrimaryAction(), canCreateColorizeMask(), colorizeMaskActive(), KisCursor::handCursor(), m_d, KisToolPaint::setOutlineVisible(), and KoToolBase::useCursor().

◆ beginAlternateAction()

void KisToolLazyBrush::beginAlternateAction ( KoPointerEvent * event,
KisTool::AlternateAction action )
overridevirtual

Reimplemented from KisToolFreehand.

Definition at line 306 of file kis_tool_lazy_brush.cpp.

307{
308 if (!m_d->activateMaskMode && (action == KisTool::Secondary || action == KisTool::Third)) {
309 beginPrimaryAction(event);
310 } else {
312 }
313}
void beginAlternateAction(KoPointerEvent *event, AlternateAction action) override
void beginPrimaryAction(KoPointerEvent *event) override

References KoToolBase::action(), KisToolFreehand::beginAlternateAction(), beginPrimaryAction(), m_d, KisTool::Secondary, and KisTool::Third.

◆ beginPrimaryAction()

void KisToolLazyBrush::beginPrimaryAction ( KoPointerEvent * event)
overridevirtual

Called by KisToolProxy when a primary action for the tool is started. The event stores the original event that started the stroke. The event is accepted by default. If the tool decides to ignore this particular action (e.g. when the node is not editable), it should call event->ignore(). Then no further continuePrimaryAction() or endPrimaryAction() will be called until the next user action.

Reimplemented from KisToolFreehand.

Definition at line 189 of file kis_tool_lazy_brush.cpp.

190{
191 if (m_d->activateMaskMode) {
194 } else if (shouldActivateKeyStrokes()) {
195 // upgrade to strong pointer
196 KisNodeSP manuallyActivatedNode = m_d->manuallyActivatedNode;
197 KisNodeSP node = currentNode();
198
199 KIS_SAFE_ASSERT_RECOVER_NOOP(!manuallyActivatedNode ||
200 manuallyActivatedNode == node);
201
204 true, image());
205 m_d->manuallyActivatedNode = node;
206 }
207 } else {
209 }
210}
void beginPrimaryAction(KoPointerEvent *event) override
bool shouldActivateKeyStrokes() const
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130

References KisToolFreehand::beginPrimaryAction(), canCreateColorizeMask(), KisLayerPropertiesIcons::colorizeEditKeyStrokes, colorizeMaskActive(), KisTool::currentNode(), KisTool::image(), KIS_SAFE_ASSERT_RECOVER_NOOP, m_d, KisLayerPropertiesIcons::setNodePropertyAutoUndo(), shouldActivateKeyStrokes(), and tryCreateColorizeMask().

◆ canCreateColorizeMask()

bool KisToolLazyBrush::canCreateColorizeMask ( ) const
private

Definition at line 130 of file kis_tool_lazy_brush.cpp.

131{
132 KisNodeSP node = currentNode();
133 return node && node->inherits("KisLayer");
134}

References KisTool::currentNode().

◆ colorizeMaskActive()

bool KisToolLazyBrush::colorizeMaskActive ( ) const
private

Definition at line 124 of file kis_tool_lazy_brush.cpp.

125{
126 KisNodeSP node = currentNode();
127 return node && node->inherits("KisColorizeMask");
128}

References KisTool::currentNode().

◆ continueAlternateAction()

void KisToolLazyBrush::continueAlternateAction ( KoPointerEvent * event,
KisTool::AlternateAction action )
overridevirtual

Reimplemented from KisToolFreehand.

Definition at line 315 of file kis_tool_lazy_brush.cpp.

316{
317 if (!m_d->activateMaskMode && (action == KisTool::Secondary || action == KisTool::Third)) {
319 } else {
321 }
322}
void continueAlternateAction(KoPointerEvent *event, AlternateAction action) override
void continuePrimaryAction(KoPointerEvent *event) override

References KoToolBase::action(), KisToolFreehand::continueAlternateAction(), continuePrimaryAction(), m_d, KisTool::Secondary, and KisTool::Third.

◆ continuePrimaryAction()

void KisToolLazyBrush::continuePrimaryAction ( KoPointerEvent * event)
overridevirtual

Called by KisToolProxy when the primary action is in progress of pointer movement. If the tool has ignored the event in beginPrimaryAction(), this method will not be called.

Actual painting

Reimplemented from KisToolFreehand.

Definition at line 212 of file kis_tool_lazy_brush.cpp.

213{
214 if (m_d->activateMaskMode) return;
216}
void continuePrimaryAction(KoPointerEvent *event) override

References KisToolFreehand::continuePrimaryAction(), and m_d.

◆ createOptionWidget()

QWidget * KisToolLazyBrush::createOptionWidget ( )
overridevirtual

Reimplement this if your tool actually has an option widget. Sets the option widget to 0 by default.

Reimplemented from KisTool.

Definition at line 345 of file kis_tool_lazy_brush.cpp.

346{
347 KisCanvas2 * kiscanvas = dynamic_cast<KisCanvas2*>(canvas());
348 KIS_ASSERT(kiscanvas);
349
350 QWidget *optionsWidget = new KisToolLazyBrushOptionsWidget(kiscanvas->viewManager()->canvasResourceProvider(), 0);
351 optionsWidget->setObjectName(toolId() + "option widget");
352
353 // // See https://bugs.kde.org/show_bug.cgi?id=316896
354 // QWidget *specialSpacer = new QWidget(optionsWidget);
355 // specialSpacer->setObjectName("SpecialSpacer");
356 // specialSpacer->setFixedSize(0, 0);
357 // optionsWidget->layout()->addWidget(specialSpacer);
358
359
360 return optionsWidget;
361}
The KisToolLazyBrushOptionsWidget class.
Q_INVOKABLE QString toolId() const

References Private::canvas, KisViewManager::canvasResourceProvider(), KIS_ASSERT, KoToolBase::toolId(), and KisCanvas2::viewManager().

◆ deactivate

void KisToolLazyBrush::deactivate ( )
overrideslot

Definition at line 89 of file kis_tool_lazy_brush.cpp.

90{
93 m_d->toolConnections.clear();
94}
void deactivate() override

References KisToolFreehand::deactivate(), m_d, and tryDisableKeyStrokesOnMask().

◆ deactivateAlternateAction()

void KisToolLazyBrush::deactivateAlternateAction ( KisTool::AlternateAction action)
overridevirtual

Reimplemented from KisToolFreehand.

Definition at line 263 of file kis_tool_lazy_brush.cpp.

264{
265 if (action == KisTool::Secondary && !m_d->activateMaskMode) {
266 KisNodeSP node = currentNode();
267 if (!node) return;
268
269 bool showKeyStrokes =
271
274 m_d->oldShowKeyStrokesValue, image());
275
276 // if the values are same, means the property update hasn't finished. So, we should hold on to the lock
277 if (m_d->oldShowKeyStrokesValue != showKeyStrokes) {
278 m_d->activatedActionLock = false;
279 }
280
282
283 } else if (action == KisTool::Third && !m_d->activateMaskMode) {
284 KisNodeSP node = currentNode();
285 if (!node) return;
286
287 bool colorizeShowColoring =
289
292 m_d->oldShowColoringValue, image());
293
294 // if the values are same, means the property update hasn't finished. So, we should hold on to the lock
295 if (m_d->oldShowColoringValue != colorizeShowColoring) {
296 m_d->activatedActionLock = false;
297 }
298
300
301 } else {
303 }
304}
void deactivateAlternateAction(AlternateAction action) override
virtual void deactivatePrimaryAction()
Definition kis_tool.cc:426

References KoToolBase::action(), KisLayerPropertiesIcons::colorizeEditKeyStrokes, KisLayerPropertiesIcons::colorizeShowColoring, KisTool::currentNode(), KisToolFreehand::deactivateAlternateAction(), KisTool::deactivatePrimaryAction(), KisTool::image(), m_d, KisLayerPropertiesIcons::nodeProperty(), KisTool::Secondary, KisLayerPropertiesIcons::setNodePropertyAutoUndo(), and KisTool::Third.

◆ deactivatePrimaryAction()

void KisToolLazyBrush::deactivatePrimaryAction ( )
overridevirtual

Called by KisToolProxy when the primary is no longer possible to be started now, e.g. when its modifiers and released. The tool is supposed to revert all the preparations it has done in activatePrimaryAction().

Reimplemented from KisTool.

Definition at line 178 of file kis_tool_lazy_brush.cpp.

179{
180 if (m_d->activateMaskMode) {
181 m_d->activateMaskMode = false;
182 setOutlineVisible(true);
184 }
185
187}
void resetCursorStyle() override

References KisTool::deactivatePrimaryAction(), m_d, resetCursorStyle(), and KisToolPaint::setOutlineVisible().

◆ endAlternateAction()

void KisToolLazyBrush::endAlternateAction ( KoPointerEvent * event,
KisTool::AlternateAction action )
overridevirtual

Reimplemented from KisToolFreehand.

Definition at line 324 of file kis_tool_lazy_brush.cpp.

325{
326 if (!m_d->activateMaskMode && (action == KisTool::Secondary || action == KisTool::Third)) {
327 endPrimaryAction(event);
328 } else {
330 }
331}
void endAlternateAction(KoPointerEvent *event, AlternateAction action) override
void endPrimaryAction(KoPointerEvent *event) override

References KoToolBase::action(), KisToolFreehand::endAlternateAction(), endPrimaryAction(), m_d, KisTool::Secondary, and KisTool::Third.

◆ endPrimaryAction()

void KisToolLazyBrush::endPrimaryAction ( KoPointerEvent * event)
overridevirtual

Called by KisToolProxy when the primary action is being finished, that is while mouseRelease or tabletRelease event. If the tool has ignored the event in beginPrimaryAction(), this method will not be called.

Reimplemented from KisToolFreehand.

Definition at line 218 of file kis_tool_lazy_brush.cpp.

219{
220 if (m_d->activateMaskMode) return;
222}
void endPrimaryAction(KoPointerEvent *event) override

References KisToolFreehand::endPrimaryAction(), and m_d.

◆ explicitUserStrokeEndRequest()

void KisToolLazyBrush::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 333 of file kis_tool_lazy_brush.cpp.

334{
335 if (m_d->activateMaskMode) {
337 } else if (colorizeMaskActive()) {
338 KisNodeSP node = currentNode();
339 if (!node) return;
340
342 }
343}

References colorizeMaskActive(), KisLayerPropertiesIcons::colorizeNeedsUpdate, KisTool::currentNode(), KisTool::image(), m_d, KisLayerPropertiesIcons::setNodePropertyAutoUndo(), and tryCreateColorizeMask().

◆ resetCursorStyle

void KisToolLazyBrush::resetCursorStyle ( )
overrideprotectedslot

Definition at line 111 of file kis_tool_lazy_brush.cpp.

112{
113 // If there's no mask yet, we show the hand cursor
116 m_d->activateMaskMode = true;
117 setOutlineVisible(false);
118 }
119 else {
121 }
122}
void resetCursorStyle() override

References canCreateColorizeMask(), colorizeMaskActive(), KisCursor::handCursor(), m_d, KisToolFreehand::resetCursorStyle(), KisToolPaint::setOutlineVisible(), and KoToolBase::useCursor().

◆ shouldActivateKeyStrokes()

bool KisToolLazyBrush::shouldActivateKeyStrokes ( ) const
private

Definition at line 136 of file kis_tool_lazy_brush.cpp.

137{
138 KisNodeSP node = currentNode();
139
140 return node && node->inherits("KisColorizeMask") &&
143 true).toBool();
144}

References KisLayerPropertiesIcons::colorizeEditKeyStrokes, KisTool::currentNode(), and KisLayerPropertiesIcons::nodeProperty().

◆ slotCurrentNodeChanged

void KisToolLazyBrush::slotCurrentNodeChanged ( KisNodeSP node)
privateslot

Definition at line 96 of file kis_tool_lazy_brush.cpp.

97{
98 // upgrade to strong pointer
99 KisNodeSP manuallyActivatedNode = m_d->manuallyActivatedNode;
100
101 if (node != manuallyActivatedNode) {
103
104 KisColorizeMask *mask = qobject_cast<KisColorizeMask*>(node.data());
105 if (mask) {
107 }
108 }
109}

References KisSharedPtr< T >::data(), m_d, KisColorizeMask::regeneratePrefilteredDeviceIfNeeded(), and tryDisableKeyStrokesOnMask().

◆ tryCreateColorizeMask()

void KisToolLazyBrush::tryCreateColorizeMask ( )
private

Definition at line 146 of file kis_tool_lazy_brush.cpp.

147{
148 KisNodeSP node = currentNode();
149 if (!node) return;
150
151 KoProperties properties;
152 properties.setProperty("visible", true);
153 properties.setProperty("locked", false);
154
155 QList<KisNodeSP> masks = node->childNodes(QStringList("KisColorizeMask"), properties);
156
157 if (!masks.isEmpty()) {
158 KisCanvas2 * kiscanvas = static_cast<KisCanvas2*>(canvas());
159 KisViewManager* viewManager = kiscanvas->viewManager();
160 viewManager->nodeManager()->slotNonUiActivatedNode(masks.first());
161 } else {
162 KisCanvas2 * kiscanvas = static_cast<KisCanvas2*>(canvas());
163 KisViewManager* viewManager = kiscanvas->viewManager();
164 viewManager->nodeManager()->createNode("KisColorizeMask");
165 }
166}
QList< QString > QStringList
KisNodeSP createNode(const QString &nodeType, bool quiet=false, KisPaintDeviceSP copyFrom=0)
void slotNonUiActivatedNode(KisNodeSP node)
KisNodeManager * nodeManager() const
The node manager handles everything about nodes.
void setProperty(const QString &name, const QVariant &value)
QList< KisNodeSP > childNodes(const QStringList &nodeTypes, const KoProperties &properties) const
Definition kis_node.cpp:439

References Private::canvas, KisNode::childNodes(), KisNodeManager::createNode(), KisTool::currentNode(), KisViewManager::nodeManager(), KoProperties::setProperty(), KisNodeManager::slotNonUiActivatedNode(), and KisCanvas2::viewManager().

◆ tryDisableKeyStrokesOnMask()

void KisToolLazyBrush::tryDisableKeyStrokesOnMask ( )
private

Definition at line 58 of file kis_tool_lazy_brush.cpp.

59{
60 // upgrade to strong pointer
61 KisNodeSP manuallyActivatedNode = m_d->manuallyActivatedNode;
62
63 if (manuallyActivatedNode) {
65 manuallyActivatedNode = 0;
66 }
67
68 m_d->manuallyActivatedNode = 0;
69}

References KisLayerPropertiesIcons::colorizeEditKeyStrokes, KisTool::image(), m_d, and KisLayerPropertiesIcons::setNodePropertyAutoUndo().

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KisToolLazyBrush::m_d
private

Definition at line 73 of file kis_tool_lazy_brush.h.


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