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

#include <KoToolProxy_p.h>

Public Member Functions

void checkAutoScroll (const KoPointerEvent &event)
 
bool isActiveLayerEditable ()
 
 KoToolProxyPrivate (KoToolProxy *p)
 
void selectionChanged (bool newSelection)
 
void setCanvasController (KoCanvasController *controller)
 the toolManager tells us which KoCanvasController this toolProxy is working for.
 
void timeout ()
 

Public Attributes

KoToolBaseactiveTool {0}
 
KoCanvasControllercontroller {0}
 
bool hasSelection {false}
 
bool isToolPressed {false}
 
boost::optional< KoPointerEventWrapperlastPointerEvent
 
QPoint mouseDownPoint
 
bool mouseLeaveWorkaround {false}
 
int multiClickCount {0}
 
QPointF multiClickGlobalPoint
 
QEvent::Type multiClickSource
 
QElapsedTimer multiClickTimeStamp
 
KoToolProxyparent {0}
 
QTimer scrollTimer
 
QVector< QKeySequence > toolPriorityShortcuts
 
QPointF widgetScrollPointDoc
 

Detailed Description

Definition at line 22 of file KoToolProxy_p.h.

Constructor & Destructor Documentation

◆ KoToolProxyPrivate()

KoToolProxyPrivate::KoToolProxyPrivate ( KoToolProxy * p)
explicit

Definition at line 41 of file KoToolProxy.cpp.

42 : parent(p)
43{
44 scrollTimer.setInterval(100);
45}
const Params2D p
KoToolProxy * parent

References scrollTimer.

Member Function Documentation

◆ checkAutoScroll()

void KoToolProxyPrivate::checkAutoScroll ( const KoPointerEvent & event)

Definition at line 65 of file KoToolProxy.cpp.

66{
67 if (controller == 0) return;
68 if (!activeTool) return;
69 if (!activeTool->wantsAutoScroll()) return;
70 if (!event.isAccepted()) return;
71 if (!isToolPressed) return;
72 if (event.buttons() != Qt::LeftButton) return;
73
74
75 widgetScrollPointDoc = event.point;
76
77 if (! scrollTimer.isActive())
78 scrollTimer.start();
79}
Qt::MouseButtons buttons() const
return buttons pressed (see QMouseEvent::buttons());
bool isAccepted() const
return if the event has been accepted.
virtual bool wantsAutoScroll() const
KoToolBase * activeTool
KoCanvasController * controller
QPointF widgetScrollPointDoc

References activeTool, KoPointerEvent::buttons(), controller, KoPointerEvent::isAccepted(), isToolPressed, scrollTimer, KoToolBase::wantsAutoScroll(), and widgetScrollPointDoc.

◆ isActiveLayerEditable()

bool KoToolProxyPrivate::isActiveLayerEditable ( )

Definition at line 89 of file KoToolProxy.cpp.

90{
91 if (!activeTool)
92 return false;
93
94 KoShapeManager * shapeManager = activeTool->canvas()->shapeManager();
95 KoShapeLayer * activeLayer = shapeManager->selection()->activeLayer();
96 if (activeLayer && !activeLayer->isShapeEditable())
97 return false;
98 return true;
99}
virtual KoShapeManager * shapeManager() const =0
KoShapeLayer * activeLayer() const
KoSelection * selection
virtual bool isShapeEditable(bool recursive=true) const
checks recursively if the shape or one of its parents is not visible or locked
Definition KoShape.cpp:1165
KoCanvasBase * canvas() const
Returns the canvas the tool is working on.

References KoSelection::activeLayer(), activeTool, KoToolBase::canvas(), KoShape::isShapeEditable(), KoShapeManager::selection, and KoCanvasBase::shapeManager().

◆ selectionChanged()

void KoToolProxyPrivate::selectionChanged ( bool newSelection)

Definition at line 81 of file KoToolProxy.cpp.

82{
83 if (hasSelection == newSelection)
84 return;
85 hasSelection = newSelection;
87}
void selectionChanged(bool hasSelection)

References hasSelection, parent, and KoToolProxy::selectionChanged().

◆ setCanvasController()

