diff --git a/src/node-context.cpp b/src/node-context.cpp
index 82d0ab670b589bfd4abf5dc262a146c46dc8a641..b85e08b689c06163f090a82262b37405d539a32e 100644 (file)
--- a/src/node-context.cpp
+++ b/src/node-context.cpp
#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"
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) {
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);
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
@@ -183,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();
}
@@ -197,41 +227,27 @@ sp_node_context_show_modifier_tip(SPEventContext *event_context, GdkEvent *event
_("<b>Alt</b>: lock handle length; <b>Ctrl+Alt</b>: move along handles"));
}
-
static gint
sp_node_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEvent *event)
{
gint ret = FALSE;
- SPNodeContext *nc = SP_NODE_CONTEXT(event_context);
- if ( prefs_get_int_attribute ("tools.nodes", "pathflash_enabled", 0) == 1 ) {
- 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)) {
- // This should be put somewhere else under the name of "generate helperpath" or something. Because basically this is copied of code from nodepath...
- SPCurve *curve_new = sp_path_get_curve_for_edit(SP_PATH(item));
- SPCurve *flash_curve = sp_curve_copy(curve_new);
- sp_curve_transform(flash_curve, sp_item_i2d_affine(item) );
- SPCanvasItem * canvasitem = sp_canvas_bpath_new(sp_desktop_tempgroup(desktop), flash_curve);
- // would be nice if its color could be XORed or something, now it is invisible for red stroked objects...
- // unless we also flash the nodes...
- guint32 color = prefs_get_int_attribute("tools.nodes", "highlight_color", 0xff0000ff);
- sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvasitem), color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
- sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvasitem), 0, SP_WIND_RULE_NONZERO);
- sp_canvas_item_show(canvasitem);
- sp_curve_unref(flash_curve);
- guint timeout = prefs_get_int_attribute("tools.nodes", "pathflash_timeout", 500);
- nc->flash_tempitem = desktop->add_temporary_canvasitem (canvasitem, timeout);
+ 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) {
+ if (lpe->pathFlashType() == Inkscape::LivePathEffect::SUPPRESS_FLASH) {
+ // suppressed and permanent flashes for LPE items are handled in
+ // sp_node_context_selection_changed()
+ return ret;
+ }
+ if (lpe->pathFlashType() == Inkscape::LivePathEffect::PERMANENT_FLASH) {
+ timeout = 0;
+ }
}
}
+ sp_node_context_flash_path(event_context, item, timeout);
}
if (((SPEventContextClass *) parent_class)->item_handler)