From 7e417fb969db6e58d87411bfb9d607b69ec040c9 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Tue, 16 May 2006 02:39:05 +0000 Subject: [PATCH] show handles toggle --- share/icons/icons.svg | 32 +++++++++++++++++++++++++++++--- src/node-context.cpp | 6 +++--- src/nodepath.cpp | 16 +++++++++++++++- src/nodepath.h | 7 ++++++- src/widgets/toolbox.cpp | 26 +++++++++++++++++++++++++- 5 files changed, 78 insertions(+), 9 deletions(-) diff --git a/share/icons/icons.svg b/share/icons/icons.svg index 2d7504f44..c4f49248a 100644 --- a/share/icons/icons.svg +++ b/share/icons/icons.svg @@ -3483,9 +3483,9 @@ inkscape:window-x="0" inkscape:window-height="998" inkscape:window-width="1235" - inkscape:cy="766.53747" - inkscape:cx="477.92614" - inkscape:zoom="6.39741" + inkscape:cy="1191.7808" + inkscape:cx="779.0784" + inkscape:zoom="8.2983948" gridtolerance="1.0000000px" snaptogrid="false" showgrid="true" @@ -12723,4 +12723,30 @@ http://www.inkscape.org/ xlink:href="#g3813" y="0" x="0" /> + + + + + diff --git a/src/node-context.cpp b/src/node-context.cpp index 67511ea30..d7848e3bb 100644 --- a/src/node-context.cpp +++ b/src/node-context.cpp @@ -174,7 +174,7 @@ sp_node_context_setup(SPEventContext *ec) nc->added_node = false; if (item) { - nc->nodepath = sp_nodepath_new(ec->desktop, item); + nc->nodepath = sp_nodepath_new(ec->desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0)); if ( nc->nodepath) { //point pack to parent in case nodepath is deleted nc->nodepath->nodeContext = nc; @@ -241,7 +241,7 @@ sp_node_context_selection_changed(Inkscape::Selection *selection, gpointer data) nc->nodepath = NULL; ec->shape_knot_holder = NULL; if (item) { - nc->nodepath = sp_nodepath_new(desktop, item); + nc->nodepath = sp_nodepath_new(desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0)); if (nc->nodepath) { nc->nodepath->nodeContext = nc; } @@ -292,7 +292,7 @@ sp_nodepath_update_from_item(SPNodeContext *nc, SPItem *item) item = selection->singleItem(); if (item) { - nc->nodepath = sp_nodepath_new(desktop, item); + nc->nodepath = sp_nodepath_new(desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0)); if (nc->nodepath) { nc->nodepath->nodeContext = nc; } diff --git a/src/nodepath.cpp b/src/nodepath.cpp index 4b9559737..1ffef1880 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -137,7 +137,7 @@ static Inkscape::NodePath::Node *active_node = NULL; /** * \brief Creates new nodepath from item */ -Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPItem *item) +Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPItem *item, bool show_handles) { Inkscape::XML::Node *repr = SP_OBJECT(item)->repr; @@ -186,6 +186,7 @@ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPItem *item) np->nodeContext = NULL; //Let the context that makes this set it np->livarot_path = NULL; np->local_change = 0; + np->show_handles = show_handles; // we need to update item's transform from the repr here, // because they may be out of sync when we respond @@ -1336,6 +1337,9 @@ static void sp_node_update_handles(Inkscape::NodePath::Node *node, bool fire_mov if (node->n.other->selected) show_handles = TRUE; } + if (node->subpath->nodepath->show_handles == false) + show_handles = FALSE; + sp_node_update_handle(node, -1, show_handles, fire_move_signals); sp_node_update_handle(node, 1, show_handles, fire_move_signals); } @@ -1364,6 +1368,16 @@ static void sp_nodepath_update_handles(Inkscape::NodePath::Path *nodepath) } } +void +sp_nodepath_show_handles(bool show) +{ + Inkscape::NodePath::Path *nodepath = sp_nodepath_current(); + if (nodepath == NULL) return; + + nodepath->show_handles = show; + sp_nodepath_update_handles(nodepath); +} + /** * Adds all selected nodes in nodepath to list. */ diff --git a/src/nodepath.h b/src/nodepath.h index 2b6131684..2b8243f5b 100644 --- a/src/nodepath.h +++ b/src/nodepath.h @@ -133,6 +133,9 @@ class Path { /// true if we changed repr, to tell this change from an external one such as from undo, simplify, or another desktop unsigned int local_change; + + /// true if we're showing selected nodes' handles + bool show_handles; }; @@ -231,7 +234,7 @@ class Node { } // namespace Inkscape // Do function documentation in nodepath.cpp -Inkscape::NodePath::Path * sp_nodepath_new (SPDesktop * desktop, SPItem * item); +Inkscape::NodePath::Path * sp_nodepath_new (SPDesktop * desktop, SPItem * item, bool show_handles); void sp_nodepath_destroy (Inkscape::NodePath::Path * nodepath); void sp_nodepath_deselect (Inkscape::NodePath::Path *nodepath); void sp_nodepath_select_all (Inkscape::NodePath::Path *nodepath, bool invert); @@ -267,6 +270,8 @@ void sp_node_selected_set_line_type (NRPathcode code); void sp_node_selected_move (gdouble dx, gdouble dy); void sp_node_selected_move_screen (gdouble dx, gdouble dy); +void sp_nodepath_show_handles(bool show); + void sp_nodepath_selected_nodes_rotate (Inkscape::NodePath::Path * nodepath, gdouble angle, int which, bool screen); void sp_nodepath_selected_nodes_scale (Inkscape::NodePath::Path * nodepath, gdouble grow, int which); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 27cc68e25..3d6434bf2 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -376,7 +376,11 @@ sp_node_path_edit_symmetrical(void) sp_node_selected_set_type(Inkscape::NodePath::NODE_SYMM); } - +static void toggle_show_handles (GtkWidget *button, gpointer data) { + bool show = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); + prefs_set_int_attribute ("tools.nodes", "show_handles", show ? 1 : 0); + sp_nodepath_show_handles(show); +} //################################ //## Node Editing Toolbox ## @@ -435,6 +439,26 @@ sp_node_toolbox_new(SPDesktop *desktop) sp_toolbox_button_normal_new_from_verb(tb, Inkscape::ICON_SIZE_SMALL_TOOLBAR, Inkscape::Verb::get(SP_VERB_SELECTION_OUTLINE), view, tt); + aux_toolbox_space(tb, AUX_BETWEEN_BUTTON_GROUPS); + + GtkWidget *cvbox = gtk_vbox_new (FALSE, 0); + GtkWidget *cbox = gtk_hbox_new (FALSE, 0); + + { + GtkWidget *button = sp_button_new_from_data( Inkscape::ICON_SIZE_DECORATION, + SP_BUTTON_TYPE_TOGGLE, + NULL, + "nodes_show_handles", + _("Show the Bezier handles of selected nodes"), + tt); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), prefs_get_int_attribute ("tools.nodes", "show_handles", 1)); + g_signal_connect_after (G_OBJECT (button), "clicked", G_CALLBACK (toggle_show_handles), desktop); + gtk_box_pack_start(GTK_BOX(cbox), button, FALSE, FALSE, 0); + } + + gtk_box_pack_start(GTK_BOX(cvbox), cbox, TRUE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(tb), cvbox, FALSE, FALSE, 0); + gtk_widget_show_all(tb); return tb; -- 2.30.2