? inkscape/doxygen
Index: inkscape/ChangeLog
===================================================================
RCS file: /cvsroot/inkscape/inkscape/ChangeLog,v
retrieving revision 1.1683
diff -u -p -u -3 -r1.1683 ChangeLog
--- inkscape/ChangeLog	5 Dec 2005 16:06:10 -0000	1.1683
+++ inkscape/ChangeLog	6 Dec 2005 10:07:57 -0000
@@ -1,3 +1,26 @@
+2005-12-05  Mathieu Dimanche <mdimanche@...8...>
+
+    * src/snapper.cpp, src/snapper.h: 
+    Added visual feedback of snapped guides
+    Added a virtual highlight_snapped_line() function to the prototype
+
+    * src/guide-snapper.cpp, src/guide-snapper.h: 
+    Added the new highlight_snapped_line() function, Guides now
+    highlight when an object selection is snapped against them.
+
+    * src/grid-snapper.cpp, src/grid-snapper.h: 
+    Added the new highlight_snapped_line function, empty for now.
+
+    * src/sp-namedview.cpp, src/sp-namedview.h: 
+    Added a new reset_snapped_visual_feedback() function to downlight 
+    every temporary visual feedback provided during snapping.
+
+    * src/select-context.cpp, src/rect-context.cpp: 
+    Added calls to reset_snapped_visual_feedback() before motion notify while dragging..
+
+    * src/event-context.cpp:
+    Added a call to reset_snapped_visual_feedback() after button release.
+
 2005-12-05  Carl Hetherington <inkscape@...169...>
 
 	* src/desktop.cpp, src/tools-switch.cpp,
Index: inkscape/src/event-context.cpp
===================================================================
RCS file: /cvsroot/inkscape/inkscape/src/event-context.cpp,v
retrieving revision 1.65
diff -u -p -u -3 -r1.65 event-context.cpp
--- inkscape/src/event-context.cpp	5 Dec 2005 16:54:35 -0000	1.65
+++ inkscape/src/event-context.cpp	6 Dec 2005 10:07:58 -0000
@@ -60,7 +60,7 @@
 #include "attributes.h"
 #include "rubberband.h"
 #include "selcue.h"
-
+#include "sp-namedview.h"
 #include "event-context.h"
 
 static void sp_event_context_class_init(SPEventContextClass *klass);
@@ -404,6 +404,9 @@ static gint sp_event_context_private_roo
             }
             break;
         case GDK_MOTION_NOTIFY:
