Krita Source Code Documentation
Loading...
Searching...
No Matches
KoCanvasController Class Referenceabstract

#include <KoCanvasController.h>

+ Inheritance diagram for KoCanvasController:

Public Member Functions

KisKActionCollectionactionCollection () const
 
virtual KoCanvasBasecanvas () const
 
virtual QPointF currentCursorPosition () const =0
 
virtual void ensureVisibleDoc (const QRectF &docRect, bool smooth)=0
 Scrolls the content of the canvas so that the given rect is visible.
 
 KoCanvasController (KisKActionCollection *actionCollection)
 
virtual void pan (const QPoint &distance)=0
 
virtual void panDown ()=0
 
virtual void panLeft ()=0
 
virtual void panRight ()=0
 
virtual void panUp ()=0
 
virtual QPointF preferredCenter () const =0
 Returns the currently set preferred center point in view coordinates (pixels)
 
 Private ()
 
virtual void resetScrollBars ()=0
 
virtual QPoint scrollBarValue () const =0
 
virtual void setCanvas (KoCanvasBase *canvas)=0
 
virtual void setPreferredCenter (const QPointF &viewPoint)=0
 
virtual void setScrollBarValue (const QPoint &value)=0
 
virtual void setZoom (KoZoomMode::Mode mode, qreal zoom)=0
 
virtual void zoomIn ()=0
 
virtual void zoomIn (const KoViewTransformStillPoint &stillPoint)=0
 zooms in keeping stillPoint not moved.
 
virtual void zoomOut ()=0
 
virtual void zoomOut (const KoViewTransformStillPoint &stillPoint)=0
 zooms out keeping stillPoint not moved.
 
virtual KoZoomState zoomState () const =0
 
virtual void zoomTo (const QRect &rect)=0
 zoom so that rect is exactly visible (as close as possible)
 
virtual ~KoCanvasController ()
 

Public Attributes

KisKActionCollectionactionCollection
 
QPoint documentOffset
 
QSizeF documentSize
 
qreal preferredCenterFractionX
 
qreal preferredCenterFractionY
 
QPointer< KoCanvasControllerProxyObjectproxyObject
 

Protected Member Functions

void setDocumentOffset (const QPoint &offset)
 

Private Attributes

Private *const d
 
- Private Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Additional Inherited Members

- Private Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Detailed Description

KoCanvasController is the base class for wrappers around your canvas that provides scrolling and zooming for your canvas.

Flake does not provide a canvas, the application will have to implement a canvas themselves. You canvas can be QWidget-based or something we haven't invented yet – as long the class that holds the canvas implements KoCanvasController, tools, scrolling and zooming will work.

A KoCanvasController implementation acts as a decorator around the canvas widget and provides a way to scroll the canvas, allows the canvas to be centered in the viewArea and manages tool activation.

The using application can instantiate this class and add its canvas using the setCanvas() call. Which is designed so it can be called multiple times if you need to exchange one canvas widget for another, for instance, switching between a plain QWidget or a QOpenGLWidget.

There is one KoCanvasController per canvas in your application.

The canvas widget is at most as big as the viewport of the scroll area, and when the view on the document is near its edges, smaller. In your canvas widget code, you can find the right place in your document in view coordinates (pixels) by adding the documentOffset

Definition at line 14 of file KoCanvasController.cpp.

Constructor & Destructor Documentation

◆ KoCanvasController()

KoCanvasController::KoCanvasController ( KisKActionCollection * actionCollection)
explicit

Constructor.

Parameters
actionCollectionthe action collection for this canvas

Definition at line 31 of file KoCanvasController.cpp.

32 : d(new Private())
33{
35 d->actionCollection = actionCollection;
36}
QPointer< KoCanvasControllerProxyObject > proxyObject
KisKActionCollection * actionCollection

References actionCollection, d, and proxyObject.

◆ ~KoCanvasController()

KoCanvasController::~KoCanvasController ( )
virtual

Definition at line 38 of file KoCanvasController.cpp.

39{
41 delete d;
42 delete proxyObject;
43}
void removeCanvasController(KoCanvasController *controller)
static KoToolManager * instance()
Return the toolmanager singleton.

References d, KoToolManager::instance(), proxyObject, and KoToolManager::removeCanvasController().

Member Function Documentation

◆ actionCollection()

KisKActionCollection * KoCanvasController::actionCollection ( ) const

Returns the action collection for the window

Returns
action collection for this window, can be 0

◆ canvas()

KoCanvasBase * KoCanvasController::canvas ( ) const
virtual

Return the currently set canvas. The default implementation will return Null

Returns
the currently set canvas

Reimplemented in KoCanvasControllerWidget.

Definition at line 45 of file KoCanvasController.cpp.

46{
47 return 0;
48}

◆ currentCursorPosition()

virtual QPointF KoCanvasController::currentCursorPosition ( ) const
pure virtual
Returns
the current position of the cursor fetched from QCursor::pos() and converted into document coordinates

Implemented in KisCanvasController.

◆ ensureVisibleDoc()

virtual void KoCanvasController::ensureVisibleDoc ( const QRectF & docRect,
bool smooth )
pure virtual

Scrolls the content of the canvas so that the given rect is visible.

The rect is to be specified in document coordinates (points). The scrollbar positions are changed so that the centerpoint of the rectangle is centered if possible.

Parameters
rectthe rectangle to make visible
smoothif true the viewport translation will make be just enough to ensure visibility, no more.