void KoToolProxyPrivate::setCanvasController ( KoCanvasController * controller)

the toolManager tells us which KoCanvasController this toolProxy is working for.

Definition at line 431 of file KoToolProxy.cpp.

432{
433 controller = c;
434}

References controller.

◆ timeout()

void KoToolProxyPrivate::timeout ( )

Definition at line 47 of file KoToolProxy.cpp.

48{
49 Q_ASSERT(controller);
50
51 const QPoint originalWidgetPoint = parent->documentToWidget(widgetScrollPointDoc).toPoint();
52
53 QRectF mouseArea(widgetScrollPointDoc, QSizeF(10, 10));
54 mouseArea.setTopLeft(mouseArea.center());
55
56 controller->ensureVisibleDoc(mouseArea, true);
57
58 widgetScrollPointDoc = parent->widgetToDocument(originalWidgetPoint);
59
60 QMouseEvent event(QEvent::MouseMove, originalWidgetPoint, Qt::LeftButton, Qt::LeftButton, QFlags<Qt::KeyboardModifier>());
63}
virtual void ensureVisibleDoc(const QRectF &docRect, bool smooth)=0
Scrolls the content of the canvas so that the given rect is visible.
virtual void mouseMoveEvent(KoPointerEvent *event)=0
virtual QPointF widgetToDocument(const QPointF &widgetPoint) const =0
virtual QPointF documentToWidget(const QPointF &documentPoint) const =0

References activeTool, controller, KoToolProxy::documentToWidget(), KoCanvasController::ensureVisibleDoc(), KoToolBase::mouseMoveEvent(), parent, widgetScrollPointDoc, and KoToolProxy::widgetToDocument().

Member Data Documentation

◆ activeTool

KoToolBase* KoToolProxyPrivate::activeTool {0}

Definition at line 38 of file KoToolProxy_p.h.

38{0};

◆ controller

KoCanvasController* KoToolProxyPrivate::controller {0}

Definition at line 42 of file KoToolProxy_p.h.

42{0};

◆ hasSelection

bool KoToolProxyPrivate::hasSelection {false}

Definition at line 39 of file KoToolProxy_p.h.

39{false};

◆ isToolPressed

bool KoToolProxyPrivate::isToolPressed {false}

Definition at line 51 of file KoToolProxy_p.h.

51{false};

◆ lastPointerEvent

boost::optional<KoPointerEventWrapper> KoToolProxyPrivate::lastPointerEvent

Definition at line 61 of file KoToolProxy_p.h.

◆ mouseDownPoint

QPoint KoToolProxyPrivate::mouseDownPoint

Definition at line 46 of file KoToolProxy_p.h.

◆ mouseLeaveWorkaround

bool KoToolProxyPrivate::mouseLeaveWorkaround {false}

Definition at line 49 of file KoToolProxy_p.h.

49{false};

◆ multiClickCount

int KoToolProxyPrivate::multiClickCount {0}

Definition at line 54 of file KoToolProxy_p.h.

54{0};

◆ multiClickGlobalPoint

QPointF KoToolProxyPrivate::multiClickGlobalPoint

Definition at line 55 of file KoToolProxy_p.h.

◆ multiClickSource

QEvent::Type KoToolProxyPrivate::multiClickSource

Definition at line 57 of file KoToolProxy_p.h.

◆ multiClickTimeStamp

QElapsedTimer KoToolProxyPrivate::multiClickTimeStamp

Definition at line 56 of file KoToolProxy_p.h.

◆ parent

KoToolProxy* KoToolProxyPrivate::parent {0}

Definition at line 43 of file KoToolProxy_p.h.

43{0};

◆ scrollTimer

QTimer KoToolProxyPrivate::scrollTimer

Definition at line 40 of file KoToolProxy_p.h.

◆ toolPriorityShortcuts

QVector<QKeySequence> KoToolProxyPrivate::toolPriorityShortcuts

Definition at line 59 of file KoToolProxy_p.h.

◆ widgetScrollPointDoc

QPointF KoToolProxyPrivate::widgetScrollPointDoc

Definition at line 41 of file KoToolProxy_p.h.


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