From 7572ee2641532716d219a9a11f03e87511ed0bab Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 8 May 2012 14:21:59 +0900 Subject: Fix for 986446 : Refactor toolbox into tool specific files (bzr r11346) --- src/widgets/node-toolbar.cpp | 662 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 662 insertions(+) create mode 100644 src/widgets/node-toolbar.cpp (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp new file mode 100644 index 000000000..baa1670a0 --- /dev/null +++ b/src/widgets/node-toolbar.cpp @@ -0,0 +1,662 @@ +/** + * @file + * Node aux toolbar + */ +/* Authors: + * MenTaLguY + * Lauris Kaplinski + * bulia byak + * Frank Felfe + * John Cliff + * David Turner + * Josh Andler + * Jon A. Cruz + * Maximilian Albert + * Tavmjong Bah + * Abhishek Sharma + * Kris De Gussem + * + * Copyright (C) 2004 David Turner + * Copyright (C) 2003 MenTaLguY + * Copyright (C) 1999-2011 authors + * Copyright (C) 2001-2002 Ximian, Inc. + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include "toolbox.h" +#include "node-toolbar.h" + +#include "../desktop.h" +#include "../desktop-handles.h" +#include "document-undo.h" +#include "../verbs.h" +#include "../inkscape.h" +#include "../connection-pool.h" +#include "../selection-chemistry.h" +#include "../selection.h" +#include "../ege-adjustment-action.h" +#include "../ege-output-action.h" +#include "../ege-select-one-action.h" +#include "../ink-action.h" +#include "../ink-comboboxentry-action.h" +#include "../widgets/button.h" +#include "../widgets/spinbutton-events.h" +#include "ui/widget/spinbutton.h" +#include "../widgets/spw-utilities.h" +#include "../widgets/widget-sizes.h" +#include "../xml/attribute-record.h" +#include "../xml/node-event-vector.h" +#include "../xml/repr.h" +#include "ui/uxmanager.h" +#include "../ui/tool/control-point-selection.h" +#include "../ui/tool/node-tool.h" +#include "../ui/tool/multi-path-manipulator.h" +#include "../ui/icon-names.h" +#include "../helper/unit-menu.h" +#include "../helper/units.h" +#include "../helper/unit-tracker.h" +#include "../lpe-tool-context.h" +#include "../sp-namedview.h" + +using Inkscape::UnitTracker; +using Inkscape::UI::UXManager; +using Inkscape::DocumentUndo; +using Inkscape::UI::ToolboxFactory; +using Inkscape::UI::PrefPusher; + +//#################################### +//# node editing callbacks +//#################################### + +/** Temporary hack: Returns the node tool in the active desktop. + * Will go away during tool refactoring. */ +static InkNodeTool *get_node_tool() +{ + InkNodeTool *tool = 0; + if (SP_ACTIVE_DESKTOP ) { + SPEventContext *ec = SP_ACTIVE_DESKTOP->event_context; + if (INK_IS_NODE_TOOL(ec)) { + tool = static_cast(ec); + } + } + return tool; +} + +static void sp_node_path_edit_add(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->insertNodes(); + } +} + +static void sp_node_path_edit_add_min_x(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MIN_X); + } +} +static void sp_node_path_edit_add_max_x(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MAX_X); + } +} +static void sp_node_path_edit_add_min_y(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MIN_Y); + } +} +static void sp_node_path_edit_add_max_y(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MAX_Y); + } +} + +static void sp_node_path_edit_delete(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + nt->_multipath->deleteNodes(prefs->getBool("/tools/nodes/delete_preserves_shape", true)); + } +} + +static void sp_node_path_edit_delete_segment(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->deleteSegments(); + } +} + +static void sp_node_path_edit_break(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->breakNodes(); + } +} + +static void sp_node_path_edit_join(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->joinNodes(); + } +} + +static void sp_node_path_edit_join_segment(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->joinSegments(); + } +} + +static void sp_node_path_edit_toline(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->setSegmentType(Inkscape::UI::SEGMENT_STRAIGHT); + } +} + +static void sp_node_path_edit_tocurve(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->setSegmentType(Inkscape::UI::SEGMENT_CUBIC_BEZIER); + } +} + +static void sp_node_path_edit_cusp(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->setNodeType(Inkscape::UI::NODE_CUSP); + } +} + +static void sp_node_path_edit_smooth(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->setNodeType(Inkscape::UI::NODE_SMOOTH); + } +} + +static void sp_node_path_edit_symmetrical(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->setNodeType(Inkscape::UI::NODE_SYMMETRIC); + } +} + +static void sp_node_path_edit_auto(void) +{ + InkNodeTool *nt = get_node_tool(); + if (nt) { + nt->_multipath->setNodeType(Inkscape::UI::NODE_AUTO); + } +} + +static void sp_node_path_edit_nextLPEparam(GtkAction * /*act*/, gpointer data) { + sp_selection_next_patheffect_param( reinterpret_cast(data) ); +} + +/* is called when the node selection is modified */ +static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tbl) +{ + GtkAction* xact = GTK_ACTION( g_object_get_data( tbl, "nodes_x_action" ) ); + GtkAction* yact = GTK_ACTION( g_object_get_data( tbl, "nodes_y_action" ) ); + GtkAdjustment *xadj = ege_adjustment_action_get_adjustment(EGE_ADJUSTMENT_ACTION(xact)); + GtkAdjustment *yadj = ege_adjustment_action_get_adjustment(EGE_ADJUSTMENT_ACTION(yact)); + + // quit if run by the attr_changed listener + if (g_object_get_data( tbl, "freeze" )) { + return; + } + + // in turn, prevent listener from responding + g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE)); + + UnitTracker* tracker = reinterpret_cast( g_object_get_data( tbl, "tracker" ) ); + if (!tracker) { + return; + } + SPUnit const *unit = tracker->getActiveUnit(); + + InkNodeTool *nt = get_node_tool(); + if (!nt || nt->_selected_nodes->empty()) { + // no path selected + gtk_action_set_sensitive(xact, FALSE); + gtk_action_set_sensitive(yact, FALSE); + } else { + gtk_action_set_sensitive(xact, TRUE); + gtk_action_set_sensitive(yact, TRUE); + Geom::Coord oldx = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit); + Geom::Coord oldy = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit); + Geom::Point mid = nt->_selected_nodes->pointwiseBounds()->midpoint(); + + if (oldx != mid[Geom::X]) { + gtk_adjustment_set_value(xadj, sp_pixels_get_units(mid[Geom::X], *unit)); + } + if (oldy != mid[Geom::Y]) { + gtk_adjustment_set_value(yadj, sp_pixels_get_units(mid[Geom::Y], *unit)); + } + } + + g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); +} + +static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::Dim2 d) +{ + SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + + UnitTracker* tracker = reinterpret_cast(g_object_get_data( tbl, "tracker" )); + if (!tracker) { + return; + } + SPUnit const *unit = tracker->getActiveUnit(); + + if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { + prefs->setDouble(Glib::ustring("/tools/nodes/") + (d == Geom::X ? "x" : "y"), + sp_units_get_pixels(gtk_adjustment_get_value(adj), *unit)); + } + + // quit if run by the attr_changed listener + if (g_object_get_data( tbl, "freeze" )) { + return; + } + + // in turn, prevent listener from responding + g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE)); + + InkNodeTool *nt = get_node_tool(); + if (nt && !nt->_selected_nodes->empty()) { + double val = sp_units_get_pixels(gtk_adjustment_get_value(adj), *unit); + double oldval = nt->_selected_nodes->pointwiseBounds()->midpoint()[d]; + Geom::Point delta(0,0); + delta[d] = val - oldval; + nt->_multipath->move(delta); + } + + g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); +} + +static void sp_node_path_x_value_changed(GtkAdjustment *adj, GObject *tbl) +{ + sp_node_path_value_changed(adj, tbl, Geom::X); +} + +static void sp_node_path_y_value_changed(GtkAdjustment *adj, GObject *tbl) +{ + sp_node_path_value_changed(adj, tbl, Geom::Y); +} + +static void sp_node_toolbox_sel_changed(Inkscape::Selection *selection, GObject *tbl) +{ + { + GtkAction* w = GTK_ACTION( g_object_get_data( tbl, "nodes_lpeedit" ) ); + SPItem *item = selection->singleItem(); + if (item && SP_IS_LPE_ITEM(item)) { + if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(item))) { + gtk_action_set_sensitive(w, TRUE); + } else { + gtk_action_set_sensitive(w, FALSE); + } + } else { + gtk_action_set_sensitive(w, FALSE); + } + } +} + +static void sp_node_toolbox_sel_modified(Inkscape::Selection *selection, guint /*flags*/, GObject *tbl) +{ + sp_node_toolbox_sel_changed (selection, tbl); +} + + + +//################################ +//## Node Editing Toolbox ## +//################################ + +void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) +{ + UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE ); + tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units ); + g_object_set_data( holder, "tracker", tracker ); + + Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1); + + { + InkToolMenuAction* inky = ink_tool_menu_action_new( "NodeInsertAction", + _("Insert node"), + _("Insert new nodes into selected segments"), + INKSCAPE_ICON("node-add"), + secondarySize ); + g_object_set( INK_ACTION(inky), "short_label", _("Insert"), NULL ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_add), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + GtkToolItem *menu_tool_button = gtk_menu_tool_button_new (NULL, NULL); + gtk_activatable_set_related_action (GTK_ACTIVATABLE (menu_tool_button), GTK_ACTION(inky)); + // also create dummy menu action: + gtk_action_group_add_action( mainActions, gtk_action_new("NodeInsertActionMenu", NULL, NULL, NULL) ); + } + + { + InkAction* inky = ink_action_new( "NodeInsertActionMinX", + _("Insert node at min X"), + _("Insert new nodes at min X into selected segments"), + INKSCAPE_ICON("node_insert_min_x"), + secondarySize ); + g_object_set( inky, "short_label", _("Insert min X"), NULL ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_add_min_x), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } + { + InkAction* inky = ink_action_new( "NodeInsertActionMaxX", + _("Insert node at max X"), + _("Insert new nodes at max X into selected segments"), + INKSCAPE_ICON("node_insert_max_x"), + secondarySize ); + g_object_set( inky, "short_label", _("Insert max X"), NULL ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_add_max_x), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } + { + InkAction* inky = ink_action_new( "NodeInsertActionMinY", + _("Insert node at min Y"), + _("Insert new nodes at min Y into selected segments"), + INKSCAPE_ICON("node_insert_min_y"), + secondarySize ); + g_object_set( inky, "short_label", _("Insert min Y"), NULL ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_add_min_y), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } + { + InkAction* inky = ink_action_new( "NodeInsertActionMaxY", + _("Insert node at max Y"), + _("Insert new nodes at max Y into selected segments"), + INKSCAPE_ICON("node_insert_max_y"), + secondarySize ); + g_object_set( inky, "short_label", _("Insert max Y"), NULL ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_add_max_y), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } + + { + InkAction* inky = ink_action_new( "NodeDeleteAction", + _("Delete node"), + _("Delete selected nodes"), + INKSCAPE_ICON("node-delete"), + secondarySize ); + g_object_set( inky, "short_label", _("Delete"), NULL ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_delete), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } + + { + InkAction* inky = ink_action_new( "NodeJoinAction", + _("Join nodes"), + _("Join selected nodes"), + INKSCAPE_ICON("node-join"), + secondarySize ); + g_object_set( inky, "short_label", _("Join"), NULL ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_join), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } + + { + InkAction* inky = ink_action_new( "NodeBreakAction", + _("Break nodes"), + _("Break path at selected nodes"), + INKSCAPE_ICON("node-break"), + secondarySize ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_break), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } + + + { + InkAction* inky = ink_action_new( "NodeJoinSegmentAction", + _("Join with segment"), + _("Join selected endnodes with a new segment"), + INKSCAPE_ICON("node-join-segment"), + secondarySize ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_join_segment), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } + + { + InkAction* inky = ink_action_new( "NodeDeleteSegmentAction", + _("Delete segment"), + _("Delete segment between two non-endpoint nodes"), + INKSCAPE_ICON("node-delete-segment"), + secondarySize ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_delete_segment), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } + + { + InkAction* inky = ink_action_new( "NodeCuspAction", + _("Node Cusp"), + _("Make selected nodes corner"), + INKSCAPE_ICON("node-type-cusp"), + secondarySize ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_cusp), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } + + { + InkAction* inky = ink_action_new( "NodeSmoothAction", + _("Node Smooth"), + _("Make selected nodes smooth"), + INKSCAPE_ICON("node-type-smooth"), + secondarySize ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_smooth), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } + + { + InkAction* inky = ink_action_new( "NodeSymmetricAction", + _("Node Symmetric"), + _("Make selected nodes symmetric"), + INKSCAPE_ICON("node-type-symmetric"), + secondarySize ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_symmetrical), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } + + { + InkAction* inky = ink_action_new( "NodeAutoAction", + _("Node Auto"), + _("Make selected nodes auto-smooth"), + INKSCAPE_ICON("node-type-auto-smooth"), + secondarySize ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_auto), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } + + { + InkAction* inky = ink_action_new( "NodeLineAction", + _("Node Line"), + _("Make selected segments lines"), + INKSCAPE_ICON("node-segment-line"), + secondarySize ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_toline), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } + + { + InkAction* inky = ink_action_new( "NodeCurveAction", + _("Node Curve"), + _("Make selected segments curves"), + INKSCAPE_ICON("node-segment-curve"), + secondarySize ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_tocurve), 0 ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } + + { + InkToggleAction* act = ink_toggle_action_new( "NodesShowTransformHandlesAction", + _("Show Transform Handles"), + _("Show transformation handles for selected nodes"), + "node-transform", + secondarySize ); + gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); + PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/nodes/show_transform_handles"); + g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); + } + + { + InkToggleAction* act = ink_toggle_action_new( "NodesShowHandlesAction", + _("Show Handles"), + _("Show Bezier handles of selected nodes"), + INKSCAPE_ICON("show-node-handles"), + secondarySize ); + gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); + PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/nodes/show_handles"); + g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); + } + + { + InkToggleAction* act = ink_toggle_action_new( "NodesShowHelperpath", + _("Show Outline"), + _("Show path outline (without path effects)"), + INKSCAPE_ICON("show-path-outline"), + secondarySize ); + gtk_action_group_add_action( mainActions, GTK_ACTION( act ) ); + PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(act), "/tools/nodes/show_outline"); + g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); + } + + { + Inkscape::Verb* verb = Inkscape::Verb::get(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER); + InkAction* inky = ink_action_new( verb->get_id(), + verb->get_name(), + verb->get_tip(), + INKSCAPE_ICON("path-effect-parameter-next"), + secondarySize ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_node_path_edit_nextLPEparam), desktop ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + g_object_set_data( holder, "nodes_lpeedit", inky); + } + + { + InkToggleAction* inky = ink_toggle_action_new( "ObjectEditClipPathAction", + _("Edit clipping paths"), + _("Show clipping path(s) of selected object(s)"), + INKSCAPE_ICON("path-clip-edit"), + secondarySize ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(inky), "/tools/nodes/edit_clipping_paths"); + g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); + } + + { + InkToggleAction* inky = ink_toggle_action_new( "ObjectEditMaskPathAction", + _("Edit masks"), + _("Show mask(s) of selected object(s)"), + INKSCAPE_ICON("path-mask-edit"), + secondarySize ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + PrefPusher *pusher = new PrefPusher(GTK_TOGGLE_ACTION(inky), "/tools/nodes/edit_masks"); + g_signal_connect( holder, "destroy", G_CALLBACK(delete_prefspusher), pusher); + } + + /* X coord of selected node(s) */ + { + EgeAdjustmentAction* eact = 0; + gchar const* labels[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + gdouble values[] = {1, 2, 3, 5, 10, 20, 50, 100, 200, 500}; + eact = create_adjustment_action( "NodeXAction", + _("X coordinate:"), _("X:"), _("X coordinate of selected node(s)"), + "/tools/nodes/Xcoord", 0, + GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, TRUE, "altx-nodes", + -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP, + labels, values, G_N_ELEMENTS(labels), + sp_node_path_x_value_changed ); + tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); + g_object_set_data( holder, "nodes_x_action", eact ); + gtk_action_set_sensitive( GTK_ACTION(eact), FALSE ); + gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); + } + + /* Y coord of selected node(s) */ + { + EgeAdjustmentAction* eact = 0; + gchar const* labels[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + gdouble values[] = {1, 2, 3, 5, 10, 20, 50, 100, 200, 500}; + eact = create_adjustment_action( "NodeYAction", + _("Y coordinate:"), _("Y:"), _("Y coordinate of selected node(s)"), + "/tools/nodes/Ycoord", 0, + GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL, + -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP, + labels, values, G_N_ELEMENTS(labels), + sp_node_path_y_value_changed ); + tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); + g_object_set_data( holder, "nodes_y_action", eact ); + gtk_action_set_sensitive( GTK_ACTION(eact), FALSE ); + gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); + } + + // add the units menu + { + GtkAction* act = tracker->createAction( "NodeUnitsAction", _("Units"), ("") ); + gtk_action_group_add_action( mainActions, act ); + } + + + sp_node_toolbox_sel_changed(sp_desktop_selection(desktop), holder); + + //watch selection + Inkscape::ConnectionPool* pool = Inkscape::ConnectionPool::new_connection_pool ("ISNodeToolbox"); + + sigc::connection *c_selection_changed = + new sigc::connection (sp_desktop_selection (desktop)->connectChanged + (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_changed), (GObject*)holder))); + pool->add_connection ("selection-changed", c_selection_changed); + + sigc::connection *c_selection_modified = + new sigc::connection (sp_desktop_selection (desktop)->connectModified + (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_modified), (GObject*)holder))); + pool->add_connection ("selection-modified", c_selection_modified); + + sigc::connection *c_subselection_changed = + new sigc::connection (desktop->connectToolSubselectionChanged + (sigc::bind (sigc::ptr_fun (sp_node_toolbox_coord_changed), (GObject*)holder))); + pool->add_connection ("tool-subselection-changed", c_subselection_changed); + + Inkscape::ConnectionPool::connect_destroy (G_OBJECT (holder), pool); + + g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder ); +} // end of sp_node_toolbox_prep() + + + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3 From 97507bc4eae716f9e4476c7d036096e3459970ef Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 28 May 2012 10:33:28 +0100 Subject: Build with GDK_DISABLE_DEPRECATED for Gtk+ 2 Fixed bugs: - https://launchpad.net/bugs/943207 (bzr r11431) --- src/widgets/node-toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index baa1670a0..1be638359 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -28,6 +28,7 @@ # include "config.h" #endif +#include "ui/widget/spinbutton.h" #include "toolbox.h" #include "node-toolbar.h" @@ -46,7 +47,6 @@ #include "../ink-comboboxentry-action.h" #include "../widgets/button.h" #include "../widgets/spinbutton-events.h" -#include "ui/widget/spinbutton.h" #include "../widgets/spw-utilities.h" #include "../widgets/widget-sizes.h" #include "../xml/attribute-record.h" -- cgit v1.2.3 From aa042e930bc5cce596829086ce84f2c3c7c885ad Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 17 Jun 2012 00:08:03 -0700 Subject: Removed outdated classes. Pruned header to not introduce extraneous includes. (bzr r11502) --- src/widgets/node-toolbar.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index 1be638359..7dca63ba2 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -28,6 +28,8 @@ # include "config.h" #endif +#include + #include "ui/widget/spinbutton.h" #include "toolbox.h" #include "node-toolbar.h" -- cgit v1.2.3 From 5da5121b9afaa8b2d1f0308dffc7d1e1b225b142 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sun, 11 Nov 2012 12:46:25 +0000 Subject: Replace remaining C-style pointer casts for src/widgets (bzr r11868) --- src/widgets/node-toolbar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index 7dca63ba2..79cdf8117 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -266,7 +266,7 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::Dim2 d) { - SPDesktop *desktop = (SPDesktop *) g_object_get_data( tbl, "desktop" ); + SPDesktop *desktop = static_cast(g_object_get_data( tbl, "desktop" )); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); UnitTracker* tracker = reinterpret_cast(g_object_get_data( tbl, "tracker" )); @@ -632,17 +632,17 @@ void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje sigc::connection *c_selection_changed = new sigc::connection (sp_desktop_selection (desktop)->connectChanged - (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_changed), (GObject*)holder))); + (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_changed), holder))); pool->add_connection ("selection-changed", c_selection_changed); sigc::connection *c_selection_modified = new sigc::connection (sp_desktop_selection (desktop)->connectModified - (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_modified), (GObject*)holder))); + (sigc::bind (sigc::ptr_fun (sp_node_toolbox_sel_modified), holder))); pool->add_connection ("selection-modified", c_selection_modified); sigc::connection *c_subselection_changed = new sigc::connection (desktop->connectToolSubselectionChanged - (sigc::bind (sigc::ptr_fun (sp_node_toolbox_coord_changed), (GObject*)holder))); + (sigc::bind (sigc::ptr_fun (sp_node_toolbox_coord_changed), holder))); pool->add_connection ("tool-subselection-changed", c_subselection_changed); Inkscape::ConnectionPool::connect_destroy (G_OBJECT (holder), pool); -- cgit v1.2.3 From 0cdd007ebf8dcfbd39c1d36ab53f43617eb692df Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 25 Mar 2013 17:42:31 +0000 Subject: Workaround usage of deprecated glib symbols in 3rd party libraries Fixed bugs: - https://launchpad.net/bugs/1122774 (bzr r12243) --- src/widgets/node-toolbar.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index 79cdf8117..849de874d 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -28,9 +28,8 @@ # include "config.h" #endif -#include - #include "ui/widget/spinbutton.h" +#include #include "toolbox.h" #include "node-toolbar.h" -- cgit v1.2.3 From 9dc7b786c9ef31060012ea4ae13a8188548b4f62 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 9 Jul 2013 16:42:04 -0400 Subject: Ported sp-namedview.cpp (todo: fix a bunch of things). (bzr r12380.1.8) --- src/widgets/node-toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index 849de874d..d6de74817 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -340,7 +340,7 @@ static void sp_node_toolbox_sel_modified(Inkscape::Selection *selection, guint / void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE ); - tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units ); + //tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units ); g_object_set_data( holder, "tracker", tracker ); Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1); -- cgit v1.2.3 From 9711852491cd6eb2992039f286ce3ced50b83d06 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 17 Jul 2013 00:53:51 -0400 Subject: Ported "widgets/node-toolbar.cpp". (bzr r12380.1.15) --- src/widgets/node-toolbar.cpp | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index d6de74817..50880f481 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -58,13 +58,14 @@ #include "../ui/tool/node-tool.h" #include "../ui/tool/multi-path-manipulator.h" #include "../ui/icon-names.h" -#include "../helper/unit-menu.h" -#include "../helper/units.h" -#include "../helper/unit-tracker.h" +#include "util/units.h" +#include "ui/widget/unit-tracker.h" #include "../lpe-tool-context.h" #include "../sp-namedview.h" -using Inkscape::UnitTracker; +using Inkscape::UI::Widget::UnitTracker; +using Inkscape::Util::Unit; +using Inkscape::Util::Quantity; using Inkscape::UI::UXManager; using Inkscape::DocumentUndo; using Inkscape::UI::ToolboxFactory; @@ -238,7 +239,7 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb if (!tracker) { return; } - SPUnit const *unit = tracker->getActiveUnit(); + Unit const unit = tracker->getActiveUnit(); InkNodeTool *nt = get_node_tool(); if (!nt || nt->_selected_nodes->empty()) { @@ -248,15 +249,17 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb } else { gtk_action_set_sensitive(xact, TRUE); gtk_action_set_sensitive(yact, TRUE); - Geom::Coord oldx = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit); - Geom::Coord oldy = sp_units_get_pixels(gtk_adjustment_get_value(xadj), *unit); + Inkscape::Util::UnitTable unit_table; + Unit px = unit_table.getUnit("px"); + Geom::Coord oldx = Quantity::convert(gtk_adjustment_get_value(xadj), &unit, &px); + Geom::Coord oldy = Quantity::convert(gtk_adjustment_get_value(yadj), &unit, &px); Geom::Point mid = nt->_selected_nodes->pointwiseBounds()->midpoint(); if (oldx != mid[Geom::X]) { - gtk_adjustment_set_value(xadj, sp_pixels_get_units(mid[Geom::X], *unit)); + gtk_adjustment_set_value(xadj, Quantity::convert(mid[Geom::X], &px, &unit)); } if (oldy != mid[Geom::Y]) { - gtk_adjustment_set_value(yadj, sp_pixels_get_units(mid[Geom::Y], *unit)); + gtk_adjustment_set_value(yadj, Quantity::convert(mid[Geom::Y], &px, &unit)); } } @@ -272,11 +275,14 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D if (!tracker) { return; } - SPUnit const *unit = tracker->getActiveUnit(); + Unit const unit = tracker->getActiveUnit(); + + Inkscape::Util::UnitTable unit_table; + Unit px = unit_table.getUnit("px"); if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { prefs->setDouble(Glib::ustring("/tools/nodes/") + (d == Geom::X ? "x" : "y"), - sp_units_get_pixels(gtk_adjustment_get_value(adj), *unit)); + Quantity::convert(gtk_adjustment_get_value(adj), &unit, &px)); } // quit if run by the attr_changed listener @@ -289,7 +295,7 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D InkNodeTool *nt = get_node_tool(); if (nt && !nt->_selected_nodes->empty()) { - double val = sp_units_get_pixels(gtk_adjustment_get_value(adj), *unit); + double val = Quantity::convert(gtk_adjustment_get_value(adj), &unit, &px); double oldval = nt->_selected_nodes->pointwiseBounds()->midpoint()[d]; Geom::Point delta(0,0); delta[d] = val - oldval; @@ -339,8 +345,9 @@ static void sp_node_toolbox_sel_modified(Inkscape::Selection *selection, guint / void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObject* holder) { - UnitTracker* tracker = new UnitTracker( SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE ); - //tracker->setActiveUnit( sp_desktop_namedview(desktop)->doc_units ); + UnitTracker* tracker = new UnitTracker(Inkscape::Util::UNIT_TYPE_LINEAR); + Unit doc_units = *sp_desktop_namedview(desktop)->doc_units; + tracker->setActiveUnit(&doc_units); g_object_set_data( holder, "tracker", tracker ); Inkscape::IconSize secondarySize = ToolboxFactory::prefToSize("/toolbox/secondary", 1); -- cgit v1.2.3 From 3772fc428950b2b946a1bd7c7c97e06219c3165f Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Thu, 18 Jul 2013 17:21:24 -0400 Subject: Switch unit functions from using pointer arguements to reference arguements. (bzr r12380.1.28) --- src/widgets/node-toolbar.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index 50880f481..d60b58886 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -250,16 +250,15 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb gtk_action_set_sensitive(xact, TRUE); gtk_action_set_sensitive(yact, TRUE); Inkscape::Util::UnitTable unit_table; - Unit px = unit_table.getUnit("px"); - Geom::Coord oldx = Quantity::convert(gtk_adjustment_get_value(xadj), &unit, &px); - Geom::Coord oldy = Quantity::convert(gtk_adjustment_get_value(yadj), &unit, &px); + Geom::Coord oldx = Quantity::convert(gtk_adjustment_get_value(xadj), unit, "px"); + Geom::Coord oldy = Quantity::convert(gtk_adjustment_get_value(yadj), unit, "px"); Geom::Point mid = nt->_selected_nodes->pointwiseBounds()->midpoint(); if (oldx != mid[Geom::X]) { - gtk_adjustment_set_value(xadj, Quantity::convert(mid[Geom::X], &px, &unit)); + gtk_adjustment_set_value(xadj, Quantity::convert(mid[Geom::X], "px", unit)); } if (oldy != mid[Geom::Y]) { - gtk_adjustment_set_value(yadj, Quantity::convert(mid[Geom::Y], &px, &unit)); + gtk_adjustment_set_value(yadj, Quantity::convert(mid[Geom::Y], "px", unit)); } } @@ -278,11 +277,10 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D Unit const unit = tracker->getActiveUnit(); Inkscape::Util::UnitTable unit_table; - Unit px = unit_table.getUnit("px"); if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { prefs->setDouble(Glib::ustring("/tools/nodes/") + (d == Geom::X ? "x" : "y"), - Quantity::convert(gtk_adjustment_get_value(adj), &unit, &px)); + Quantity::convert(gtk_adjustment_get_value(adj), unit, "px")); } // quit if run by the attr_changed listener @@ -295,7 +293,7 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D InkNodeTool *nt = get_node_tool(); if (nt && !nt->_selected_nodes->empty()) { - double val = Quantity::convert(gtk_adjustment_get_value(adj), &unit, &px); + double val = Quantity::convert(gtk_adjustment_get_value(adj), unit, "px"); double oldval = nt->_selected_nodes->pointwiseBounds()->midpoint()[d]; Geom::Point delta(0,0); delta[d] = val - oldval; -- cgit v1.2.3 From ef3bfa7e8bb2996c4042314accc34f6a72f072e1 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Fri, 19 Jul 2013 14:19:03 -0400 Subject: Removed "helper/unit-menu.h" from "widgest/toolbar.*" and associated files. (bzr r12380.1.30) --- src/widgets/node-toolbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index d60b58886..65e42a60b 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -594,7 +594,7 @@ void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje eact = create_adjustment_action( "NodeXAction", _("X coordinate:"), _("X:"), _("X coordinate of selected node(s)"), "/tools/nodes/Xcoord", 0, - GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, TRUE, "altx-nodes", + GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-nodes", -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_node_path_x_value_changed ); @@ -612,7 +612,7 @@ void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje eact = create_adjustment_action( "NodeYAction", _("Y coordinate:"), _("Y:"), _("Y coordinate of selected node(s)"), "/tools/nodes/Ycoord", 0, - GTK_WIDGET(desktop->canvas), NULL/*us*/, holder, FALSE, NULL, + GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), sp_node_path_y_value_changed ); -- cgit v1.2.3 From 6ae6c0bea96eef09907091279e0678aa5f83102d Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 4 Aug 2013 18:01:18 -0400 Subject: Switched to global UnitTable. (bzr r12380.1.62) --- src/widgets/node-toolbar.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index 65e42a60b..a9e298f1d 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -70,6 +70,7 @@ using Inkscape::UI::UXManager; using Inkscape::DocumentUndo; using Inkscape::UI::ToolboxFactory; using Inkscape::UI::PrefPusher; +using Inkscape::Util::unit_table; //#################################### //# node editing callbacks @@ -249,7 +250,6 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb } else { gtk_action_set_sensitive(xact, TRUE); gtk_action_set_sensitive(yact, TRUE); - Inkscape::Util::UnitTable unit_table; Geom::Coord oldx = Quantity::convert(gtk_adjustment_get_value(xadj), unit, "px"); Geom::Coord oldy = Quantity::convert(gtk_adjustment_get_value(yadj), unit, "px"); Geom::Point mid = nt->_selected_nodes->pointwiseBounds()->midpoint(); @@ -276,8 +276,6 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D } Unit const unit = tracker->getActiveUnit(); - Inkscape::Util::UnitTable unit_table; - if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { prefs->setDouble(Glib::ustring("/tools/nodes/") + (d == Geom::X ? "x" : "y"), Quantity::convert(gtk_adjustment_get_value(adj), unit, "px")); -- cgit v1.2.3 From 5614df9770b985070122b3c08b45902317c9bd15 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 15 Sep 2013 19:07:21 -0400 Subject: Enable unit evaluation in toolbars. (bzr r12475.1.22) --- src/widgets/node-toolbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index a9e298f1d..c3e5b22ce 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -595,7 +595,7 @@ void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje GTK_WIDGET(desktop->canvas), holder, TRUE, "altx-nodes", -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), - sp_node_path_x_value_changed ); + sp_node_path_x_value_changed, tracker ); tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); g_object_set_data( holder, "nodes_x_action", eact ); gtk_action_set_sensitive( GTK_ACTION(eact), FALSE ); @@ -613,7 +613,7 @@ void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObje GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, -1e6, 1e6, SPIN_STEP, SPIN_PAGE_STEP, labels, values, G_N_ELEMENTS(labels), - sp_node_path_y_value_changed ); + sp_node_path_y_value_changed, tracker ); tracker->addAdjustment( ege_adjustment_action_get_adjustment(eact) ); g_object_set_data( holder, "nodes_y_action", eact ); gtk_action_set_sensitive( GTK_ACTION(eact), FALSE ); -- cgit v1.2.3 From 96190a607cf8edbcb8d4d2f88f0e451cf6abfa83 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 25 Sep 2013 23:51:52 +0200 Subject: C++ify calling a few SPLPEItem functions, much more work than expected... slowly slowly... (bzr r12593) --- src/widgets/node-toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index c3e5b22ce..2348acc46 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -317,7 +317,7 @@ static void sp_node_toolbox_sel_changed(Inkscape::Selection *selection, GObject GtkAction* w = GTK_ACTION( g_object_get_data( tbl, "nodes_lpeedit" ) ); SPItem *item = selection->singleItem(); if (item && SP_IS_LPE_ITEM(item)) { - if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(item))) { + if (SP_LPE_ITEM(item)->hasPathEffect()) { gtk_action_set_sensitive(w, TRUE); } else { gtk_action_set_sensitive(w, FALSE); -- cgit v1.2.3 From a970dc423d59ea844bdb1af48d5d9419a5e2a287 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 13 Oct 2013 00:24:05 +0200 Subject: Units: stop newing Unit objects. pass around pointers to "undeletable" Unit objects in the UnitTable. I think we should move to using indexed units, and pass around the index of the unit in the unittable, or smth like that... ? (bzr r12679) --- src/widgets/node-toolbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index 2348acc46..0d4868642 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -240,7 +240,7 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb if (!tracker) { return; } - Unit const unit = tracker->getActiveUnit(); + Unit const *unit = tracker->getActiveUnit(); InkNodeTool *nt = get_node_tool(); if (!nt || nt->_selected_nodes->empty()) { @@ -274,7 +274,7 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D if (!tracker) { return; } - Unit const unit = tracker->getActiveUnit(); + Unit const *unit = tracker->getActiveUnit(); if (DocumentUndo::getUndoSensitive(sp_desktop_document(desktop))) { prefs->setDouble(Glib::ustring("/tools/nodes/") + (d == Geom::X ? "x" : "y"), -- cgit v1.2.3 From 55b451bf382e0c3d5ed8728e42fbb535acfa8a33 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Thu, 7 Nov 2013 21:44:00 +0100 Subject: First step of moving tools into appropriate namespaces. (bzr r12782) --- src/widgets/node-toolbar.cpp | 45 ++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index 0d4868642..8d24fdf82 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -71,6 +71,7 @@ using Inkscape::DocumentUndo; using Inkscape::UI::ToolboxFactory; using Inkscape::UI::PrefPusher; using Inkscape::Util::unit_table; +using Inkscape::UI::Tools::NodeTool; //#################################### //# node editing callbacks @@ -78,13 +79,13 @@ using Inkscape::Util::unit_table; /** Temporary hack: Returns the node tool in the active desktop. * Will go away during tool refactoring. */ -static InkNodeTool *get_node_tool() +static NodeTool *get_node_tool() { - InkNodeTool *tool = 0; + NodeTool *tool = 0; if (SP_ACTIVE_DESKTOP ) { - SPEventContext *ec = SP_ACTIVE_DESKTOP->event_context; + Inkscape::UI::Tools::ToolBase *ec = SP_ACTIVE_DESKTOP->event_context; if (INK_IS_NODE_TOOL(ec)) { - tool = static_cast(ec); + tool = static_cast(ec); } } return tool; @@ -92,7 +93,7 @@ static InkNodeTool *get_node_tool() static void sp_node_path_edit_add(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { nt->_multipath->insertNodes(); } @@ -100,28 +101,28 @@ static void sp_node_path_edit_add(void) static void sp_node_path_edit_add_min_x(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MIN_X); } } static void sp_node_path_edit_add_max_x(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MAX_X); } } static void sp_node_path_edit_add_min_y(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MIN_Y); } } static void sp_node_path_edit_add_max_y(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MAX_Y); } @@ -129,7 +130,7 @@ static void sp_node_path_edit_add_max_y(void) static void sp_node_path_edit_delete(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); nt->_multipath->deleteNodes(prefs->getBool("/tools/nodes/delete_preserves_shape", true)); @@ -138,7 +139,7 @@ static void sp_node_path_edit_delete(void) static void sp_node_path_edit_delete_segment(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { nt->_multipath->deleteSegments(); } @@ -146,7 +147,7 @@ static void sp_node_path_edit_delete_segment(void) static void sp_node_path_edit_break(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { nt->_multipath->breakNodes(); } @@ -154,7 +155,7 @@ static void sp_node_path_edit_break(void) static void sp_node_path_edit_join(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { nt->_multipath->joinNodes(); } @@ -162,7 +163,7 @@ static void sp_node_path_edit_join(void) static void sp_node_path_edit_join_segment(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { nt->_multipath->joinSegments(); } @@ -170,7 +171,7 @@ static void sp_node_path_edit_join_segment(void) static void sp_node_path_edit_toline(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { nt->_multipath->setSegmentType(Inkscape::UI::SEGMENT_STRAIGHT); } @@ -178,7 +179,7 @@ static void sp_node_path_edit_toline(void) static void sp_node_path_edit_tocurve(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { nt->_multipath->setSegmentType(Inkscape::UI::SEGMENT_CUBIC_BEZIER); } @@ -186,7 +187,7 @@ static void sp_node_path_edit_tocurve(void) static void sp_node_path_edit_cusp(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { nt->_multipath->setNodeType(Inkscape::UI::NODE_CUSP); } @@ -194,7 +195,7 @@ static void sp_node_path_edit_cusp(void) static void sp_node_path_edit_smooth(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { nt->_multipath->setNodeType(Inkscape::UI::NODE_SMOOTH); } @@ -202,7 +203,7 @@ static void sp_node_path_edit_smooth(void) static void sp_node_path_edit_symmetrical(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { nt->_multipath->setNodeType(Inkscape::UI::NODE_SYMMETRIC); } @@ -210,7 +211,7 @@ static void sp_node_path_edit_symmetrical(void) static void sp_node_path_edit_auto(void) { - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt) { nt->_multipath->setNodeType(Inkscape::UI::NODE_AUTO); } @@ -242,7 +243,7 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb } Unit const *unit = tracker->getActiveUnit(); - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (!nt || nt->_selected_nodes->empty()) { // no path selected gtk_action_set_sensitive(xact, FALSE); @@ -289,7 +290,7 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D // in turn, prevent listener from responding g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE)); - InkNodeTool *nt = get_node_tool(); + NodeTool *nt = get_node_tool(); if (nt && !nt->_selected_nodes->empty()) { double val = Quantity::convert(gtk_adjustment_get_value(adj), unit, "px"); double oldval = nt->_selected_nodes->pointwiseBounds()->midpoint()[d]; -- cgit v1.2.3 From c04e30df241a3ee039077425bab9b9c37abe2854 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 9 Nov 2013 23:36:13 +0100 Subject: Moved and renamed some tool-related files. (bzr r12785) --- src/widgets/node-toolbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index 8d24fdf82..6a0968424 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -55,12 +55,12 @@ #include "../xml/repr.h" #include "ui/uxmanager.h" #include "../ui/tool/control-point-selection.h" -#include "../ui/tool/node-tool.h" +#include "ui/tools/node-tool.h" #include "../ui/tool/multi-path-manipulator.h" #include "../ui/icon-names.h" #include "util/units.h" #include "ui/widget/unit-tracker.h" -#include "../lpe-tool-context.h" +#include "ui/tools/lpe-tool.h" #include "../sp-namedview.h" using Inkscape::UI::Widget::UnitTracker; -- cgit v1.2.3 From a24ee5c086e294133abe65bd7fab9cd22ad4d5a5 Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Thu, 9 Jan 2014 08:09:43 +0100 Subject: null check: fix regression Bug #1258815 (crash after using Edit nodes icon twice (rev >= 12730)) (bzr r12903) --- src/widgets/node-toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index 6a0968424..a4ea52287 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -244,7 +244,7 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb Unit const *unit = tracker->getActiveUnit(); NodeTool *nt = get_node_tool(); - if (!nt || nt->_selected_nodes->empty()) { + if (!nt || !(nt->_selected_nodes) ||nt->_selected_nodes->empty()) { // no path selected gtk_action_set_sensitive(xact, FALSE); gtk_action_set_sensitive(yact, FALSE); -- cgit v1.2.3 From 7825ad6d1ac979689ac79d6497079aec36c6ae4b Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 2 Mar 2014 23:58:28 +0100 Subject: Fixed includes for tools. (bzr r13097) --- src/widgets/node-toolbar.cpp | 47 ++++++++++++++++---------------------------- 1 file changed, 17 insertions(+), 30 deletions(-) (limited to 'src/widgets/node-toolbar.cpp') diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp index a4ea52287..53161857a 100644 --- a/src/widgets/node-toolbar.cpp +++ b/src/widgets/node-toolbar.cpp @@ -28,45 +28,32 @@ # include "config.h" #endif -#include "ui/widget/spinbutton.h" +#include "ui/tool/multi-path-manipulator.h" #include -#include "toolbox.h" #include "node-toolbar.h" - -#include "../desktop.h" -#include "../desktop-handles.h" +#include "connection-pool.h" +#include "desktop-handles.h" +#include "desktop.h" #include "document-undo.h" -#include "../verbs.h" -#include "../inkscape.h" -#include "../connection-pool.h" -#include "../selection-chemistry.h" -#include "../selection.h" -#include "../ege-adjustment-action.h" -#include "../ege-output-action.h" -#include "../ege-select-one-action.h" -#include "../ink-action.h" -#include "../ink-comboboxentry-action.h" -#include "../widgets/button.h" -#include "../widgets/spinbutton-events.h" -#include "../widgets/spw-utilities.h" -#include "../widgets/widget-sizes.h" -#include "../xml/attribute-record.h" -#include "../xml/node-event-vector.h" -#include "../xml/repr.h" -#include "ui/uxmanager.h" -#include "../ui/tool/control-point-selection.h" +#include "ege-adjustment-action.h" +#include "ink-action.h" +#include "inkscape.h" +#include "preferences.h" +#include "selection-chemistry.h" +#include "selection.h" +#include "sp-namedview.h" +#include "toolbox.h" +#include "ui/icon-names.h" +#include "ui/tool/control-point-selection.h" #include "ui/tools/node-tool.h" -#include "../ui/tool/multi-path-manipulator.h" -#include "../ui/icon-names.h" -#include "util/units.h" #include "ui/widget/unit-tracker.h" -#include "ui/tools/lpe-tool.h" -#include "../sp-namedview.h" +#include "util/units.h" +#include "verbs.h" +#include "widgets/widget-sizes.h" using Inkscape::UI::Widget::UnitTracker; using Inkscape::Util::Unit; using Inkscape::Util::Quantity; -using Inkscape::UI::UXManager; using Inkscape::DocumentUndo; using Inkscape::UI::ToolboxFactory; using Inkscape::UI::PrefPusher; -- cgit v1.2.3