11#include <glibmm/i18n.h>
13#include <gtkmm/button.h>
14#include <gtkmm/cellrenderertext.h>
15#include <gtkmm/cellrenderertoggle.h>
16#include <gtkmm/image.h>
17#include <gtkmm/scrolledwindow.h>
18#include <gtkmm/treemodel.h>
19#include <gtkmm/treestore.h>
20#include <gtkmm/treeview.h>
42class PathArrayParam::ModelColumns :
public Gtk::TreeModel::ColumnRecord
53 Gtk::TreeModelColumn<PathAndDirectionAndVisible*> _colObject;
54 Gtk::TreeModelColumn<Glib::ustring> _colLabel;
55 Gtk::TreeModelColumn<bool> _colReverse;
56 Gtk::TreeModelColumn<bool> _colVisible;
87 _tree = std::make_unique<Gtk::TreeView>();
88 _model = std::make_unique<ModelColumns>();
92 _tree->set_reorderable(
true);
93 _tree->enable_model_drag_dest (Gdk::DragAction::MOVE);
95 auto const toggle_reverse = Gtk::make_managed<Gtk::CellRendererToggle>();
96 int reverseColNum =
_tree->append_column(_(
"Reverse"), *toggle_reverse) - 1;
97 Gtk::TreeViewColumn* col_reverse =
_tree->get_column(reverseColNum);
98 toggle_reverse->set_activatable(
true);
100 col_reverse->add_attribute(toggle_reverse->property_active(),
_model->_colReverse);
103 auto const toggle_visible = Gtk::make_managed<Gtk::CellRendererToggle>();
104 int visibleColNum =
_tree->append_column(_(
"Visible"), *toggle_visible) - 1;
105 Gtk::TreeViewColumn* col_visible =
_tree->get_column(visibleColNum);
106 toggle_visible->set_activatable(
true);
108 col_visible->add_attribute(toggle_visible->property_active(),
_model->_colVisible);
110 auto const text_renderer = Gtk::make_managed<Gtk::CellRendererText>();
111 int nameColNum =
_tree->append_column(_(
"Name"), *text_renderer) - 1;
112 Gtk::TreeView::Column *name_column =
_tree->get_column(nameColNum);
113 name_column->add_attribute(text_renderer->property_text(),
_model->_colLabel);
115 _tree->set_expander_column(*
_tree->get_column(nameColNum) );
118 _scroller = std::make_unique<Gtk::ScrolledWindow>();
122 _scroller->set_policy( Gtk::PolicyType::AUTOMATIC, Gtk::PolicyType::AUTOMATIC );
129 auto const iter =
_store->get_iter(path);
130 Gtk::TreeModel::Row row = *iter;
140 auto const iter =
_store->get_iter(path);
141 Gtk::TreeModel::Row row = *iter;
154 auto const vbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::VERTICAL);
155 auto const hbox = Gtk::make_managed<Gtk::Box>(Gtk::Orientation::HORIZONTAL);
167 auto const pIcon = Gtk::manage(
sp_get_icon_image(
"edit-clone", Gtk::IconSize::NORMAL));
168 auto const pButton = Gtk::make_managed<Gtk::Button>();
169 pButton->set_has_frame(
false);
170 pButton->set_child(*pIcon);
173 pButton->set_tooltip_text(_(
"Link to path in clipboard"));
177 auto const pIcon = Gtk::manage(
sp_get_icon_image(
"list-remove", Gtk::IconSize::NORMAL));
178 auto const pButton = Gtk::make_managed<Gtk::Button>();
179 pButton->set_has_frame(
false);
180 pButton->set_child(*pIcon);
183 pButton->set_tooltip_text(_(
"Remove Path"));
187 auto const pIcon = Gtk::manage(
sp_get_icon_image(
"go-down", Gtk::IconSize::NORMAL));
188 auto const pButton = Gtk::make_managed<Gtk::Button>();
189 pButton->set_has_frame(
false);
190 pButton->set_child(*pIcon);
193 pButton->set_tooltip_text(_(
"Move Down"));
197 auto const pIcon = Gtk::manage(
sp_get_icon_image(
"go-up", Gtk::IconSize::NORMAL));
198 auto const pButton = Gtk::make_managed<Gtk::Button>();
199 pButton->set_has_frame(
false);
200 pButton->set_child(*pIcon);
203 pButton->set_tooltip_text(_(
"Move Up"));
214 _tree->get_selection()->select(iter);
222 std::vector<SPObject *> objs;
223 for (
auto const &iter :
_vector) {
224 if (iter && iter->ref.isAttached()) {
225 SPObject *obj = iter->ref.getObject();
236 auto const iter =
_tree->get_selection()->get_selected();
238 Gtk::TreeModel::Row row = *iter;
242 for (
auto iter =
_vector.begin(); iter !=
_vector.end(); piter = iter, ++i, ++iter) {
243 if (*iter == row[
_model->_colObject]) {
257 auto const iter =
_tree->get_selection()->get_selected();
259 Gtk::TreeModel::Row row = *iter;
262 for (
auto iter =
_vector.begin(); iter !=
_vector.end(); ++i, ++iter) {
263 if (*iter == row[
_model->_colObject]) {
264 auto niter =
_vector.erase(iter);
281 auto const iter =
_tree->get_selection()->get_selected();
283 Gtk::TreeModel::Row row = *iter;
294 std::vector<Glib::ustring> pathsid = cm->
getElementsOfType(SP_ACTIVE_DESKTOP,
"svg:path");
295 std::vector<Glib::ustring> textsid = cm->
getElementsOfType(SP_ACTIVE_DESKTOP,
"svg:text");
296 pathsid.insert(pathsid.end(), textsid.begin(), textsid.end());
297 if (pathsid.empty()) {
301 bool foundOne =
false;
304 for (
auto const &iter :
_vector) {
310 os << iter->href.c_str() <<
"," << (iter->reversed ?
"1" :
"0") <<
"," << (iter->visibled ?
"1" :
"0");
313 for (
auto &&pathid : std::move(pathsid)) {
315 pathid.insert(pathid.begin(),
'#');
322 os << pathid.c_str() <<
",0,1";
337 for (
auto iter =
_vector.begin(); iter !=
_vector.end(); ++iter) {
364 Gtk::TreeModel::Row row = *iter;
365 if (row[
_model->_colObject] == pd) {
378 if (new_obj && is<SPItem>(new_obj)) {
401 std::optional<Geom::PathVector>
curve;
402 auto text = cast<SPText>(linked_obj);
403 if (
auto shape = cast<SPShape>(linked_obj)) {
404 auto lpe_item = cast<SPLPEItem>(linked_obj);
410 for (
auto const &i : lpelist) {
411 if (
auto const lpeobj = i->lpeobject) {
412 auto const lpe = lpeobj->get_lpe();
425 bool hidden = text->isHidden();
428 text->setHidden(
false);
429 curve = text->getNormalizedBpath();
430 text->setHidden(
true);
438 curve = text->getNormalizedBpath();
452 if (!
_updating && flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
453 SP_OBJECT_CHILD_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
480 auto const strarray = g_strsplit(strvalue,
"|", 0);
482 for (
auto iter = strarray; *iter !=
nullptr; ++iter) {
483 if ((*iter)[0] ==
'#') {
484 auto const substrarray = g_strsplit(*iter,
",", 0);
488 Glib::ustring
id = *substrarray;
489 if (tmpsuccessor && tmpsuccessor->
getId()) {
490 id = tmpsuccessor->
getId();
491 id.insert(
id.begin(),
'#');
494 *(substrarray) = g_strdup(
id.c_str());
497 w->href = *substrarray;
498 w->reversed = *(substrarray+1) !=
nullptr && (*(substrarray+1))[0] ==
'1';
500 w->visibled = *(substrarray+2) ==
nullptr || (*(substrarray+2))[0] ==
'1';
501 w->linked_changed_connection =
w->ref.changedSignal().connect(
503 w->ref.attach(
URI(
w->href.c_str()));
508 auto const iter =
_store->append();
509 Gtk::TreeModel::Row row = *iter;
514 row[
_model->_colReverse] =
w->reversed;
515 row[
_model->_colVisible] =
w->visibled;
518 g_strfreev (substrarray);
522 g_strfreev (strarray);
537 bool foundOne =
false;
538 for (
auto const &iter :
_vector) {
544 os << iter->href.c_str() <<
"," << (iter->reversed ?
"1" :
"0") <<
"," << (iter->visibled ?
"1" :
"0");
556 for (
auto const &iter :
_vector) {
557 SPObject *linked_obj = iter->ref.getObject();
bool empty() const
Check whether the vector contains any paths.
void makeUndoDone(Glib::ustring message)
LivePathEffectObject * getLPEObj()
Inkscape::Display::TemporaryItem * ownerlocator
void param_write_to_repr(const char *svgd)
Geom::PathVector _pathvector
sigc::connection linked_release_connection
sigc::connection linked_modified_connection
Gtk::Widget * param_newWidget() override
void on_reverse_toggled(const Glib::ustring &path)
void unlink(PathAndDirectionAndVisible *to)
std::vector< SPObject * > param_get_satellites() override
void linked_modified(SPObject *linked_obj, guint flags, PathAndDirectionAndVisible *to)
void on_link_button_click()
PathArrayParam(const Glib::ustring &label, const Glib::ustring &tip, const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr, Effect *effect)
void on_remove_button_click()
void linked_changed(SPObject *old_obj, SPObject *new_obj, PathAndDirectionAndVisible *to)
void linked_release(SPObject *release, PathAndDirectionAndVisible *to)
bool _updateLink(const Gtk::TreeModel::iterator &iter, PathAndDirectionAndVisible *pd)
bool _allow_only_bspline_spiro
std::unique_ptr< Gtk::TreeView > _tree
std::vector< PathAndDirectionAndVisible * > _vector
~PathArrayParam() override
Glib::RefPtr< Gtk::TreeStore > _store
bool param_readSVGValue(char const *strvalue) override
void on_up_button_click()
bool _selectIndex(const Gtk::TreeModel::iterator &iter, int *i)
Glib::ustring param_getDefaultSVGValue() const override
void on_down_button_click()
void param_set_default() override
void setPathVector(SPObject *linked_obj, guint flags, PathAndDirectionAndVisible *to)
Glib::ustring param_getSVGValue() const override
std::unique_ptr< Gtk::ScrolledWindow > _scroller
std::unique_ptr< ModelColumns > _model
void on_visible_toggled(const Glib::ustring &path)
System-wide clipboard manager.
virtual std::vector< Glib::ustring > getElementsOfType(SPDesktop *desktop, gchar const *type="*", gint maxdepth=-1)=0
static ClipboardManager * get()
SPObject * getObject() const
Returns a pointer to the current referrent of the attached URI, or NULL.
void detach()
Detaches from the currently attached URI target, if any; the current referrent is signaled as NULL.
Represents an URI as per RFC 2396.
To do: update description of desktop.
SPObject * getObjectByHref(std::string const &href) const
SPObject is an abstract base class of all of the document nodes at the SVG document level.
char const * label() const
Gets the author-visible label property for the object or a default if no label is defined.
void requestModified(unsigned int flags)
Requests that a modification notification signal be emitted later (e.g.
char const * getId() const
Returns the objects current ID string.
sigc::connection connectRelease(sigc::slot< void(SPObject *)> slot)
Connects to the release request signal.
sigc::connection connectModified(sigc::slot< void(SPObject *, unsigned int)> slot)
Connects to the modification notification signal.
System-wide clipboard management - class declaration.
auto ptr_to_opt(T const &p)
Create a std::optional<T> from a (generalised) pointer to T.
Gtk::Image * sp_get_icon_image(Glib::ustring const &icon_name, int size)
void sp_bspline_do_effect(Geom::PathVector &curve, double helper_size, Geom::PathVector &hp, bool uniform)
void sp_spiro_do_effect(Geom::PathVector &curve)
void pack_end(Gtk::Box &box, Gtk::Widget &child, bool const expand, bool const fill, unsigned const padding)
Adds child to box, packed with reference to the end of box.
void pack_start(Gtk::Box &box, Gtk::Widget &child, bool const expand, bool const fill, unsigned const padding)
Adds child to box, packed with reference to the start of box.
static cairo_user_data_key_t key
Helpers for using Gtk::Boxes, encapsulating large changes between GTK3 & GTK4.
std::list< PathEffectSharedPtr > PathEffectList
TODO: insert short description here.