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
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 color.
79 * This is nominally per canvas/view, but in practice per mainwindow.
80 * @code
81color = Application.activeWindow().activeView().foregroundColor()
82components = color.components()
83components[0] = 1.0
84components[1] = 0.6
85components[2] = 0.7
86color.setComponents(components)
87Application.activeWindow().activeView().setForeGroundColor(color)
88 * @endcode
89 */
90 ManagedColor *foregroundColor() const;
91 void setForeGroundColor(ManagedColor *color);
92
93 ManagedColor *backgroundColor() const;
94 void setBackGroundColor(ManagedColor *color);
95
96 Resource *currentBrushPreset() const;
97 void setCurrentBrushPreset(Resource *resource);
98
99 Resource *currentPattern() const;
100 void setCurrentPattern(Resource *resource);
101
102 Resource *currentGradient() const;
103 void setCurrentGradient(Resource *resource);
104
105 QString currentBlendingMode() const;
106 void setCurrentBlendingMode(const QString &blendingMode);
107
108 float HDRExposure() const;
109 void setHDRExposure(float exposure);
110
111 float HDRGamma() const;
112 void setHDRGamma(float gamma);
113
114 qreal paintingOpacity() const;
115 void setPaintingOpacity(qreal opacity);
116
117 qreal brushSize() const;
118 void setBrushSize(qreal brushSize);
119
120 qreal brushRotation() const;
121 void setBrushRotation(qreal brushRotation);
122
123 qreal paintingFlow() const;
124 void setPaintingFlow(qreal flow);
125
126 /**
127 * @brief showFloatingMessage displays a floating message box on the top-left corner of the canvas
128 * @param message: Message to be displayed inside the floating message box
129 * @param icon: Icon to be displayed inside the message box next to the message string
130 * @param timeout: Milliseconds until the message box disappears
131 * @param priority: 0 = High, 1 = Medium, 2 = Low. Higher priority
132 * messages will be displayed in place of lower priority messages
133 */
134 void showFloatingMessage(const QString &message, const QIcon& icon, int timeout, int priority);
135
136 /**
137 * @brief selectedNodes returns a list of Nodes that are selected in this view.
138 *
139 *
140@code
141from krita import *
142w = Krita.instance().activeWindow()
143v = w.activeView()
144selected_nodes = v.selectedNodes()
145print(selected_nodes)
146@endcode
147 *
148 *
149 * @return a list of Node objects which may be empty.
150 */
151 QList<Node *> selectedNodes() const;
152
153 /**
154 * @brief flakeToDocumentTransform
155 * The transformation of the document relative to the view without rotation and mirroring
156 * @return QTransform
157 */
158 QTransform flakeToDocumentTransform() const;
159
160 /**
161 * @brief flakeToCanvasTransform
162 * The transformation of the canvas relative to the view without rotation and mirroring
163 * @return QTransform
164 */
165 QTransform flakeToCanvasTransform() const;
166
167 /**
168 * @brief flakeToImageTransform
169 * The transformation of the image relative to the view without rotation and mirroring
170 * @return QTransform
171 */
172 QTransform flakeToImageTransform() const;
173
174private:
175
176 friend class Window;
177 friend class Scratchpad;
178
179
180 KisView *view();
181
182 struct Private;
183 Private *const d;
184
185};
186
187#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:34
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:22
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:28
View represents one view on a document.
Definition View.h:25
Window represents one Krita mainwindow.
Definition Window.h:23
Q_SLOTSQ_SLOTS
T qobject_cast(QObject *object)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:53 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.