18#include <glibmm/i18n.h>
19#include <gtkmm/liststore.h>
20#include <gtkmm/scrolledwindow.h>
21#include <gtkmm/treeview.h>
22#include <sigc++/adaptors/bind.h>
23#include <sigc++/functors/mem_fun.h>
43 btn->set_image_from_icon_name(iconName, Gtk::IconSize::NORMAL);
44 btn->set_has_frame(
false);
56 _vectors = Gtk::make_managed<GradientVectorSelector>(
nullptr,
nullptr);
60 _treeview = Gtk::make_managed<Gtk::TreeView>();
69 auto icon_column =
_treeview->get_column(0);
72 icon_column->set_clickable(
true);
75 auto name_column =
_treeview->get_column(1);
78 name_column->set_min_width(180);
79 name_column->set_clickable(
true);
80 name_column->set_resizable(
true);
83 auto count_column =
_treeview->get_column(2);
84 count_column->set_clickable(
true);
85 count_column->set_resizable(
true);
87 Controller::add_key<&GradientSelector::onKeyPressed>(*
_treeview, *
this);
101 _scrolled_window->set_policy(Gtk::PolicyType::AUTOMATIC, Gtk::PolicyType::AUTOMATIC);
114 _add = Gtk::make_managed<Gtk::Button>();
121 _add->set_sensitive(
false);
122 _add->set_has_frame(
false);
123 _add->set_tooltip_text(_(
"Create a duplicate gradient"));
125 _del2 = Gtk::make_managed<Gtk::Button>();
131 _del2->set_sensitive(
false);
132 _del2->set_has_frame(
false);
133 _del2->set_tooltip_text(_(
"Delete unused gradient"));
136 _edit = Gtk::make_managed<Gtk::Button>();
142 _edit->set_sensitive(
false);
143 _edit->set_has_frame(
false);
144 _edit->set_tooltip_text(_(
"Edit gradient"));
145 _edit->set_visible(
false);
147 _del = Gtk::make_managed<Gtk::Button>();
153 _del->set_sensitive(
false);
154 _del->set_has_frame(
false);
155 _del->set_tooltip_text(_(
"Delete swatch"));
172 it->set_visible(
false);
175 swatch_widget->set_visible(
true);
178 auto icon_column =
_treeview->get_column(0);
179 icon_column->set_title(_(
"Swatch"));
184 it->set_visible(
true);
187 swatch_widget->set_visible(
false);
189 auto icon_column =
_treeview->get_column(0);
190 icon_column->set_title(_(
"Gradient"));
203 Gtk::TreePath path(path_string);
204 auto iter =
_store->get_iter(path);
207 Gtk::TreeModel::Row row = *iter;
242 auto select =
_treeview->get_selection();
243 auto iter = select->get_selected();
256 while (canary && (toEnd || amount > 0)) {
267 select->select(iter);
272 unsigned ,
unsigned const keycode,
273 GdkModifierType
const state)
275 auto display = Gdk::Display::get_default();
277 gdk_display_translate_key(gdk_display_get_default(),
292 case GDK_KEY_KP_Down:
296 case GDK_KEY_Page_Up:
297 case GDK_KEY_KP_Page_Up:
301 case GDK_KEY_Page_Down:
302 case GDK_KEY_KP_Page_Down:
312 case GDK_KEY_KP_Home:
338 const auto sel =
_treeview->get_selection();
345 auto iter = sel->get_selected();
347 Gtk::TreeModel::Row row = *iter;
359 const auto sel =
_treeview->get_selection();
366 auto iter = sel->get_selected();
368 Gtk::TreeModel::Row row = *iter;
380 Gtk::TreeModel::Row row = *iter;
383 auto select =
_treeview->get_selection();
386 select->select(iter);
401 g_return_if_fail(!vector || (vector->
document == doc));
403 if (vector && !vector->
hasStops()) {
415 it->set_visible(
false);
419 it->set_visible(
true);
425 swatch_widget->set_visible(
false);
428 it->set_visible(
true);
433 _edit->set_sensitive(
true);
436 _add->set_sensitive(
true);
439 _del->set_sensitive(
true);
444 _edit->set_sensitive(
false);
447 _add->set_sensitive(doc !=
nullptr);
450 _del->set_sensitive(
false);
453 _del2->set_sensitive(
false);
476 const auto selection =
_treeview->get_selection();
483 Gtk::TreeModel::iterator iter = selection->get_selected();
485 Gtk::TreeModel::Row row = *iter;
490 if (
auto repr = obj->
getRepr()) {
500 selection->select(move);
509 const auto selection =
_treeview->get_selection();
516 Gtk::TreeModel::iterator iter = selection->get_selected();
518 Gtk::TreeModel::Row row = *iter;
523 std::string
id = obj->
getId();
548 repr = gr->getRepr()->
duplicate(xml_doc);
551 gr->setAttribute(
"id", new_id.c_str());
552 doc->getDefs()->getRepr()->addChild(repr,
nullptr);
557 stop->
setAttribute(
"style",
"stop-color:#000;stop-opacity:1;");
562 stop->
setAttribute(
"style",
"stop-color:#fff;stop-opacity:1;");
565 doc->getDefs()->getRepr()->addChild(repr,
nullptr);
566 gr = cast<SPGradient>(doc->getObjectByRepr(repr));
580 _edit->set_visible(show);
584 auto name_column =
_treeview->get_column(1);
585 name_column->set_min_width(min_width);
static void done(SPDocument *document, Glib::ustring const &event_description, Glib::ustring const &undo_icon)
Interface for refcounted XML nodes.
virtual void appendChild(Node *child)=0
Append a node as the last child of this node.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
virtual Node * duplicate(Document *doc) const =0
Create a duplicate of this node.
void removeAttribute(Inkscape::Util::const_char_ptr key)
Remove an attribute of this node.
Typed SVG document implementation.
SPObject is an abstract base class of all of the document nodes at the SVG document level.
void setAttribute(Inkscape::Util::const_char_ptr key, Inkscape::Util::const_char_ptr value)
char const * getId() const
Returns the objects current ID string.
void setLabel(char const *label)
Sets the author-visible label for this object.
Inkscape::XML::Node * getRepr()
Returns the XML representation of tree.
Utilities to more easily use Gtk::EventController & subclasses like Gesture.
TODO: insert short description here.
void sp_gradient_unset_swatch(SPDesktop *desktop, std::string const &id)
int sp_get_gradient_refcount(SPDocument *document, SPGradient *gradient)
SPGradient * sp_gradient_ensure_vector_normalized(SPGradient *gr)
Either normalizes given gradient to vector, or returns fresh normalized vector - in latter case,...
Glib::ustring gr_prepare_label(SPObject *obj)
Macro for icon names used in Inkscape.
Glib::ustring generate_similar_unique_id(SPDocument *document, const Glib::ustring &base_name)
Modify 'base_name' to create a new ID that is not used in the 'document'.
TODO: insert short description here.
static R & release(R &r)
Decrements the reference count of a anchored object.
Button
helper to stop accidents on int vs gtkmm3's weak=typed enums, & looks nicer!
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.
@ HORIZONTAL
The x-dimension (0).
@ VERTICAL
The y-dimension (1).
static cairo_user_data_key_t key
Helpers for using Gtk::Boxes, encapsulating large changes between GTK3 & GTK4.
Singleton class to access the preferences file in a convenient way.
@ SP_GRADIENT_UNITS_USERSPACEONUSE
Interface for XML documents.
virtual Node * createElement(char const *name)=0