Changeset View
Changeset View
Standalone View
Standalone View
libs/pigment/resources/KisSwatchGroup.h
- This file was added.
1 | /* This file is part of the KDE project | ||||
---|---|---|---|---|---|
2 | Copyright (c) 2005 Boudewijn Rempt <boud@valdyas.org> | ||||
3 | Copyright (c) 2016 L. E. Segovia <leo.segovia@siggraph.org> | ||||
4 | Copyright (c) 2018 Michael Zhou <simerixh@gmail.com> | ||||
5 | | ||||
6 | This library is free software; you can redistribute it and/or | ||||
7 | modify it under the terms of the GNU Lesser General Public | ||||
8 | License as published by the Free Software Foundation; either | ||||
9 | version 2.1 of the License, or (at your option) any later version. | ||||
10 | | ||||
11 | This library is distributed in the hope that it will be useful, | ||||
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
14 | Lesser General Public License for more details. | ||||
15 | | ||||
16 | You should have received a copy of the GNU Lesser General Public | ||||
17 | License along with this library; if not, write to the Free Software | ||||
18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||||
19 | | ||||
20 | */ | ||||
21 | | ||||
22 | #ifndef KISSWATCHGROUP_H | ||||
23 | #define KISSWATCHGROUP_H | ||||
24 | | ||||
25 | #include "KisSwatch.h" | ||||
26 | | ||||
27 | #include "kritapigment_export.h" | ||||
28 | | ||||
29 | #include <QVector> | ||||
30 | #include <QList> | ||||
31 | #include <QMap> | ||||
32 | #include <QScopedPointer> | ||||
33 | | ||||
34 | /** | ||||
35 | * @brief The KisSwatchGroup class stores a matrix of color swatches | ||||
36 | * swatches can accessed using (x, y) coordinates. | ||||
37 | * x is the column number from left to right and y is the row number from top | ||||
38 | * to bottom. | ||||
39 | * Both x and y start at 0 | ||||
40 | * there could be empty entries, so the checkEntry(int, int) method must used | ||||
41 | * whenever you want to get an entry from the matrix | ||||
42 | */ | ||||
43 | class KRITAPIGMENT_EXPORT KisSwatchGroup | ||||
44 | { | ||||
45 | public /* struct */: | ||||
46 | struct SwatchInfo { | ||||
47 | QString group; | ||||
48 | KisSwatch swatch; | ||||
49 | int row; | ||||
50 | int column; | ||||
51 | }; | ||||
52 | | ||||
53 | public: | ||||
54 | KisSwatchGroup(); | ||||
55 | ~KisSwatchGroup(); | ||||
56 | KisSwatchGroup(const KisSwatchGroup &rhs); | ||||
57 | KisSwatchGroup &operator =(const KisSwatchGroup &rhs); | ||||
58 | | ||||
59 | public /* methods */: | ||||
60 | void setName(const QString &name); | ||||
61 | QString name() const; | ||||
62 | | ||||
63 | void setColumnCount(int columnCount); | ||||
64 | int columnCount() const; | ||||
65 | | ||||
66 | void setRowCount(int newRowCount); | ||||
67 | int rowCount() const; | ||||
68 | | ||||
69 | int colorCount() const; | ||||
70 | | ||||
71 | QList<SwatchInfo> infoList() const; | ||||
72 | | ||||
73 | /** | ||||
74 | * @brief checkEntry | ||||
75 | * checks if position x and y has a valid entry | ||||
76 | * both x and y start from 0 | ||||
77 | * @param x | ||||
78 | * @param y | ||||
79 | * @return true if there is a valid entry at position (x, y) | ||||
80 | */ | ||||
81 | bool checkEntry(int column, int row) const; | ||||
82 | /** | ||||
83 | * @brief setEntry | ||||
84 | * sets the entry at position (x, y) to be e | ||||
85 | * @param e | ||||
86 | * @param x | ||||
87 | * @param y | ||||
88 | */ | ||||
89 | void setEntry(const KisSwatch &e, int column, int row); | ||||
90 | /** | ||||
91 | * @brief getEntry | ||||
92 | * used to get the swatch entry at position (x, y) | ||||
93 | * there is an assertion to make sure that this position isn't empty, | ||||
94 | * so checkEntry(int, int) must be used before this method to ensure | ||||
95 | * a valid entry can be found | ||||
96 | * @param x | ||||
97 | * @param y | ||||
98 | * @return the swatch entry at position (x, y) | ||||
99 | */ | ||||
100 | KisSwatch getEntry(int column, int row) const; | ||||
101 | /** | ||||
102 | * @brief removeEntry | ||||
103 | * removes the entry at position (x, y) | ||||
104 | * @param x | ||||
105 | * @param y | ||||
106 | * @return true if these is an entry at (x, y) | ||||
107 | */ | ||||
108 | bool removeEntry(int column, int row); | ||||
109 | /** | ||||
110 | * @brief addEntry | ||||
111 | * adds the entry e to the right of the rightmost entry in the last row | ||||
112 | * if the rightmost entry in the last row is in the right most column, | ||||
113 | * add e to the leftmost column of a new row | ||||
114 | * | ||||
115 | * when column is set to 0, resize number of columns to default | ||||
116 | * @param e | ||||
117 | */ | ||||
118 | void addEntry(const KisSwatch &e); | ||||
119 | | ||||
120 | void clear(); | ||||
121 | | ||||
122 | private /* member variables */: | ||||
123 | struct Private; | ||||
124 | QScopedPointer<Private> d; | ||||
125 | }; | ||||
126 | | ||||
127 | #endif // KISSWATCHGROUP_H |