From 9abd33133650d77714fccf09d0c9ff27c9b75a78 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 5 Jul 2012 22:39:08 +0100 Subject: Drop GTK+ 2.20 support. Fixed bugs: - https://launchpad.net/bugs/1020494 (bzr r11529) --- src/connector-context.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index daea4a0ac..5f87ab712 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -194,10 +194,6 @@ using Inkscape::DocumentUndo; -#if !GTK_CHECK_VERSION(2,22,0) -#include "compat-key-syms.h" -#endif - static void sp_connector_context_class_init(SPConnectorContextClass *klass); static void sp_connector_context_init(SPConnectorContext *conn_context); static void sp_connector_context_dispose(GObject *object); -- cgit v1.2.3 From 2f4efa8a787d175807a40b5bbafb1197e4dcc318 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 30 Nov 2012 14:22:44 -0500 Subject: Step 1. Remove junk and keep functionality. (bzr r11894.1.1) --- src/connector-context.cpp | 595 +++++----------------------------------------- 1 file changed, 53 insertions(+), 542 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 5f87ab712..1848652e3 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -5,10 +5,11 @@ * Michael Wybrow * Abhishek Sharma * Jon A. Cruz + * Martin Owens * * Copyright (C) 2005-2008 Michael Wybrow * Copyright (C) 2009 Monash University - * Copyright (C) 2010 authors + * Copyright (C) 2012 Authors * * Released under GNU GPL, read the file 'COPYING' for more information * @@ -22,7 +23,6 @@ * in the connector tool. Perhaps have a way to convert between. * o Only call libavoid's updateEndPoint as required. Currently we do it * for both endpoints, even if only one is moving. - * o Allow user-placeable connection points. * o Deal sanely with connectors with both endpoints attached to the * same connection point, and drawing of connectors attaching * overlapping shapes (currently tries to adjust connector to be @@ -41,30 +41,17 @@ * o Fix up libavoid's representation after undo actions. It doesn't see * any transform signals and hence doesn't know shapes have moved back to * there earlier positions. - * o Decide whether drawing/editing mode should be an Inkscape preference - * or the connector tool should always start in drawing mode. - * o Correct the problem with switching to the select tool when pressing - * space bar (there are moments when it refuses to do so). * * ---------------------------------------------------------------------------- * - * mjwybrow's observations on acracan's Summer of Code connector work: + * Notes: * - * - GUI comments: - * - * - Buttons for adding and removing user-specified connection - * points should probably have "+" and "-" symbols on them so they - * are consistent with the similar buttons for the node tool. - * - Controls on the connector tool be should be reordered logically, - * possibly as follows: - * - * *Connector*: [Polyline-radio-button] [Orthgonal-radio-button] - * [Curvature-control] | *Shape*: [Avoid-button] [Dont-avoid-button] - * [Spacing-control] | *Connection pts*: [Edit-mode] [Add-pt] [Rm-pt] - * - * I think that the network layout controls be moved to the - * Align and Distribute dialog (there is already the layout button - * there, but no options are exposed). + * Much of the way connectors work for user-defined points has been + * changed so that it no longer defines special attributes to record + * the points. Instead it uses single node paths to define points + * who are then seperate objects that can be fixed on the canvas, + * grouped into objects and take full advantage of all tranform, snap + * and align functionality of all other objects. * * I think that the style change between polyline and orthogonal * would be much clearer with two buttons (radio behaviour -- just @@ -74,80 +61,9 @@ * depending on whether an object is selected. We could consider * this but there may not be space. * - * The Add-pt and Rm-pt buttons should be greyed out (inactive) if - * we are not in connection point editing mode. And probably also - * if there is no shape selected, i.e. at the times they have no - * effect when clicked. - * * Likewise for the avoid/ignore shapes buttons. These should be * inactive when a shape is not selected in the connector context. * - * - When creating/editing connection points: - * - * - Strange things can happen if you have connectors selected, or - * try rerouting connectors by dragging their endpoints when in - * connection point editing mode. - * - * - Possibly the selected shape's connection points should always - * be shown (i.e., have knots) when in editing mode. - * - * - It is a little strange to be able to place connection points - * competely outside shapes. Especially when you later can't draw - * connectors to them since the knots are only visible when you - * are over the shape. I think that you should only be able to - * place connection points inside or on the boundary of the shape - * itself. - * - * - The intended ability to place a new point at the current cursor - * position by pressing RETURN does not seem to work. - * - * - The Status bar tooltip should change to reflect editing mode - * and tell the user about RETURN and how to use the tool. - * - * - Connection points general: - * - * - Connection points that were inside the shape can end up outside - * after a rotation is applied to the shape in the select tool. - * It doesn't seem like the correct transform is being applied to - * these, or it is being applied at the wrong time. I'd expect - * connection points to rotate with the shape, and stay at the - * same position "on the shape" - * - * - I was able to make the connectors attached to a shape fall off - * the shape after scaling it. Not sure the exact cause, but may - * require more investigation/debugging. - * - * - The user-defined connection points should be either absolute - * (as the current ones are) or defined as a percentage of the - * shape. These would be based on a toggle setting on the - * toolbar, and they would be placed in exactly the same way by - * the user. The only difference would be that they would be - * store as percentage positions in the SVG connection-points - * property and that they would update/move automatically if the - * object was resized or scaled. - * - * - Thinking more, I think you always want to store and think about - * the positions of connection points to be pre-transform, but - * obviously the shape transform is applied to them. That way, - * they will rotate and scale automatically with the shape, when - * the shape transform is altered. The Percentage version would - * compute their position from the pre-transform dimensions and - * then have the transform applied to them, for example. - * - * - The connection points in the test_connection_points.svg file - * seem to follow the shape when it is moved, but connection - * points I add to new shapes, do not follow the shape, either - * when the shape is just moved or transformed. There is - * something wrong here. What exactly should the behaviour be - * currently? - * - * - I see that connection points are specified at absolute canvas - * positions. I really think that they should be specified in - * shape coordinated relative to the shapes. There may be - * transforms applied to layers and the canvas which would make - * specifying them quite difficult. I'd expect a position of 0, 0 - * to be on the shape in question or very close to it, for example. - * */ @@ -158,7 +74,6 @@ #include "connector-context.h" #include "pixmaps/cursor-connector.xpm" -#include "pixmaps/cursor-node.xpm" #include "xml/node-event-vector.h" #include "xml/repr.h" #include "svg/svg.h" @@ -219,12 +134,13 @@ static gint connector_handle_motion_notify(SPConnectorContext *const cc, GdkEven static gint connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton const &revent); static gint connector_handle_key_press(SPConnectorContext *const cc, guint const keyval); -static void cc_active_shape_add_knot(SPDesktop* desktop, SPItem* item, ConnectionPointMap &cphandles, ConnectionPoint& cp); +static void cc_active_shape_add_knot(SPConnectorContext *cc, SPItem* item); static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item); +static void cc_clear_active_knots(SPKnotList k); static void cc_clear_active_shape(SPConnectorContext *cc); static void cc_set_active_conn(SPConnectorContext *cc, SPItem *item); static void cc_clear_active_conn(SPConnectorContext *cc); -static bool conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p, gchar **href, gchar **cpid); +static bool conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p, gchar **href); static void cc_select_handle(SPKnot* knot); static void cc_deselect_handle(SPKnot* knot); static bool cc_item_is_shape(SPItem *item); @@ -238,10 +154,6 @@ static void shape_event_attr_changed(Inkscape::XML::Node *repr, gchar const *nam gchar const *old_value, gchar const *new_value, bool is_interactive, gpointer data); - -static char* cc_knot_tips[] = { _("Connection point: click or drag to create a new connector"), - _("Connection point: click to select, drag to move") }; - /*static Geom::Point connector_drag_origin_w(0, 0); static bool connector_within_tolerance = false;*/ static SPEventContextClass *parent_class; @@ -316,9 +228,6 @@ sp_connector_context_init(SPConnectorContext *cc) ec->xp = 0; ec->yp = 0; - cc->mode = SP_CONNECTOR_CONTEXT_DRAWING_MODE; - cc->knot_tip = 0; - cc->red_color = 0xff00007f; cc->newconn = NULL; @@ -341,16 +250,14 @@ sp_connector_context_init(SPConnectorContext *cc) cc->clickeditem = NULL; cc->clickedhandle = NULL; - new (&cc->connpthandles) ConnectionPointMap(); + new (&cc->knots) SPKnotList(); for (int i = 0; i < 2; ++i) { cc->endpt_handle[i] = NULL; cc->endpt_handler_id[i] = 0; } cc->shref = NULL; - cc->scpid = NULL; cc->ehref = NULL; - cc->ecpid = NULL; cc->npoints = 0; cc->state = SP_CONNECTOR_CONTEXT_IDLE; } @@ -363,14 +270,6 @@ sp_connector_context_dispose(GObject *object) cc->sel_changed_connection.disconnect(); - if (!cc->connpthandles.empty()) { - for (ConnectionPointMap::iterator it = cc->connpthandles.begin(); - it != cc->connpthandles.end(); ++it) { - g_object_unref(it->first); - } - cc->connpthandles.clear(); - } - cc->connpthandles.~ConnectionPointMap(); for (int i = 0; i < 2; ++i) { if (cc->endpt_handle[1]) { g_object_unref(cc->endpt_handle[i]); @@ -381,18 +280,10 @@ sp_connector_context_dispose(GObject *object) g_free(cc->shref); cc->shref = NULL; } - if (cc->scpid) { - g_free(cc->scpid); - cc->scpid = NULL; - } if (cc->ehref) { g_free(cc->shref); cc->shref = NULL; } - if (cc->ecpid) { - g_free(cc->scpid); - cc->scpid = NULL; - } g_assert( cc->newConnRef == NULL ); G_OBJECT_CLASS(parent_class)->dispose(object); @@ -435,8 +326,6 @@ sp_connector_context_setup(SPEventContext *ec) sp_event_context_read(ec, "curvature"); sp_event_context_read(ec, "orthogonal"); - sp_event_context_read(ec, "mode"); - cc->knot_tip = cc->mode == SP_CONNECTOR_CONTEXT_DRAWING_MODE ? cc_knot_tips[0] : cc_knot_tips[1]; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/tools/connector/selcue", 0)) { ec->enableSelectionCue(); @@ -462,50 +351,8 @@ sp_connector_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) else if ( name == "orthogonal" ) { cc->isOrthogonal = val->getBool(); } - else if ( name == "mode") - { - sp_connector_context_switch_mode(ec, val->getBool() ? SP_CONNECTOR_CONTEXT_EDITING_MODE : SP_CONNECTOR_CONTEXT_DRAWING_MODE); - } } -void sp_connector_context_switch_mode(SPEventContext* ec, unsigned int newMode) -{ - SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); - - cc->mode = newMode; - if ( cc->mode == SP_CONNECTOR_CONTEXT_DRAWING_MODE ) - { - ec->cursor_shape = cursor_connector_xpm; - cc->knot_tip = cc_knot_tips[0]; - if (cc->selected_handle) - cc_deselect_handle( cc->selected_handle ); - cc->selected_handle = NULL; - // Show all default connection points - - } - else if ( cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE ) - { - ec->cursor_shape = cursor_node_xpm; - cc->knot_tip = cc_knot_tips[1]; -/* if (cc->active_shape) - { - cc->selection->set( cc->active_shape ); - } - else - { - SPItem* item = cc->selection->singleItem(); - if ( item ) - { - cc_set_active_shape(cc, item); - cc->selection->set( item ); - } - }*/ - } - sp_event_context_update_cursor(ec); - -} - - static void sp_connector_context_finish(SPEventContext *ec) { @@ -554,16 +401,20 @@ cc_clear_active_shape(SPConnectorContext *cc) cc->active_shape_layer_repr = NULL; } + cc_clear_active_knots(cc->knots); +} + +static void +cc_clear_active_knots(SPKnotList k) +{ // Hide the connection points if they exist. - if (cc->connpthandles.size()) { - for (ConnectionPointMap::iterator it = cc->connpthandles.begin(); - it != cc->connpthandles.end(); ++it) { + if (k.size()) { + for (SPKnotList::iterator it = k.begin(); it != k.end(); ++it) { sp_knot_hide(it->first); } } } - static void cc_clear_active_conn(SPConnectorContext *cc) { @@ -590,21 +441,15 @@ cc_clear_active_conn(SPConnectorContext *cc) static bool -conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p, gchar **href, gchar **cpid) +conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p, gchar **href) { - // TODO: this will need to change when there are more connection - // points available for each shape. - - if (cc->active_handle && (cc->connpthandles.find(cc->active_handle) != cc->connpthandles.end())) + if (cc->active_handle && (cc->knots.find(cc->active_handle) != cc->knots.end())) { p = cc->active_handle->pos; - const ConnectionPoint& cp = cc->connpthandles[cc->active_handle]; - *href = g_strdup_printf("#%s", cc->active_shape->getId()); - *cpid = g_strdup_printf("%c%d", cp.type == ConnPointDefault ? 'd' : 'u' , cp.id); + *href = g_strdup_printf("#%s", cc->active_handle->owner->getId()); return true; } *href = NULL; - *cpid = NULL; return false; } @@ -660,14 +505,8 @@ sp_connector_context_item_handler(SPEventContext *event_context, SPItem *item, G cc->selection->toggle(item); } else { cc->selection->set(item); - if ( cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE && cc->selected_handle ) - { - cc_deselect_handle( cc->selected_handle ); - cc->selected_handle = NULL; - } - /* When selecting a new item, - do not allow showing connection points - on connectors. (yet?) + /* When selecting a new item, do not allow showing + connection points on connectors. (yet?) */ if ( item != cc->active_shape && !cc_item_is_connector( item ) ) cc_set_active_shape( cc, item ); @@ -678,20 +517,9 @@ sp_connector_context_item_handler(SPEventContext *event_context, SPItem *item, G break; case GDK_ENTER_NOTIFY: { - if (cc->mode == SP_CONNECTOR_CONTEXT_DRAWING_MODE || (cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE && !cc->selected_handle)) + if (!cc->selected_handle) { if (cc_item_is_shape(item)) { - - // I don't really understand what the above does, - // so I commented it. - // This is a shape, so show connection point(s). - /* if (!(cc->active_shape) - // Don't show handle for another handle. - // || (cc->connpthandles.find((SPKnot*) item) != cc->connpthandles.end()) - ) - { - cc_set_active_shape(cc, item); - }*/ cc_set_active_shape(cc, item); } ret = TRUE; @@ -754,8 +582,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const SPEventContext *event_context = SP_EVENT_CONTEXT(cc); gint ret = FALSE; - if ( cc->mode == SP_CONNECTOR_CONTEXT_DRAWING_MODE ) - { + if ( bevent.button == 1 && !event_context->space_panning ) { SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); @@ -766,7 +593,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const Geom::Point const event_w(bevent.x, bevent.y); -// connector_drag_origin_w = event_w; + cc->xp = bevent.x; cc->yp = bevent.y; cc->within_tolerance = true; @@ -790,7 +617,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const Geom::Point p = event_dt; // Test whether we clicked on a connection point - bool found = conn_pt_handle_test(cc, p, &cc->shref, &cc->scpid); + bool found = conn_pt_handle_test(cc, p, &cc->shref); if (!found) { // This is the first point, so just snap it to the grid @@ -815,8 +642,8 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const spcc_connector_set_subsequent_point(cc, p); spcc_connector_finish_segment(cc, p); - // Test whether we clicked on a connection point - /*bool found = */conn_pt_handle_test(cc, p, &cc->ehref, &cc->ecpid); + + conn_pt_handle_test(cc, p, &cc->ehref); if (cc->npoints != 0) { spcc_connector_finish(cc); } @@ -850,73 +677,9 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const ret = TRUE; } } - } - else if ( cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE ) - { - if ( bevent.button == 1 && !event_context->space_panning ) - { - // Initialize variables in case of dragging - - SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); - - if (Inkscape::have_viable_layer(desktop, cc->_message_context) == false) { - return TRUE; - } - - cc->xp = bevent.x; - cc->yp = bevent.y; - cc->within_tolerance = true; - - ConnectionPointMap::iterator const& active_knot_it = cc->connpthandles.find( cc->active_handle ); - - switch (cc->state) - { - case SP_CONNECTOR_CONTEXT_IDLE: - if ( active_knot_it != cc->connpthandles.end() ) - { - // We do not allow selecting and, thereby, moving default knots - if ( active_knot_it->second.type != ConnPointDefault) - { - if (cc->selected_handle != cc->active_handle) - { - if ( cc->selected_handle ) - cc_deselect_handle( cc->selected_handle ); - cc->selected_handle = cc->active_handle; - cc_select_handle( cc->selected_handle ); - } - } - else - // Just ignore the default connection point - return FALSE; - } - else - if ( cc->selected_handle ) - { - cc_deselect_handle( cc->selected_handle ); - cc->selected_handle = NULL; - } - - if ( cc->selected_handle ) - { - cc->state = SP_CONNECTOR_CONTEXT_DRAGGING; - cc->selection->set( cc->active_shape ); - } - - ret = TRUE; - break; - // Dragging valid because of the way we create - // new connection points. - case SP_CONNECTOR_CONTEXT_DRAGGING: - // Do nothing. - ret = TRUE; - break; - } - } - } return ret; } - static gint connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion const &mevent) { @@ -948,8 +711,6 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons /* Find desktop coordinates */ Geom::Point p = dt->w2d(event_w); - if ( cc->mode == SP_CONNECTOR_CONTEXT_DRAWING_MODE ) - { SnapManager &m = dt->namedview->snap_manager; switch (cc->state) { @@ -1010,26 +771,9 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons } break; } - } - else if ( cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE ) - { - switch ( cc->state ) - { - case SP_CONNECTOR_CONTEXT_DRAGGING: - sp_knot_set_position(cc->selected_handle, p, 0); - ret = TRUE; - break; - case SP_CONNECTOR_CONTEXT_NEWCONNPOINT: - sp_knot_set_position(cc->selected_handle, p, 0); - ret = TRUE; - break; - } - } - return ret; } - static gint connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton const &revent) { @@ -1046,8 +790,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con /* Find desktop coordinates */ Geom::Point p = cc->desktop->w2d(event_w); - if ( cc->mode == SP_CONNECTOR_CONTEXT_DRAWING_MODE ) - { + switch (cc->state) { //case SP_CONNECTOR_CONTEXT_POINT: case SP_CONNECTOR_CONTEXT_DRAGGING: @@ -1065,7 +808,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con spcc_connector_set_subsequent_point(cc, p); spcc_connector_finish_segment(cc, p); // Test whether we clicked on a connection point - /*bool found = */conn_pt_handle_test(cc, p, &cc->ehref, &cc->ecpid); + conn_pt_handle_test(cc, p, &cc->ehref); if (cc->npoints != 0) { spcc_connector_finish(cc); } @@ -1093,68 +836,14 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con } ret = TRUE; } - else if ( cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE ) - { - switch ( cc->state ) - { - case SP_CONNECTOR_CONTEXT_DRAGGING: - - if (!cc->within_tolerance) - { - m.setup(desktop); - m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); - m.unSetup(); - sp_knot_set_position(cc->selected_handle, p, 0); - ConnectionPoint& cp = cc->connpthandles[cc->selected_handle]; - cp.pos = p * (cc->active_shape)->dt2i_affine(); - cc->active_shape->avoidRef->updateConnectionPoint(cp); - } - - cc->state = SP_CONNECTOR_CONTEXT_IDLE; - ret = TRUE; - break; - - - case SP_CONNECTOR_CONTEXT_NEWCONNPOINT: - m.setup(desktop); - m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); - m.unSetup(); - - sp_knot_set_position(cc->selected_handle, p, 0); - - ConnectionPoint cp; - cp.type = ConnPointUserDefined; - cp.pos = p * (cc->active_shape)->dt2i_affine(); - cp.dir = Avoid::ConnDirAll; - g_object_unref(cc->selected_handle); - cc->active_shape->avoidRef->addConnectionPoint(cp); - doc->ensureUpToDate(); - for (ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end(); ++it) - if (it->second.type == ConnPointUserDefined && it->second.id == cp.id) - { - cc->selected_handle = it->first; - break; - } - cc_select_handle( cc->selected_handle ); - cc->state = SP_CONNECTOR_CONTEXT_IDLE; - ret = TRUE; - break; - } - } - } - - return ret; } - static gint connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) { gint ret = FALSE; - /* fixme: */ - if ( cc->mode == SP_CONNECTOR_CONTEXT_DRAWING_MODE ) - { + switch (keyval) { case GDK_KEY_Return: case GDK_KEY_KP_Enter: @@ -1189,100 +878,6 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) default: break; } - } - else if ( cc->mode == SP_CONNECTOR_CONTEXT_EDITING_MODE ) - { - switch ( cc->state ) - { - case SP_CONNECTOR_CONTEXT_DRAGGING: - if ( keyval == GDK_KEY_Escape ) - { - // Cancel connection point dragging - - // Obtain original position - ConnectionPoint const& cp = cc->connpthandles[cc->selected_handle]; - SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); - const Geom::Affine& i2doc = (cc->active_shape)->i2doc_affine(); - sp_knot_set_position(cc->selected_handle, cp.pos * i2doc * desktop->doc2dt(), 0); - cc->state = SP_CONNECTOR_CONTEXT_IDLE; - desktop->messageStack()->flash( Inkscape::NORMAL_MESSAGE, - _("Connection point drag cancelled.")); - ret = TRUE; - } - else if ( keyval == GDK_KEY_Return || keyval == GDK_KEY_KP_Enter ) - { - // Put connection point at current position - - Geom::Point p = cc->selected_handle->pos; - - if (!cc->within_tolerance) - { - SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); - SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop); - m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); - m.unSetup(); - sp_knot_set_position(cc->selected_handle, p, 0); - ConnectionPoint& cp = cc->connpthandles[cc->selected_handle]; - cp.pos = p * (cc->active_shape)->dt2i_affine(); - cc->active_shape->avoidRef->updateConnectionPoint(cp); - } - - cc->state = SP_CONNECTOR_CONTEXT_IDLE; - ret = TRUE; - } - break; - case SP_CONNECTOR_CONTEXT_NEWCONNPOINT: - if ( keyval == GDK_KEY_Escape ) - { - // Just destroy the knot - g_object_unref( cc->selected_handle ); - cc->selected_handle = NULL; - cc->state = SP_CONNECTOR_CONTEXT_IDLE; - ret = TRUE; - } - else if ( keyval == GDK_KEY_Return || keyval == GDK_KEY_KP_Enter ) - { - SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); - SPDocument *doc = sp_desktop_document(desktop); - SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop); - Geom::Point p = cc->selected_handle->pos; - m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); - m.unSetup(); - sp_knot_set_position(cc->selected_handle, p, 0); - - ConnectionPoint cp; - cp.type = ConnPointUserDefined; - cp.pos = p * (cc->active_shape)->dt2i_affine(); - cp.dir = Avoid::ConnDirAll; - g_object_unref(cc->selected_handle); - cc->active_shape->avoidRef->addConnectionPoint(cp); - doc->ensureUpToDate(); - for (ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end(); ++it) - if (it->second.type == ConnPointUserDefined && it->second.id == cp.id) - { - cc->selected_handle = it->first; - break; - } - cc_select_handle( cc->selected_handle ); - cc->state = SP_CONNECTOR_CONTEXT_IDLE; - ret = TRUE; - } - - break; - case SP_CONNECTOR_CONTEXT_IDLE: - if ( keyval == GDK_KEY_Delete && cc->selected_handle ) - { - cc->active_shape->avoidRef->deleteConnectionPoint(cc->connpthandles[cc->selected_handle]); - cc->selected_handle = NULL; - ret = TRUE; - } - - break; - } - } - return ret; } @@ -1300,17 +895,15 @@ cc_connector_rerouting_finish(SPConnectorContext *const cc, Geom::Point *const p if (p != NULL) { // Test whether we clicked on a connection point - gchar *shape_label, *cpid; - bool found = conn_pt_handle_test(cc, *p, &shape_label, &cpid); + gchar *shape_label; + bool found = conn_pt_handle_test(cc, *p, &shape_label); if (found) { if (cc->clickedhandle == cc->endpt_handle[0]) { cc->clickeditem->setAttribute("inkscape:connection-start", shape_label, NULL); - cc->clickeditem->setAttribute("inkscape:connection-start-point", cpid, NULL); } else { cc->clickeditem->setAttribute("inkscape:connection-end", shape_label, NULL); - cc->clickeditem->setAttribute("inkscape:connection-end-point", cpid, NULL); } g_free(shape_label); } @@ -1456,18 +1049,12 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) if (cc->shref) { cc->newconn->setAttribute( "inkscape:connection-start", cc->shref, NULL); - if (cc->scpid) { - cc->newconn->setAttribute( "inkscape:connection-start-point", cc->scpid, NULL); - } connection = true; } if (cc->ehref) { cc->newconn->setAttribute( "inkscape:connection-end", cc->ehref, NULL); - if (cc->ecpid) { - cc->newconn->setAttribute( "inkscape:connection-end-point", cc->ecpid, NULL); - } connection = true; } // Process pending updates. @@ -1540,7 +1127,7 @@ cc_generic_knot_handler(SPCanvasItem *, GdkEvent *event, SPKnot *knot) gboolean consumed = FALSE; - gchar* knot_tip = knot->tip ? knot->tip : cc->knot_tip; + gchar* knot_tip = "Click to join at this point"; switch (event->type) { case GDK_ENTER_NOTIFY: sp_knot_set_flag(knot, SP_KNOT_MOUSEOVER, TRUE); @@ -1624,10 +1211,12 @@ endpt_handler(SPKnot */*knot*/, GdkEvent *event, SPConnectorContext *cc) return consumed; } -static void cc_active_shape_add_knot(SPDesktop* desktop, SPItem* item, ConnectionPointMap &cphandles, ConnectionPoint& cp) +static void cc_active_shape_add_knot(SPConnectorContext *cc, SPItem* item) { + SPDesktop *desktop = cc->desktop; SPKnot *knot = sp_knot_new(desktop, 0); + knot->owner = item; knot->setShape(SP_KNOT_SHAPE_SQUARE); knot->setSize(8); knot->setAnchor(SP_ANCHOR_CENTER); @@ -1641,17 +1230,15 @@ static void cc_active_shape_add_knot(SPDesktop* desktop, SPItem* item, Connectio g_signal_connect(G_OBJECT(knot->item), "event", G_CALLBACK(cc_generic_knot_handler), knot); - sp_knot_set_position(knot, item->avoidRef->getConnectionPointPos(cp.type, cp.id) * desktop->doc2dt(), 0); + sp_knot_set_position(knot, item->avoidRef->getConnectionPointPos() * desktop->doc2dt(), 0); sp_knot_show(knot); - cphandles[knot] = cp; + cc->knots[knot] = 1; } static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item) { g_assert(item != NULL ); - std::map* connpts = &item->avoidRef->connection_points; - if (cc->active_shape != item) { // The active shape has changed @@ -1677,84 +1264,23 @@ static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item) sp_repr_add_listener(cc->active_shape_layer_repr, &layer_repr_events, cc); } + cc_clear_active_knots(cc->knots); + + // The idea here is to try and add a group's children to solidify + // connection handling. We react to path objects with only one node. + for (SPObject *child = item->firstChild() ; child ; child = child->getNext() ) { + if (SP_IS_PATH(child) && SP_PATH(child)->nodesInPath() == 1) { + cc_active_shape_add_knot(cc, (SPItem *) child); + } + } + cc_active_shape_add_knot(cc, item); - // Set the connection points. - if ( cc->connpthandles.size() ) - // destroy the old list - while (! cc->connpthandles.empty() ) - { - g_object_unref(cc->connpthandles.begin()->first); - cc->connpthandles.erase(cc->connpthandles.begin()); - } - // build the new one - if ( connpts->size() ) - for (std::map::iterator it = connpts->begin(); it != connpts->end(); ++it) - cc_active_shape_add_knot(cc->desktop, item, cc->connpthandles, it->second); - - // Also add default connection points - // For now, only centre default connection point will - // be available - ConnectionPoint centre; - centre.type = ConnPointDefault; - centre.id = ConnPointPosCC; - cc_active_shape_add_knot(cc->desktop, item, cc->connpthandles, centre); } else { - // The active shape didn't change - // Update only the connection point knots - // Ensure the item's connection_points map // has been updated item->document->ensureUpToDate(); - - std::set seen; - for ( ConnectionPointMap::iterator it = cc->connpthandles.begin(); it != cc->connpthandles.end() ;) - { - bool removed = false; - if ( it->second.type == ConnPointUserDefined ) - { - std::map::iterator p = connpts->find(it->second.id); - if (p != connpts->end()) - { - if ( it->second != p->second ) - // Connection point position has changed - // Update knot position - sp_knot_set_position(it->first, - item->avoidRef->getConnectionPointPos(it->second.type, it->second.id) * cc->desktop->doc2dt(), 0); - seen.insert(it->second.id); - sp_knot_show(it->first); - } - else - { - // This connection point does no longer exist, - // remove the knot - ConnectionPointMap::iterator curr = it; - ++it; - g_object_unref( curr->first ); - cc->connpthandles.erase(curr); - removed = true; - } - } - else - { - // It's a default connection point - // Just make sure it's position is correct - sp_knot_set_position(it->first, - item->avoidRef->getConnectionPointPos(it->second.type, it->second.id) * cc->desktop->doc2dt(), 0); - sp_knot_show(it->first); - - } - if ( !removed ) - ++it; - } - // Add knots for new connection points. - if (connpts->size()) - for ( std::map::iterator it = connpts->begin(); it != connpts->end(); ++it ) - if ( seen.find(it->first) == seen.end() ) - // A new connection point has been added - // to the shape. Add a knot for it. - cc_active_shape_add_knot(cc->desktop, item, cc->connpthandles, it->second); } } @@ -1885,15 +1411,6 @@ void cc_create_connection_point(SPConnectorContext* cc) } } -void cc_remove_connection_point(SPConnectorContext* cc) -{ - if (cc->selected_handle && cc->state == SP_CONNECTOR_CONTEXT_IDLE ) - { - cc->active_shape->avoidRef->deleteConnectionPoint(cc->connpthandles[cc->selected_handle]); - cc->selected_handle = NULL; - } -} - static bool cc_item_is_shape(SPItem *item) { if (SP_IS_PATH(item)) { @@ -2032,12 +1549,6 @@ shape_event_attr_changed(Inkscape::XML::Node *repr, gchar const *name, cc_set_active_conn(cc, cc->active_conn); } } - else - if ( !strcmp(name, "inkscape:connection-points") ) - if (repr == cc->active_shape_repr) - // The connection points of the active shape - // have changed. Update them. - cc_set_active_shape(cc, cc->active_shape); } -- cgit v1.2.3 From 4cff9f1b30d110eba814d9adc0689fa073c79157 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 31 Dec 2012 12:20:39 +0000 Subject: Replace C-style pointer casts in event contexts (bzr r12001) --- src/connector-context.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 5f87ab712..db2e049c7 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -287,13 +287,10 @@ sp_connector_context_get_type(void) static void sp_connector_context_class_init(SPConnectorContextClass *klass) { - GObjectClass *object_class; - SPEventContextClass *event_context_class; + GObjectClass *object_class = G_OBJECT_CLASS(klass); + SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - object_class = (GObjectClass *) klass; - event_context_class = (SPEventContextClass *) klass; - - parent_class = (SPEventContextClass*)g_type_class_peek_parent(klass); + parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); object_class->dispose = sp_connector_context_dispose; @@ -405,8 +402,8 @@ sp_connector_context_setup(SPEventContext *ec) SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); SPDesktop *dt = ec->desktop; - if (((SPEventContextClass *) parent_class)->setup) { - ((SPEventContextClass *) parent_class)->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) { + (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); } cc->selection = sp_desktop_selection(dt); @@ -514,8 +511,8 @@ sp_connector_context_finish(SPEventContext *ec) spcc_connector_finish(cc); cc->state = SP_CONNECTOR_CONTEXT_IDLE; - if (((SPEventContextClass *) parent_class)->finish) { - ((SPEventContextClass *) parent_class)->finish(ec); + if ((SP_EVENT_CONTEXT_CLASS(parent_class))->finish) { + (SP_EVENT_CONTEXT_CLASS(parent_class))->finish(ec); } if (cc->selection) { @@ -735,7 +732,7 @@ sp_connector_context_root_handler(SPEventContext *ec, GdkEvent *event) if (!ret) { gint (*const parent_root_handler)(SPEventContext *, GdkEvent *) - = ((SPEventContextClass *) parent_class)->root_handler; + = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler; if (parent_root_handler) { ret = parent_root_handler(ec, event); } @@ -1939,12 +1936,12 @@ void cc_selection_set_avoid(bool const set_avoid) Inkscape::Selection *selection = sp_desktop_selection(desktop); - GSList *l = (GSList *) selection->itemList(); + GSList *l = const_cast(selection->itemList()); int changes = 0; while (l) { - SPItem *item = (SPItem *) l->data; + SPItem *item = SP_ITEM(l->data); char const *value = (set_avoid) ? "true" : NULL; -- cgit v1.2.3 From 89f799d73d59da228c8d57593b02a87594909cdd Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Sun, 13 Jan 2013 00:49:26 -0800 Subject: Minor warning and dead code cleanup. (bzr r12018) --- src/connector-context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index b9d6e46b3..24a7203ac 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -1124,7 +1124,7 @@ cc_generic_knot_handler(SPCanvasItem *, GdkEvent *event, SPKnot *knot) gboolean consumed = FALSE; - gchar* knot_tip = "Click to join at this point"; + gchar const *knot_tip = "Click to join at this point"; switch (event->type) { case GDK_ENTER_NOTIFY: sp_knot_set_flag(knot, SP_KNOT_MOUSEOVER, TRUE); -- cgit v1.2.3 From 1615436543169f305d1df4d830ed8f5ec5dc75ed Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 26 Jan 2013 19:33:04 +0000 Subject: More GObject boilerplate reduction (bzr r12065) --- src/connector-context.cpp | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 24a7203ac..9631eecb1 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -109,8 +109,6 @@ using Inkscape::DocumentUndo; -static void sp_connector_context_class_init(SPConnectorContextClass *klass); -static void sp_connector_context_init(SPConnectorContext *conn_context); static void sp_connector_context_dispose(GObject *object); static void sp_connector_context_setup(SPEventContext *ec); @@ -156,8 +154,6 @@ static void shape_event_attr_changed(Inkscape::XML::Node *repr, gchar const *nam /*static Geom::Point connector_drag_origin_w(0, 0); static bool connector_within_tolerance = false;*/ -static SPEventContextClass *parent_class; - static Inkscape::XML::NodeEventVector shape_repr_events = { NULL, /* child_added */ @@ -175,26 +171,7 @@ static Inkscape::XML::NodeEventVector layer_repr_events = { NULL /* order_changed */ }; - -GType -sp_connector_context_get_type(void) -{ - static GType type = 0; - if (!type) { - GTypeInfo info = { - sizeof(SPConnectorContextClass), - NULL, NULL, - (GClassInitFunc) sp_connector_context_class_init, - NULL, NULL, - sizeof(SPConnectorContext), - 4, - (GInstanceInitFunc) sp_connector_context_init, - NULL, /* value_table */ - }; - type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPConnectorContext", &info, (GTypeFlags)0); - } - return type; -} +G_DEFINE_TYPE(SPConnectorContext, sp_connector_context, SP_TYPE_EVENT_CONTEXT); static void sp_connector_context_class_init(SPConnectorContextClass *klass) @@ -202,8 +179,6 @@ sp_connector_context_class_init(SPConnectorContextClass *klass) GObjectClass *object_class = G_OBJECT_CLASS(klass); SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - parent_class = SP_EVENT_CONTEXT_CLASS(g_type_class_peek_parent(klass)); - object_class->dispose = sp_connector_context_dispose; event_context_class->setup = sp_connector_context_setup; @@ -283,7 +258,7 @@ sp_connector_context_dispose(GObject *object) } g_assert( cc->newConnRef == NULL ); - G_OBJECT_CLASS(parent_class)->dispose(object); + G_OBJECT_CLASS(sp_connector_context_parent_class)->dispose(object); } @@ -293,8 +268,8 @@ sp_connector_context_setup(SPEventContext *ec) SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); SPDesktop *dt = ec->desktop; - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->setup) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->setup(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->setup) { + (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->setup(ec); } cc->selection = sp_desktop_selection(dt); @@ -358,8 +333,8 @@ sp_connector_context_finish(SPEventContext *ec) spcc_connector_finish(cc); cc->state = SP_CONNECTOR_CONTEXT_IDLE; - if ((SP_EVENT_CONTEXT_CLASS(parent_class))->finish) { - (SP_EVENT_CONTEXT_CLASS(parent_class))->finish(ec); + if ((SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->finish) { + (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->finish(ec); } if (cc->selection) { @@ -560,7 +535,7 @@ sp_connector_context_root_handler(SPEventContext *ec, GdkEvent *event) if (!ret) { gint (*const parent_root_handler)(SPEventContext *, GdkEvent *) - = (SP_EVENT_CONTEXT_CLASS(parent_class))->root_handler; + = (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->root_handler; if (parent_root_handler) { ret = parent_root_handler(ec, event); } -- cgit v1.2.3 From 577e007bb19822739a75702b7672cdd16cb86275 Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Sun, 31 Mar 2013 19:55:16 -0400 Subject: Fix copyright email for Martin Owens (bzr r12261) --- src/connector-context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 9631eecb1..9468894a0 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -5,7 +5,7 @@ * Michael Wybrow * Abhishek Sharma * Jon A. Cruz - * Martin Owens + * Martin Owens * * Copyright (C) 2005-2008 Michael Wybrow * Copyright (C) 2009 Monash University -- cgit v1.2.3 From e58cac52b258e64c2cc88b0044bf9cfbaecedce2 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 9 Apr 2013 00:23:07 +0200 Subject: Started conversion of SPEventContext tree; added virtual pads to all classes. (bzr r11608.1.89) --- src/connector-context.cpp | 49 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 9468894a0..aff1dcb4c 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -188,10 +188,17 @@ sp_connector_context_class_init(SPConnectorContextClass *klass) event_context_class->item_handler = sp_connector_context_item_handler; } +CConnectorContext::CConnectorContext(SPConnectorContext* connectorcontext) : CEventContext(connectorcontext) { + this->spconnectorcontext = connectorcontext; +} static void sp_connector_context_init(SPConnectorContext *cc) { + cc->cconnectorcontext = new CConnectorContext(cc); + delete cc->ceventcontext; + cc->ceventcontext = cc->cconnectorcontext; + SPEventContext *ec = SP_EVENT_CONTEXT(cc); ec->cursor_shape = cursor_connector_xpm; @@ -265,6 +272,12 @@ sp_connector_context_dispose(GObject *object) static void sp_connector_context_setup(SPEventContext *ec) { + ec->ceventcontext->setup(); +} + +void CConnectorContext::setup() { + SPConnectorContext* ec = this->spconnectorcontext; + SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); SPDesktop *dt = ec->desktop; @@ -312,6 +325,12 @@ sp_connector_context_setup(SPEventContext *ec) static void sp_connector_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) { + ec->ceventcontext->set(val); +} + +void CConnectorContext::set(Inkscape::Preferences::Entry* val) { + SPEventContext* ec = this->spconnectorcontext; + SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); /* fixme: Proper error handling for non-numeric data. Use a locale-independent function like @@ -328,6 +347,12 @@ sp_connector_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) static void sp_connector_context_finish(SPEventContext *ec) { + ec->ceventcontext->finish(); +} + +void CConnectorContext::finish() { + SPEventContext* ec = this->speventcontext; + SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); spcc_connector_finish(cc); @@ -348,7 +373,6 @@ sp_connector_context_finish(SPEventContext *ec) desktop->canvas->gen_all_enter_events = false; } - //----------------------------------------------------------------------------- @@ -448,6 +472,12 @@ cc_deselect_handle(SPKnot* knot) static gint sp_connector_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event) { + return event_context->ceventcontext->item_handler(item, event); +} + +gint CConnectorContext::item_handler(SPItem* item, GdkEvent* event) { + SPEventContext* event_context = this->speventcontext; + gint ret = FALSE; SPDesktop *desktop = event_context->desktop; @@ -509,6 +539,12 @@ sp_connector_context_item_handler(SPEventContext *event_context, SPItem *item, G gint sp_connector_context_root_handler(SPEventContext *ec, GdkEvent *event) { + return ec->ceventcontext->root_handler(event); +} + +gint CConnectorContext::root_handler(GdkEvent* event) { + SPEventContext* ec = this->speventcontext; + SPConnectorContext *const cc = SP_CONNECTOR_CONTEXT(ec); gint ret = FALSE; @@ -534,11 +570,12 @@ sp_connector_context_root_handler(SPEventContext *ec, GdkEvent *event) } if (!ret) { - gint (*const parent_root_handler)(SPEventContext *, GdkEvent *) - = (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->root_handler; - if (parent_root_handler) { - ret = parent_root_handler(ec, event); - } +// gint (*const parent_root_handler)(SPEventContext *, GdkEvent *) +// = (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->root_handler; +// if (parent_root_handler) { +// ret = parent_root_handler(ec, event); +// } + ret = CEventContext::root_handler(event); } return ret; -- cgit v1.2.3 From 1d8f1753cd8cab38d19fcc26a4ad70ba2e794ac8 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 9 Apr 2013 22:12:07 +0200 Subject: Added constructors to EventContext tree / some missing virtual pads. (bzr r11608.1.90) --- src/connector-context.cpp | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index aff1dcb4c..7b29126e6 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -181,24 +181,34 @@ sp_connector_context_class_init(SPConnectorContextClass *klass) object_class->dispose = sp_connector_context_dispose; - event_context_class->setup = sp_connector_context_setup; - event_context_class->set = sp_connector_context_set; - event_context_class->finish = sp_connector_context_finish; - event_context_class->root_handler = sp_connector_context_root_handler; - event_context_class->item_handler = sp_connector_context_item_handler; +// event_context_class->setup = sp_connector_context_setup; +// event_context_class->set = sp_connector_context_set; +// event_context_class->finish = sp_connector_context_finish; +// event_context_class->root_handler = sp_connector_context_root_handler; +// event_context_class->item_handler = sp_connector_context_item_handler; } CConnectorContext::CConnectorContext(SPConnectorContext* connectorcontext) : CEventContext(connectorcontext) { this->spconnectorcontext = connectorcontext; } -static void -sp_connector_context_init(SPConnectorContext *cc) -{ +SPConnectorContext::SPConnectorContext() : SPEventContext() { + SPConnectorContext* cc = this; + cc->cconnectorcontext = new CConnectorContext(cc); delete cc->ceventcontext; cc->ceventcontext = cc->cconnectorcontext; + cc->red_curve = 0; + cc->isOrthogonal = false; + cc->c1 = 0; + cc->red_bpath = 0; + cc->green_curve = 0; + cc->selection = 0; + cc->cl0 = 0; + cc->cl1 = 0; + cc->c0 = 0; + SPEventContext *ec = SP_EVENT_CONTEXT(cc); ec->cursor_shape = cursor_connector_xpm; @@ -241,6 +251,12 @@ sp_connector_context_init(SPConnectorContext *cc) cc->state = SP_CONNECTOR_CONTEXT_IDLE; } +static void +sp_connector_context_init(SPConnectorContext *cc) +{ + new (cc) SPConnectorContext(); +} + static void sp_connector_context_dispose(GObject *object) @@ -281,9 +297,10 @@ void CConnectorContext::setup() { SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); SPDesktop *dt = ec->desktop; - if ((SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->setup) { - (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->setup(ec); - } +// if ((SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->setup) { +// (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->setup(ec); +// } + CEventContext::setup(); cc->selection = sp_desktop_selection(dt); @@ -358,9 +375,10 @@ void CConnectorContext::finish() { spcc_connector_finish(cc); cc->state = SP_CONNECTOR_CONTEXT_IDLE; - if ((SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->finish) { - (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->finish(ec); - } +// if ((SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->finish) { +// (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->finish(ec); +// } + CEventContext::finish(); if (cc->selection) { cc->selection = NULL; -- cgit v1.2.3 From fbb85064cfaaf03cc09bacedb16a8561f61f2b3d Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 13 Apr 2013 00:37:18 +0200 Subject: Added prefPaths to contexts; modified SPFactory (bzr r11608.1.94) --- src/connector-context.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 7b29126e6..5c7bf97c8 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -171,6 +171,8 @@ static Inkscape::XML::NodeEventVector layer_repr_events = { NULL /* order_changed */ }; +const std::string SPConnectorContext::prefsPath = "/tools/connector"; + G_DEFINE_TYPE(SPConnectorContext, sp_connector_context, SP_TYPE_EVENT_CONTEXT); static void -- cgit v1.2.3 From fbdc8b84ff670c684dafc7d7d403ed01e7077e70 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 13 Apr 2013 18:13:17 +0200 Subject: Replaced casting macros for EventContext tree; added contructors. (bzr r11608.1.96) --- src/connector-context.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 5c7bf97c8..d5a628d46 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -171,6 +171,21 @@ static Inkscape::XML::NodeEventVector layer_repr_events = { NULL /* order_changed */ }; + +#include "sp-factory.h" + +namespace { + SPEventContext* createConnectorContext() { + return new SPConnectorContext(); + } + + bool connectorContextRegistered = ToolFactory::instance().registerObject("/tools/connector", createConnectorContext); +} + +const std::string& CConnectorContext::getPrefsPath() { + return SPConnectorContext::prefsPath; +} + const std::string SPConnectorContext::prefsPath = "/tools/connector"; G_DEFINE_TYPE(SPConnectorContext, sp_connector_context, SP_TYPE_EVENT_CONTEXT); @@ -200,6 +215,7 @@ SPConnectorContext::SPConnectorContext() : SPEventContext() { cc->cconnectorcontext = new CConnectorContext(cc); delete cc->ceventcontext; cc->ceventcontext = cc->cconnectorcontext; + types.insert(typeid(SPConnectorContext)); cc->red_curve = 0; cc->isOrthogonal = false; -- cgit v1.2.3 From 65ba6ad9a82f8f47974eb10665478fd783692bb5 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 20 Apr 2013 23:19:46 +0200 Subject: Merging of EventContext classes complete. (bzr r11608.1.98) --- src/connector-context.cpp | 112 ++++++++-------------------------------------- 1 file changed, 18 insertions(+), 94 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index d5a628d46..1dad3cad9 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -109,14 +109,6 @@ using Inkscape::DocumentUndo; -static void sp_connector_context_dispose(GObject *object); - -static void sp_connector_context_setup(SPEventContext *ec); -static void sp_connector_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val); -static void sp_connector_context_finish(SPEventContext *ec); -static gint sp_connector_context_root_handler(SPEventContext *ec, GdkEvent *event); -static gint sp_connector_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event); - // Stuff borrowed from DrawContext static void spcc_connector_set_initial_point(SPConnectorContext *cc, Geom::Point const p); static void spcc_connector_set_subsequent_point(SPConnectorContext *cc, Geom::Point const p); @@ -182,41 +174,15 @@ namespace { bool connectorContextRegistered = ToolFactory::instance().registerObject("/tools/connector", createConnectorContext); } -const std::string& CConnectorContext::getPrefsPath() { +const std::string& SPConnectorContext::getPrefsPath() { return SPConnectorContext::prefsPath; } const std::string SPConnectorContext::prefsPath = "/tools/connector"; -G_DEFINE_TYPE(SPConnectorContext, sp_connector_context, SP_TYPE_EVENT_CONTEXT); - -static void -sp_connector_context_class_init(SPConnectorContextClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS(klass); - SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - - object_class->dispose = sp_connector_context_dispose; - -// event_context_class->setup = sp_connector_context_setup; -// event_context_class->set = sp_connector_context_set; -// event_context_class->finish = sp_connector_context_finish; -// event_context_class->root_handler = sp_connector_context_root_handler; -// event_context_class->item_handler = sp_connector_context_item_handler; -} - -CConnectorContext::CConnectorContext(SPConnectorContext* connectorcontext) : CEventContext(connectorcontext) { - this->spconnectorcontext = connectorcontext; -} - SPConnectorContext::SPConnectorContext() : SPEventContext() { SPConnectorContext* cc = this; - cc->cconnectorcontext = new CConnectorContext(cc); - delete cc->ceventcontext; - cc->ceventcontext = cc->cconnectorcontext; - types.insert(typeid(SPConnectorContext)); - cc->red_curve = 0; cc->isOrthogonal = false; cc->c1 = 0; @@ -257,7 +223,7 @@ SPConnectorContext::SPConnectorContext() : SPEventContext() { cc->clickeditem = NULL; cc->clickedhandle = NULL; - new (&cc->knots) SPKnotList(); + //new (&cc->knots) SPKnotList(); for (int i = 0; i < 2; ++i) { cc->endpt_handle[i] = NULL; @@ -269,17 +235,8 @@ SPConnectorContext::SPConnectorContext() : SPEventContext() { cc->state = SP_CONNECTOR_CONTEXT_IDLE; } -static void -sp_connector_context_init(SPConnectorContext *cc) -{ - new (cc) SPConnectorContext(); -} - - -static void -sp_connector_context_dispose(GObject *object) -{ - SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(object); +SPConnectorContext::~SPConnectorContext() { + SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(this); cc->sel_changed_connection.disconnect(); @@ -299,18 +256,11 @@ sp_connector_context_dispose(GObject *object) } g_assert( cc->newConnRef == NULL ); - G_OBJECT_CLASS(sp_connector_context_parent_class)->dispose(object); + //G_OBJECT_CLASS(sp_connector_context_parent_class)->dispose(object); } - -static void -sp_connector_context_setup(SPEventContext *ec) -{ - ec->ceventcontext->setup(); -} - -void CConnectorContext::setup() { - SPConnectorContext* ec = this->spconnectorcontext; +void SPConnectorContext::setup() { + SPConnectorContext* ec = this; SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); SPDesktop *dt = ec->desktop; @@ -318,7 +268,7 @@ void CConnectorContext::setup() { // if ((SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->setup) { // (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->setup(ec); // } - CEventContext::setup(); + SPEventContext::setup(); cc->selection = sp_desktop_selection(dt); @@ -356,15 +306,8 @@ void CConnectorContext::setup() { dt->canvas->gen_all_enter_events = true; } - -static void -sp_connector_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) -{ - ec->ceventcontext->set(val); -} - -void CConnectorContext::set(Inkscape::Preferences::Entry* val) { - SPEventContext* ec = this->spconnectorcontext; +void SPConnectorContext::set(Inkscape::Preferences::Entry* val) { + SPEventContext* ec = this; SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); @@ -379,14 +322,8 @@ void CConnectorContext::set(Inkscape::Preferences::Entry* val) { } } -static void -sp_connector_context_finish(SPEventContext *ec) -{ - ec->ceventcontext->finish(); -} - -void CConnectorContext::finish() { - SPEventContext* ec = this->speventcontext; +void SPConnectorContext::finish() { + SPEventContext* ec = this; SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); @@ -396,7 +333,7 @@ void CConnectorContext::finish() { // if ((SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->finish) { // (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->finish(ec); // } - CEventContext::finish(); + SPEventContext::finish(); if (cc->selection) { cc->selection = NULL; @@ -505,14 +442,8 @@ cc_deselect_handle(SPKnot* knot) sp_knot_update_ctrl(knot); } -static gint -sp_connector_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event) -{ - return event_context->ceventcontext->item_handler(item, event); -} - -gint CConnectorContext::item_handler(SPItem* item, GdkEvent* event) { - SPEventContext* event_context = this->speventcontext; +gint SPConnectorContext::item_handler(SPItem* item, GdkEvent* event) { + SPEventContext* event_context = this; gint ret = FALSE; @@ -571,15 +502,8 @@ gint CConnectorContext::item_handler(SPItem* item, GdkEvent* event) { return ret; } - -gint -sp_connector_context_root_handler(SPEventContext *ec, GdkEvent *event) -{ - return ec->ceventcontext->root_handler(event); -} - -gint CConnectorContext::root_handler(GdkEvent* event) { - SPEventContext* ec = this->speventcontext; +gint SPConnectorContext::root_handler(GdkEvent* event) { + SPEventContext* ec = this; SPConnectorContext *const cc = SP_CONNECTOR_CONTEXT(ec); @@ -611,7 +535,7 @@ gint CConnectorContext::root_handler(GdkEvent* event) { // if (parent_root_handler) { // ret = parent_root_handler(ec, event); // } - ret = CEventContext::root_handler(event); + ret = SPEventContext::root_handler(event); } return ret; -- cgit v1.2.3 From 5512f857e2f33f1aa40124dc82b353e5f2e5a0b0 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 20 Apr 2013 23:58:53 +0200 Subject: Moved factories to different files. (bzr r11608.1.100) --- src/connector-context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 1dad3cad9..b7e3942b9 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -164,7 +164,7 @@ static Inkscape::XML::NodeEventVector layer_repr_events = { }; -#include "sp-factory.h" +#include "tool-factory.h" namespace { SPEventContext* createConnectorContext() { -- cgit v1.2.3 From bdde74bbab299f2ee448f1c55469c56a66fb01f7 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 21 Apr 2013 23:58:15 +0200 Subject: Removed some unused files; more refactoring in EventContext tree. (bzr r11608.1.104) --- src/connector-context.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index b7e3942b9..42bf6584b 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -306,19 +306,19 @@ void SPConnectorContext::setup() { dt->canvas->gen_all_enter_events = true; } -void SPConnectorContext::set(Inkscape::Preferences::Entry* val) { +void SPConnectorContext::set(const Inkscape::Preferences::Entry& val) { SPEventContext* ec = this; SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); /* fixme: Proper error handling for non-numeric data. Use a locale-independent function like * g_ascii_strtod (or a thin wrapper that does the right thing for invalid values inf/nan). */ - Glib::ustring name = val->getEntryName(); + Glib::ustring name = val.getEntryName(); if ( name == "curvature" ) { - cc->curvature = val->getDoubleLimited(); // prevents NaN and +/-Inf from messing up + cc->curvature = val.getDoubleLimited(); // prevents NaN and +/-Inf from messing up } else if ( name == "orthogonal" ) { - cc->isOrthogonal = val->getBool(); + cc->isOrthogonal = val.getBool(); } } -- cgit v1.2.3 From 9b2956fbaefb4e12bad3fc359c47e5923f33bb41 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sun, 28 Apr 2013 00:05:16 +0200 Subject: various changes (bzr r11608.1.105) --- src/connector-context.cpp | 266 +++++++++++++++++++--------------------------- 1 file changed, 110 insertions(+), 156 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 42bf6584b..12d9e41b8 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -134,7 +134,6 @@ static bool conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p, gchar ** static void cc_select_handle(SPKnot* knot); static void cc_deselect_handle(SPKnot* knot); static bool cc_item_is_shape(SPItem *item); -static void cc_selection_changed(Inkscape::Selection *selection, gpointer data); static void cc_connector_rerouting_finish(SPConnectorContext *const cc, Geom::Point *const p); @@ -181,169 +180,145 @@ const std::string& SPConnectorContext::getPrefsPath() { const std::string SPConnectorContext::prefsPath = "/tools/connector"; SPConnectorContext::SPConnectorContext() : SPEventContext() { - SPConnectorContext* cc = this; + this->red_curve = 0; + this->isOrthogonal = false; + this->c1 = 0; + this->red_bpath = 0; + this->green_curve = 0; + this->selection = 0; + this->cl0 = 0; + this->cl1 = 0; + this->c0 = 0; - cc->red_curve = 0; - cc->isOrthogonal = false; - cc->c1 = 0; - cc->red_bpath = 0; - cc->green_curve = 0; - cc->selection = 0; - cc->cl0 = 0; - cc->cl1 = 0; - cc->c0 = 0; + this->cursor_shape = cursor_connector_xpm; + this->hot_x = 1; + this->hot_y = 1; + this->xp = 0; + this->yp = 0; - SPEventContext *ec = SP_EVENT_CONTEXT(cc); + this->red_color = 0xff00007f; - ec->cursor_shape = cursor_connector_xpm; - ec->hot_x = 1; - ec->hot_y = 1; - ec->xp = 0; - ec->yp = 0; + this->newconn = NULL; + this->newConnRef = NULL; + this->curvature = 0.0; - cc->red_color = 0xff00007f; + this->sel_changed_connection = sigc::connection(); - cc->newconn = NULL; - cc->newConnRef = NULL; - cc->curvature = 0.0; + this->active_shape = NULL; + this->active_shape_repr = NULL; + this->active_shape_layer_repr = NULL; - cc->sel_changed_connection = sigc::connection(); + this->active_conn = NULL; + this->active_conn_repr = NULL; - cc->active_shape = NULL; - cc->active_shape_repr = NULL; - cc->active_shape_layer_repr = NULL; - - cc->active_conn = NULL; - cc->active_conn_repr = NULL; - - cc->active_handle = NULL; + this->active_handle = NULL; - cc->selected_handle = NULL; + this->selected_handle = NULL; - cc->clickeditem = NULL; - cc->clickedhandle = NULL; - - //new (&cc->knots) SPKnotList(); + this->clickeditem = NULL; + this->clickedhandle = NULL; for (int i = 0; i < 2; ++i) { - cc->endpt_handle[i] = NULL; - cc->endpt_handler_id[i] = 0; + this->endpt_handle[i] = NULL; + this->endpt_handler_id[i] = 0; } - cc->shref = NULL; - cc->ehref = NULL; - cc->npoints = 0; - cc->state = SP_CONNECTOR_CONTEXT_IDLE; + + this->shref = NULL; + this->ehref = NULL; + this->npoints = 0; + this->state = SP_CONNECTOR_CONTEXT_IDLE; } SPConnectorContext::~SPConnectorContext() { - SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(this); - - cc->sel_changed_connection.disconnect(); + this->sel_changed_connection.disconnect(); for (int i = 0; i < 2; ++i) { - if (cc->endpt_handle[1]) { - g_object_unref(cc->endpt_handle[i]); - cc->endpt_handle[i] = NULL; + if (this->endpt_handle[1]) { + g_object_unref(this->endpt_handle[i]); + this->endpt_handle[i] = NULL; } } - if (cc->shref) { - g_free(cc->shref); - cc->shref = NULL; + + if (this->shref) { + g_free(this->shref); + this->shref = NULL; } - if (cc->ehref) { - g_free(cc->shref); - cc->shref = NULL; + + if (this->ehref) { + g_free(this->shref); + this->shref = NULL; } - g_assert( cc->newConnRef == NULL ); - - //G_OBJECT_CLASS(sp_connector_context_parent_class)->dispose(object); + + g_assert( this->newConnRef == NULL ); } void SPConnectorContext::setup() { - SPConnectorContext* ec = this; - - SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); - SPDesktop *dt = ec->desktop; - -// if ((SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->setup) { -// (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->setup(ec); -// } SPEventContext::setup(); - cc->selection = sp_desktop_selection(dt); + this->selection = sp_desktop_selection(this->desktop); - cc->sel_changed_connection.disconnect(); - cc->sel_changed_connection = cc->selection->connectChanged( - sigc::bind(sigc::ptr_fun(&cc_selection_changed), - (gpointer) cc)); + this->sel_changed_connection.disconnect(); + this->sel_changed_connection = this->selection->connectChanged( + sigc::mem_fun(this, &SPConnectorContext::selection_changed) + ); /* Create red bpath */ - cc->red_bpath = sp_canvas_bpath_new(sp_desktop_sketch(ec->desktop), NULL); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cc->red_bpath), cc->red_color, + this->red_bpath = sp_canvas_bpath_new(sp_desktop_sketch(this->desktop), NULL); + sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->red_bpath), this->red_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cc->red_bpath), 0x00000000, + sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(this->red_bpath), 0x00000000, SP_WIND_RULE_NONZERO); /* Create red curve */ - cc->red_curve = new SPCurve(); + this->red_curve = new SPCurve(); /* Create green curve */ - cc->green_curve = new SPCurve(); + this->green_curve = new SPCurve(); // Notice the initial selection. - cc_selection_changed(cc->selection, (gpointer) cc); + //cc_selection_changed(this->selection, (gpointer) this); + this->selection_changed(this->selection); - cc->within_tolerance = false; + this->within_tolerance = false; - sp_event_context_read(ec, "curvature"); - sp_event_context_read(ec, "orthogonal"); + sp_event_context_read(this, "curvature"); + sp_event_context_read(this, "orthogonal"); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/tools/connector/selcue", 0)) { - ec->enableSelectionCue(); + this->enableSelectionCue(); } // Make sure we see all enter events for canvas items, // even if a mouse button is depressed. - dt->canvas->gen_all_enter_events = true; + this->desktop->canvas->gen_all_enter_events = true; } void SPConnectorContext::set(const Inkscape::Preferences::Entry& val) { - SPEventContext* ec = this; - - SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); - /* fixme: Proper error handling for non-numeric data. Use a locale-independent function like * g_ascii_strtod (or a thin wrapper that does the right thing for invalid values inf/nan). */ Glib::ustring name = val.getEntryName(); - if ( name == "curvature" ) { - cc->curvature = val.getDoubleLimited(); // prevents NaN and +/-Inf from messing up - } - else if ( name == "orthogonal" ) { - cc->isOrthogonal = val.getBool(); + + if (name == "curvature") { + this->curvature = val.getDoubleLimited(); // prevents NaN and +/-Inf from messing up + } else if (name == "orthogonal") { + this->isOrthogonal = val.getBool(); } } void SPConnectorContext::finish() { - SPEventContext* ec = this; - - SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(ec); + spcc_connector_finish(this); + this->state = SP_CONNECTOR_CONTEXT_IDLE; - spcc_connector_finish(cc); - cc->state = SP_CONNECTOR_CONTEXT_IDLE; - -// if ((SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->finish) { -// (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->finish(ec); -// } SPEventContext::finish(); - if (cc->selection) { - cc->selection = NULL; + if (this->selection) { + this->selection = NULL; } - cc_clear_active_shape(cc); - cc_clear_active_conn(cc); + + cc_clear_active_shape(this); + cc_clear_active_conn(this); // Restore the default event generating behaviour. - SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(ec); - desktop->canvas->gen_all_enter_events = false; + this->desktop->canvas->gen_all_enter_events = false; } //----------------------------------------------------------------------------- @@ -443,58 +418,53 @@ cc_deselect_handle(SPKnot* knot) } gint SPConnectorContext::item_handler(SPItem* item, GdkEvent* event) { - SPEventContext* event_context = this; - gint ret = FALSE; - SPDesktop *desktop = event_context->desktop; - - SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(event_context); - Geom::Point p(event->button.x, event->button.y); switch (event->type) { case GDK_BUTTON_RELEASE: - if (event->button.button == 1 && !event_context->space_panning) { - if ((cc->state == SP_CONNECTOR_CONTEXT_DRAGGING) && - (event_context->within_tolerance)) - { - spcc_reset_colors(cc); - cc->state = SP_CONNECTOR_CONTEXT_IDLE; + if (event->button.button == 1 && !this->space_panning) { + if ((this->state == SP_CONNECTOR_CONTEXT_DRAGGING) && this->within_tolerance) { + spcc_reset_colors(this); + this->state = SP_CONNECTOR_CONTEXT_IDLE; } - if (cc->state != SP_CONNECTOR_CONTEXT_IDLE) { + + if (this->state != SP_CONNECTOR_CONTEXT_IDLE) { // Doing something else like rerouting. break; } + // find out clicked item, honoring Alt - SPItem *item = sp_event_context_find_item(desktop, - p, event->button.state & GDK_MOD1_MASK, FALSE); + SPItem *item = sp_event_context_find_item(desktop, p, event->button.state & GDK_MOD1_MASK, FALSE); if (event->button.state & GDK_SHIFT_MASK) { - cc->selection->toggle(item); + this->selection->toggle(item); } else { - cc->selection->set(item); + this->selection->set(item); /* When selecting a new item, do not allow showing connection points on connectors. (yet?) */ - if ( item != cc->active_shape && !cc_item_is_connector( item ) ) - cc_set_active_shape( cc, item ); + + if (item != this->active_shape && !cc_item_is_connector(item)) { + cc_set_active_shape(this, item); + } } - ret = TRUE; + ret = TRUE; } break; + case GDK_ENTER_NOTIFY: - { - if (!cc->selected_handle) - { + if (!this->selected_handle) { if (cc_item_is_shape(item)) { - cc_set_active_shape(cc, item); + cc_set_active_shape(this, item); } + ret = TRUE; } break; - } + default: break; } @@ -503,26 +473,23 @@ gint SPConnectorContext::item_handler(SPItem* item, GdkEvent* event) { } gint SPConnectorContext::root_handler(GdkEvent* event) { - SPEventContext* ec = this; - - SPConnectorContext *const cc = SP_CONNECTOR_CONTEXT(ec); - gint ret = FALSE; switch (event->type) { case GDK_BUTTON_PRESS: - ret = connector_handle_button_press(cc, event->button); + ret = connector_handle_button_press(this, event->button); break; case GDK_MOTION_NOTIFY: - ret = connector_handle_motion_notify(cc, event->motion); + ret = connector_handle_motion_notify(this, event->motion); break; case GDK_BUTTON_RELEASE: - ret = connector_handle_button_release(cc, event->button); + ret = connector_handle_button_release(this, event->button); break; + case GDK_KEY_PRESS: - ret = connector_handle_key_press(cc, get_group0_keyval (&event->key)); + ret = connector_handle_key_press(this, get_group0_keyval (&event->key)); break; default: @@ -530,11 +497,6 @@ gint SPConnectorContext::root_handler(GdkEvent* event) { } if (!ret) { -// gint (*const parent_root_handler)(SPEventContext *, GdkEvent *) -// = (SP_EVENT_CONTEXT_CLASS(sp_connector_context_parent_class))->root_handler; -// if (parent_root_handler) { -// ret = parent_root_handler(ec, event); -// } ret = SPEventContext::root_handler(event); } @@ -1455,32 +1417,24 @@ void cc_selection_set_avoid(bool const set_avoid) DocumentUndo::done(document, SP_VERB_CONTEXT_CONNECTOR, event_desc); } - -static void -cc_selection_changed(Inkscape::Selection *selection, gpointer data) -{ - SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(data); - //SPEventContext *ec = SP_EVENT_CONTEXT(cc); - +void SPConnectorContext::selection_changed(Inkscape::Selection *selection) { SPItem *item = selection->singleItem(); - if (cc->active_conn == item) - { + if (this->active_conn == item) { // Nothing to change. return; } - if (item == NULL) - { - cc_clear_active_conn(cc); + + if (item == NULL) { + cc_clear_active_conn(this); return; } if (cc_item_is_connector(item)) { - cc_set_active_conn(cc, item); + cc_set_active_conn(this, item); } } - static void shape_event_attr_deleted(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, Inkscape::XML::Node */*ref*/, gpointer data) -- cgit v1.2.3 From b2dd3583e7372d23d18bbc6e861f4f645ec3dc37 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Tue, 30 Jul 2013 23:17:21 +0200 Subject: Further refactoring of EventContexts. (bzr r11608.1.109) --- src/connector-context.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 12d9e41b8..72a01dee9 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -417,7 +417,7 @@ cc_deselect_handle(SPKnot* knot) sp_knot_update_ctrl(knot); } -gint SPConnectorContext::item_handler(SPItem* item, GdkEvent* event) { +bool SPConnectorContext::item_handler(SPItem* item, GdkEvent* event) { gint ret = FALSE; Geom::Point p(event->button.x, event->button.y); @@ -472,7 +472,7 @@ gint SPConnectorContext::item_handler(SPItem* item, GdkEvent* event) { return ret; } -gint SPConnectorContext::root_handler(GdkEvent* event) { +bool SPConnectorContext::root_handler(GdkEvent* event) { gint ret = FALSE; switch (event->type) { @@ -1096,7 +1096,7 @@ cc_generic_knot_handler(SPCanvasItem *, GdkEvent *event, SPKnot *knot) static gboolean endpt_handler(SPKnot */*knot*/, GdkEvent *event, SPConnectorContext *cc) { - g_assert( SP_IS_CONNECTOR_CONTEXT(cc) ); + //g_assert( SP_IS_CONNECTOR_CONTEXT(cc) ); gboolean consumed = FALSE; -- cgit v1.2.3 From 989abbac025a8b3349748d19a613a08586c5fdcd Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 31 Jul 2013 21:11:20 +0200 Subject: Fixed SPObject ctor and dtor; removed singleton.h; some smaller changes. (bzr r11608.1.110) --- src/connector-context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 72a01dee9..c79c58125 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -518,7 +518,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); - if (Inkscape::have_viable_layer(desktop, cc->_message_context) == false) { + if (Inkscape::have_viable_layer(desktop, cc->message_context) == false) { return TRUE; } -- cgit v1.2.3 From 632414c7cdd5f8992c6d6439d25128b82e93d499 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Mon, 2 Sep 2013 15:51:04 -0400 Subject: Fix bug that added transforms to new objects. (bzr r12475.1.11) --- src/connector-context.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 9468894a0..acff93360 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -1039,6 +1039,8 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) cc->newconn->updateRepr(); } + cc->newconn->doWriteTransform(cc->newconn->getRepr(), cc->newconn->transform, NULL, true); + // Only set the selection after we are finished with creating the attributes of // the connector. Otherwise, the selection change may alter the defaults for // values like curvature in the connector context, preventing subsequent lookup -- cgit v1.2.3 From 30422af227381c9aa900690586d25adec4fa262f Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 9 Oct 2013 21:09:49 +0200 Subject: Documentation/Translation. Fix for Bug #1236382 (Typos in comments and message, localization context needed) by Yuri Chornoivan. Fixed bugs: - https://launchpad.net/bugs/1236382 (bzr r12673) --- src/connector-context.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 3d6a4f28e..99239533d 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -50,7 +50,7 @@ * changed so that it no longer defines special attributes to record * the points. Instead it uses single node paths to define points * who are then seperate objects that can be fixed on the canvas, - * grouped into objects and take full advantage of all tranform, snap + * grouped into objects and take full advantage of all transform, snap * and align functionality of all other objects. * * I think that the style change between polyline and orthogonal -- 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/connector-context.cpp | 135 ++++++++++++++++++++++++---------------------- 1 file changed, 71 insertions(+), 64 deletions(-) (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 99239533d..6af223b54 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -109,32 +109,38 @@ using Inkscape::DocumentUndo; +#include "tool-factory.h" + +namespace Inkscape { +namespace UI { +namespace Tools { + // Stuff borrowed from DrawContext -static void spcc_connector_set_initial_point(SPConnectorContext *cc, Geom::Point const p); -static void spcc_connector_set_subsequent_point(SPConnectorContext *cc, Geom::Point const p); -static void spcc_connector_finish_segment(SPConnectorContext *cc, Geom::Point p); -static void spcc_reset_colors(SPConnectorContext *cc); -static void spcc_connector_finish(SPConnectorContext *cc); -static void spcc_concat_colors_and_flush(SPConnectorContext *cc); -static void spcc_flush_white(SPConnectorContext *cc, SPCurve *gc); +static void spcc_connector_set_initial_point(ConnectorTool *cc, Geom::Point const p); +static void spcc_connector_set_subsequent_point(ConnectorTool *cc, Geom::Point const p); +static void spcc_connector_finish_segment(ConnectorTool *cc, Geom::Point p); +static void spcc_reset_colors(ConnectorTool *cc); +static void spcc_connector_finish(ConnectorTool *cc); +static void spcc_concat_colors_and_flush(ConnectorTool *cc); +static void spcc_flush_white(ConnectorTool *cc, SPCurve *gc); // Context event handlers -static gint connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const &bevent); -static gint connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion const &mevent); -static gint connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton const &revent); -static gint connector_handle_key_press(SPConnectorContext *const cc, guint const keyval); +static gint connector_handle_button_press(ConnectorTool *const cc, GdkEventButton const &bevent); +static gint connector_handle_motion_notify(ConnectorTool *const cc, GdkEventMotion const &mevent); +static gint connector_handle_button_release(ConnectorTool *const cc, GdkEventButton const &revent); +static gint connector_handle_key_press(ConnectorTool *const cc, guint const keyval); -static void cc_active_shape_add_knot(SPConnectorContext *cc, SPItem* item); -static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item); +static void cc_active_shape_add_knot(ConnectorTool *cc, SPItem* item); +static void cc_set_active_shape(ConnectorTool *cc, SPItem *item); static void cc_clear_active_knots(SPKnotList k); -static void cc_clear_active_shape(SPConnectorContext *cc); -static void cc_set_active_conn(SPConnectorContext *cc, SPItem *item); -static void cc_clear_active_conn(SPConnectorContext *cc); -static bool conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p, gchar **href); +static void cc_clear_active_shape(ConnectorTool *cc); +static void cc_set_active_conn(ConnectorTool *cc, SPItem *item); +static void cc_clear_active_conn(ConnectorTool *cc); +static bool conn_pt_handle_test(ConnectorTool *cc, Geom::Point& p, gchar **href); static void cc_select_handle(SPKnot* knot); static void cc_deselect_handle(SPKnot* knot); static bool cc_item_is_shape(SPItem *item); -static void cc_connector_rerouting_finish(SPConnectorContext *const cc, +static void cc_connector_rerouting_finish(ConnectorTool *const cc, Geom::Point *const p); static void shape_event_attr_deleted(Inkscape::XML::Node *repr, @@ -162,24 +168,21 @@ static Inkscape::XML::NodeEventVector layer_repr_events = { NULL /* order_changed */ }; - -#include "tool-factory.h" - namespace { - SPEventContext* createConnectorContext() { - return new SPConnectorContext(); + ToolBase* createConnectorContext() { + return new ConnectorTool(); } bool connectorContextRegistered = ToolFactory::instance().registerObject("/tools/connector", createConnectorContext); } -const std::string& SPConnectorContext::getPrefsPath() { - return SPConnectorContext::prefsPath; +const std::string& ConnectorTool::getPrefsPath() { + return ConnectorTool::prefsPath; } -const std::string SPConnectorContext::prefsPath = "/tools/connector"; +const std::string ConnectorTool::prefsPath = "/tools/connector"; -SPConnectorContext::SPConnectorContext() : SPEventContext() { +ConnectorTool::ConnectorTool() : ToolBase() { this->red_curve = 0; this->isOrthogonal = false; this->c1 = 0; @@ -229,7 +232,7 @@ SPConnectorContext::SPConnectorContext() : SPEventContext() { this->state = SP_CONNECTOR_CONTEXT_IDLE; } -SPConnectorContext::~SPConnectorContext() { +ConnectorTool::~ConnectorTool() { this->sel_changed_connection.disconnect(); for (int i = 0; i < 2; ++i) { @@ -252,14 +255,14 @@ SPConnectorContext::~SPConnectorContext() { g_assert( this->newConnRef == NULL ); } -void SPConnectorContext::setup() { - SPEventContext::setup(); +void ConnectorTool::setup() { + ToolBase::setup(); this->selection = sp_desktop_selection(this->desktop); this->sel_changed_connection.disconnect(); this->sel_changed_connection = this->selection->connectChanged( - sigc::mem_fun(this, &SPConnectorContext::selection_changed) + sigc::mem_fun(this, &ConnectorTool::selection_changed) ); /* Create red bpath */ @@ -292,7 +295,7 @@ void SPConnectorContext::setup() { this->desktop->canvas->gen_all_enter_events = true; } -void SPConnectorContext::set(const Inkscape::Preferences::Entry& val) { +void ConnectorTool::set(const Inkscape::Preferences::Entry& val) { /* fixme: Proper error handling for non-numeric data. Use a locale-independent function like * g_ascii_strtod (or a thin wrapper that does the right thing for invalid values inf/nan). */ Glib::ustring name = val.getEntryName(); @@ -304,11 +307,11 @@ void SPConnectorContext::set(const Inkscape::Preferences::Entry& val) { } } -void SPConnectorContext::finish() { +void ConnectorTool::finish() { spcc_connector_finish(this); this->state = SP_CONNECTOR_CONTEXT_IDLE; - SPEventContext::finish(); + ToolBase::finish(); if (this->selection) { this->selection = NULL; @@ -325,7 +328,7 @@ void SPConnectorContext::finish() { static void -cc_clear_active_shape(SPConnectorContext *cc) +cc_clear_active_shape(ConnectorTool *cc) { if (cc->active_shape == NULL) { return; @@ -360,7 +363,7 @@ cc_clear_active_knots(SPKnotList k) } static void -cc_clear_active_conn(SPConnectorContext *cc) +cc_clear_active_conn(ConnectorTool *cc) { if (cc->active_conn == NULL) { return; @@ -385,7 +388,7 @@ cc_clear_active_conn(SPConnectorContext *cc) static bool -conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p, gchar **href) +conn_pt_handle_test(ConnectorTool *cc, Geom::Point& p, gchar **href) { if (cc->active_handle && (cc->knots.find(cc->active_handle) != cc->knots.end())) { @@ -417,7 +420,7 @@ cc_deselect_handle(SPKnot* knot) sp_knot_update_ctrl(knot); } -bool SPConnectorContext::item_handler(SPItem* item, GdkEvent* event) { +bool ConnectorTool::item_handler(SPItem* item, GdkEvent* event) { gint ret = FALSE; Geom::Point p(event->button.x, event->button.y); @@ -472,7 +475,7 @@ bool SPConnectorContext::item_handler(SPItem* item, GdkEvent* event) { return ret; } -bool SPConnectorContext::root_handler(GdkEvent* event) { +bool ConnectorTool::root_handler(GdkEvent* event) { gint ret = FALSE; switch (event->type) { @@ -497,7 +500,7 @@ bool SPConnectorContext::root_handler(GdkEvent* event) { } if (!ret) { - ret = SPEventContext::root_handler(event); + ret = ToolBase::root_handler(event); } return ret; @@ -505,12 +508,12 @@ bool SPConnectorContext::root_handler(GdkEvent* event) { static gint -connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const &bevent) +connector_handle_button_press(ConnectorTool *const cc, GdkEventButton const &bevent) { Geom::Point const event_w(bevent.x, bevent.y); /* Find desktop coordinates */ Geom::Point p = cc->desktop->w2d(event_w); - SPEventContext *event_context = SP_EVENT_CONTEXT(cc); + ToolBase *event_context = SP_EVENT_CONTEXT(cc); gint ret = FALSE; @@ -612,10 +615,10 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const } static gint -connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion const &mevent) +connector_handle_motion_notify(ConnectorTool *const cc, GdkEventMotion const &mevent) { gint ret = FALSE; - SPEventContext *event_context = SP_EVENT_CONTEXT(cc); + ToolBase *event_context = SP_EVENT_CONTEXT(cc); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (event_context->space_panning || mevent.state & GDK_BUTTON2_MASK || mevent.state & GDK_BUTTON3_MASK) { @@ -706,10 +709,10 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons } static gint -connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton const &revent) +connector_handle_button_release(ConnectorTool *const cc, GdkEventButton const &revent) { gint ret = FALSE; - SPEventContext *event_context = SP_EVENT_CONTEXT(cc); + ToolBase *event_context = SP_EVENT_CONTEXT(cc); if ( revent.button == 1 && !event_context->space_panning ) { SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); @@ -771,7 +774,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con } static gint -connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) +connector_handle_key_press(ConnectorTool *const cc, guint const keyval) { gint ret = FALSE; @@ -814,7 +817,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval) static void -cc_connector_rerouting_finish(SPConnectorContext *const cc, Geom::Point *const p) +cc_connector_rerouting_finish(ConnectorTool *const cc, Geom::Point *const p) { SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); SPDocument *doc = sp_desktop_document(desktop); @@ -849,7 +852,7 @@ cc_connector_rerouting_finish(SPConnectorContext *const cc, Geom::Point *const p static void -spcc_reset_colors(SPConnectorContext *cc) +spcc_reset_colors(ConnectorTool *cc) { /* Red */ cc->red_curve->reset(); @@ -861,7 +864,7 @@ spcc_reset_colors(SPConnectorContext *cc) static void -spcc_connector_set_initial_point(SPConnectorContext *const cc, Geom::Point const p) +spcc_connector_set_initial_point(ConnectorTool *const cc, Geom::Point const p) { g_assert( cc->npoints == 0 ); @@ -873,7 +876,7 @@ spcc_connector_set_initial_point(SPConnectorContext *const cc, Geom::Point const static void -spcc_connector_set_subsequent_point(SPConnectorContext *const cc, Geom::Point const p) +spcc_connector_set_subsequent_point(ConnectorTool *const cc, Geom::Point const p) { g_assert( cc->npoints != 0 ); @@ -910,7 +913,7 @@ spcc_connector_set_subsequent_point(SPConnectorContext *const cc, Geom::Point co * Invoke _flush_white to write result back to object. */ static void -spcc_concat_colors_and_flush(SPConnectorContext *cc) +spcc_concat_colors_and_flush(ConnectorTool *cc) { SPCurve *c = cc->green_curve; cc->green_curve = new SPCurve(); @@ -938,7 +941,7 @@ spcc_concat_colors_and_flush(SPConnectorContext *cc) */ static void -spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) +spcc_flush_white(ConnectorTool *cc, SPCurve *gc) { SPCurve *c; @@ -1015,7 +1018,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc) static void -spcc_connector_finish_segment(SPConnectorContext *const cc, Geom::Point const /*p*/) +spcc_connector_finish_segment(ConnectorTool *const cc, Geom::Point const /*p*/) { if (!cc->red_curve->is_empty()) { cc->green_curve->append_continuous(cc->red_curve, 0.0625); @@ -1030,7 +1033,7 @@ spcc_connector_finish_segment(SPConnectorContext *const cc, Geom::Point const /* static void -spcc_connector_finish(SPConnectorContext *const cc) +spcc_connector_finish(ConnectorTool *const cc) { SPDesktop *const desktop = cc->desktop; desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Finishing connector")); @@ -1055,7 +1058,7 @@ cc_generic_knot_handler(SPCanvasItem *, GdkEvent *event, SPKnot *knot) g_object_ref(knot); - SPConnectorContext *cc = SP_CONNECTOR_CONTEXT( + ConnectorTool *cc = SP_CONNECTOR_CONTEXT( knot->desktop->event_context); gboolean consumed = FALSE; @@ -1096,7 +1099,7 @@ cc_generic_knot_handler(SPCanvasItem *, GdkEvent *event, SPKnot *knot) static gboolean -endpt_handler(SPKnot */*knot*/, GdkEvent *event, SPConnectorContext *cc) +endpt_handler(SPKnot */*knot*/, GdkEvent *event, ConnectorTool *cc) { //g_assert( SP_IS_CONNECTOR_CONTEXT(cc) ); @@ -1144,7 +1147,7 @@ endpt_handler(SPKnot */*knot*/, GdkEvent *event, SPConnectorContext *cc) return consumed; } -static void cc_active_shape_add_knot(SPConnectorContext *cc, SPItem* item) +static void cc_active_shape_add_knot(ConnectorTool *cc, SPItem* item) { SPDesktop *desktop = cc->desktop; SPKnot *knot = sp_knot_new(desktop, 0); @@ -1168,7 +1171,7 @@ static void cc_active_shape_add_knot(SPConnectorContext *cc, SPItem* item) cc->knots[knot] = 1; } -static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item) +static void cc_set_active_shape(ConnectorTool *cc, SPItem *item) { g_assert(item != NULL ); @@ -1219,7 +1222,7 @@ static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item) static void -cc_set_active_conn(SPConnectorContext *cc, SPItem *item) +cc_set_active_conn(ConnectorTool *cc, SPItem *item) { g_assert( SP_IS_PATH(item) ); @@ -1323,7 +1326,7 @@ cc_set_active_conn(SPConnectorContext *cc, SPItem *item) sp_knot_show(cc->endpt_handle[1]); } -void cc_create_connection_point(SPConnectorContext* cc) +void cc_create_connection_point(ConnectorTool* cc) { if (cc->active_shape && cc->state == SP_CONNECTOR_CONTEXT_IDLE) { @@ -1419,7 +1422,7 @@ void cc_selection_set_avoid(bool const set_avoid) DocumentUndo::done(document, SP_VERB_CONTEXT_CONNECTOR, event_desc); } -void SPConnectorContext::selection_changed(Inkscape::Selection *selection) { +void ConnectorTool::selection_changed(Inkscape::Selection *selection) { SPItem *item = selection->singleItem(); if (this->active_conn == item) { @@ -1442,7 +1445,7 @@ shape_event_attr_deleted(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *chi Inkscape::XML::Node */*ref*/, gpointer data) { g_assert(data); - SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(data); + ConnectorTool *cc = SP_CONNECTOR_CONTEXT(data); if (child == cc->active_shape_repr) { // The active shape has been deleted. Clear active shape. @@ -1457,7 +1460,7 @@ shape_event_attr_changed(Inkscape::XML::Node *repr, gchar const *name, bool /*is_interactive*/, gpointer data) { g_assert(data); - SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(data); + ConnectorTool *cc = SP_CONNECTOR_CONTEXT(data); // Look for changes that result in onscreen movement. if (!strcmp(name, "d") || !strcmp(name, "x") || !strcmp(name, "y") || @@ -1476,6 +1479,10 @@ shape_event_attr_changed(Inkscape::XML::Node *repr, gchar const *name, } } +} +} +} + /* Local Variables: -- 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/connector-context.cpp | 1496 --------------------------------------------- 1 file changed, 1496 deletions(-) delete mode 100644 src/connector-context.cpp (limited to 'src/connector-context.cpp') diff --git a/src/connector-context.cpp b/src/connector-context.cpp deleted file mode 100644 index 6af223b54..000000000 --- a/src/connector-context.cpp +++ /dev/null @@ -1,1496 +0,0 @@ -/* - * Connector creation tool - * - * Authors: - * Michael Wybrow - * Abhishek Sharma - * Jon A. Cruz - * Martin Owens - * - * Copyright (C) 2005-2008 Michael Wybrow - * Copyright (C) 2009 Monash University - * Copyright (C) 2012 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - * - * TODO: - * o Show a visual indicator for objects with the 'avoid' property set. - * o Allow user to change a object between a path and connector through - * the interface. - * o Create an interface for setting markers (arrow heads). - * o Better distinguish between paths and connectors to prevent problems - * in the node tool and paths accidentally being turned into connectors - * in the connector tool. Perhaps have a way to convert between. - * o Only call libavoid's updateEndPoint as required. Currently we do it - * for both endpoints, even if only one is moving. - * o Deal sanely with connectors with both endpoints attached to the - * same connection point, and drawing of connectors attaching - * overlapping shapes (currently tries to adjust connector to be - * outside both bounding boxes). - * o Fix many special cases related to connectors updating, - * e.g., copying a couple of shapes and a connector that are - * attached to each other. - * e.g., detach connector when it is moved or transformed in - * one of the other contexts. - * o Cope with shapes whose ids change when they have attached - * connectors. - * o During dragging motion, gobble up to and use the final motion event. - * Gobbling away all duplicates after the current can occasionally result - * in the path lagging behind the mouse cursor if it is no longer being - * dragged. - * o Fix up libavoid's representation after undo actions. It doesn't see - * any transform signals and hence doesn't know shapes have moved back to - * there earlier positions. - * - * ---------------------------------------------------------------------------- - * - * Notes: - * - * Much of the way connectors work for user-defined points has been - * changed so that it no longer defines special attributes to record - * the points. Instead it uses single node paths to define points - * who are then seperate objects that can be fixed on the canvas, - * grouped into objects and take full advantage of all transform, snap - * and align functionality of all other objects. - * - * I think that the style change between polyline and orthogonal - * would be much clearer with two buttons (radio behaviour -- just - * one is true). - * - * The other tools show a label change from "New:" to "Change:" - * depending on whether an object is selected. We could consider - * this but there may not be space. - * - * Likewise for the avoid/ignore shapes buttons. These should be - * inactive when a shape is not selected in the connector context. - * - */ - - - -#include -#include -#include - -#include "connector-context.h" -#include "pixmaps/cursor-connector.xpm" -#include "xml/node-event-vector.h" -#include "xml/repr.h" -#include "svg/svg.h" -#include "desktop.h" -#include "desktop-style.h" -#include "desktop-handles.h" -#include "document.h" -#include "document-undo.h" -#include "message-context.h" -#include "message-stack.h" -#include "selection.h" -#include "inkscape.h" -#include "preferences.h" -#include "sp-path.h" -#include "display/sp-canvas.h" -#include "display/canvas-bpath.h" -#include "display/sodipodi-ctrl.h" -#include -#include -#include "snap.h" -#include "knot.h" -#include "sp-conn-end.h" -#include "sp-conn-end-pair.h" -#include "conn-avoid-ref.h" -#include "libavoid/vertices.h" -#include "libavoid/router.h" -#include "context-fns.h" -#include "sp-namedview.h" -#include "sp-text.h" -#include "sp-flowtext.h" -#include "display/curve.h" -#include "verbs.h" - -using Inkscape::DocumentUndo; - -#include "tool-factory.h" - -namespace Inkscape { -namespace UI { -namespace Tools { - -// Stuff borrowed from DrawContext -static void spcc_connector_set_initial_point(ConnectorTool *cc, Geom::Point const p); -static void spcc_connector_set_subsequent_point(ConnectorTool *cc, Geom::Point const p); -static void spcc_connector_finish_segment(ConnectorTool *cc, Geom::Point p); -static void spcc_reset_colors(ConnectorTool *cc); -static void spcc_connector_finish(ConnectorTool *cc); -static void spcc_concat_colors_and_flush(ConnectorTool *cc); -static void spcc_flush_white(ConnectorTool *cc, SPCurve *gc); - -// Context event handlers -static gint connector_handle_button_press(ConnectorTool *const cc, GdkEventButton const &bevent); -static gint connector_handle_motion_notify(ConnectorTool *const cc, GdkEventMotion const &mevent); -static gint connector_handle_button_release(ConnectorTool *const cc, GdkEventButton const &revent); -static gint connector_handle_key_press(ConnectorTool *const cc, guint const keyval); - -static void cc_active_shape_add_knot(ConnectorTool *cc, SPItem* item); -static void cc_set_active_shape(ConnectorTool *cc, SPItem *item); -static void cc_clear_active_knots(SPKnotList k); -static void cc_clear_active_shape(ConnectorTool *cc); -static void cc_set_active_conn(ConnectorTool *cc, SPItem *item); -static void cc_clear_active_conn(ConnectorTool *cc); -static bool conn_pt_handle_test(ConnectorTool *cc, Geom::Point& p, gchar **href); -static void cc_select_handle(SPKnot* knot); -static void cc_deselect_handle(SPKnot* knot); -static bool cc_item_is_shape(SPItem *item); -static void cc_connector_rerouting_finish(ConnectorTool *const cc, - Geom::Point *const p); - -static void shape_event_attr_deleted(Inkscape::XML::Node *repr, - Inkscape::XML::Node *child, Inkscape::XML::Node *ref, gpointer data); -static void shape_event_attr_changed(Inkscape::XML::Node *repr, gchar const *name, - gchar const *old_value, gchar const *new_value, bool is_interactive, - gpointer data); - -/*static Geom::Point connector_drag_origin_w(0, 0); -static bool connector_within_tolerance = false;*/ - -static Inkscape::XML::NodeEventVector shape_repr_events = { - NULL, /* child_added */ - NULL, /* child_added */ - shape_event_attr_changed, - NULL, /* content_changed */ - NULL /* order_changed */ -}; - -static Inkscape::XML::NodeEventVector layer_repr_events = { - NULL, /* child_added */ - shape_event_attr_deleted, - NULL, /* child_added */ - NULL, /* content_changed */ - NULL /* order_changed */ -}; - -namespace { - ToolBase* createConnectorContext() { - return new ConnectorTool(); - } - - bool connectorContextRegistered = ToolFactory::instance().registerObject("/tools/connector", createConnectorContext); -} - -const std::string& ConnectorTool::getPrefsPath() { - return ConnectorTool::prefsPath; -} - -const std::string ConnectorTool::prefsPath = "/tools/connector"; - -ConnectorTool::ConnectorTool() : ToolBase() { - this->red_curve = 0; - this->isOrthogonal = false; - this->c1 = 0; - this->red_bpath = 0; - this->green_curve = 0; - this->selection = 0; - this->cl0 = 0; - this->cl1 = 0; - this->c0 = 0; - - this->cursor_shape = cursor_connector_xpm; - this->hot_x = 1; - this->hot_y = 1; - this->xp = 0; - this->yp = 0; - - this->red_color = 0xff00007f; - - this->newconn = NULL; - this->newConnRef = NULL; - this->curvature = 0.0; - - this->sel_changed_connection = sigc::connection(); - - this->active_shape = NULL; - this->active_shape_repr = NULL; - this->active_shape_layer_repr = NULL; - - this->active_conn = NULL; - this->active_conn_repr = NULL; - - this->active_handle = NULL; - - this->selected_handle = NULL; - - this->clickeditem = NULL; - this->clickedhandle = NULL; - - for (int i = 0; i < 2; ++i) { - this->endpt_handle[i] = NULL; - this->endpt_handler_id[i] = 0; - } - - this->shref = NULL; - this->ehref = NULL; - this->npoints = 0; - this->state = SP_CONNECTOR_CONTEXT_IDLE; -} - -ConnectorTool::~ConnectorTool() { - this->sel_changed_connection.disconnect(); - - for (int i = 0; i < 2; ++i) { - if (this->endpt_handle[1]) { - g_object_unref(this->endpt_handle[i]); - this->endpt_handle[i] = NULL; - } - } - - if (this->shref) { - g_free(this->shref); - this->shref = NULL; - } - - if (this->ehref) { - g_free(this->shref); - this->shref = NULL; - } - - g_assert( this->newConnRef == NULL ); -} - -void ConnectorTool::setup() { - ToolBase::setup(); - - this->selection = sp_desktop_selection(this->desktop); - - this->sel_changed_connection.disconnect(); - this->sel_changed_connection = this->selection->connectChanged( - sigc::mem_fun(this, &ConnectorTool::selection_changed) - ); - - /* Create red bpath */ - this->red_bpath = sp_canvas_bpath_new(sp_desktop_sketch(this->desktop), NULL); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->red_bpath), this->red_color, - 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(this->red_bpath), 0x00000000, - SP_WIND_RULE_NONZERO); - /* Create red curve */ - this->red_curve = new SPCurve(); - - /* Create green curve */ - this->green_curve = new SPCurve(); - - // Notice the initial selection. - //cc_selection_changed(this->selection, (gpointer) this); - this->selection_changed(this->selection); - - this->within_tolerance = false; - - sp_event_context_read(this, "curvature"); - sp_event_context_read(this, "orthogonal"); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (prefs->getBool("/tools/connector/selcue", 0)) { - this->enableSelectionCue(); - } - - // Make sure we see all enter events for canvas items, - // even if a mouse button is depressed. - this->desktop->canvas->gen_all_enter_events = true; -} - -void ConnectorTool::set(const Inkscape::Preferences::Entry& val) { - /* fixme: Proper error handling for non-numeric data. Use a locale-independent function like - * g_ascii_strtod (or a thin wrapper that does the right thing for invalid values inf/nan). */ - Glib::ustring name = val.getEntryName(); - - if (name == "curvature") { - this->curvature = val.getDoubleLimited(); // prevents NaN and +/-Inf from messing up - } else if (name == "orthogonal") { - this->isOrthogonal = val.getBool(); - } -} - -void ConnectorTool::finish() { - spcc_connector_finish(this); - this->state = SP_CONNECTOR_CONTEXT_IDLE; - - ToolBase::finish(); - - if (this->selection) { - this->selection = NULL; - } - - cc_clear_active_shape(this); - cc_clear_active_conn(this); - - // Restore the default event generating behaviour. - this->desktop->canvas->gen_all_enter_events = false; -} - -//----------------------------------------------------------------------------- - - -static void -cc_clear_active_shape(ConnectorTool *cc) -{ - if (cc->active_shape == NULL) { - return; - } - g_assert( cc->active_shape_repr ); - g_assert( cc->active_shape_layer_repr ); - - cc->active_shape = NULL; - - if (cc->active_shape_repr) { - sp_repr_remove_listener_by_data(cc->active_shape_repr, cc); - Inkscape::GC::release(cc->active_shape_repr); - cc->active_shape_repr = NULL; - - sp_repr_remove_listener_by_data(cc->active_shape_layer_repr, cc); - Inkscape::GC::release(cc->active_shape_layer_repr); - cc->active_shape_layer_repr = NULL; - } - - cc_clear_active_knots(cc->knots); -} - -static void -cc_clear_active_knots(SPKnotList k) -{ - // Hide the connection points if they exist. - if (k.size()) { - for (SPKnotList::iterator it = k.begin(); it != k.end(); ++it) { - sp_knot_hide(it->first); - } - } -} - -static void -cc_clear_active_conn(ConnectorTool *cc) -{ - if (cc->active_conn == NULL) { - return; - } - g_assert( cc->active_conn_repr ); - - cc->active_conn = NULL; - - if (cc->active_conn_repr) { - sp_repr_remove_listener_by_data(cc->active_conn_repr, cc); - Inkscape::GC::release(cc->active_conn_repr); - cc->active_conn_repr = NULL; - } - - // Hide the endpoint handles. - for (int i = 0; i < 2; ++i) { - if (cc->endpt_handle[i]) { - sp_knot_hide(cc->endpt_handle[i]); - } - } -} - - -static bool -conn_pt_handle_test(ConnectorTool *cc, Geom::Point& p, gchar **href) -{ - if (cc->active_handle && (cc->knots.find(cc->active_handle) != cc->knots.end())) - { - p = cc->active_handle->pos; - *href = g_strdup_printf("#%s", cc->active_handle->owner->getId()); - return true; - } - *href = NULL; - return false; -} - -static void -cc_select_handle(SPKnot* knot) -{ - knot->setShape(SP_KNOT_SHAPE_SQUARE); - knot->setSize(10); - knot->setAnchor(SP_ANCHOR_CENTER); - knot->setFill(0x0000ffff, 0x0000ffff, 0x0000ffff); - sp_knot_update_ctrl(knot); -} - -static void -cc_deselect_handle(SPKnot* knot) -{ - knot->setShape(SP_KNOT_SHAPE_SQUARE); - knot->setSize(8); - knot->setAnchor(SP_ANCHOR_CENTER); - knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff); - sp_knot_update_ctrl(knot); -} - -bool ConnectorTool::item_handler(SPItem* item, GdkEvent* event) { - gint ret = FALSE; - - Geom::Point p(event->button.x, event->button.y); - - switch (event->type) { - case GDK_BUTTON_RELEASE: - if (event->button.button == 1 && !this->space_panning) { - if ((this->state == SP_CONNECTOR_CONTEXT_DRAGGING) && this->within_tolerance) { - spcc_reset_colors(this); - this->state = SP_CONNECTOR_CONTEXT_IDLE; - } - - if (this->state != SP_CONNECTOR_CONTEXT_IDLE) { - // Doing something else like rerouting. - break; - } - - // find out clicked item, honoring Alt - SPItem *item = sp_event_context_find_item(desktop, p, event->button.state & GDK_MOD1_MASK, FALSE); - - if (event->button.state & GDK_SHIFT_MASK) { - this->selection->toggle(item); - } else { - this->selection->set(item); - /* When selecting a new item, do not allow showing - connection points on connectors. (yet?) - */ - - if (item != this->active_shape && !cc_item_is_connector(item)) { - cc_set_active_shape(this, item); - } - } - - ret = TRUE; - } - break; - - case GDK_ENTER_NOTIFY: - if (!this->selected_handle) { - if (cc_item_is_shape(item)) { - cc_set_active_shape(this, item); - } - - ret = TRUE; - } - break; - - default: - break; - } - - return ret; -} - -bool ConnectorTool::root_handler(GdkEvent* event) { - gint ret = FALSE; - - switch (event->type) { - case GDK_BUTTON_PRESS: - ret = connector_handle_button_press(this, event->button); - break; - - case GDK_MOTION_NOTIFY: - ret = connector_handle_motion_notify(this, event->motion); - break; - - case GDK_BUTTON_RELEASE: - ret = connector_handle_button_release(this, event->button); - break; - - case GDK_KEY_PRESS: - ret = connector_handle_key_press(this, get_group0_keyval (&event->key)); - break; - - default: - break; - } - - if (!ret) { - ret = ToolBase::root_handler(event); - } - - return ret; -} - - -static gint -connector_handle_button_press(ConnectorTool *const cc, GdkEventButton const &bevent) -{ - Geom::Point const event_w(bevent.x, bevent.y); - /* Find desktop coordinates */ - Geom::Point p = cc->desktop->w2d(event_w); - ToolBase *event_context = SP_EVENT_CONTEXT(cc); - - gint ret = FALSE; - - if ( bevent.button == 1 && !event_context->space_panning ) { - - SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); - - if (Inkscape::have_viable_layer(desktop, cc->message_context) == false) { - return TRUE; - } - - Geom::Point const event_w(bevent.x, - bevent.y); - - cc->xp = bevent.x; - cc->yp = bevent.y; - cc->within_tolerance = true; - - Geom::Point const event_dt = cc->desktop->w2d(event_w); - - SnapManager &m = cc->desktop->namedview->snap_manager; - - switch (cc->state) { - case SP_CONNECTOR_CONTEXT_STOP: - /* This is allowed, if we just canceled curve */ - case SP_CONNECTOR_CONTEXT_IDLE: - { - if ( cc->npoints == 0 ) { - cc_clear_active_conn(cc); - - SP_EVENT_CONTEXT_DESKTOP(cc)->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating new connector")); - - /* Set start anchor */ - /* Create green anchor */ - Geom::Point p = event_dt; - - // Test whether we clicked on a connection point - bool found = conn_pt_handle_test(cc, p, &cc->shref); - - if (!found) { - // This is the first point, so just snap it to the grid - // as there's no other points to go off. - m.setup(cc->desktop); - m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); - m.unSetup(); - } - spcc_connector_set_initial_point(cc, p); - - } - cc->state = SP_CONNECTOR_CONTEXT_DRAGGING; - ret = TRUE; - break; - } - case SP_CONNECTOR_CONTEXT_DRAGGING: - { - // This is the second click of a connector creation. - m.setup(cc->desktop); - m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); - m.unSetup(); - - spcc_connector_set_subsequent_point(cc, p); - spcc_connector_finish_segment(cc, p); - - conn_pt_handle_test(cc, p, &cc->ehref); - if (cc->npoints != 0) { - spcc_connector_finish(cc); - } - cc_set_active_conn(cc, cc->newconn); - cc->state = SP_CONNECTOR_CONTEXT_IDLE; - ret = TRUE; - break; - } - case SP_CONNECTOR_CONTEXT_CLOSE: - { - g_warning("Button down in CLOSE state"); - break; - } - default: - break; - } - } else if (bevent.button == 3) { - if (cc->state == SP_CONNECTOR_CONTEXT_REROUTING) { - // A context menu is going to be triggered here, - // so end the rerouting operation. - cc_connector_rerouting_finish(cc, &p); - - cc->state = SP_CONNECTOR_CONTEXT_IDLE; - - // Don't set ret to TRUE, so we drop through to the - // parent handler which will open the context menu. - } - else if (cc->npoints != 0) { - spcc_connector_finish(cc); - cc->state = SP_CONNECTOR_CONTEXT_IDLE; - ret = TRUE; - } - } - return ret; -} - -static gint -connector_handle_motion_notify(ConnectorTool *const cc, GdkEventMotion const &mevent) -{ - gint ret = FALSE; - ToolBase *event_context = SP_EVENT_CONTEXT(cc); - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - - if (event_context->space_panning || mevent.state & GDK_BUTTON2_MASK || mevent.state & GDK_BUTTON3_MASK) { - // allow middle-button scrolling - return FALSE; - } - - Geom::Point const event_w(mevent.x, mevent.y); - - if (cc->within_tolerance) { - cc->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); - if ( ( abs( (gint) mevent.x - cc->xp ) < cc->tolerance ) && - ( abs( (gint) mevent.y - cc->yp ) < cc->tolerance ) ) { - return FALSE; // Do not drag if we're within tolerance from origin. - } - } - // Once the user has moved farther than tolerance from the original location - // (indicating they intend to move the object, not click), then always process - // the motion notify coordinates as given (no snapping back to origin) - cc->within_tolerance = false; - - SPDesktop *const dt = cc->desktop; - - /* Find desktop coordinates */ - Geom::Point p = dt->w2d(event_w); - - SnapManager &m = dt->namedview->snap_manager; - - switch (cc->state) { - case SP_CONNECTOR_CONTEXT_DRAGGING: - { - gobble_motion_events(mevent.state); - // This is movement during a connector creation. - if ( cc->npoints > 0 ) { - m.setup(dt); - m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); - m.unSetup(); - cc->selection->clear(); - spcc_connector_set_subsequent_point(cc, p); - ret = TRUE; - } - break; - } - case SP_CONNECTOR_CONTEXT_REROUTING: - { - gobble_motion_events(GDK_BUTTON1_MASK); - g_assert( SP_IS_PATH(cc->clickeditem)); - - m.setup(dt); - m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); - m.unSetup(); - - // Update the hidden path - Geom::Affine i2d ( (cc->clickeditem)->i2dt_affine() ); - Geom::Affine d2i = i2d.inverse(); - SPPath *path = SP_PATH(cc->clickeditem); - SPCurve *curve = path->get_curve(); - if (cc->clickedhandle == cc->endpt_handle[0]) { - Geom::Point o = cc->endpt_handle[1]->pos; - curve->stretch_endpoints(p * d2i, o * d2i); - } - else { - Geom::Point o = cc->endpt_handle[0]->pos; - curve->stretch_endpoints(o * d2i, p * d2i); - } - sp_conn_reroute_path_immediate(path); - - // Copy this to the temporary visible path - cc->red_curve = path->get_curve_for_edit(); - cc->red_curve->transform(i2d); - - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve); - ret = TRUE; - break; - } - case SP_CONNECTOR_CONTEXT_STOP: - /* This is perfectly valid */ - break; - default: - if (!sp_event_context_knot_mouseover(cc)) { - m.setup(dt); - m.preSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE)); - m.unSetup(); - } - break; - } - return ret; -} - -static gint -connector_handle_button_release(ConnectorTool *const cc, GdkEventButton const &revent) -{ - gint ret = FALSE; - ToolBase *event_context = SP_EVENT_CONTEXT(cc); - if ( revent.button == 1 && !event_context->space_panning ) { - - SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); - SPDocument *doc = sp_desktop_document(desktop); - - SnapManager &m = desktop->namedview->snap_manager; - - Geom::Point const event_w(revent.x, revent.y); - - /* Find desktop coordinates */ - Geom::Point p = cc->desktop->w2d(event_w); - - switch (cc->state) { - //case SP_CONNECTOR_CONTEXT_POINT: - case SP_CONNECTOR_CONTEXT_DRAGGING: - { - m.setup(desktop); - m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); - m.unSetup(); - - if (cc->within_tolerance) - { - spcc_connector_finish_segment(cc, p); - return TRUE; - } - // Connector has been created via a drag, end it now. - spcc_connector_set_subsequent_point(cc, p); - spcc_connector_finish_segment(cc, p); - // Test whether we clicked on a connection point - conn_pt_handle_test(cc, p, &cc->ehref); - if (cc->npoints != 0) { - spcc_connector_finish(cc); - } - cc_set_active_conn(cc, cc->newconn); - cc->state = SP_CONNECTOR_CONTEXT_IDLE; - break; - } - case SP_CONNECTOR_CONTEXT_REROUTING: - { - m.setup(desktop); - m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_OTHER_HANDLE); - m.unSetup(); - cc_connector_rerouting_finish(cc, &p); - - doc->ensureUpToDate(); - cc->state = SP_CONNECTOR_CONTEXT_IDLE; - return TRUE; - break; - } - case SP_CONNECTOR_CONTEXT_STOP: - /* This is allowed, if we just cancelled curve */ - break; - default: - break; - } - ret = TRUE; - } - return ret; -} - -static gint -connector_handle_key_press(ConnectorTool *const cc, guint const keyval) -{ - gint ret = FALSE; - - switch (keyval) { - case GDK_KEY_Return: - case GDK_KEY_KP_Enter: - if (cc->npoints != 0) { - spcc_connector_finish(cc); - cc->state = SP_CONNECTOR_CONTEXT_IDLE; - ret = TRUE; - } - break; - case GDK_KEY_Escape: - if (cc->state == SP_CONNECTOR_CONTEXT_REROUTING) { - - SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); - SPDocument *doc = sp_desktop_document(desktop); - - cc_connector_rerouting_finish(cc, NULL); - - DocumentUndo::undo(doc); - - cc->state = SP_CONNECTOR_CONTEXT_IDLE; - desktop->messageStack()->flash( Inkscape::NORMAL_MESSAGE, - _("Connector endpoint drag cancelled.")); - ret = TRUE; - } - else if (cc->npoints != 0) { - // if drawing, cancel, otherwise pass it up for deselecting - cc->state = SP_CONNECTOR_CONTEXT_STOP; - spcc_reset_colors(cc); - ret = TRUE; - } - break; - default: - break; - } - return ret; -} - - -static void -cc_connector_rerouting_finish(ConnectorTool *const cc, Geom::Point *const p) -{ - SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); - SPDocument *doc = sp_desktop_document(desktop); - - // Clear the temporary path: - cc->red_curve->reset(); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), NULL); - - if (p != NULL) - { - // Test whether we clicked on a connection point - gchar *shape_label; - bool found = conn_pt_handle_test(cc, *p, &shape_label); - - if (found) { - if (cc->clickedhandle == cc->endpt_handle[0]) { - cc->clickeditem->setAttribute("inkscape:connection-start", shape_label, NULL); - } - else { - cc->clickeditem->setAttribute("inkscape:connection-end", shape_label, NULL); - } - g_free(shape_label); - } - } - cc->clickeditem->setHidden(false); - sp_conn_reroute_path_immediate(SP_PATH(cc->clickeditem)); - cc->clickeditem->updateRepr(); - DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, - _("Reroute connector")); - cc_set_active_conn(cc, cc->clickeditem); -} - - -static void -spcc_reset_colors(ConnectorTool *cc) -{ - /* Red */ - cc->red_curve->reset(); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), NULL); - - cc->green_curve->reset(); - cc->npoints = 0; -} - - -static void -spcc_connector_set_initial_point(ConnectorTool *const cc, Geom::Point const p) -{ - g_assert( cc->npoints == 0 ); - - cc->p[0] = p; - cc->p[1] = p; - cc->npoints = 2; - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), NULL); -} - - -static void -spcc_connector_set_subsequent_point(ConnectorTool *const cc, Geom::Point const p) -{ - g_assert( cc->npoints != 0 ); - - SPDesktop *dt = cc->desktop; - Geom::Point o = dt->dt2doc(cc->p[0]); - Geom::Point d = dt->dt2doc(p); - Avoid::Point src(o[Geom::X], o[Geom::Y]); - Avoid::Point dst(d[Geom::X], d[Geom::Y]); - - if (!cc->newConnRef) { - Avoid::Router *router = sp_desktop_document(dt)->router; - cc->newConnRef = new Avoid::ConnRef(router); - cc->newConnRef->setEndpoint(Avoid::VertID::src, src); - if (cc->isOrthogonal) - cc->newConnRef->setRoutingType(Avoid::ConnType_Orthogonal); - else - cc->newConnRef->setRoutingType(Avoid::ConnType_PolyLine); - } - // Set new endpoint. - cc->newConnRef->setEndpoint(Avoid::VertID::tar, dst); - // Immediately generate new routes for connector. - cc->newConnRef->makePathInvalid(); - cc->newConnRef->router()->processTransaction(); - // Recreate curve from libavoid route. - recreateCurve( cc->red_curve, cc->newConnRef, cc->curvature ); - cc->red_curve->transform(dt->doc2dt()); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve); -} - - -/** - * Concats red, blue and green. - * If any anchors are defined, process these, optionally removing curves from white list - * Invoke _flush_white to write result back to object. - */ -static void -spcc_concat_colors_and_flush(ConnectorTool *cc) -{ - SPCurve *c = cc->green_curve; - cc->green_curve = new SPCurve(); - - cc->red_curve->reset(); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), NULL); - - if (c->is_empty()) { - c->unref(); - return; - } - - spcc_flush_white(cc, c); - - c->unref(); -} - - -/* - * Flushes white curve(s) and additional curve into object - * - * No cleaning of colored curves - this has to be done by caller - * No rereading of white data, so if you cannot rely on ::modified, do it in caller - * - */ - -static void -spcc_flush_white(ConnectorTool *cc, SPCurve *gc) -{ - SPCurve *c; - - if (gc) { - c = gc; - c->ref(); - } else { - return; - } - - /* Now we have to go back to item coordinates at last */ - c->transform(SP_EVENT_CONTEXT_DESKTOP(cc)->dt2doc()); - - SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc); - SPDocument *doc = sp_desktop_document(desktop); - Inkscape::XML::Document *xml_doc = doc->getReprDoc(); - - if ( c && !c->is_empty() ) { - /* We actually have something to write */ - - Inkscape::XML::Node *repr = xml_doc->createElement("svg:path"); - /* Set style */ - sp_desktop_apply_style_tool(desktop, repr, "/tools/connector", false); - - gchar *str = sp_svg_write_path( c->get_pathvector() ); - g_assert( str != NULL ); - repr->setAttribute("d", str); - g_free(str); - - /* Attach repr */ - cc->newconn = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); - cc->newconn->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); - - bool connection = false; - cc->newconn->setAttribute( "inkscape:connector-type", - cc->isOrthogonal ? "orthogonal" : "polyline", NULL ); - cc->newconn->setAttribute( "inkscape:connector-curvature", - Glib::Ascii::dtostr(cc->curvature).c_str(), NULL ); - if (cc->shref) - { - cc->newconn->setAttribute( "inkscape:connection-start", cc->shref, NULL); - connection = true; - } - - if (cc->ehref) - { - cc->newconn->setAttribute( "inkscape:connection-end", cc->ehref, NULL); - connection = true; - } - // Process pending updates. - cc->newconn->updateRepr(); - doc->ensureUpToDate(); - - if (connection) { - // Adjust endpoints to shape edge. - sp_conn_reroute_path_immediate(SP_PATH(cc->newconn)); - cc->newconn->updateRepr(); - } - - cc->newconn->doWriteTransform(cc->newconn->getRepr(), cc->newconn->transform, NULL, true); - - // Only set the selection after we are finished with creating the attributes of - // the connector. Otherwise, the selection change may alter the defaults for - // values like curvature in the connector context, preventing subsequent lookup - // of their original values. - cc->selection->set(repr); - Inkscape::GC::release(repr); - } - - c->unref(); - - DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, _("Create connector")); -} - - -static void -spcc_connector_finish_segment(ConnectorTool *const cc, Geom::Point const /*p*/) -{ - if (!cc->red_curve->is_empty()) { - cc->green_curve->append_continuous(cc->red_curve, 0.0625); - - cc->p[0] = cc->p[3]; - cc->p[1] = cc->p[4]; - cc->npoints = 2; - - cc->red_curve->reset(); - } -} - - -static void -spcc_connector_finish(ConnectorTool *const cc) -{ - SPDesktop *const desktop = cc->desktop; - desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Finishing connector")); - - cc->red_curve->reset(); - spcc_concat_colors_and_flush(cc); - - cc->npoints = 0; - - if (cc->newConnRef) { - cc->newConnRef->removeFromGraph(); - delete cc->newConnRef; - cc->newConnRef = NULL; - } -} - - -static gboolean -cc_generic_knot_handler(SPCanvasItem *, GdkEvent *event, SPKnot *knot) -{ - g_assert (knot != NULL); - - g_object_ref(knot); - - ConnectorTool *cc = SP_CONNECTOR_CONTEXT( - knot->desktop->event_context); - - gboolean consumed = FALSE; - - gchar const *knot_tip = "Click to join at this point"; - switch (event->type) { - case GDK_ENTER_NOTIFY: - sp_knot_set_flag(knot, SP_KNOT_MOUSEOVER, TRUE); - - cc->active_handle = knot; - if (knot_tip) - { - knot->desktop->event_context->defaultMessageContext()->set( - Inkscape::NORMAL_MESSAGE, knot_tip); - } - - consumed = TRUE; - break; - case GDK_LEAVE_NOTIFY: - sp_knot_set_flag(knot, SP_KNOT_MOUSEOVER, FALSE); - - cc->active_handle = NULL; - - if (knot_tip) { - knot->desktop->event_context->defaultMessageContext()->clear(); - } - - consumed = TRUE; - break; - default: - break; - } - - g_object_unref(knot); - - return consumed; -} - - -static gboolean -endpt_handler(SPKnot */*knot*/, GdkEvent *event, ConnectorTool *cc) -{ - //g_assert( SP_IS_CONNECTOR_CONTEXT(cc) ); - - gboolean consumed = FALSE; - - switch (event->type) { - case GDK_BUTTON_PRESS: - g_assert( (cc->active_handle == cc->endpt_handle[0]) || - (cc->active_handle == cc->endpt_handle[1]) ); - if (cc->state == SP_CONNECTOR_CONTEXT_IDLE) { - cc->clickeditem = cc->active_conn; - cc->clickedhandle = cc->active_handle; - cc_clear_active_conn(cc); - cc->state = SP_CONNECTOR_CONTEXT_REROUTING; - - // Disconnect from attached shape - unsigned ind = (cc->active_handle == cc->endpt_handle[0]) ? 0 : 1; - sp_conn_end_detach(cc->clickeditem, ind); - - Geom::Point origin; - if (cc->clickedhandle == cc->endpt_handle[0]) { - origin = cc->endpt_handle[1]->pos; - } - else { - origin = cc->endpt_handle[0]->pos; - } - - // Show the red path for dragging. - cc->red_curve = SP_PATH(cc->clickeditem)->get_curve_for_edit(); - Geom::Affine i2d = (cc->clickeditem)->i2dt_affine(); - cc->red_curve->transform(i2d); - sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve); - - cc->clickeditem->setHidden(true); - - // The rest of the interaction rerouting the connector is - // handled by the context root handler. - consumed = TRUE; - } - break; - default: - break; - } - - return consumed; -} - -static void cc_active_shape_add_knot(ConnectorTool *cc, SPItem* item) -{ - SPDesktop *desktop = cc->desktop; - SPKnot *knot = sp_knot_new(desktop, 0); - - knot->owner = item; - knot->setShape(SP_KNOT_SHAPE_SQUARE); - knot->setSize(8); - knot->setAnchor(SP_ANCHOR_CENTER); - knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff); - sp_knot_update_ctrl(knot); - - // We don't want to use the standard knot handler. - g_signal_handler_disconnect(G_OBJECT(knot->item), - knot->_event_handler_id); - knot->_event_handler_id = 0; - - g_signal_connect(G_OBJECT(knot->item), "event", - G_CALLBACK(cc_generic_knot_handler), knot); - sp_knot_set_position(knot, item->avoidRef->getConnectionPointPos() * desktop->doc2dt(), 0); - sp_knot_show(knot); - cc->knots[knot] = 1; -} - -static void cc_set_active_shape(ConnectorTool *cc, SPItem *item) -{ - g_assert(item != NULL ); - - if (cc->active_shape != item) - { - // The active shape has changed - // Rebuild everything - cc->active_shape = item; - // Remove existing active shape listeners - if (cc->active_shape_repr) { - sp_repr_remove_listener_by_data(cc->active_shape_repr, cc); - Inkscape::GC::release(cc->active_shape_repr); - - sp_repr_remove_listener_by_data(cc->active_shape_layer_repr, cc); - Inkscape::GC::release(cc->active_shape_layer_repr); - } - - // Listen in case the active shape changes - cc->active_shape_repr = item->getRepr(); - if (cc->active_shape_repr) { - Inkscape::GC::anchor(cc->active_shape_repr); - sp_repr_add_listener(cc->active_shape_repr, &shape_repr_events, cc); - - cc->active_shape_layer_repr = cc->active_shape_repr->parent(); - Inkscape::GC::anchor(cc->active_shape_layer_repr); - sp_repr_add_listener(cc->active_shape_layer_repr, &layer_repr_events, cc); - } - - cc_clear_active_knots(cc->knots); - - // The idea here is to try and add a group's children to solidify - // connection handling. We react to path objects with only one node. - for (SPObject *child = item->firstChild() ; child ; child = child->getNext() ) { - if (SP_IS_PATH(child) && SP_PATH(child)->nodesInPath() == 1) { - cc_active_shape_add_knot(cc, (SPItem *) child); - } - } - cc_active_shape_add_knot(cc, item); - - } - else - { - // Ensure the item's connection_points map - // has been updated - item->document->ensureUpToDate(); - } -} - - -static void -cc_set_active_conn(ConnectorTool *cc, SPItem *item) -{ - g_assert( SP_IS_PATH(item) ); - - const SPCurve *curve = SP_PATH(item)->get_curve_reference(); - Geom::Affine i2dt = item->i2dt_affine(); - - if (cc->active_conn == item) - { - if (curve->is_empty()) - { - // Connector is invisible because it is clipped to the boundary of - // two overlpapping shapes. - sp_knot_hide(cc->endpt_handle[0]); - sp_knot_hide(cc->endpt_handle[1]); - } - else - { - // Just adjust handle positions. - Geom::Point startpt = *(curve->first_point()) * i2dt; - sp_knot_set_position(cc->endpt_handle[0], startpt, 0); - - Geom::Point endpt = *(curve->last_point()) * i2dt; - sp_knot_set_position(cc->endpt_handle[1], endpt, 0); - } - - return; - } - - cc->active_conn = item; - - // Remove existing active conn listeners - if (cc->active_conn_repr) { - sp_repr_remove_listener_by_data(cc->active_conn_repr, cc); - Inkscape::GC::release(cc->active_conn_repr); - cc->active_conn_repr = NULL; - } - - // Listen in case the active conn changes - cc->active_conn_repr = item->getRepr(); - if (cc->active_conn_repr) { - Inkscape::GC::anchor(cc->active_conn_repr); - sp_repr_add_listener(cc->active_conn_repr, &shape_repr_events, cc); - } - - for (int i = 0; i < 2; ++i) { - - // Create the handle if it doesn't exist - if ( cc->endpt_handle[i] == NULL ) { - SPKnot *knot = sp_knot_new(cc->desktop, - _("Connector endpoint: drag to reroute or connect to new shapes")); - - knot->setShape(SP_KNOT_SHAPE_SQUARE); - knot->setSize(7); - knot->setAnchor(SP_ANCHOR_CENTER); - knot->setFill(0xffffff00, 0xff0000ff, 0xff0000ff); - knot->setStroke(0x000000ff, 0x000000ff, 0x000000ff); - sp_knot_update_ctrl(knot); - - // We don't want to use the standard knot handler, - // since we don't want this knot to be draggable. - g_signal_handler_disconnect(G_OBJECT(knot->item), - knot->_event_handler_id); - knot->_event_handler_id = 0; - - g_signal_connect(G_OBJECT(knot->item), "event", - G_CALLBACK(cc_generic_knot_handler), knot); - - cc->endpt_handle[i] = knot; - } - - // Remove any existing handlers - if (cc->endpt_handler_id[i]) { - g_signal_handlers_disconnect_by_func( - G_OBJECT(cc->endpt_handle[i]->item), - (void*)G_CALLBACK(endpt_handler), (gpointer) cc ); - cc->endpt_handler_id[i] = 0; - } - - // Setup handlers for connector endpoints, this is - // is as 'after' so that cc_generic_knot_handler is - // triggered first for any endpoint. - cc->endpt_handler_id[i] = g_signal_connect_after( - G_OBJECT(cc->endpt_handle[i]->item), "event", - G_CALLBACK(endpt_handler), cc); - } - - if (curve->is_empty()) - { - // Connector is invisible because it is clipped to the boundary - // of two overlpapping shapes. So, it doesn't need endpoints. - return; - } - - Geom::Point startpt = *(curve->first_point()) * i2dt; - sp_knot_set_position(cc->endpt_handle[0], startpt, 0); - - Geom::Point endpt = *(curve->last_point()) * i2dt; - sp_knot_set_position(cc->endpt_handle[1], endpt, 0); - - sp_knot_show(cc->endpt_handle[0]); - sp_knot_show(cc->endpt_handle[1]); -} - -void cc_create_connection_point(ConnectorTool* cc) -{ - if (cc->active_shape && cc->state == SP_CONNECTOR_CONTEXT_IDLE) - { - if (cc->selected_handle) - { - cc_deselect_handle( cc->selected_handle ); - } - SPKnot *knot = sp_knot_new(cc->desktop, 0); - // We do not process events on this knot. - g_signal_handler_disconnect(G_OBJECT(knot->item), - knot->_event_handler_id); - knot->_event_handler_id = 0; - - cc_select_handle( knot ); - cc->selected_handle = knot; - sp_knot_show(cc->selected_handle); - cc->state = SP_CONNECTOR_CONTEXT_NEWCONNPOINT; - } -} - -static bool cc_item_is_shape(SPItem *item) -{ - if (SP_IS_PATH(item)) { - const SPCurve * curve = (SP_SHAPE(item))->_curve; - if ( curve && !(curve->is_closed()) ) { - // Open paths are connectors. - return false; - } - } - else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) { - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - if (prefs->getBool("/tools/connector/ignoretext", true)) { - // Don't count text as a shape we can connect connector to. - return false; - } - } - return true; -} - - -bool cc_item_is_connector(SPItem *item) -{ - if (SP_IS_PATH(item)) { - bool closed = SP_PATH(item)->get_curve_reference()->is_closed(); - if (SP_PATH(item)->connEndPair.isAutoRoutingConn() && !closed) { - // To be considered a connector, an object must be a non-closed - // path that is marked with a "inkscape:connector-type" attribute. - return true; - } - } - return false; -} - - -void cc_selection_set_avoid(bool const set_avoid) -{ - SPDesktop *desktop = inkscape_active_desktop(); - if (desktop == NULL) { - return; - } - - SPDocument *document = sp_desktop_document(desktop); - - Inkscape::Selection *selection = sp_desktop_selection(desktop); - - GSList *l = const_cast(selection->itemList()); - - int changes = 0; - - while (l) { - SPItem *item = SP_ITEM(l->data); - - char const *value = (set_avoid) ? "true" : NULL; - - if (cc_item_is_shape(item)) { - item->setAttribute("inkscape:connector-avoid", value, NULL); - item->avoidRef->handleSettingChange(); - changes++; - } - - l = l->next; - } - - if (changes == 0) { - desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, - _("Select at least one non-connector object.")); - return; - } - - char *event_desc = (set_avoid) ? - _("Make connectors avoid selected objects") : - _("Make connectors ignore selected objects"); - DocumentUndo::done(document, SP_VERB_CONTEXT_CONNECTOR, event_desc); -} - -void ConnectorTool::selection_changed(Inkscape::Selection *selection) { - SPItem *item = selection->singleItem(); - - if (this->active_conn == item) { - // Nothing to change. - return; - } - - if (item == NULL) { - cc_clear_active_conn(this); - return; - } - - if (cc_item_is_connector(item)) { - cc_set_active_conn(this, item); - } -} - -static void -shape_event_attr_deleted(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *child, - Inkscape::XML::Node */*ref*/, gpointer data) -{ - g_assert(data); - ConnectorTool *cc = SP_CONNECTOR_CONTEXT(data); - - if (child == cc->active_shape_repr) { - // The active shape has been deleted. Clear active shape. - cc_clear_active_shape(cc); - } -} - - -static void -shape_event_attr_changed(Inkscape::XML::Node *repr, gchar const *name, - gchar const */*old_value*/, gchar const */*new_value*/, - bool /*is_interactive*/, gpointer data) -{ - g_assert(data); - ConnectorTool *cc = SP_CONNECTOR_CONTEXT(data); - - // Look for changes that result in onscreen movement. - if (!strcmp(name, "d") || !strcmp(name, "x") || !strcmp(name, "y") || - !strcmp(name, "width") || !strcmp(name, "height") || - !strcmp(name, "transform")) - { - if (repr == cc->active_shape_repr) { - // Active shape has moved. Clear active shape. - cc_clear_active_shape(cc); - } - else if (repr == cc->active_conn_repr) { - // The active conn has been moved. - // Set it again, which just sets new handle positions. - cc_set_active_conn(cc, cc->active_conn); - } - } -} - -} -} -} - - -/* - 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