+             // reset snapping visual feedback does not work here... why ? (mtou - Mathieu Dimanche)
+            // desktop->namedview->reset_snapped_visual_feedback();
+
             if (panning) {
                 if ((panning == 2 && !(event->motion.state & GDK_BUTTON2_MASK)) 
                         || (panning == 3 && !(event->motion.state & GDK_BUTTON3_MASK))) {
@@ -485,6 +488,10 @@ static gint sp_event_context_private_roo
                 sp_rubberband_stop();
             }
             xp = yp = 0; 
+
+           // reset snapping visual feedback
+            desktop->namedview->reset_snapped_visual_feedback();
+
             break;
         case GDK_KEY_PRESS:
             switch (get_group0_keyval(&event->key)) {
Index: inkscape/src/grid-snapper.cpp
===================================================================
RCS file: /cvsroot/inkscape/inkscape/src/grid-snapper.cpp,v
retrieving revision 1.2
diff -u -p -u -3 -r1.2 grid-snapper.cpp
--- inkscape/src/grid-snapper.cpp	30 Nov 2005 14:12:31 -0000	1.2
+++ inkscape/src/grid-snapper.cpp	6 Dec 2005 10:07:58 -0000
@@ -50,6 +50,17 @@ Snapper::LineList GridSnapper::get_snap_
     return s;
 }
 
+/**
+ * Provide visual feedback of a snapped line in the grid.  
+ * @return True if a line was showed.
+ * TODO: create a temporary line (on the sketch layer ?)
+ */
+bool GridSnapper::highlight_snapped_line(NR::Point const normal, NR::Coord const position) const
+{
+    return false;
+}
+
+
 /*
   Local Variables:
   mode:c++
Index: inkscape/src/grid-snapper.h
===================================================================
RCS file: /cvsroot/inkscape/inkscape/src/grid-snapper.h,v
retrieving revision 1.2
diff -u -p -u -3 -r1.2 grid-snapper.h
--- inkscape/src/grid-snapper.h	30 Nov 2005 14:12:31 -0000	1.2
+++ inkscape/src/grid-snapper.h	6 Dec 2005 10:07:58 -0000
@@ -25,6 +25,9 @@ public:
 
 private:    
     LineList get_snap_lines(NR::Point const &p) const;
+
+    bool highlight_snapped_line(NR::Point const normal, NR::Coord const position) const;
+
 };
 
 #endif
Index: inkscape/src/guide-snapper.cpp
===================================================================
RCS file: /cvsroot/inkscape/inkscape/src/guide-snapper.cpp,v
retrieving revision 1.2
diff -u -p -u -3 -r1.2 guide-snapper.cpp
--- inkscape/src/guide-snapper.cpp	30 Nov 2005 14:12:31 -0000	1.2
+++ inkscape/src/guide-snapper.cpp	6 Dec 2005 10:07:58 -0000
@@ -17,6 +17,8 @@
 #include "sp-namedview.h"
 #include "sp-guide.h"
 #include "guide-snapper.h"
+#include "display/guideline.h"
+
 
 GuideSnapper::GuideSnapper(SPNamedView const *nv, NR::Coord const d) : Snapper(nv, d)
 {
@@ -35,6 +37,31 @@ Snapper::LineList GuideSnapper::get_snap
     return s;
 }
 
+
+/**
+ * Provide visual feedback of a snapped guide.  
+ * @return True if a guide was showed.
+ */
+bool GuideSnapper::highlight_snapped_line(NR::Point const normal, NR::Coord const position) const
+{
+    bool guidefound;
+
+    guidefound = false;
+
+    for (GSList const *l = _named_view->guides; l != NULL; l = l->next) {
+        SPGuide &g = *SP_GUIDE(l->data);
+        if ( ( g.normal == normal ) && ( g.position == position ) ) {
+            for (GSList *l2 = g.views; l2 != NULL; l2 = l2->next) {
+                sp_guideline_set_color(SP_GUIDELINE(l2->data), _named_view->guidehicolor);
+            }
+            guidefound = true;
+        }
+    }
+    
+    return guidefound;
+}
+
+
 /*
   Local Variables:
   mode:c++
Index: inkscape/src/guide-snapper.h
===================================================================
RCS file: /cvsroot/inkscape/inkscape/src/guide-snapper.h,v
retrieving revision 1.2
diff -u -p -u -3 -r1.2 guide-snapper.h
--- inkscape/src/guide-snapper.h	30 Nov 2005 14:12:31 -0000	1.2
+++ inkscape/src/guide-snapper.h	6 Dec 2005 10:07:58 -0000
@@ -29,6 +29,9 @@ public:
 
 private:
     LineList get_snap_lines(NR::Point const &p) const;
+    
+    bool highlight_snapped_line(NR::Point const normal, NR::Coord const position) const;
+
 };
 
 #endif
Index: inkscape/src/rect-context.cpp
===================================================================
RCS file: /cvsroot/inkscape/inkscape/src/rect-context.cpp,v
retrieving revision 1.78
diff -u -p -u -3 -r1.78 rect-context.cpp
--- inkscape/src/rect-context.cpp	5 Dec 2005 16:52:03 -0000	1.78
+++ inkscape/src/rect-context.cpp	6 Dec 2005 10:07:58 -0000
@@ -370,6 +370,7 @@ static gint sp_rect_context_root_handler
             ret = TRUE;
             sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
                                   event->button.time);
+
         }
         break;
     case GDK_KEY_PRESS:
@@ -442,6 +443,8 @@ static gint sp_rect_context_root_handler
 
 static void sp_rect_drag(SPRectContext &rc, NR::Point const pt, guint state)
 {
+
+
     SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop;
 
     if (!rc.item) {
@@ -468,6 +471,9 @@ static void sp_rect_drag(SPRectContext &
         rc.item->updateRepr();
     }
 
+    //reset snapping visual feedback
+    desktop->namedview->reset_snapped_visual_feedback();
+   
     NR::Point p0, p1;
     if ( state & GDK_CONTROL_MASK ) {
         NR::Point delta = pt - rc.center;
Index: inkscape/src/select-context.cpp
===================================================================
RCS file: /cvsroot/inkscape/inkscape/src/select-context.cpp,v
retrieving revision 1.115
diff -u -p -u -3 -r1.115 select-context.cpp
--- inkscape/src/select-context.cpp	5 Dec 2005 16:02:05 -0000	1.115
+++ inkscape/src/select-context.cpp	6 Dec 2005 10:07:58 -0000
@@ -481,6 +481,9 @@ sp_select_context_root_handler(SPEventCo
                 if (sc->button_press_ctrl || sc->button_press_alt) // if ctrl or alt was pressed and it's not click, we want to drag rather than rubberband
                     sc->dragging = TRUE;
 
+                 // reset snapping visual feedback
+                desktop->namedview->reset_snapped_visual_feedback();
+
                 if (sc->dragging) {
                     /* User has dragged fast, so we get events on root (lauris)*/
                     // not only that; we will end up here when ctrl-dragging as well
@@ -632,6 +635,7 @@ sp_select_context_root_handler(SPEventCo
             sc->button_press_shift = false;
             sc->button_press_ctrl = false;
             sc->button_press_alt = false;
+
             break;
 
         case GDK_KEY_PRESS: // keybindings for select context
@@ -829,6 +833,7 @@ sp_select_context_root_handler(SPEventCo
 }
 
 
+
 /*
   Local Variables:
   mode:c++
Index: inkscape/src/snapper.cpp
===================================================================
RCS file: /cvsroot/inkscape/inkscape/src/snapper.cpp,v
retrieving revision 1.3
diff -u -p -u -3 -r1.3 snapper.cpp
--- inkscape/src/snapper.cpp	30 Nov 2005 14:12:31 -0000	1.3
+++ inkscape/src/snapper.cpp	6 Dec 2005 10:07:58 -0000
@@ -133,11 +133,16 @@ NR::Coord Snapper::vector_snap(PointType
         if (intersector_line_intersection(n2, d2, i->first, i->second, trial) == INTERSECTS) {
             const NR::Coord dist = L2(trial - req);
             if (dist < upper) {
+                
                 upper = best = dist;
                 snapped = trial;
+
+                // the snapping occured, provide visual feedback
+                highlight_snapped_line(i->first, i->second);
             }
+
         }
-    }
+}
 
     req = snapped;
     return best;
Index: inkscape/src/snapper.h
===================================================================
RCS file: /cvsroot/inkscape/inkscape/src/snapper.h,v
retrieving revision 1.3
diff -u -p -u -3 -r1.3 snapper.h
--- inkscape/src/snapper.h	30 Nov 2005 16:50:11 -0000	1.3
+++ inkscape/src/snapper.h	6 Dec 2005 10:07:58 -0000
@@ -52,7 +52,16 @@ protected:
      *  \return List of lines that we should try snapping to.
      */
     virtual LineList get_snap_lines(NR::Point const &p) const = 0;
-    
+
+    /**
+     * Provide visual feedback of a snapped guide.  
+     *  \param normal Normal of the line to show.
+     *  \param position Point through which the line passes.
+     *  \return True if the line was showed.
+     */
+    virtual bool highlight_snapped_line(NR::Point const normal, NR::Coord const position) const = 0;
+
+
     SPNamedView const *_named_view;
     
 private:
Index: inkscape/src/sp-namedview.cpp
===================================================================
RCS file: /cvsroot/inkscape/inkscape/src/sp-namedview.cpp,v
retrieving revision 1.78
diff -u -p -u -3 -r1.78 sp-namedview.cpp
--- inkscape/src/sp-namedview.cpp	2 Dec 2005 14:13:43 -0000	1.78
+++ inkscape/src/sp-namedview.cpp	6 Dec 2005 10:07:58 -0000
@@ -36,6 +36,8 @@
 #include "sp-namedview.h"
 #include "prefs-utils.h"
 #include "desktop.h"
+#include "display/guideline.h"
+
 
 #include "isnan.h" //temp fox for isnan().  include last
 
@@ -931,6 +933,27 @@ SPMetric SPNamedView::getDefaultMetric()
 }
 
 
+/**
+ *  Downlight or delete all temporary highlighted item used
+ *  to provide a visual feedback of where elements where snapped
+ *  \return True if all visual feedback was cleared
+ */
+bool
+SPNamedView::reset_snapped_visual_feedback() {
+
+    // downlight all the guides (for now)
+   for (GSList const *l = guides; l != NULL; l = l->next) {
+        SPGuide &g = *SP_GUIDE(l->data);
+        for (GSList *l2 = g.views; l2 != NULL; l2 = l2->next) {
+            sp_guideline_set_color(SP_GUIDELINE(l2->data), guidecolor);
+        }
+    }
+
+    // TODO: downlight grid items (when they'll be highlightable)
+
+    return true;
+}
+
 /*
   Local Variables:
   mode:c++
Index: inkscape/src/sp-namedview.h
===================================================================
RCS file: /cvsroot/inkscape/inkscape/src/sp-namedview.h,v
retrieving revision 1.29
diff -u -p -u -3 -r1.29 sp-namedview.h
--- inkscape/src/sp-namedview.h	2 Dec 2005 14:13:43 -0000	1.29
+++ inkscape/src/sp-namedview.h	6 Dec 2005 10:07:58 -0000
@@ -90,6 +90,9 @@ struct SPNamedView : public SPObjectGrou
     guint getViewCount();
     GSList const *getViewList() const;
     SPMetric getDefaultMetric() const;
+
+    bool reset_snapped_visual_feedback();
+
 };
 
 struct SPNamedViewClass {