Implemented in KisCanvasController.

◆ pan()

virtual void KoCanvasController::pan ( const QPoint & distance)
pure virtual

Move the canvas over the x and y distance of the parameter distance

Parameters
distancethe distance in view coordinates (pixels). A positive distance means moving the canvas up/left.

Implemented in KoCanvasControllerWidget.

◆ panDown()

virtual void KoCanvasController::panDown ( )
pure virtual

Move the canvas down. This behaves the same as

See also
pan() with a negative y coordinate.

Implemented in KoCanvasControllerWidget.

◆ panLeft()

virtual void KoCanvasController::panLeft ( )
pure virtual

Move the canvas to the left. This behaves the same as

See also
pan() with a positive x coordinate.

Implemented in KoCanvasControllerWidget.

◆ panRight()

virtual void KoCanvasController::panRight ( )
pure virtual

Move the canvas to the right. This behaves the same as

See also
pan() with a negative x coordinate.

Implemented in KoCanvasControllerWidget.

◆ panUp()

virtual void KoCanvasController::panUp ( )
pure virtual

Move the canvas up. This behaves the same as

See also
pan() with a positive y coordinate.

Implemented in KoCanvasControllerWidget.

◆ preferredCenter()

virtual QPointF KoCanvasController::preferredCenter ( ) const
pure virtual

Returns the currently set preferred center point in view coordinates (pixels)

Implemented in KisCanvasController.

◆ Private()

KoCanvasController::Private ( )
inline

Definition at line 17 of file KoCanvasController.cpp.

◆ resetScrollBars()

virtual void KoCanvasController::resetScrollBars ( )
pure virtual

Update the range of scroll bars

Implemented in KisCanvasController.

◆ scrollBarValue()

virtual QPoint KoCanvasController::scrollBarValue ( ) const
pure virtual

Get the position of the scrollbar

Implemented in KoCanvasControllerWidget.

◆ setCanvas()

virtual void KoCanvasController::setCanvas ( KoCanvasBase * canvas)
pure virtual

Set the new canvas to be shown as a child Calling this will Q_EMIT canvasRemoved() if there was a canvas before, and will emit canvasSet() with the new canvas.

Parameters
canvasthe new canvas. The KoCanvasBase::canvas() will be called to retrieve the actual widget which will then be added as child of this one.

Implemented in KisCanvasController, and KoCanvasControllerWidget.

◆ setDocumentOffset()

void KoCanvasController::setDocumentOffset ( const QPoint & offset)
protected

◆ setPreferredCenter()

virtual void KoCanvasController::setPreferredCenter ( const QPointF & viewPoint)
pure virtual

Sets the preferred center point in view coordinates (pixels).

Parameters
viewPointthe new preferred center

Implemented in KisCanvasController.

◆ setScrollBarValue()

virtual void KoCanvasController::setScrollBarValue ( const QPoint & value)
pure virtual

Set the position of the scrollbar

Parameters
valuethe new values of the scroll bars

Implemented in KoCanvasControllerWidget.

◆ setZoom()

virtual void KoCanvasController::setZoom ( KoZoomMode::Mode mode,
qreal zoom )
pure virtual

Implemented in KoCanvasControllerWidget.

◆ zoomIn() [1/2]

virtual void KoCanvasController::zoomIn ( )
pure virtual

Implemented in KisCanvasController.

◆ zoomIn() [2/2]

virtual void KoCanvasController::zoomIn ( const KoViewTransformStillPoint & stillPoint)
pure virtual

zooms in keeping stillPoint not moved.

Implemented in KisCanvasController.

◆ zoomOut() [1/2]

virtual void KoCanvasController::zoomOut ( )
pure virtual

Implemented in KisCanvasController.

◆ zoomOut() [2/2]

virtual void KoCanvasController::zoomOut ( const KoViewTransformStillPoint & stillPoint)
pure virtual

zooms out keeping stillPoint not moved.

Implemented in KisCanvasController.

◆ zoomState()

virtual KoZoomState KoCanvasController::zoomState ( ) const
pure virtual

Implemented in KisCanvasController.

◆ zoomTo()

virtual void KoCanvasController::zoomTo ( const QRect & rect)
pure virtual

zoom so that rect is exactly visible (as close as possible)

The rect must be specified in widget coordinates. The scrollbar positions are changed so that the center of the rect becomes center if possible.

Parameters
rectthe rect in widget coordinates that should fit the view afterwards

Implemented in KoCanvasControllerWidget.

Member Data Documentation

◆ actionCollection

KisKActionCollection * KoCanvasController::actionCollection

Definition at line 28 of file KoCanvasController.cpp.

◆ d

Private* const KoCanvasController::d
private

Definition at line 197 of file KoCanvasController.h.

◆ documentOffset

QPoint KoCanvasController::documentOffset

Definition at line 25 of file KoCanvasController.cpp.

◆ documentSize

QSizeF KoCanvasController::documentSize

Definition at line 24 of file KoCanvasController.cpp.

◆ preferredCenterFractionX

qreal KoCanvasController::preferredCenterFractionX

Definition at line 26 of file KoCanvasController.cpp.

◆ preferredCenterFractionY

qreal KoCanvasController::preferredCenterFractionY

Definition at line 27 of file KoCanvasController.cpp.

◆ proxyObject

QPointer<KoCanvasControllerProxyObject> KoCanvasController::proxyObject

Definition at line 65 of file KoCanvasController.h.


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