diff --git a/src/node-context.cpp b/src/node-context.cpp
index 56b6dd760ff13ff44159feb5af7b115bca8dc3a0..d8a1ec1d7deb953f20517561dfd35d78ff8b5d2b 100644 (file)
--- a/src/node-context.cpp
+++ b/src/node-context.cpp
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
+#include <cstring>
+#include <string>
#include <gdk/gdkkeysyms.h>
#include "macros.h"
#include <glibmm/i18n.h>
#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);
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
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->current_state = SP_NODE_CONTEXT_INACTIVE;
if (item) {
- nc->shape_editor->set_item(item);
+ nc->shape_editor->set_item(item, SH_NODEPATH);
+ nc->shape_editor->set_item(item, SH_KNOTHOLDER);
}
if (prefs_get_int_attribute("tools.nodes", "selcue", 0) != 0) {
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) {
+ g_print ("-----> sp_node_context_flash_path(): TODO: generate the helper path!!\n");
+ 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_helperpath_from_path(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
@@ -168,10 +207,11 @@ sp_node_context_selection_changed(Inkscape::Selection *selection, gpointer data)
SPNodeContext *nc = SP_NODE_CONTEXT(data);
// TODO: update ShapeEditorsCollective instead
- nc->shape_editor->unset_item();
+ nc->shape_editor->unset_item(SH_NODEPATH);
+ nc->shape_editor->unset_item(SH_KNOTHOLDER);
SPItem *item = selection->singleItem();
- nc->shape_editor->set_item(item);
-
+ nc->shape_editor->set_item(item, SH_NODEPATH);
+ nc->shape_editor->set_item(item, SH_KNOTHOLDER);
nc->shape_editor->update_statusbar();
}
@@ -185,12 +225,25 @@ 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;
+ 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);
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:
if (event->type == GDK_BUTTON_RELEASE) {
event_context->xp = event_context->yp = 0;
if (event->button.button == 1) {
- NR::Maybe<NR::Rect> b = Inkscape::Rubberband::get()->getRectangle();
+ boost::optional<NR::Rect> b = Inkscape::Rubberband::get()->getRectangle();
if (nc->shape_editor->hits_curve() && !event_context->within_tolerance) { //drag curve
nc->shape_editor->finish_drag();
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;
}
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;
}
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;
}
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;
}
break;
case GDK_Escape:
{
- NR::Maybe<NR::Rect> const b = Inkscape::Rubberband::get()->getRectangle();
+ boost::optional<NR::Rect> const b = Inkscape::Rubberband::get()->getRectangle();
if (b) {
Inkscape::Rubberband::get()->stop();
nc->current_state = SP_NODE_CONTEXT_INACTIVE;