Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
effect-enum.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2#ifndef INKSCAPE_LIVEPATHEFFECT_ENUM_H
3#define INKSCAPE_LIVEPATHEFFECT_ENUM_H
4
5/*
6 * Inkscape::LivePathEffect::EffectType
7 *
8 * Copyright (C) Johan Engelen 2008 <j.b.c.engelen@utwente.nl>
9 *
10 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
11 */
12
13#include "util/enums.h"
14#include <map>
15
16namespace Inkscape {
17namespace LivePathEffect {
18
19// Please fill in the same order than in effect.cpp:98
84// ALPHABETIC
114
116
117template <typename E>
120 const Glib::ustring label;
121 const Glib::ustring key;
122 const Glib::ustring icon;
123 const Glib::ustring description;
125 const bool on_path;
126 const bool on_shape;
127 const bool on_group;
128 const bool on_image;
129 const bool on_text;
130 const bool experimental;
131};
132
133const Glib::ustring empty_string("");
134
141template <typename E>
143 public:
145
146 EnumEffectDataConverter(const EnumEffectData<E> *cd, const unsigned int length)
147 : _length(length)
148 , _data(cd)
149 {
150 }
151
152 E get_id_from_label(const Glib::ustring &label) const
153 {
154 for (unsigned int i = 0; i < _length; ++i) {
155 if (_data[i].label == label)
156 return _data[i].id;
157 }
158
159 return (E)0;
160 }
161
162 E get_id_from_key(const Glib::ustring &key) const
163 {
164 for (unsigned int i = 0; i < _length; ++i) {
165 if (_data[i].key == key)
166 return _data[i].id;
167 }
168
169 return (E)0;
170 }
171
172 bool is_valid_key(const Glib::ustring &key) const
173 {
174 for (unsigned int i = 0; i < _length; ++i) {
175 if (_data[i].key == key)
176 return true;
177 }
178
179 return false;
180 }
181
182 bool is_valid_id(const E id) const
183 {
184 for (unsigned int i = 0; i < _length; ++i) {
185 if (_data[i].id == id)
186 return true;
187 }
188 return false;
189 }
190
191 const Glib::ustring &get_label(const E id) const
192 {
193 for (unsigned int i = 0; i < _length; ++i) {
194 if (_data[i].id == id)
195 return _data[i].label;
196 }
197
198 return empty_string;
199 }
200
201 const Glib::ustring &get_key(const E id) const
202 {
203 for (unsigned int i = 0; i < _length; ++i) {
204 if (_data[i].id == id)
205 return _data[i].key;
206 }
207
208 return empty_string;
209 }
210
211 const Glib::ustring &get_icon(const E id) const
212 {
213 for (unsigned int i = 0; i < _length; ++i) {
214 if (_data[i].id == id)
215 return _data[i].icon;
216 }
217
218 return empty_string;
219 }
220
221 const Glib::ustring &get_description(const E id) const
222 {
223 for (unsigned int i = 0; i < _length; ++i) {
224 if (_data[i].id == id)
225 return _data[i].description;
226 }
227
228 return empty_string;
229 }
230
231 LPECategory get_category(const E id) const
232 {
233 for (unsigned int i = 0; i < _length; ++i) {
234 if (_data[i].id == id)
235 return _data[i].category;
236 }
237
239 }
240
241 bool get_on_path(const E id) const
242 {
243 for (unsigned int i = 0; i < _length; ++i) {
244 if (_data[i].id == id)
245 return _data[i].on_path;
246 }
247
248 return false;
249 }
250
251 bool get_on_shape(const E id) const
252 {
253 for (unsigned int i = 0; i < _length; ++i) {
254 if (_data[i].id == id)
255 return _data[i].on_shape;
256 }
257
258 return false;
259 }
260
261 bool get_on_group(const E id) const
262 {
263 for (unsigned int i = 0; i < _length; ++i) {
264 if (_data[i].id == id)
265 return _data[i].on_group;
266 }
267
268 return false;
269 }
270
271 bool get_on_image(const E id) const
272 {
273 for (unsigned int i = 0; i < _length; ++i) {
274 if (_data[i].id == id)
275 return _data[i].on_image;
276 }
277
278 return false;
279 }
280
281 bool get_on_text(const E id) const
282 {
283 for (unsigned int i = 0; i < _length; ++i) {
284 if (_data[i].id == id)
285 return _data[i].on_text;
286 }
287
288 return false;
289 }
290
291 bool get_experimental(const E id) const
292 {
293 for (unsigned int i = 0; i < _length; ++i) {
294 if (_data[i].id == id)
295 return _data[i].experimental;
296 }
297
298 return false;
299 }
300
301 const EnumEffectData<E> &data(const unsigned int i) const { return _data[i]; }
302
303 const unsigned int _length;
304
305 private:
307};
308
311
312} //namespace LivePathEffect
313} //namespace Inkscape
314
315#endif
316
317/*
318 Local Variables:
319 mode:c++
320 c-file-style:"stroustrup"
321 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
322 indent-tabs-mode:nil
323 fill-column:99
324 End:
325*/
326// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
Simplified management of enumerations of LPE items with UI labels.
E get_id_from_key(const Glib::ustring &key) const
const Glib::ustring & get_description(const E id) const
const Glib::ustring & get_label(const E id) const
EnumEffectDataConverter(const EnumEffectData< E > *cd, const unsigned int length)
const Glib::ustring & get_key(const E id) const
const EnumEffectData< E > & data(const unsigned int i) const
const Glib::ustring & get_icon(const E id) const
E get_id_from_label(const Glib::ustring &label) const
bool is_valid_key(const Glib::ustring &key) const
Glib::ustring label
Coord length(LineSegment const &seg)
const EnumEffectData< EffectType > LPETypeData[]
Definition effect.cpp:97
const Glib::ustring empty_string("")
const EnumEffectDataConverter< EffectType > LPETypeConverter
defined in effect.cpp
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key