Code

add preferences for path flashing on mouseover
authorjohanengelen <johanengelen@users.sourceforge.net>
Thu, 6 Mar 2008 20:13:43 +0000 (20:13 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Thu, 6 Mar 2008 20:13:43 +0000 (20:13 +0000)
src/display/canvas-temporary-item.cpp
src/node-context.cpp
src/nodepath.cpp
src/preferences-skeleton.h
src/ui/dialog/inkscape-preferences.cpp
src/ui/dialog/inkscape-preferences.h

index da6caf2c1f392fb738e0c3032e2cb6195740e3fd..7d7f8087c04e8ef45b901fb6dbf1eb0e5dbb664a 100644 (file)
@@ -27,6 +27,7 @@ TemporaryItem::TemporaryItem(SPCanvasItem *item, guint lifetime)
     : canvasitem(item),\r
       timeout_id(0)\r
 {\r
+    // zero lifetime means stay forever, so do not add timeout event.\r
     if (lifetime > 0) {\r
         timeout_id = g_timeout_add(lifetime, &TemporaryItem::_timeout, this);\r
     }\r
index 29b8886b863cc198f0b3183f424363906d8328ac..82d0ab670b589bfd4abf5dc262a146c46dc8a641 100644 (file)
@@ -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);
+            }
         }
     }
 
index c7e6f700125aa39d324c764c69e0555a25de7438..380a740fa0c1c85024ae3a693de9e7367d614693 100644 (file)
@@ -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;
index 8997ae3495889efade49b43bfda0f046ec34c3db..3db878067767e4976acffda7753e5e7c7915245d 100644 (file)
@@ -74,7 +74,7 @@ static char const preferences_skeleton[] =
 "    <eventcontext id=\"text\"  usecurrent=\"0\" gradientdrag=\"1\"\n" 
 "                       font_sample=\"AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()\"\n"
 "                  style=\"fill:black;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;font-style:normal;font-weight:normal;font-size:40px;\" selcue=\"1\"/>\n"
-"    <eventcontext id=\"nodes\" selcue=\"1\" gradientdrag=\"1\" show_handles=\"1\" show_helperpath=\"0\" sculpting_profile=\"1\" />\n"
+"    <eventcontext id=\"nodes\" selcue=\"1\" gradientdrag=\"1\" highlight_color=\"4278190335\" pathflash_enabled=\"1\" pathflash_timeout=\"500\" show_handles=\"1\" show_helperpath=\"0\" sculpting_profile=\"1\" />\n"
 "    <eventcontext id=\"tweak\" selcue=\"0\" gradientdrag=\"0\" show_handles=\"0\" width=\"0.2\" force=\"0.2\" fidelity=\"0.5\" usepressure=\"1\" style=\"fill:red;stroke:none;\" usecurrent=\"0\"/>\n"
 "    <eventcontext id=\"gradient\" selcue=\"1\"/>\n"
 "    <eventcontext id=\"zoom\" selcue=\"1\" gradientdrag=\"0\"/>\n"
index f391e23d7a9b72ac46e514815f0651767208cea8..453d3812a0b2d067f85981767888caec10fc1c98 100644 (file)
@@ -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);
index c5652de1108f7c93aee3e16fc7416308bc8ba055..72afe1b3a5092f16de22f9eaccbbfb231cdb2f7c 100644 (file)
@@ -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;