Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_canvas_controller.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2010 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef KIS_CANVAS_CONTROLLER_H
8#define KIS_CANVAS_CONTROLLER_H
9
12
13#include "kritaui_export.h"
14#include "kis_types.h"
15#include "KisWraparoundAxis.h"
16
17class KisCanvasState;
18class KConfigGroup;
19class KisView;
20class KisCanvasState;
21
22
23class KRITAUI_EXPORT KisCanvasController : public KoCanvasControllerWidget
24{
25 Q_OBJECT
26
27public:
28 KisCanvasController(QPointer<KisView>parent, KoCanvasSupervisor *observerProvider, KisKActionCollection * actionCollection);
29 ~KisCanvasController() override;
30
31 void ensureVisibleDoc(const QRectF &docRect, bool smooth) override;
32 void setCanvas(KoCanvasBase *canvas) override;
33 void keyPressEvent(QKeyEvent *event) override;
34 void wheelEvent(QWheelEvent *event) override;
35 bool eventFilter(QObject *watched, QEvent *event) override;
36 void activate() override;
37
38 QPointF currentCursorPosition() const override;
39
40 KisCanvasState canvasState() const override;
41 KoZoomState zoomState() const override;
42
43 QPointF preferredCenter() const override;
44 void setPreferredCenter(const QPointF &viewPoint) override;
45
46 void zoomIn() override;
47 void zoomIn(const KoViewTransformStillPoint &widgetStillPoint) override;
48 void zoomOut() override;
49 void zoomOut(const KoViewTransformStillPoint &widgetStillPoint) override;
50
51 void syncOnReferencesChange(const QRectF &referencesRect);
52 void syncOnImageResolutionChange();
53 void syncOnImageSizeChange(const QPointF &oldStillPoint, const QPointF &newStillPoint);
54
55 void rotateCanvas(qreal angle, const std::optional<KoViewTransformStillPoint> &stillPoint, bool isNativeGesture = false);
56
57public:
58 bool wrapAroundMode() const;
59 WrapAroundAxis wrapAroundModeAxis() const;
60 bool levelOfDetailMode() const;
61
62 void saveCanvasState(KisPropertiesConfiguration &config) const;
63 void restoreCanvasState(const KisPropertiesConfiguration &config);
64
65 void resetScrollBars() override;
66
67 void updateScreenResolution(QWidget *parentWidget);
68 bool usePrintResolutionMode();
69
70 qreal effectiveCanvasResolutionX() const;
71 qreal effectiveCanvasResolutionY() const;
72
73public Q_SLOTS:
74 void setUsePrintResolutionMode(bool value);
75
76 void mirrorCanvas(bool enable);
77 void mirrorCanvasAroundCursor(bool enable);
78 void mirrorCanvasAroundCanvas(bool enable);
79
80 void beginCanvasRotation();
81 void endCanvasRotation();
82 void rotateCanvas(qreal angle);
83 void rotateCanvasRight15();
84 void rotateCanvasLeft15();
85 qreal rotation() const;
86 void resetCanvasRotation();
87
88 void slotToggleWrapAroundMode(bool value);
89 void slotSetWrapAroundModeAxis(WrapAroundAxis axis);
90 void slotSetWrapAroundModeAxisHV();
91 void slotSetWrapAroundModeAxisH();
92 void slotSetWrapAroundModeAxisV();
93 void slotTogglePixelGrid(bool value);
94 void slotToggleLevelOfDetailMode(bool value);
95
96protected:
97 void updateCanvasOffsetInternal(const QPointF &newOffset) override;
98 void updateCanvasWidgetSizeInternal(const QSize &newSize) override;
99 void updateCanvasZoomInternal(KoZoomMode::Mode mode, qreal zoom, qreal resolutionX, qreal resolutionY, const std::optional<KoViewTransformStillPoint> &docStillPoint) override;
100 void zoomToInternal(const QRect &viewRect) override;
101
102private:
103 void zoomInImpl(const std::optional<KoViewTransformStillPoint> &stillPoint);
104 void zoomOutImpl(const std::optional<KoViewTransformStillPoint> &stillPoint);
105 void mirrorCanvasImpl(const std::optional<KoViewTransformStillPoint> &stillPoint, bool enable);
106
107Q_SIGNALS:
109
110Q_SIGNALS:
112
113
114private:
115 struct Private;
116 Private * const m_d;
117};
118
119#endif /* KIS_CANVAS_CONTROLLER_H */
float value(const T *src, size_t ch)
WrapAroundAxis
void sigUsePrintResolutionModeChanged(bool value)
A container for a set of QAction objects.
virtual void updateCanvasOffsetInternal(const QPointF &newOffset)=0
virtual void activate()
Reimplemented from KoCanvasController.
virtual void zoomToInternal(const QRect &viewRect)=0
void setCanvas(KoCanvasBase *canvas) override
virtual void updateCanvasWidgetSizeInternal(const QSize &newSize)=0
virtual void updateCanvasZoomInternal(KoZoomMode::Mode mode, qreal zoom, qreal resolutionX, qreal resolutionY, const std::optional< KoViewTransformStillPoint > &docStillPoint)=0
virtual KisCanvasState canvasState() const =0
virtual QPointF preferredCenter() const =0
Returns the currently set preferred center point in view coordinates (pixels)
virtual void zoomIn()=0
virtual void ensureVisibleDoc(const QRectF &docRect, bool smooth)=0
Scrolls the content of the canvas so that the given rect is visible.
virtual void setPreferredCenter(const QPointF &viewPoint)=0
virtual void resetScrollBars()=0
virtual KoZoomState zoomState() const =0
virtual void zoomOut()=0
virtual QPointF currentCursorPosition() const =0