22#include <glibmm/i18n.h>
23#include <gtkmm/comboboxtext.h>
24#include <gtkmm/liststore.h>
25#include <gtkmm/messagedialog.h>
26#include <gtkmm/togglebutton.h>
53std::vector<SPMeshGradient *> ms_get_dt_selected_gradients(Selection *selection)
55 std::vector<SPMeshGradient *> ms_selected;
58 bool edit_fill = prefs->getBool(
"/tools/mesh/edit_fill",
true);
59 bool edit_stroke = prefs->getBool(
"/tools/mesh/edit_stroke",
true);
67 if (edit_fill && style->fill.isPaintserver()) {
69 if (
auto mesh = cast<SPMeshGradient>(server)) {
70 ms_selected.push_back(mesh);
74 if (edit_stroke && style->stroke.isPaintserver()) {
76 if (
auto mesh = cast<SPMeshGradient>(server)) {
77 ms_selected.push_back(mesh);
88void ms_read_selection(Selection *selection,
90 bool &ms_selected_multi,
94 ms_selected =
nullptr;
95 ms_selected_multi =
false;
97 ms_type_multi =
false;
102 for (
auto const &mesh : ms_get_dt_selected_gradients(selection)) {
105 ms_type = mesh->
type;
108 if (ms_selected != mesh) {
109 ms_selected_multi =
true;
111 if (ms_type != mesh->type) {
112 ms_type_multi =
true;
136 auto store = Gtk::ListStore::create(columns);
137 Gtk::TreeModel::Row row;
139 row = *
store->append();
140 row[columns.
col_label] = C_(
"Type",
"Coons");
143 row = *
store->append();
150 _(
"Coons: no smoothing. Bicubic: smoothing across patch boundaries."),
"Not Used",
store));
192 auto &btn =
dynamic_cast<Gtk::ToggleButton &
>(
item);
193 btn.set_active(btn_index ==
mode);
198 mode = prefs->getInt(
"/tools/mesh/newfillorstroke");
202 auto &btn =
dynamic_cast<Gtk::ToggleButton &
>(
item);
203 btn.set_active(btn_index ==
mode);
204 btn.signal_clicked().connect(
224 get_widget<Gtk::Button>(
builder,
"toggle_sides_btn")
227 get_widget<Gtk::Button>(
builder,
"make_elliptical_btn")
230 get_widget<Gtk::Button>(
builder,
"pick_colors_btn")
233 get_widget<Gtk::Button>(
builder,
"scale_mesh_btn")
237 get_widget<Gtk::Button>(
builder,
"warning_btn").signal_clicked().connect([
this] {
warning_popup(); });
271 auto const path =
"/tools/mesh/" +
name;
274 auto adj = btn.get_adjustment();
276 adj->signal_value_changed().connect(sigc::mem_fun(*
this, value_changed_mem_fun));
299 int rows =
_row_item.get_adjustment()->get_value();
312 int cols =
_col_item.get_adjustment()->get_value();
320 prefs->setBool(
"/tools/mesh/edit_fill",
_edit_fill_btn->get_active());
324 auto drag = mt->get_drag();
325 drag->updateDraggers();
327 drag->updateLevels();
338 mt->get_drag()->refreshDraggers();
359 bool ms_selected_multi =
false;
360 bool ms_type_multi =
false;
361 ms_read_selection(selection, ms_selected, ms_selected_multi, ms_type, ms_type_multi);
373 char *
msg = _(
"Mesh gradients are part of SVG 2:\n"
374 "* Syntax may change.\n"
375 "* Web browser implementation is not guaranteed.\n"
377 "For web: convert to bitmap (Edit->Make bitmap copy).\n"
378 "For print: export to PDF.");
379 auto dialog = std::make_unique<Gtk::MessageDialog>(
msg,
false, Gtk::MessageType::WARNING, Gtk::ButtonsType::OK,
true);
393 auto meshes = ms_get_dt_selected_gradients(selection);
396 for (
auto &mesh : meshes) {
398 mesh->type_set =
true;
402 if (!meshes.empty()) {
431 mt->fit_mesh_in_bbox();
static void done(SPDocument *document, Glib::ustring const &event_description, Glib::ustring const &undo_icon, unsigned int object_modified_tag=0)
double getDouble(Glib::ustring const &pref_path, double def=0.0, Glib::ustring const &unit="")
Retrieve a floating point value.
static Preferences * get()
Access the singleton Preferences object.
void setInt(Glib::ustring const &pref_path, int value)
Set an integer value.
A simple mediator class that sets the state of a Gtk::ToggleButton when a preference is changed.
To do: update description of desktop.
SPDocument * getDocument() const
Inkscape::Selection * getSelection() const
Inkscape::UI::Tools::ToolBase * getTool() const
sigc::connection connectModified(ModifiedSignal::slot_type slot)
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
SPPaintServer * getFillPaintServer()
SPPaintServer * getStrokePaintServer()
Editable view implementation.
TODO: insert short description here.
Macro for icon names used in Inkscape.
void dialog_show_modal_and_selfdestruct(std::unique_ptr< Gtk::Dialog > dialog, Gtk::Root *root)
Show a dialog modally, destroying it when the user dismisses it.
W & get_widget(const Glib::RefPtr< Gtk::Builder > &builder, const char *id)
Gtk::Widget * for_each_child(Gtk::Widget &widget, Func &&func, bool const plus_self=false, bool const recurse=false, int const level=0)
Call Func with a reference to each child of parent, until it returns _break.
W & get_derived_widget(const Glib::RefPtr< Gtk::Builder > &builder, const char *id, Args &&... args)
Glib::RefPtr< Gtk::Builder > create_builder(const char *filename)
@ SP_MESH_GEOMETRY_NORMAL
SPMeshType
A group of classes and functions for manipulating mesh gradients.
TODO: insert short description here.
SPStyle - a style object for SPItem objects.
Glib::RefPtr< Gtk::Builder > builder