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 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
141 from krita import *
142 w = Krita.instance().activeWindow()
143 v = w.activeView()
144 selected_nodes = v.selectedNodes()
145 print(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 
174 private:
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
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 Thu Nov 30 2023 04:01:29 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.