Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_scratch_pad.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 * Copyright 2010 (C) Boudewijn Rempt <boud@valdyas.org>
3 * Copyright 2011 (C) Dmitry Kazakov <dimula73@gmail.com>
4 *
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7#ifndef KIS_SCRATCH_PAD_H
8#define KIS_SCRATCH_PAD_H
9
10#include <QImage>
11#include <QWidget>
12#include <QRect>
13
14#include <KoColor.h>
15
16
18#include <kis_types.h>
20#include <kritaui_export.h>
21#include <KisDisplayConfig.h>
23
24class QColor;
25
26class KoPointerEvent;
27
30class KisUndoStore;
37
38
44class KRITAUI_EXPORT KisScratchPad : public QWidget
45{
46
47 Q_OBJECT
48
49public:
50 void setupScratchPad(KisCanvasResourceProvider* resourceProvider,
51 const QColor &defaultColor);
52
53 KisScratchPad(QWidget *parent = 0);
54 ~KisScratchPad() override;
55
57 void setCutoutOverlayRect(const QRect&rc);
58
64 void setModeManually(bool value);
65
70 void setModeType(QString modeName);
71
75 bool canvasZoomLink();
76
81 void setCanvasZoomLink(bool value);
82
89 bool setScale(qreal scaleX, qreal scaleY);
90
94 qreal scaleX();
98 qreal scaleY();
99
103 void scaleToFit();
107 void scaleReset();
108
114 void panTo(qint32 x, qint32 y);
115
119 void panCenter();
120
122 QImage cutoutOverlay() const;
123
124 // A callback for our own node graph listener
125 void imageUpdated(const QRect &rect);
126
127 // A callback for scratch pad default bounds
128 QRect imageBounds() const;
129 QRect viewportBounds() const;
130
131 // A callback for scratch pad content bounds
132 QRect contentBounds() const;
133
134
135 // Called by the event filter
136 void wheelDelta(QWheelEvent *event);
137 void pointerPress(KoPointerEvent *event);
138 void pointerRelease(KoPointerEvent *event);
139 void pointerMove(KoPointerEvent *event);
140 void resetState();
141
142public Q_SLOTS:
143 void fillDefault();
144 void fillPattern(QTransform transform);
145 void fillGradient(const QPoint &gradientVectorStart,
146 const QPoint &gradientVectorEnd,
149 bool reverseGradient,
150 bool dither);
151 void fillGradient();
152 void fillBackground();
153 void fillForeground();
154 void fillTransparent();
155
156 void setFillColor(QColor newColor);
157
159 void fillLayer(bool fullContent);
160 void fillDocument();
161 void fillDocument(bool fullContent);
162
166 void setPresetImage(const QImage& image);
167
174 void paintPresetImage();
175
180 void paintCustomImage(const QImage & loadedImage);
181
182
183 void loadScratchpadImage(QImage image);
184
185 QImage copyScratchpadImageData();
186
187Q_SIGNALS:
192 void scaleChanged(qreal scale);
193
198
203 void viewportChanged(const QRect rect);
204
205private Q_SLOTS:
206 void slotScreenChanged(QScreen *screen);
207 void setOnScreenResolution(qreal scaleX, qreal scaleY);
208 void slotUpdateCanvas(const QRect &rect);
209 void slotConfigChanged();
210
211Q_SIGNALS:
212 void colorSelected(const KoColor& color);
213 void sigUpdateCanvas(const QRect &rect);
214
215protected:
216 void paintEvent ( QPaintEvent * event ) override;
217 void resizeEvent( QResizeEvent *event) override;
218
219private:
220 void beginStroke(KoPointerEvent *event);
221 void doStroke(KoPointerEvent *event);
222 void endStroke(KoPointerEvent *event);
223
224 void beginPan(KoPointerEvent *event);
225 void doPan(KoPointerEvent *event);
226 void endPan(KoPointerEvent *event);
227
228 void sample(KoPointerEvent *event);
229
230 void updateTransformations();
231
232 bool setScaleImpl(qreal scaleX, qreal scaleY);
233
234 void updateViewport();
235 bool updateViewportImpl();
236
237 void assignNewSurfaceState(const KisMultiSurfaceStateManager::State &newState);
238
239 QTransform documentToWidget() const;
240 QTransform widgetToDocument() const;
241
243
244private:
246
247 void resetWheelDelta();
248
249private:
256
257 Mode modeFromButton(Qt::MouseButton button) const;
258
259private:
260
266
267 // canvasScaleX & canvasScaleY: keep in memory current canvas zoom level
270
271 // scratchpadScaleX & scratchpadScaleY: keep in memory current scratchpad zoom level
274
275 // store accumulated mouse delta from mouseWheel
277
278 // keep viewport in memory
280
284 QCursor m_cursor;
289
295
296 QScopedPointer<KisToolFreehandHelper> m_helper;
298
301
304
306 QScopedPointer<KisScreenMigrationTracker> m_screenMigrationTracker;
309};
310
311#endif // KIS_SCRATCH_PAD_H
float value(const T *src, size_t ch)
KisDisplayConfig This class keeps track of the color management configuration for image to display....
KisScratchPadEventFilter * m_eventFilter
void sigUpdateCanvas(const QRect &rect)
KisCanvasResourceProvider * m_resourceProvider
KisUndoStore * m_undoStore
KisPaintingInformationBuilder * m_infoBuilder
KisUpdateScheduler * m_updateScheduler
QCursor m_colorSamplerCursor
QTransform m_scaleTransform
KisNodeGraphListener * m_nodeListener
void viewportChanged(const QRect rect)
signal is emitted when scratchpad viewport has been modified (pan, zoom)
KisDisplayConfig m_displayConfig
void colorSelected(const KoColor &color)
KisPaintLayerSP m_paintLayer
const KoColorProfile * m_displayProfile
KisPostExecutionUndoAdapter * m_undoAdapter
QScopedPointer< KisToolFreehandHelper > m_helper
void scaleChanged(qreal scale)
signal is emitted when scratchpad scale is changed (from zoom canvas or manually)
QTransform m_translateTransform
void contentChanged()
signal is emitted when scratchpad content is changed (stroke or fill)
KisMultiSurfaceStateManager m_multiSurfaceStateManager
friend KisScratchPadEventFilter
QScopedPointer< KisScreenMigrationTracker > m_screenMigrationTracker
KisMultiSurfaceStateManager::State m_multiSurfaceState
QString button(const QWheelEvent &ev)