summaryrefslogtreecommitdiffstats
path: root/src/live_effects/parameter/satellitearray.h
blob: 0a8534d0d2feca10b7e18dabde894d81eaf0a4ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_SATELLITEARRAY_H
#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_SATELLITEARRAY_H

/*
 * Inkscape::LivePathEffectParameters
 *
 * Copyright (C) Theodore Janeczko 2012 <flutterguy317@gmail.com>
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#include <gtkmm/scrolledwindow.h>
#include <gtkmm/treestore.h>
#include <sigc++/sigc++.h>

#include "live_effects/lpeobject.h"
#include "live_effects/parameter/array.h"
#include "live_effects/parameter/parameter.h"
#include "live_effects/parameter/satellite-reference.h"

class SPObject;

namespace Inkscape {
namespace LivePathEffect {
class SatelliteReference;
class SatelliteArrayParam : public ArrayParam<std::shared_ptr<SatelliteReference>>
{
public:
    class ModelColumns;

    SatelliteArrayParam(const Glib::ustring &label, const Glib::ustring &tip, const Glib::ustring &key,
                        Inkscape::UI::Widget::Registry *wr, Effect *effect, bool visible);

    ~SatelliteArrayParam() override;
    Gtk::Widget *param_newWidget() override;
    bool param_readSVGValue(const gchar *strvalue) override;
    void link(SPObject *to, size_t pos = Glib::ustring::npos);
    void unlink(std::shared_ptr<SatelliteReference> to);
    void unlink(SPObject *to);
    bool is_connected(){ return linked_connections.size() != 0; };
    void clear();
    void setUpdating(bool updating) { _updating = updating; }
    bool getUpdating() const { return _updating; }
    void start_listening();
    ParamType paramType() const override { return ParamType::SATELLITE_ARRAY; };
protected:
    void quit_listening();
    void linked_modified(SPObject *linked_obj, guint flags);
    bool _updateLink(const Gtk::TreeIter &iter, std::shared_ptr<SatelliteReference> lpref);
    bool _selectIndex(const Gtk::TreeIter &iter, int *i);
    void updatesignal();
    ModelColumns *_model;
    Glib::RefPtr<Gtk::TreeStore> _store;
    Gtk::TreeView *_tree;
    Gtk::ScrolledWindow *_scroller;
    Gtk::CellRendererText *_text_renderer;
    Gtk::CellRendererToggle *_toggle_active;
    Gtk::TreeView::Column *_name_column;
    void on_link_button_click();
    void on_remove_button_click();
    void on_up_button_click();
    void on_down_button_click();
    void on_active_toggled(const Glib::ustring &item);

private:
    bool _updating = false;
    void update();
    void initui();
    bool _visible;
    std::vector<sigc::connection> linked_connections;
    std::vector<SPObject *> param_get_satellites() override;
    SatelliteArrayParam(const SatelliteArrayParam &) = delete;
    SatelliteArrayParam &operator=(const SatelliteArrayParam &) = delete;
};

} // namespace LivePathEffect

} // namespace Inkscape

#endif

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :