From: johanengelen Date: Thu, 6 Mar 2008 20:13:43 +0000 (+0000) Subject: add preferences for path flashing on mouseover X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=88df5e1977cc337adbcf3c1b2e33dd2114ecd3b2;p=inkscape.git add preferences for path flashing on mouseover --- diff --git a/src/display/canvas-temporary-item.cpp b/src/display/canvas-temporary-item.cpp index da6caf2c1..7d7f8087c 100644 --- a/src/display/canvas-temporary-item.cpp +++ b/src/display/canvas-temporary-item.cpp @@ -27,6 +27,7 @@ TemporaryItem::TemporaryItem(SPCanvasItem *item, guint lifetime) : canvasitem(item), timeout_id(0) { + // zero lifetime means stay forever, so do not add timeout event. if (lifetime > 0) { timeout_id = g_timeout_add(lifetime, &TemporaryItem::_timeout, this); } diff --git a/src/node-context.cpp b/src/node-context.cpp index 29b8886b8..82d0ab670 100644 --- a/src/node-context.cpp +++ b/src/node-context.cpp @@ -204,29 +204,33 @@ sp_node_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve gint ret = FALSE; 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 ( 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... - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvasitem), 0xff0000ff, 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); - nc->flash_tempitem = desktop->add_temporary_canvasitem (canvasitem, 600); + 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); + } } } diff --git a/src/nodepath.cpp b/src/nodepath.cpp index c7e6f7001..380a740fa 100644 --- a/src/nodepath.cpp +++ b/src/nodepath.cpp @@ -202,7 +202,7 @@ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPObject *object, np->local_change = 0; np->show_handles = show_handles; np->helper_path = NULL; - np->helperpath_rgba = 0xff0000ff; + np->helperpath_rgba = prefs_get_int_attribute("tools.nodes", "highlight_color", 0xff0000ff); np->helperpath_width = 1.0; np->curve = sp_curve_copy(curve); np->show_helperpath = prefs_get_int_attribute ("tools.nodes", "show_helperpath", 0) == 1; diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h index 8997ae349..3db878067 100644 --- a/src/preferences-skeleton.h +++ b/src/preferences-skeleton.h @@ -74,7 +74,7 @@ static char const preferences_skeleton[] = " \n" -" \n" +" \n" " \n" " \n" " \n" diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index f391e23d7..453d3812a 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -382,6 +382,14 @@ void InkscapePreferences::initPageTools() this->AddPage(_page_node, _("Node"), iter_tools, PREFS_PAGE_TOOLS_NODE); AddSelcueCheckbox(_page_node, "tools.nodes", true); AddGradientCheckbox(_page_node, "tools.nodes", true); + _page_node.add_group_header( _("Path outline:")); + _t_node_pathoutline_color.init(_("Path outline color"), "tools.nodes", "highlight_color", 0xff0000ff); + _page_node.add_line( false, _("Path outline color"), _t_node_pathoutline_color, "", _("Selects the color used for showing the path outline."), false); + _t_node_pathflash_enabled.init ( _("Path outline flash on mouse-over"), "tools.nodes", "pathflash_enabled", false); + _page_node.add_line( true, "", _t_node_pathflash_enabled, "", _("When hovering over a path, briefly flash its outline.")); + _t_node_pathflash_timeout.init("tools.nodes", "pathflash_timeout", 0, 10000.0, 100.0, 100.0, 1000.0, true, false); + _page_node.add_line( false, _("Flash time"), _t_node_pathflash_timeout, "ms", _("Specifies how long the path outline will be visible after a mouse-over (in milliseconds). Specify 0 to have the outline shown until mouse leaves the path."), false); + //Tweak this->AddPage(_page_tweak, _("Tweak"), iter_tools, PREFS_PAGE_TOOLS_NODE); AddSelcueCheckbox(_page_tweak, "tools.tweak", true); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index c5652de11..72afe1b3a 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -125,6 +125,9 @@ protected: PrefRadioButton _t_sel_trans_obj, _t_sel_trans_outl, _t_sel_cue_none, _t_sel_cue_mark, _t_sel_cue_box, _t_bbox_visual, _t_bbox_geometric; PrefCheckButton _t_cvg_keep_objects; + PrefCheckButton _t_node_pathflash_enabled; + PrefSpinButton _t_node_pathflash_timeout; + PrefColorPicker _t_node_pathoutline_color; PrefSpinButton _t_pencil_tolerance;