Krita

GridConfig.h
1/*
2 * SPDX-FileCopyrightText: 2024 Grum999 <grum999@grum.fr>
3 *
4 * SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6#ifndef LIBKIS_GRIDCONFIG_H
7#define LIBKIS_GRIDCONFIG_H
8
9#include <QObject>
10#include "kis_grid_config.h"
11
12#include "kritalibkis_export.h"
13#include "libkis.h"
14
15/**
16 * The GridConfig class encapsulates a Krita Guides configuration.
17 *
18 */
19class KRITALIBKIS_EXPORT GridConfig : public QObject
20{
21 Q_OBJECT
22
23public:
24 GridConfig(KisGridConfig *guidesConfig);
25
26 /**
27 * Create a new, empty GridConfig.
28 */
29 explicit GridConfig(QObject *parent = 0);
30 ~GridConfig() override;
31
32 bool operator==(const GridConfig &other) const;
33 bool operator!=(const GridConfig &other) const;
34
35public Q_SLOTS:
36
37 /**
38 * @brief Returns grid visibility for document.
39 * @return If grid is visible, return True.
40 */
41 bool visible() const;
42
43 /**
44 * @brief Set grid visibility for document.
45 * @param snap Set to True to get grid visible.
46 */
47 void setVisible(bool visible);
48
49 /**
50 * @brief Returns snap to grid status for document.
51 * @return If snap to grid is active on document, return True.
52 */
53 bool snap() const;
54
55 /**
56 * @brief Activate or deactivate snap to grid for document
57 * @param snap Set to True to activate snap to grid.
58 */
59 void setSnap(bool snap);
60
61 /**
62 * @brief Returns grid offset (in pixels, from origin) for document.
63 * @return A QPoint that define X and Y offset.
64 */
65 QPoint offset() const;
66
67 /**
68 * @brief Define grid offset (in pixels, from origin) for document.
69 * @param offset A QPoint that define X and Y offset (X and Y in range [0 - 500])
70 */
71 void setOffset(QPoint offset);
72
73 /**
74 * @brief Returns grid spacing (in pixels) for document.
75 * Spacing value is used for grid type "rectangular".
76 * @return A QPoint that define X and Y spacing.
77 */
78 QPoint spacing() const;
79
80 /**
81 * @brief Set grid spacing (in pixels) for document.
82 * Spacing value is used for grid type "rectangular".
83 * @param spacing A QPoint that define X and Y spacing (minimum value for X and Y is 1)
84 */
85 void setSpacing(QPoint spacing);
86
87 /**
88 * @brief Returns if horizontal grid spacing is active.
89 * Spacing value is used for grid type "rectangular".
90 *
91 * @returns a boolean which indicate if horizontal grid is active or not
92 */
93 bool spacingActiveHorizontal() const;
94
95 /**
96 * @brief Set horizontal grid spacing active.
97 * Spacing value is used for grid type "rectangular".
98 *
99 * @param active True to activate horizontal spacing, False to deactivate it.
100 */
101 void setSpacingActiveHorizontal(bool active);
102
103 /**
104 * @brief Returns if vertical grid spacing is active.
105 * Spacing value is used for grid type "rectangular".
106 *
107 * @returns a boolean which indicate if vertical grid is active or not
108 */
109 bool spacingActiveVertical() const;
110
111 /**
112 * @brief Set vertical grid spacing active.
113 * Spacing value is used for grid type "rectangular".
114 *
115 * @param active True to activate vertical spacing, False to deactivate it.
116 */
117 void setSpacingActiveVertical(bool active);
118
119 /**
120 * @brief Returns number of grid subdivision for document.
121 * Subdivision value is used for grid type "rectangular".
122 * @return A positive integer value, starting from 1
123 */
124 int subdivision() const;
125
126 /**
127 * @brief Set number of grid subdivision for document.
128 * Subdivision value is used for grid type "rectangular".
129 * @param subdivision A positive integer value, in range [1 - 10]
130 */
131 void setSubdivision(int subdivision);
132
133 /**
134 * @brief Returns left angle (in degrees) of isometric grid for document.
135 * AngleLeft value is used for grid type "isometric".
136 * @return A positive decimal value, in range [0.00 - 89.00]
137 */
138 qreal angleLeft() const;
139
140 /**
141 * @brief Set left angle (in degrees) of isometric grid for document.
142 * AngleLeft value is used for grid type "isometric".
143 * @param angleLeft A positive decimal value, in range [0.00 - 89.00]
144 */
145 void setAngleLeft(qreal angleLeft);
146
147 /**
148 * @brief Returns right angle (in degrees) of isometric grid for document.
149 * AngleRight value is used for grid type "isometric".
150 * @return A positive decimal value, in range [0.00 - 89.00]
151 */
152 qreal angleRight() const;
153
154 /**
155 * @brief Set right angle (in degrees) of isometric grid for document.
156 * AngleRight value is used for grid type "isometric".
157 * @param angleRight A positive decimal value, in range [0.00 - 89.00]
158 */
159 void setAngleRight(qreal angleRight);
160
161 /**
162 * @brief Returns if left angle grid is active.
163 * Spacing value is used for grid type "isometric".
164 *
165 * @returns a boolean which indicate if left angle grid is active or not
166 */
167 bool angleLeftActive() const;
168
169 /**
170 * @brief Set left angle grid active.
171 * Spacing value is used for grid type "isometric".
172 *
173 * @param active True to activate left angle grid, False to deactivate it.
174 */
175 void setAngleLeftActive(bool active);
176
177 /**
178 * @brief Returns if right angle grid is active.
179 * Spacing value is used for grid type "isometric".
180 *
181 * @returns a boolean which indicate if right angle grid is active or not
182 */
183 bool angleRightActive() const;
184
185 /**
186 * @brief Set right angle grid active.
187 * Spacing value is used for grid type "isometric".
188 *
189 * @param active True to activate right angle grid, False to deactivate it.
190 */
191 void setAngleRightActive(bool active);
192
193 /**
194 * @brief Returns grid cell spacing (in pixels) for document.
195 * Cell spacing value is used for grid type "isometric_legacy".
196 * @return A positive integer value, minimum value is 10
197 */
198 int cellSpacing() const;
199
200 /**
201 * @brief Set grid cell spacing for document.
202 * Cell spacing value is used for grid type "isometric_legacy".
203 * @param cellSpacing A integer that define spacing, in range [10 - 1000]
204 */
205 void setCellSpacing(int cellSpacing);
206
207 /**
208 * @brief Returns grid cell border size (in pixels) for document.
209 * Cell spacing value is used for grid type "isometric".
210 * @return A positive integer value, in range [10 - 1000]
211 */
212 int cellSize() const;
213
214 /**
215 * @brief Set grid cell size (in pixels) for document.
216 * Cell spacing value is used for grid type "isometric".
217 * @param cellSize An integer that define cell border size.
218 */
219 void setCellSize(int cellSize);
220
221 /**
222 * @brief Returns current grid type applied for document.
223 * @return The grid type can be:
224 * - "rectangular"
225 * - "isometric"
226 * - "isometric_legacy"
227 */
228 QString type() const;
229
230 /**
231 * @brief Set current grid type applied for document.
232 * @param gridType The grid type can be:
233 * - "rectangular"
234 * - "isometric"
235 * - "isometric_legacy"
236 */
237 void setType(const QString &gridType);
238
239 /**
240 * @brief Returns status of "Aspect locked" property for offset values
241 * (X and Y values are linked to keep ratio)
242 * @return If locked, return True.
243 */
244 bool offsetAspectLocked() const;
245
246 /**
247 * @brief Set status of "Aspect locked" property for offset values
248 * (X and Y values are linked to keep ratio)
249 * @param offsetAspectLocked Set to True lock aspect.
250 */
251 void setOffsetAspectLocked(bool offsetAspectLocked);
252
253 /**
254 * @brief Returns status of "Aspect locked" property for spacing values
255 * (mean, X and Y values are linked to keep ratio)
256 * SpacingAspectLocked value is used for grid type "rectangular".
257 * @return If locked, return True.
258 */
259 bool spacingAspectLocked() const;
260
261 /**
262 * @brief Set status of "Aspect locked" property for spacing values
263 * (X and Y values are linked to keep ratio)
264 * SpacingAspectLocked value is used for grid type "rectangular".
265 * @param spacingAspectLocked Set to True lock aspect.
266 */
267 void setSpacingAspectLocked(bool spacingAspectLocked);
268
269 /**
270 * @brief Returns status of "Aspect locked" property for angles values
271 * (mean, left and right angles values are linked to keep ratio)
272 * AngleAspectLocked value is used for grid type "isometric" and "isometric_legacy".
273 * @return If locked, return True.
274 */
275 bool angleAspectLocked() const;
276
277 /**
278 * @brief Set status of "Aspect locked" property for angles values
279 * (left and right angles values are linked to keep ratio)
280 * AngleAspectLocked value is used for grid type "isometric" and "isometric_legacy".
281 * @param angleAspectLocked Set to True lock aspect.
282 */
283 void setAngleAspectLocked(bool angleAspectLocked);
284
285 /**
286 * @brief Returns grid main line type
287 * @return The main line type for grid in current document
288 * Can be:
289 * - "solid"
290 * - "dashed"
291 * - "dotted"
292 */
293 QString lineTypeMain() const;
294
295 /**
296 * @brief Set grid main line type
297 * @param lineType The main line type to apply for grid
298 * Can be:
299 * - "solid"
300 * - "dashed"
301 * - "dotted"
302 */
303 void setLineTypeMain(const QString &lineType);
304
305 /**
306 * @brief Returns grid subdivision line type
307 * @return The subdivision line type for grid in current document
308 * Can be:
309 * - "solid"
310 * - "dashed"
311 * - "dotted"
312 *
313 * LineTypeSubdivision value is used for grid type "rectangular".
314 */
315 QString lineTypeSubdivision() const;
316
317 /**
318 * @brief Set grid subdivision line type
319 * @param lineType The subdivision line type to apply for grid
320 * Can be:
321 * - "solid"
322 * - "dashed"
323 * - "dotted"
324 *
325 * LineTypeSubdivision value is used for grid type "rectangular".
326 */
327 void setLineTypeSubdivision(const QString &lineType);
328
329 /**
330 * @brief Returns grid vertical line type
331 * @return The vertical line type for grid in current document
332 * Can be:
333 * - "solid"
334 * - "dashed"
335 * - "dotted"
336 * - "none"
337 *
338 * LineTypeVertical value is used for grid type "isometric".
339 */
340 QString lineTypeVertical() const;
341
342 /**
343 * @brief Set grid vertical line type
344 * @param lineType The vertical line type to apply for grid
345 * Can be:
346 * - "solid"
347 * - "dashed"
348 * - "dotted"
349 * - "none"
350 *
351 * LineTypeVertical value is used for grid type "isometric".
352 */
353 void setLineTypeVertical(const QString &lineType);
354
355 /**
356 * @brief Returns grid main line color
357 * @return The color for grid main line
358 */
359 QColor colorMain() const;
360
361 /**
362 * @brief Set grid main line color
363 * @param color The color to apply for grid main line
364 */
365 void setColorMain(QColor colorMain);
366
367 /**
368 * @brief Returns grid subdivision line color
369 * ColorSubdivision value is used for grid type "rectangular".
370 * @return The color for grid subdivision line
371 */
372 QColor colorSubdivision() const;
373
374 /**
375 * @brief Set grid subdivision line color
376 * ColorSubdivision value is used for grid type "rectangular".
377 * @param color The color to apply for grid subdivision line
378 */
379 void setColorSubdivision(QColor colorSubdivision);
380
381 /**
382 * @brief Returns grid vertical line color
383 * ColorSubdivision value is used for grid type "isometric".
384 * @return The color for grid vertical line
385 */
386 QColor colorVertical() const;
387
388 /**
389 * @brief Set grid vertical line color
390 * ColorSubdivision value is used for grid type "isometric".
391 * @param color The color to apply for grid vertical line
392 */
393 void setColorVertical(QColor colorVertical);
394
395 /**
396 * @brief Load grid definition from an XML document
397 * @param xmlContent xml content provided as a string
398 * @return True if xml content is valid and grid has been loaded, otherwise False
399 */
400 bool fromXml(const QString &xmlContent) const;
401
402 /**
403 * @brief Save grid definition as an XML document
404 * @return A string with xml content
405 */
406 QString toXml() const;
407
408
409private:
410 friend class Document;
411
412 KisGridConfig gridConfig() const;
413
414private:
415 struct Private;
416 Private *d;
417
418};
419
420#endif // LIBKIS_GRIDCONFIG_H
The Document class encapsulates a Krita Document/Image.
Definition Document.h:37
The GridConfig class encapsulates a Krita Guides configuration.
Definition GridConfig.h:20
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:09 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.