summaryrefslogtreecommitdiffstats
path: root/src/widgets/mesh-toolbar.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-03-14 16:37:50 +0000
committerJabiertxof <jtx@jtx.marker.es>2016-03-14 16:37:50 +0000
commitb8d22beef5345210ad27cdc2685083aeae6f8f3b (patch)
treed69b8bfd19d3627a8425a1b265c2abf229b05354 /src/widgets/mesh-toolbar.cpp
parentfixes for update to trunk (diff)
parent"Relative to" option for node alignment. (diff)
downloadinkscape-b8d22beef5345210ad27cdc2685083aeae6f8f3b.tar.gz
inkscape-b8d22beef5345210ad27cdc2685083aeae6f8f3b.zip
update to trunk
(bzr r13708.1.39)
Diffstat (limited to 'src/widgets/mesh-toolbar.cpp')
-rw-r--r--src/widgets/mesh-toolbar.cpp95
1 files changed, 87 insertions, 8 deletions
diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp
index 1af55d9cd..3643ce00c 100644
--- a/src/widgets/mesh-toolbar.cpp
+++ b/src/widgets/mesh-toolbar.cpp
@@ -34,6 +34,7 @@
#include "widgets/gradient-image.h"
#include "style.h"
+#include "inkscape.h"
#include "preferences.h"
#include "document-private.h"
#include "document-undo.h"
@@ -66,6 +67,7 @@
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::PrefPusher;
+using Inkscape::UI::Tools::MeshTool;
static bool blocked = false;
@@ -88,7 +90,7 @@ void ms_read_selection( Inkscape::Selection *selection,
ms_type = SP_MESH_TYPE_COONS;
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();++i){
SPItem *item = *i;
SPStyle *style = item->style;
@@ -215,7 +217,7 @@ void ms_get_dt_selected_gradient(Inkscape::Selection *selection, SPMesh *&ms_sel
SPMesh *gradient = 0;
std::vector<SPItem*> itemlist=selection->itemList();
- for(std::vector<SPItem*>::const_iterator i=itemlist.begin();i!=itemlist.end();i++){
+ for(std::vector<SPItem*>::const_iterator 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;
@@ -290,6 +292,9 @@ static void ms_col_changed(GtkAdjustment *adj, GObject * /*tbl*/ )
blocked = FALSE;
}
+/**
+ * Sets mesh type: Coons, Bicubic
+ */
static void ms_type_changed(EgeSelectOneAction *act, GtkWidget *widget)
{
// std::cout << "ms_type_changed" << std::endl;
@@ -309,15 +314,54 @@ static void ms_type_changed(EgeSelectOneAction *act, GtkWidget *widget)
gradient->type_set = true;
gradient->updateRepr();
- DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_GRADIENT,
+ DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH,
_("Set mesh type"));
}
}
+/** Temporary hack: Returns the mesh tool in the active desktop.
+ * Will go away during tool refactoring. */
+static MeshTool *get_mesh_tool()
+{
+ MeshTool *tool = 0;
+ if (SP_ACTIVE_DESKTOP ) {
+ Inkscape::UI::Tools::ToolBase *ec = SP_ACTIVE_DESKTOP->event_context;
+ if (SP_IS_MESH_CONTEXT(ec)) {
+ tool = static_cast<MeshTool*>(ec);
+ }
+ }
+ return tool;
+}
+
+static void ms_toggle_sides(void)
+{
+ MeshTool *mt = get_mesh_tool();
+ if (mt) {
+ sp_mesh_context_corner_operation( mt, MG_CORNER_SIDE_TOGGLE );
+ }
+}
+
+static void ms_make_elliptical(void)
+{
+ MeshTool *mt = get_mesh_tool();
+ if (mt) {
+ sp_mesh_context_corner_operation( mt, MG_CORNER_SIDE_ARC );
+ }
+}
+
+static void ms_pick_colors(void)
+{
+ MeshTool *mt = get_mesh_tool();
+ if (mt) {
+ sp_mesh_context_corner_operation( mt, MG_CORNER_COLOR_PICK );
+ }
+}
+
static void mesh_toolbox_watch_ec(SPDesktop* dt, Inkscape::UI::Tools::ToolBase* ec, GObject* holder);
/**
* Mesh auxiliary toolbar construction and setup.
+ * Don't forget to add to XML in widgets/toolbox.cpp!
*
*/
void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObject* holder)
@@ -389,14 +433,14 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj
/* Number of mesh rows */
{
- gchar const* labels[] = {};
+ gchar const** labels = NULL;
gdouble values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
eact = create_adjustment_action( "MeshRowAction",
_("Rows"), _("Rows:"), _("Number of rows in new mesh"),
"/tools/mesh/mesh_rows", 1,
GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
1, 20, 1, 1,
- labels, values, G_N_ELEMENTS(labels),
+ labels, values, 0,
ms_row_changed, NULL /*unit tracker*/,
1.0, 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
@@ -405,14 +449,14 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj
/* Number of mesh columns */
{
- gchar const* labels[] = {};
+ gchar const** labels = NULL;
gdouble values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
eact = create_adjustment_action( "MeshColumnAction",
_("Columns"), _("Columns:"), _("Number of columns in new mesh"),
"/tools/mesh/mesh_cols", 1,
GTK_WIDGET(desktop->canvas), holder, FALSE, NULL,
1, 20, 1, 1,
- labels, values, G_N_ELEMENTS(labels),
+ labels, values, 0,
ms_col_changed, NULL /*unit tracker*/,
1.0, 0 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
@@ -466,7 +510,7 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj
gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
}
- /* Typeing method */
+ /* Type */
{
GtkListStore* model = gtk_list_store_new( 2, G_TYPE_STRING, G_TYPE_INT );
@@ -487,6 +531,41 @@ void sp_mesh_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, GObj
gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
g_object_set_data( holder, "mesh_select_type_action", act );
}
+
+ {
+ InkAction* act = ink_action_new( "MeshToggleSidesAction",
+ _("Toggle Sides"),
+ _("Toggle selected sides between Beziers and lines."),
+ INKSCAPE_ICON("node-segment-line"),
+ secondarySize );
+ g_object_set( act, "short_label", _("Toggle side:"), NULL );
+ g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_toggle_sides), 0 );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+
+ {
+ InkAction* act = ink_action_new( "MeshMakeEllipticalAction",
+ _("Make elliptical"),
+ _("Make selected sides elliptical by changing length of handles. Works best if handles already approximate ellipse."),
+ INKSCAPE_ICON("node-segment-curve"),
+ secondarySize );
+ g_object_set( act, "short_label", _("Make elliptical:"), NULL );
+ g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_make_elliptical), 0 );
+ gtk_action_group_add_action( mainActions, GTK_ACTION(act) );
+ }
+
+ {
+ InkAction* act = ink_action_new( "MeshPickColorsAction",
+ _("Pick colors:"),
+ _("Pick colors for selected corner nodes from underneath mesh."),
+ INKSCAPE_ICON("color-picker"),
+ secondarySize );
+ g_object_set( act, "short_label", _("Pick Color"), NULL );
+ g_signal_connect_after( G_OBJECT(act), "activate", G_CALLBACK(ms_pick_colors), 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)