Krita

View.h
1/*
2 * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6#ifndef LIBKIS_VIEW_H
7#define LIBKIS_VIEW_H
8
9#include <QObject>
10
11#include "kritalibkis_export.h"
12#include "libkis.h"
13
14class ManagedColor;
15class Resource;
16class Scratchpad;
17class Node;
18class KisView;
19
20/**
21 * View represents one view on a document. A document can be
22 * shown in more than one view at a time.
23 */
24class KRITALIBKIS_EXPORT View : public QObject
25{
26 Q_OBJECT
27 Q_DISABLE_COPY(View)
28
29public:
30 explicit View(KisView *view, QObject *parent = 0);
31 ~View() override;
32
33 bool operator==(const View &other) const;
34 bool operator!=(const View &other) const;
35
36public Q_SLOTS:
37
38 /**
39 * @return the window this view is shown in.
40 */
41 Window* window() const;
42
43 /**
44 * @return the document this view is showing.
45 */
46 Document* document() const;
47
48 /**
49 * Reset the view to show @p document.
50 */
51 void setDocument(Document *document);
52
53 /**
54 * @return True if the current view is visible, False if not.
55 */
56 bool visible() const;
57
58 /**
59 * Make the current view visible.
60 */
61 void setVisible();
62
63 /**
64 * @return the canvas this view is showing. The canvas controls
65 * things like zoom and rotation.
66 */
67 Canvas* canvas() const;
68
69 /**
70 * @brief activateResource activates the given resource.
71 * @param resource: a pattern, gradient or paintop preset
72 */
73 void activateResource(Resource *resource);
74
75
76
77 /**
78 * @brief foregroundColor allows access to the currently active foreground color.
79 * This is nominally per canvas/view, but in practice per mainwindow.
80 *
81 * @code
82color = Application.activeWindow().activeView().foregroundColor()
83components = color.components()
84components[0] = 1.0
85components[1] = 0.6
86components[2] = 0.7
87color.setComponents(components)
88Application.activeWindow().activeView().setForeGroundColor(color)
89 * @endcode
90 *
91 * @return The current foreground color
92 */
93 ManagedColor *foregroundColor() const;
94 void setForeGroundColor(ManagedColor *color);
95
96 /**
97 * @brief backgroundColor allows access to the currently active background color.
98 * This is nominally per canvas/view, but in practice per mainwindow.
99 *
100 * @return The current background color
101 */
102 ManagedColor *backgroundColor() const;
103 void setBackGroundColor(ManagedColor *color);
104
105 /**
106 * @brief return the current selected preset
107 *
108 * @return the current preset (Resource type = 'preset')
109 */
110 Resource *currentBrushPreset() const;
111
112 /**
113 * @brief set the current selected preset
114 *
115 * @param resource the current preset to set (Resource type = 'preset')
116 */
117 void setCurrentBrushPreset(Resource *resource);
118
119 /**
120 * @brief return the current selected pattern
121 *
122 * @return the current pattern (Resource type = 'pattern')
123 */
124 Resource *currentPattern() const;
125
126 /**
127 * @brief set the current selected pattern
128 *
129 * @param resource the current pattern to set (Resource type = 'pattern')
130 */
131 void setCurrentPattern(Resource *resource);
132
133 /**
134 * @brief return the current selected gradient
135 *
136 * @return the current gradient (Resource type = 'gradient')
137 */
138 Resource *currentGradient() const;
139
140 /**
141 * @brief set the current selected gradient
142 *
143 * @param resource the current gradient to set (Resource type = 'gradient')
144 */
145 void setCurrentGradient(Resource *resource);
146
147 /**
148 * @brief return the current blending mode for brush
149 *
150 * @return the current blending mode identifier
151 */
152 QString currentBlendingMode() const;
153
154 /**
155 * @brief set the current blending mode for brush
156 *
157 * @param blendingMode the current belding mode identifier
158 */
159 void setCurrentBlendingMode(const QString &blendingMode);
160
161 /**
162 * @return the current HDR Exposure value
163 */
164 float HDRExposure() const;
165
166 /**
167 * @brief set the current HDR Exposure value
168 *
169 * @param exposure the HDR Exposure to set
170 */
171 void setHDRExposure(float exposure);
172
173 /**
174 * @return the current HDR Gamma value
175 */
176 float HDRGamma() const;
177
178 /**
179 * @brief set the current HDR Gamma value
180 *
181 * @param exposure the HDR Gamma to set
182 */
183 void setHDRGamma(float gamma);
184
185 /**
186 * @brief return the current opacity for brush
187 *
188 * @return the brush opacity value (0.00=fully transparent - 1.00=fully opaque)
189 */
190 qreal paintingOpacity() const;
191
192 /**
193 * @brief set the current opacity for brush
194 *
195 * @param opacity the opacity value (0.00=fully transparent - 1.00=fully opaque)
196 */
197 void setPaintingOpacity(qreal opacity);
198
199 /**
200 * @brief return the current size for brush
201 *
202 * @return the brush size value (in pixels)
203 */
204 qreal brushSize() const;
205
206 /**
207 * @brief set the current size for brush
208 *
209 * @param brushSize the brush size (in pixels)
210 */
211 void setBrushSize(qreal brushSize);
212
213 /**
214 * @brief return the current rotation for brush tip
215 *
216 * @return the brush tip rotation value (in degrees)
217 */
218 qreal brushRotation() const;
219
220 /**
221 * @brief set the current rotation for brush tip
222 *
223 * @param brushRotation the brush tip rotation (in degrees)
224 */
225 void setBrushRotation(qreal brushRotation);
226
227 /**
228 * @brief return the current flow for brush
229 *
230 * @return the brush flow value
231 */
232 qreal paintingFlow() const;
233
234 /**
235 * @brief set the current flow value for brush
236 *
237 * @param flow the brush flow
238 */
239 void setPaintingFlow(qreal flow);
240
241 /**
242 * @brief return the current pattern size for brush
243 *
244 * @return the brush pattern size value
245 */
246 qreal patternSize() const;
247
248 /**
249 * @brief set the current pattern size value for brush
250 *
251 * @param flow the brush pattern size
252 */
253 void setPatternSize(qreal size);
254
255 /**
256 * @brief return current eraser mode status (active/inactive)
257 *
258 * @return True if eraser mode is active, otherwise False
259 */
260 bool eraserMode() const;
261
262 /**
263 * @brief set current eraser active/inactive
264 *
265 * @param value Set to True to activate eraser mode, False to deactivate
266 */
267 void setEraserMode(bool value);
268
269 /**
270 * @brief return current global alpha lock mode (active/inactive)
271 *
272 * @return True if is active, otherwise False
273 */
274 bool globalAlphaLock() const;
275
276 /**
277 * @brief set current global alpha lock mode active/inactive
278 *
279 * @param value Set to True to lock global alpha mode, False to unlock
280 */
281 void setGlobalAlphaLock(bool value);
282
283 /**
284 * @brief return current disabled pressure status
285 *
286 * @return True if is pressure is disabled, otherwise False
287 */
288 bool disablePressure() const;
289
290 /**
291 * @brief set current disabled pressure status
292 *
293 * @param value Set to True to disable pressure, False to enabled pressure
294 */
295 void setDisablePressure(bool value);
296
297 /**
298 * @brief showFloatingMessage displays a floating message box on the top-left corner of the canvas
299 * @param message: Message to be displayed inside the floating message box
300 * @param icon: Icon to be displayed inside the message box next to the message string
301 * @param timeout: Milliseconds until the message box disappears
302 * @param priority: 0 = High, 1 = Medium, 2 = Low. Higher priority
303 * messages will be displayed in place of lower priority messages
304 */
305 void showFloatingMessage(const QString &message, const QIcon& icon, int timeout, int priority);
306
307 /**
308 * @brief selectedNodes returns a list of Nodes that are selected in this view.
309 *
310 *
311@code
312from krita import *
313w = Krita.instance().activeWindow()
314v = w.activeView()
315selected_nodes = v.selectedNodes()
316print(selected_nodes)
317@endcode
318 *
319 *
320 * @return a list of Node objects which may be empty.
321 */
322 QList<Node *> selectedNodes() const;
323
324 /**
325 * @brief flakeToDocumentTransform
326 * The transformation of the document relative to the view without rotation and mirroring
327 * @return QTransform
328 */
329 QTransform flakeToDocumentTransform() const;
330
331 /**
332 * @brief flakeToCanvasTransform
333 * The transformation of the canvas relative to the view without rotation and mirroring
334 * @return QTransform
335 */
336 QTransform flakeToCanvasTransform() const;
337
338 /**
339 * @brief flakeToImageTransform
340 * The transformation of the image relative to the view without rotation and mirroring
341 * @return QTransform
342 */
343 QTransform flakeToImageTransform() const;
344
345private:
346
347 friend class Window;
348 friend class Scratchpad;
349
350
351 KisView *view();
352
353 struct Private;
354 Private *const d;
355
356};
357
358#endif // LIBKIS_VIEW_H
Canvas wraps the canvas inside a view on an image/document.
Definition Canvas.h:23
The Document class encapsulates a Krita Document/Image.
Definition Document.h:37
The ManagedColor class is a class to handle colors that are color managed.
Node represents a layer or mask in a Krita image's Node hierarchy.
Definition Node.h:24
A Resource represents a gradient, pattern, brush tip, brush preset, palette or workspace definition.
Definition Resource.h:31
The Scratchpad class A scratchpad is a type of blank canvas area that can be painted on with the norm...
Definition Scratchpad.h:27
View represents one view on a document.
Definition View.h:25
Window represents one Krita mainwindow.
Definition Window.h:23
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:53:16 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.