X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fnode-context.cpp;h=9a4bff88e361f17f8b2321fa6d25eaaa4bad56b4;hb=a2fbdfc8e80d3d1845bf0d5df989726ae2ffd5bf;hp=56b6dd760ff13ff44159feb5af7b115bca8dc3a0;hpb=c937856620c840189b5416135aa7a5664314fa47;p=inkscape.git diff --git a/src/node-context.cpp b/src/node-context.cpp index 56b6dd760..9a4bff88e 100644 --- a/src/node-context.cpp +++ b/src/node-context.cpp @@ -13,6 +13,8 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif +#include +#include #include #include "macros.h" #include @@ -33,6 +35,13 @@ #include "style.h" #include "splivarot.h" #include "shape-editor.h" +#include "live_effects/effect.h" + +#include "sp-lpe-item.h" + +// needed for flash nodepath upon mouseover: +#include "display/canvas-bpath.h" +#include "display/curve.h" static void sp_node_context_class_init(SPNodeContextClass *klass); static void sp_node_context_init(SPNodeContext *node_context); @@ -95,6 +104,10 @@ sp_node_context_init(SPNodeContext *node_context) node_context->rightctrl = FALSE; new (&node_context->sel_changed_connection) sigc::connection(); + + node_context->flash_tempitem = NULL; + node_context->flashed_item = NULL; + node_context->remove_flash_counter = 0; } static void @@ -108,6 +121,12 @@ sp_node_context_dispose(GObject *object) nc->sel_changed_connection.disconnect(); nc->sel_changed_connection.~connection(); + // TODO: should this be here? + SPItem *item = sp_desktop_selection(ec->desktop)->singleItem(); + if (item && SP_IS_LPE_ITEM(item)) { + sp_lpe_item_remove_temporary_canvasitems(SP_LPE_ITEM(item), ec->desktop); + } + delete nc->shape_editor; if (nc->_node_message_context) { @@ -125,10 +144,11 @@ sp_node_context_setup(SPEventContext *ec) if (((SPEventContextClass *) parent_class)->setup) ((SPEventContextClass *) parent_class)->setup(ec); + Inkscape::Selection *selection = sp_desktop_selection (ec->desktop); nc->sel_changed_connection.disconnect(); - nc->sel_changed_connection = sp_desktop_selection(ec->desktop)->connectChanged(sigc::bind(sigc::ptr_fun(&sp_node_context_selection_changed), (gpointer)nc)); + nc->sel_changed_connection = + selection->connectChanged(sigc::bind(sigc::ptr_fun(&sp_node_context_selection_changed), (gpointer)nc)); - Inkscape::Selection *selection = sp_desktop_selection(ec->desktop); SPItem *item = selection->singleItem(); nc->shape_editor = new ShapeEditor(ec->desktop); @@ -153,11 +173,34 @@ sp_node_context_setup(SPEventContext *ec) ec->enableGrDrag(); } + ec->desktop->emitToolSubselectionChanged(NULL); // sets the coord entry fields to inactive + nc->_node_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack()); nc->shape_editor->update_statusbar(); } +static void +sp_node_context_flash_path(SPEventContext *event_context, SPItem *item, guint timeout) { + SPNodeContext *nc = SP_NODE_CONTEXT(event_context); + + nc->remove_flash_counter = 3; // for some reason root_handler is called twice after each item_handler... + if (nc->flashed_item != item) { + // we entered a new item + nc->flashed_item = item; + SPDesktop *desktop = event_context->desktop; + if (nc->flash_tempitem) { + desktop->remove_temporary_canvasitem(nc->flash_tempitem); + nc->flash_tempitem = NULL; + } + + if (SP_IS_PATH(item)) { + SPCanvasItem *canvasitem = sp_nodepath_generate_helperpath(desktop, SP_PATH(item)); + nc->flash_tempitem = desktop->add_temporary_canvasitem (canvasitem, timeout); + } + } +} + /** \brief Callback that processes the "changed" signal on the selection; destroys old and creates new nodepath and reassigns listeners to the new selected item's repr @@ -171,7 +214,6 @@ sp_node_context_selection_changed(Inkscape::Selection *selection, gpointer data) nc->shape_editor->unset_item(); SPItem *item = selection->singleItem(); nc->shape_editor->set_item(item); - nc->shape_editor->update_statusbar(); } @@ -185,12 +227,25 @@ sp_node_context_show_modifier_tip(SPEventContext *event_context, GdkEvent *event _("Alt: lock handle length; Ctrl+Alt: move along handles")); } - static gint sp_node_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event) { gint ret = FALSE; + if (prefs_get_int_attribute ("tools.nodes", "pathflash_enabled", 0) == 1) { + guint timeout = prefs_get_int_attribute("tools.nodes", "pathflash_timeout", 500); + if (SP_IS_LPE_ITEM(item)) { + Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); + if (lpe && (lpe->providesOwnFlashPaths() || + lpe->pathFlashType() == Inkscape::LivePathEffect::SUPPRESS_FLASH)) { + // path should be suppressed or permanent; this is handled in + // sp_node_context_selection_changed() + return ret; + } + } + sp_node_context_flash_path(event_context, item, timeout); + } + if (((SPEventContextClass *) parent_class)->item_handler) ret = ((SPEventContextClass *) parent_class)->item_handler(event_context, item, event); @@ -209,6 +264,14 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) int const snaps = prefs_get_int_attribute("options.rotationsnapsperpi", "value", 12); double const offset = prefs_get_double_attribute_limited("options.defaultscale", "value", 2, 0, 1000); + if ( (nc->flash_tempitem) && (nc->remove_flash_counter <= 0) ) { + desktop->remove_temporary_canvasitem(nc->flash_tempitem); + nc->flash_tempitem = NULL; + nc->flashed_item = NULL; // also reset this one, so the next time the same object is hovered over it shows again the highlight + } else { + nc->remove_flash_counter--; + } + gint ret = FALSE; switch (event->type) { case GDK_BUTTON_PRESS: @@ -482,17 +545,26 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) ret = TRUE; } break; + case GDK_x: + case GDK_X: + if (MOD__ALT_ONLY) { + desktop->setToolboxFocusTo ("altx-nodes"); + ret = TRUE; + } + break; case GDK_Left: // move selection left case GDK_KP_Left: case GDK_KP_4: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(-10, 0); // shift - else nc->shape_editor->move_nodes_screen(-1, 0); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(mul*-10, 0); // shift + else nc->shape_editor->move_nodes_screen(mul*-1, 0); // no shift } else { // no alt - if (MOD__SHIFT) nc->shape_editor->move_nodes(-10*nudge, 0); // shift - else nc->shape_editor->move_nodes(-nudge, 0); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes(mul*-10*nudge, 0); // shift + else nc->shape_editor->move_nodes(mul*-nudge, 0); // no shift } ret = TRUE; } @@ -501,13 +573,15 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KP_Up: case GDK_KP_8: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(0, 10); // shift - else nc->shape_editor->move_nodes_screen(0, 1); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(0, mul*10); // shift + else nc->shape_editor->move_nodes_screen(0, mul*1); // no shift } else { // no alt - if (MOD__SHIFT) nc->shape_editor->move_nodes(0, 10*nudge); // shift - else nc->shape_editor->move_nodes(0, nudge); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes(0, mul*10*nudge); // shift + else nc->shape_editor->move_nodes(0, mul*nudge); // no shift } ret = TRUE; } @@ -516,13 +590,15 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KP_Right: case GDK_KP_6: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(10, 0); // shift - else nc->shape_editor->move_nodes_screen(1, 0); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(mul*10, 0); // shift + else nc->shape_editor->move_nodes_screen(mul*1, 0); // no shift } else { // no alt - if (MOD__SHIFT) nc->shape_editor->move_nodes(10*nudge, 0); // shift - else nc->shape_editor->move_nodes(nudge, 0); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes(mul*10*nudge, 0); // shift + else nc->shape_editor->move_nodes(mul*nudge, 0); // no shift } ret = TRUE; } @@ -531,13 +607,15 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) case GDK_KP_Down: case GDK_KP_2: if (!MOD__CTRL) { // not ctrl + gint mul = 1 + gobble_key_events( + get_group0_keyval(&event->key), 0); // with any mask if (MOD__ALT) { // alt - if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(0, -10); // shift - else nc->shape_editor->move_nodes_screen(0, -1); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes_screen(0, mul*-10); // shift + else nc->shape_editor->move_nodes_screen(0, mul*-1); // no shift } else { // no alt - if (MOD__SHIFT) nc->shape_editor->move_nodes(0, -10*nudge); // shift - else nc->shape_editor->move_nodes(0, -nudge); // no shift + if (MOD__SHIFT) nc->shape_editor->move_nodes(0, mul*-10*nudge); // shift + else nc->shape_editor->move_nodes(0, mul*-nudge); // no shift } ret = TRUE; }