Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
enumarray.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Inkscape::LivePathEffectParameters
4 *
5 *
6 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
7 */
8
9#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUMARRAY_H
10#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUMARRAY_H
11
12#include <glib.h>
14#include "live_effects/effect.h"
17
18namespace Inkscape {
19
20namespace LivePathEffect {
21typedef unsigned E;
22class EnumArrayParam : public ArrayParam<Glib::ustring> {
23public:
24 EnumArrayParam( const Glib::ustring& label,
25 const Glib::ustring& tip,
26 const Glib::ustring& key,
29 Effect* effect,
30 E default_value,
31 bool visible = true,
32 size_t n = 0,
33 bool sort = true)
34 : ArrayParam<Glib::ustring>(label, tip, key, wr, effect, n)
35 , defvalue(default_value)
36 {
37 enumdataconv = &c;
38
39 sorted = sort;
41 }
42
43 ~EnumArrayParam() override = default;
44
45 Gtk::Widget *param_newWidget() override {
47 auto const regenum = Gtk::make_managed<UI::Widget::RegisteredEnum<E>>(param_label, param_tooltip,
49 regenum->combobox()->setProgrammatically = true;
50 regenum->set_active_by_id(enumdataconv->get_id_from_key(_vector[_active_index]));
51 regenum->combobox()->setProgrammatically = true;
52 regenum->combobox()->signal_changed().connect(sigc::bind(sigc::mem_fun (*this, &EnumArrayParam::_on_change_combo),regenum));
53 regenum->set_undo_parameters(_("Change enumeration parameter"), INKSCAPE_ICON("dialog-path-effects"));
54 regenum->combobox()->setProgrammatically = true;
55 return regenum;
56 } else {
57 return nullptr;
58 }
59 };
60
62 auto key = regenum->combobox()->get_as_attribute();
63 if (key.empty()) return;
64
65 regenum->combobox()->setProgrammatically = true;
68 }
69
74
75 Glib::ustring param_getDefaultSVGValue() const override {
76 return enumdataconv->get_key(defvalue).c_str();
77 };
78
79 void param_set_default() override {
80 for (auto &vec : _vector) {
81 vec = enumdataconv->get_key(defvalue).c_str();
82 }
83 };
84
85 void param_update_default(E default_value) {
86 defvalue = default_value;
87 };
88
89 void param_update_default(const gchar *default_value) override {
90 param_update_default(enumdataconv->get_id_from_key(Glib::ustring(default_value)));
91 }
92
93 ParamType paramType() const override { return ParamType::ENUM_ARRAY; };
94
95protected:
96 friend class LPETaperStroke;
97
98private:
99 size_t _active_index = 0;
101 bool sorted;
105};
106
107
108} // namespace LivePathEffect
109
110} // namespace Inkscape
111
112#endif // INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUMARRAY_H
113
114/*
115 Local Variables:
116 mode:c++
117 c-file-style:"stroustrup"
118 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
119 indent-tabs-mode:nil
120 fill-column:99
121 End:
122*/
123// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
Geom::IntRect visible
Definition canvas.cpp:154
void param_set_and_write_new_value(std::vector< Glib::ustring > const &new_vector)
Definition array.h:92
Inkscape::XML::Node * getRepr()
Definition effect.cpp:1928
Gtk::Widget * param_newWidget() override
Definition enumarray.h:45
const Util::EnumDataConverter< E > * enumdataconv
Definition enumarray.h:102
Glib::ustring param_getDefaultSVGValue() const override
Definition enumarray.h:75
void _on_change_combo(Inkscape::UI::Widget::RegisteredEnum< E > *regenum)
Definition enumarray.h:61
ParamType paramType() const override
Definition enumarray.h:93
void param_update_default(const gchar *default_value) override
Definition enumarray.h:89
EnumArrayParam(const Glib::ustring &label, const Glib::ustring &tip, const Glib::ustring &key, const Util::EnumDataConverter< E > &c, Inkscape::UI::Widget::Registry *wr, Effect *effect, E default_value, bool visible=true, size_t n=0, bool sort=true)
Definition enumarray.h:24
EnumArrayParam & operator=(const EnumArrayParam &)=delete
void param_update_default(E default_value)
Definition enumarray.h:85
EnumArrayParam(const EnumArrayParam &)=delete
Inkscape::UI::Widget::Registry * param_wr
Definition parameter.h:99
Simplified management of enumerations in the UI as combobox.
Simplified management of enumerations of svg items with UI labels.
Definition enums.h:42
double c[8][4]
Glib::ustring label
Helper class to stream background task notifications as a series of messages.
static cairo_user_data_key_t key
int index