summaryrefslogtreecommitdiffstats
path: root/src/live_effects/parameter/originalitemarray.h
blob: baa764622768977e09082b8ccfd425aa00694f87 (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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_ORIGINALITEMARRAY_H
#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ORIGINALITEMARRAY_H

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

#include <vector>

#include <gtkmm/box.h>
#include <gtkmm/treeview.h>
#include <gtkmm/treestore.h>
#include <gtkmm/scrolledwindow.h>

#include "live_effects/parameter/parameter.h"
#include "live_effects/parameter/item-reference.h"

#include "svg/svg.h"
#include "svg/stringstream.h"
#include "item-reference.h"

class SPObject;

namespace Inkscape {

namespace LivePathEffect {

class ItemAndActive {
public:
    ItemAndActive(SPObject *owner)
    : href(nullptr),
    ref(owner),
    actived(true)
    {
        
    }
    gchar *href;
    URIReference ref;
    bool actived;
    
    sigc::connection linked_changed_connection;
    sigc::connection linked_delete_connection;
    sigc::connection linked_modified_connection;
    sigc::connection linked_transformed_connection;
};
    
class OriginalItemArrayParam : public Parameter {
public:
    class ModelColumns;
    
    OriginalItemArrayParam( const Glib::ustring& label,
                const Glib::ustring& tip,
                const Glib::ustring& key,
                Inkscape::UI::Widget::Registry* wr,
                Effect* effect);

    ~OriginalItemArrayParam() override;

    Gtk::Widget * param_newWidget() override;
    bool param_readSVGValue(const gchar * strvalue) override;
    Glib::ustring param_getSVGValue() const override;
    Glib::ustring param_getDefaultSVGValue() const override;
    void param_set_default() override;
    void param_update_default(const gchar * default_value) override{};
    /** Disable the canvas indicators of parent class by overriding this method */
    void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) override {};
    /** Disable the canvas indicators of parent class by overriding this method */
    void addCanvasIndicators(SPLPEItem const* /*lpeitem*/, std::vector<Geom::PathVector> & /*hp_vec*/) override {};

    std::vector<ItemAndActive*> _vector;
    
protected:
    bool _updateLink(const Gtk::TreeIter& iter, ItemAndActive* pd);
    bool _selectIndex(const Gtk::TreeIter& iter, int* i);
    void unlink(ItemAndActive* to);
    void remove_link(ItemAndActive* to);
    void setItem(SPObject *linked_obj, guint flags, ItemAndActive* to);
    
    void linked_changed(SPObject *old_obj, SPObject *new_obj, ItemAndActive* to);
    void linked_modified(SPObject *linked_obj, guint flags, ItemAndActive* to);
    void linked_transformed(Geom::Affine const *, SPItem *, ItemAndActive*) {}
    void linked_delete(SPObject *deleted, ItemAndActive* to);
    
    ModelColumns *_model;
    Glib::RefPtr<Gtk::TreeStore> _store;
    Gtk::TreeView _tree;
    Gtk::CellRendererText *_text_renderer;
    Gtk::CellRendererToggle *_toggle_active;
    Gtk::TreeView::Column *_name_column;
    Gtk::ScrolledWindow _scroller;
    
    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:
    void update();
    OriginalItemArrayParam(const OriginalItemArrayParam&);
    OriginalItemArrayParam& operator=(const OriginalItemArrayParam&);
};

} //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 :