Krita

View.h
1 /*
2  * SPDX-FileCopyrightText: 2016 Boudewijn Rempt <[email protected]>
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 
14 class ManagedColor;
15 class Resource;
16 class Scratchpad;
17 class Node;
18 class 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  */
24 class KRITALIBKIS_EXPORT View : public QObject
25 {
26  Q_OBJECT
28 
29 public:
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 
36 public 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
81 color = Application.activeWindow().activeView().foregroundColor()
82 components = color.components()
83 components[0] = 1.0
84 components[1] = 0.6
85 components[2] = 0.7
86 color.setComponents(components)
87 Application.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 paintingFlow() const;
121  void setPaintingFlow(qreal flow);
122 
123  /**
124  * @brief showFloatingMessage displays a floating message box on the top-left corner of the canvas
125  * @param message: Message to be displayed inside the floating message box
126  * @param icon: Icon to be displayed inside the message box next to the message string
127  * @param timeout: Milliseconds until the message box disappears
128  * @param priority: 0 = High, 1 = Medium, 2 = Low. Higher priority
129  * messages will be displayed in place of lower priority messages
130  */
131  void showFloatingMessage(const QString &message, const QIcon& icon, int timeout, int priority);
132 
133  /**
134  * @brief selectedNodes returns a list of Nodes that are selected in this view.
135  *
136  *
137 @code
138 from krita import *
139 w = Krita.instance().activeWindow()
140 v = w.activeView()
141 selected_nodes = v.selectedNodes()
142 print(selected_nodes)
143 @endcode
144  *
145  *
146  * @return a list of Node objects which may be empty.
147  */
148  QList<Node *> selectedNodes() const;
149 
150  /**
151  * @brief flakeToDocumentTransform
152  * The tranformation of the document relative to the view without rotation and mirroring
153  * @return QTransform
154  */
155  QTransform flakeToDocumentTransform() const;
156 
157  /**
158  * @brief flakeToCanvasTransform
159  * The tranformation of the canvas relative to the view without rotation and mirroring
160  * @return QTransform
161  */
162  QTransform flakeToCanvasTransform() const;
163 
164  /**
165  * @brief flakeToImageTransform
166  * The tranformation of the image relative to the view without rotation and mirroring
167  * @return QTransform
168  */
169  QTransform flakeToImageTransform() const;
170 
171 private:
172 
173  friend class Window;
174  friend class Scratchpad;
175 
176 
177  KisView *view();
178 
179  struct Private;
180  Private *const d;
181 
182 };
183 
184 #endif // LIBKIS_VIEW_H
Q_SLOTSQ_SLOTS
A Resource represents a gradient, pattern, brush tip, brush preset, palette or workspace definition.
Definition: Resource.h:30
Window represents one Krita mainwindow.
Definition: Window.h:22
The Document class encapsulates a Krita Document/Image.
Definition: Document.h:33
View represents one view on a document.
Definition: View.h:24
The Scratchpad class A scratchpad is a type of blank canvas area that can be painted on with the norm...
Definition: Scratchpad.h:27
The ManagedColor class is a class to handle colors that are color managed.
Definition: ManagedColor.h:45
Node represents a layer or mask in a Krita image's Node hierarchy.
Definition: Node.h:21
Canvas wraps the canvas inside a view on an image/document.
Definition: Canvas.h:22
Q_DISABLE_COPY(Class)
QString message
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon May 8 2023 04:08:41 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.