From 1636c1dd1651780d01759676b194312529f211f7 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Sat, 25 Jun 2016 22:24:26 +0200 Subject: Moved next functions, added namespace, renamed range functions (bzr r14954.1.10) --- src/widgets/mesh-toolbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets/mesh-toolbar.cpp') diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 3643ce00c..5d326253c 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -89,7 +89,7 @@ void ms_read_selection( Inkscape::Selection *selection, bool first = true; ms_type = SP_MESH_TYPE_COONS; - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i; SPStyle *style = item->style; @@ -216,7 +216,7 @@ void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMesh *&ms_sel { SPMesh *gradient = 0; - std::vector itemlist=selection->itemList(); + std::vector itemlist= selection->items(); for(std::vector::const_iterator i=itemlist.begin();i!=itemlist.end();++i){ SPItem *item = *i;// get the items gradient, not the getVector() version SPStyle *style = item->style; -- cgit v1.2.3 From f35bb1f74a0ffeb5c6477a25e3c4cde87a97bcf1 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 12:06:06 +0200 Subject: Removed unused includes, decrease compilation time (bzr r15025) --- src/widgets/mesh-toolbar.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'src/widgets/mesh-toolbar.cpp') diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 3643ce00c..1e5c12d41 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include #endif // REVIEW THESE AT END OF REWRITE @@ -25,17 +25,13 @@ #include "verbs.h" -#include "macros.h" #include "widgets/button.h" -#include "widgets/widget-sizes.h" -#include "widgets/spw-utilities.h" #include "widgets/spinbutton-events.h" #include "widgets/gradient-vector.h" #include "widgets/gradient-image.h" #include "style.h" #include "inkscape.h" -#include "preferences.h" #include "document-private.h" #include "document-undo.h" #include "desktop.h" @@ -47,23 +43,16 @@ #include "gradient-drag.h" #include "sp-mesh.h" #include "gradient-chemistry.h" -#include "gradient-selector.h" -#include "selection.h" #include "ui/icon-names.h" #include "widgets/ege-adjustment-action.h" -#include "widgets/ege-output-action.h" #include "widgets/ege-select-one-action.h" #include "widgets/ink-action.h" -#include "widgets/ink-comboboxentry-action.h" #include "sp-stop.h" #include "svg/css-ostringstream.h" -#include "svg/svg-color.h" #include "desktop-style.h" -#include "toolbox.h" - using Inkscape::DocumentUndo; using Inkscape::UI::ToolboxFactory; using Inkscape::UI::PrefPusher; -- cgit v1.2.3 From 43b49e325db73cc19b1731db6c69545664ee8fbe Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Thu, 28 Jul 2016 13:26:17 +0200 Subject: Reverted changes to r15024 after many building problems (bzr r15027) --- src/widgets/mesh-toolbar.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/widgets/mesh-toolbar.cpp') diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 1e5c12d41..3643ce00c 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -#include +# include "config.h" #endif // REVIEW THESE AT END OF REWRITE @@ -25,13 +25,17 @@ #include "verbs.h" +#include "macros.h" #include "widgets/button.h" +#include "widgets/widget-sizes.h" +#include "widgets/spw-utilities.h" #include "widgets/spinbutton-events.h" #include "widgets/gradient-vector.h" #include "widgets/gradient-image.h" #include "style.h" #include "inkscape.h" +#include "preferences.h" #include "document-private.h" #include "document-undo.h" #include "desktop.h" @@ -43,16 +47,23 @@ #include "gradient-drag.h" #include "sp-mesh.h" #include "gradient-chemistry.h" +#include "gradient-selector.h" +#include "selection.h" #include "ui/icon-names.h" #include "widgets/ege-adjustment-action.h" +#include "widgets/ege-output-action.h" #include "widgets/ege-select-one-action.h" #include "widgets/ink-action.h" +#include "widgets/ink-comboboxentry-action.h" #include "sp-stop.h" #include "svg/css-ostringstream.h" +#include "svg/svg-color.h" #include "desktop-style.h" +#include "toolbox.h" + using Inkscape::DocumentUndo; using Inkscape::UI::ToolboxFactory; using Inkscape::UI::PrefPusher; -- cgit v1.2.3 From 35830f456cadaecf8b8e3944e3031a1a93f6cb41 Mon Sep 17 00:00:00 2001 From: Adrian Boguszewski Date: Wed, 3 Aug 2016 15:29:38 +0200 Subject: Removed unused includes, decreased compilation time. Once again (bzr r15034) --- src/widgets/mesh-toolbar.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'src/widgets/mesh-toolbar.cpp') diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 3643ce00c..1e5c12d41 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -15,7 +15,7 @@ */ #ifdef HAVE_CONFIG_H -# include "config.h" +#include #endif // REVIEW THESE AT END OF REWRITE @@ -25,17 +25,13 @@ #include "verbs.h" -#include "macros.h" #include "widgets/button.h" -#include "widgets/widget-sizes.h" -#include "widgets/spw-utilities.h" #include "widgets/spinbutton-events.h" #include "widgets/gradient-vector.h" #include "widgets/gradient-image.h" #include "style.h" #include "inkscape.h" -#include "preferences.h" #include "document-private.h" #include "document-undo.h" #include "desktop.h" @@ -47,23 +43,16 @@ #include "gradient-drag.h" #include "sp-mesh.h" #include "gradient-chemistry.h" -#include "gradient-selector.h" -#include "selection.h" #include "ui/icon-names.h" #include "widgets/ege-adjustment-action.h" -#include "widgets/ege-output-action.h" #include "widgets/ege-select-one-action.h" #include "widgets/ink-action.h" -#include "widgets/ink-comboboxentry-action.h" #include "sp-stop.h" #include "svg/css-ostringstream.h" -#include "svg/svg-color.h" #include "desktop-style.h" -#include "toolbox.h" - using Inkscape::DocumentUndo; using Inkscape::UI::ToolboxFactory; using Inkscape::UI::PrefPusher; -- cgit v1.2.3 From a0cacd78d5d987eafa3739bb8f45587d82246780 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Fri, 5 Aug 2016 19:07:48 +0100 Subject: Split InkAction classes into separate files (bzr r15043) --- src/widgets/mesh-toolbar.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/widgets/mesh-toolbar.cpp') diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 1e5c12d41..3bc6cb288 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -47,7 +47,9 @@ #include "widgets/ege-adjustment-action.h" #include "widgets/ege-select-one-action.h" -#include "widgets/ink-action.h" +#include "ink-action.h" +#include "ink-radio-action.h" +#include "ink-toggle-action.h" #include "sp-stop.h" #include "svg/css-ostringstream.h" -- cgit v1.2.3 From f9ec83dbb254701f39d3b7a30c0bacb5eaae9ee9 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 27 Sep 2016 10:51:26 +0200 Subject: Rename to per SVG 2 CR specificiation. Note: has been repurposed to be a special shape that tightly wraps a mesh gradient. (bzr r15137) --- src/widgets/mesh-toolbar.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/widgets/mesh-toolbar.cpp') diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index fb540b5f5..0e689fee0 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -41,7 +41,7 @@ #include "ui/tools/gradient-tool.h" #include "ui/tools/mesh-tool.h" #include "gradient-drag.h" -#include "sp-mesh.h" +#include "sp-mesh-gradient.h" #include "gradient-chemistry.h" #include "ui/icon-names.h" @@ -70,7 +70,7 @@ static bool blocked = false; * Get the current selection and dragger status from the desktop */ void ms_read_selection( Inkscape::Selection *selection, - SPMesh *&ms_selected, + SPMeshGradient *&ms_selected, bool &ms_selected_multi, SPMeshType &ms_type, bool &ms_type_multi ) @@ -87,9 +87,9 @@ void ms_read_selection( Inkscape::Selection *selection, if (style && (style->fill.isPaintserver())) { SPPaintServer *server = item->style->getFillPaintServer(); - if ( SP_IS_MESH(server) ) { + if ( SP_IS_MESHGRADIENT(server) ) { - SPMesh *gradient = SP_MESH(server); // ->getVector(); + SPMeshGradient *gradient = SP_MESHGRADIENT(server); // ->getVector(); SPMeshType type = gradient->type; if (gradient != ms_selected) { @@ -112,9 +112,9 @@ void ms_read_selection( Inkscape::Selection *selection, if (style && (style->stroke.isPaintserver())) { SPPaintServer *server = item->style->getStrokePaintServer(); - if ( SP_IS_MESH(server) ) { + if ( SP_IS_MESHGRADIENT(server) ) { - SPMesh *gradient = SP_MESH(server); // ->getVector(); + SPMeshGradient *gradient = SP_MESHGRADIENT(server); // ->getVector(); SPMeshType type = gradient->type; if (gradient != ms_selected) { @@ -164,7 +164,7 @@ static void ms_tb_selection_changed(Inkscape::Selection * /*selection*/, gpointe // // Hide/show handles? // } - SPMesh *ms_selected = 0; + SPMeshGradient *ms_selected = 0; SPMeshType ms_type = SP_MESH_TYPE_COONS; bool ms_selected_multi = false; bool ms_type_multi = false; @@ -203,9 +203,9 @@ static void ms_defs_modified(SPObject * /*defs*/, guint /*flags*/, GObject *widg ms_tb_selection_changed(NULL, widget); } -void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMesh *&ms_selected) +void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMeshGradient *&ms_selected) { - SPMesh *gradient = 0; + SPMeshGradient *gradient = 0; auto itemlist= selection->items(); for(auto i=itemlist.begin();i!=itemlist.end();++i){ @@ -220,8 +220,8 @@ void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMesh *&ms_sel server = item->style->getStrokePaintServer(); } - if ( SP_IS_MESH(server) ) { - gradient = SP_MESH(server); + if ( SP_IS_MESHGRADIENT(server) ) { + gradient = SP_MESHGRADIENT(server); } } @@ -295,7 +295,7 @@ static void ms_type_changed(EgeSelectOneAction *act, GtkWidget *widget) SPDesktop *desktop = static_cast(g_object_get_data(G_OBJECT(widget), "desktop")); Inkscape::Selection *selection = desktop->getSelection(); - SPMesh *gradient = 0; + SPMeshGradient *gradient = 0; ms_get_dt_selected_gradient(selection, gradient); if (gradient) { -- cgit v1.2.3 From 619f8b5d9173f2bcc9d9aefccee832d686724e79 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 17 Oct 2016 15:04:09 +0200 Subject: Add option to scale mesh to fit in bounding box. (bzr r15173) --- src/widgets/mesh-toolbar.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/widgets/mesh-toolbar.cpp') diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 0e689fee0..898104ad3 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -348,6 +348,14 @@ static void ms_pick_colors(void) } } +static void ms_fit_mesh(void) +{ + MeshTool *mt = get_mesh_tool(); + if (mt) { + sp_mesh_context_fit_mesh_in_bbox( mt ); + } +} + static void mesh_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder); /** @@ -557,6 +565,17 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj } + { + InkAction* act = ink_action_new( "MeshFitInBoundingBoxAction", + _("Scale mesh to bounding box:"), + _("Scale mesh to fit inside bounding box."), + INKSCAPE_ICON("mesh-gradient-fit"), + secondarySize ); + g_object_set( act, "short_label", _("Fit mesh"), NULL ); + g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_fit_mesh), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); + } + } static void mesh_toolbox_watch_ec(SPDesktop* desktop, Inkscape::UI::Tools::ToolBase* ec, GObject* holder) -- cgit v1.2.3 From 430533b9a259eb3dac44755306dfb0fddb34951d Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 8 Nov 2016 15:05:30 +0100 Subject: Improve mesh handling in Fill and Stroke dialog. Create new meshes with alternating color/white pattern (makes it more obvious a mesh has been created). (bzr r15229) --- src/widgets/mesh-toolbar.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'src/widgets/mesh-toolbar.cpp') diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 898104ad3..a960782cb 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -36,6 +36,7 @@ #include "document-undo.h" #include "desktop.h" +#include #include #include "ui/tools/gradient-tool.h" @@ -356,6 +357,20 @@ static void ms_fit_mesh(void) } } +static void ms_warning_popup(void) +{ + char *msg = _("Mesh gradients are part of SVG 2:\n" + "* Syntax may change.\n" + "* Web browser implementation is not guaranteed.\n" + "\n" + "For web: convert to bitmap (Edit->Make bitmap copy).\n" + "For print: export to PDF."); + Gtk::MessageDialog dialog(msg, false, Gtk::MESSAGE_WARNING, + Gtk::BUTTONS_OK, true); + dialog.run(); + +} + static void mesh_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder); /** @@ -504,9 +519,14 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj /* Warning */ { - GtkAction* act = gtk_action_new( "MeshWarningAction", - _("WARNING: Mesh SVG Syntax Subject to Change"), NULL, NULL ); + InkAction* act = ink_action_new( "MeshWarningAction", + _("WARNING: Mesh SVG Syntax Subject to Change"), + _("WARNING: Mesh SVG Syntax Subject to Change"), + INKSCAPE_ICON("dialog-warning"), + secondarySize ); gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); + g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_warning_popup), holder ); + gtk_action_set_sensitive( GTK_ACTION(act), TRUE ); } /* Type */ -- cgit v1.2.3 From d87cfa4971963dfb8118ce31e169854fce85bccd Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 1 Dec 2016 14:05:02 +0100 Subject: Add toggles for handle visibility, editing fill, and editing stroke. (bzr r15289) --- src/widgets/mesh-toolbar.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src/widgets/mesh-toolbar.cpp') diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index a960782cb..f7b7a6ec9 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -357,6 +357,26 @@ static void ms_fit_mesh(void) } } +static void ms_toggle_handles(void) +{ + MeshTool *mt = get_mesh_tool(); + if (mt) { + GrDrag *drag = mt->_grdrag; + drag->refreshDraggers(); + } +} + +static void ms_toggle_fill_stroke(void) +{ + MeshTool *mt = get_mesh_tool(); + if (mt) { + GrDrag *drag = mt->_grdrag; + drag->updateDraggers(); + drag->updateLines(); + drag->updateLevels(); + } +} + static void ms_warning_popup(void) { char *msg = _("Mesh gradients are part of SVG 2:\n" @@ -487,6 +507,7 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/mesh/edit_fill"); g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); + g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_toggle_fill_stroke), 0); } /* Edit stroke mesh */ @@ -499,18 +520,20 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/mesh/edit_stroke"); g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); + g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_toggle_fill_stroke), 0); } /* Show/hide side and tensor handles */ { InkToggleAction* act = ink_toggle_action_new( "MeshShowHandlesAction", _("Show Handles"), - _("Show side and tensor handles"), + _("Show handles"), INKSCAPE_ICON("show-node-handles"), secondarySize ); gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/mesh/show_handles"); g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); + g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_toggle_handles), 0); } g_object_set_data(holder, "desktop", desktop); -- cgit v1.2.3 From 1fd1dd7808cf71640e9f8ec418f37b2a08088866 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Thu, 8 Dec 2016 14:13:14 +0100 Subject: Improve working of Type (Smoothing) menu. (bzr r15312) --- src/widgets/mesh-toolbar.cpp | 165 ++++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 95 deletions(-) (limited to 'src/widgets/mesh-toolbar.cpp') diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index f7b7a6ec9..ea0faf1df 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -67,76 +67,79 @@ static bool blocked = false; //## Mesh ## //######################## -/* - * Get the current selection and dragger status from the desktop - */ -void ms_read_selection( Inkscape::Selection *selection, - SPMeshGradient *&ms_selected, - bool &ms_selected_multi, - SPMeshType &ms_type, - bool &ms_type_multi ) + +// Get a list of selected meshes taking into account fill/stroke toggles +std::vector ms_get_dt_selected_gradients(Inkscape::Selection *selection) { + std::vector ms_selected; + + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool edit_fill = prefs->getBool("/tools/mesh/edit_fill", true); + bool edit_stroke = prefs->getBool("/tools/mesh/edit_stroke", true); - // Read desktop selection - bool first = true; - ms_type = SP_MESH_TYPE_COONS; - auto itemlist= selection->items(); for(auto i=itemlist.begin();i!=itemlist.end();++i){ - SPItem *item = *i; + SPItem *item = *i;// get the items gradient, not the getVector() version SPStyle *style = item->style; - if (style && (style->fill.isPaintserver())) { - SPPaintServer *server = item->style->getFillPaintServer(); - if ( SP_IS_MESHGRADIENT(server) ) { - - SPMeshGradient *gradient = SP_MESHGRADIENT(server); // ->getVector(); - SPMeshType type = gradient->type; + if (style) { - if (gradient != ms_selected) { - if (ms_selected) { - ms_selected_multi = true; - } else { - ms_selected = gradient; - } + + if (edit_fill && style->fill.isPaintserver()) { + SPPaintServer *server = item->style->getFillPaintServer(); + SPMeshGradient *mesh = dynamic_cast(server); + if (mesh) { + ms_selected.push_back(mesh); } - if( type != ms_type ) { - if (ms_type != SP_MESH_TYPE_COONS && !first) { - ms_type_multi = true; - } else { - ms_type = type; - } + } + + if (edit_stroke && style->stroke.isPaintserver()) { + SPPaintServer *server = item->style->getStrokePaintServer(); + SPMeshGradient *mesh = dynamic_cast(server); + if (mesh) { + ms_selected.push_back(mesh); } - first = false; } } - if (style && (style->stroke.isPaintserver())) { - SPPaintServer *server = item->style->getStrokePaintServer(); - if ( SP_IS_MESHGRADIENT(server) ) { + } + return ms_selected; +} - SPMeshGradient *gradient = SP_MESHGRADIENT(server); // ->getVector(); - SPMeshType type = gradient->type; - if (gradient != ms_selected) { - if (ms_selected) { - ms_selected_multi = true; - } else { - ms_selected = gradient; - } - } - if( type != ms_type ) { - if (ms_type != SP_MESH_TYPE_COONS && !first) { - ms_type_multi = true; - } else { - ms_type = type; - } - } - first = false; +/* + * Get the current selection status from the desktop + */ +void ms_read_selection( Inkscape::Selection *selection, + SPMeshGradient *&ms_selected, + bool &ms_selected_multi, + SPMeshType &ms_type, + bool &ms_type_multi ) +{ + ms_selected = NULL; + ms_selected_multi = false; + ms_type = SP_MESH_TYPE_COONS; + ms_type_multi = false; + + bool first = true; + + // Read desktop selection, taking into account fill/stroke toggles + std::vector meshes = ms_get_dt_selected_gradients( selection ); + for (auto i = meshes.begin(); i != meshes.end(); ++i) { + if (first) { + ms_selected = (*i); + ms_type = (*i)->type; + first = false; + } else { + if (ms_selected != (*i)) { + ms_selected_multi = true; + } + if (ms_type != (*i)->type) { + ms_type_multi = true; } } } - } +} /* * Core function, setup all the widgets whenever something changes on the desktop @@ -173,7 +176,7 @@ static void ms_tb_selection_changed(Inkscape::Selection * /*selection*/, gpointe // std::cout << " type: " << ms_type << std::endl; EgeSelectOneAction* type = (EgeSelectOneAction *) g_object_get_data(G_OBJECT(widget), "mesh_select_type_action"); - gtk_action_set_sensitive( GTK_ACTION(type), (ms_selected && !ms_selected_multi) ); + gtk_action_set_sensitive( GTK_ACTION(type), (ms_selected && !ms_type_multi) ); if (ms_selected) { blocked = TRUE; ege_select_one_action_set_active( type, ms_type ); @@ -204,34 +207,6 @@ static void ms_defs_modified(SPObject * /*defs*/, guint /*flags*/, GObject *widg ms_tb_selection_changed(NULL, widget); } -void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMeshGradient *&ms_selected) -{ - SPMeshGradient *gradient = 0; - - auto itemlist= selection->items(); - for(auto i=itemlist.begin();i!=itemlist.end();++i){ - SPItem *item = *i;// get the items gradient, not the getVector() version - SPStyle *style = item->style; - SPPaintServer *server = 0; - - if (style && (style->fill.isPaintserver())) { - server = item->style->getFillPaintServer(); - } - if (style && (style->stroke.isPaintserver())) { - server = item->style->getStrokePaintServer(); - } - - if ( SP_IS_MESHGRADIENT(server) ) { - gradient = SP_MESHGRADIENT(server); - } - } - - if (gradient) { - ms_selected = gradient; - } -} - - /* * Callback functions for user actions */ @@ -296,18 +271,17 @@ static void ms_type_changed(EgeSelectOneAction *act, GtkWidget *widget) SPDesktop *desktop = static_cast(g_object_get_data(G_OBJECT(widget), "desktop")); Inkscape::Selection *selection = desktop->getSelection(); - SPMeshGradient *gradient = 0; - ms_get_dt_selected_gradient(selection, gradient); + std::vector meshes = ms_get_dt_selected_gradients(selection); - if (gradient) { - SPMeshType type = (SPMeshType) ege_select_one_action_get_active(act); + SPMeshType type = (SPMeshType) ege_select_one_action_get_active(act); + for (auto i = meshes.begin(); i != meshes.end(); ++i) { // std::cout << " type: " << type << std::endl; - gradient->type = type; - gradient->type_set = true; - gradient->updateRepr(); - - DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH, - _("Set mesh type")); + (*i)->type = type; + (*i)->type_set = true; + (*i)->updateRepr(); + } + if (!meshes.empty() ) { + DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH,_("Set mesh type")); } } @@ -366,7 +340,7 @@ static void ms_toggle_handles(void) } } -static void ms_toggle_fill_stroke(void) +static void ms_toggle_fill_stroke(InkToggleAction * /*act*/, gpointer data) { MeshTool *mt = get_mesh_tool(); if (mt) { @@ -374,6 +348,7 @@ static void ms_toggle_fill_stroke(void) drag->updateDraggers(); drag->updateLines(); drag->updateLevels(); + ms_tb_selection_changed(NULL, data); // Need to update Type widget } } @@ -507,7 +482,7 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/mesh/edit_fill"); g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); - g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_toggle_fill_stroke), 0); + g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_toggle_fill_stroke), holder); } /* Edit stroke mesh */ @@ -520,7 +495,7 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/mesh/edit_stroke"); g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); - g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_toggle_fill_stroke), 0); + g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_toggle_fill_stroke), holder); } /* Show/hide side and tensor handles */ -- cgit v1.2.3 From 223ba2e5e0060a4fef243fb3249c946168698e59 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 26 Dec 2016 23:00:38 +0000 Subject: Fix header inclusion ordering (bzr r15365) --- src/widgets/mesh-toolbar.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/widgets/mesh-toolbar.cpp') diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index ea0faf1df..b1cbb98b0 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -18,6 +18,8 @@ #include #endif +#include + // REVIEW THESE AT END OF REWRITE #include "ui/widget/color-preview.h" #include "toolbox.h" @@ -36,7 +38,6 @@ #include "document-undo.h" #include "desktop.h" -#include #include #include "ui/tools/gradient-tool.h" -- cgit v1.2.3 From 1718bfb10a12c22b9f4a9d502e715634c2cc153c Mon Sep 17 00:00:00 2001 From: Ivan Mas??r Date: Fri, 30 Dec 2016 17:11:45 +0100 Subject: fix typos, add translator comment (bzr r15373) --- src/widgets/mesh-toolbar.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/widgets/mesh-toolbar.cpp') diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index b1cbb98b0..7a37376db 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -539,6 +539,7 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj gtk_list_store_append( model, &iter ); gtk_list_store_set( model, &iter, 0, _("Bicubic"), 1, SP_MESH_TYPE_BICUBIC, -1 ); + // TRANSLATORS: Type of Smoothing. See https://en.wikipedia.org/wiki/Coons_patch EgeSelectOneAction* act = ege_select_one_action_new( "MeshSmoothAction", _("Coons"), _("Coons: no smoothing. Bicubic: smoothing across patch boundaries."), NULL, GTK_TREE_MODEL(model) ); -- cgit v1.2.3 From ce555f3f7791bd58649c022ac1320cbb513385db Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Fri, 6 Jan 2017 16:29:15 +0200 Subject: Remove an old comment which I don't understand. It seems like a todo which may or may not have been followed. (bzr r15369.1.14) --- src/widgets/mesh-toolbar.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/widgets/mesh-toolbar.cpp') diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp index 7a37376db..0ca1cc027 100644 --- a/src/widgets/mesh-toolbar.cpp +++ b/src/widgets/mesh-toolbar.cpp @@ -20,7 +20,6 @@ #include -// REVIEW THESE AT END OF REWRITE #include "ui/widget/color-preview.h" #include "toolbox.h" #include "mesh-toolbar.h" -- cgit v1.2.3