Code

Fix fallback icon loading order for icons with legacy names.
[inkscape.git] / src / knot-holder-entity.cpp
index 4225dd9e3b19eb15292f8865bc967e527ce6db3a..005ca24c71c1fbe2e1b8bbb8112c5c5401f4ed26 100644 (file)
@@ -1,11 +1,10 @@
-#define __KNOT_HOLDER_ENTITY_C__
-
 /** \file
  * KnotHolderEntity definition.
  *
  * Authors:
  *   Mitsuru Oka <oka326@parkcity.ne.jp>
  *   Maximilian Albert <maximilian.albert@gmail.com>
+ *   Abhishek Sharma
  *
  * Copyright (C) 1999-2001 Lauris Kaplinski
  * Copyright (C) 2000-2001 Ximian, Inc.
@@ -77,7 +76,7 @@ KnotHolderEntity::~KnotHolderEntity()
 void
 KnotHolderEntity::update_knot()
 {
-    Geom::Matrix const i2d(sp_item_i2d_affine(item));
+    Geom::Matrix const i2d(item->i2d_affine());
 
     Geom::Point dp(knot_get() * i2d);
 
@@ -89,23 +88,33 @@ KnotHolderEntity::update_knot()
 Geom::Point
 KnotHolderEntity::snap_knot_position(Geom::Point const &p)
 {
-    Geom::Matrix const i2d (sp_item_i2d_affine(item));
+    Geom::Matrix const i2d (item->i2d_affine());
     Geom::Point s = p * i2d;
+
     SnapManager &m = desktop->namedview->snap_manager;
     m.setup(desktop, true, item);
-    m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, s, Inkscape::SNAPSOURCE_HANDLE);
+    m.freeSnapReturnByRef(s, Inkscape::SNAPSOURCE_NODE_HANDLE);
+    m.unSetup();
+
     return s * i2d.inverse();
 }
 
 Geom::Point
-KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::ConstraintLine const &constraint)
+KnotHolderEntity::snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint)
 {
-    Geom::Matrix const i2d (sp_item_i2d_affine(item));
+    Geom::Matrix const i2d (item->i2d_affine());
     Geom::Point s = p * i2d;
-    Inkscape::Snapper::ConstraintLine transformed_constraint = Inkscape::Snapper::ConstraintLine(constraint.getPoint() * i2d, (constraint.getPoint() + constraint.getDirection()) * i2d - constraint.getPoint() * i2d);
+
     SnapManager &m = desktop->namedview->snap_manager;
     m.setup(desktop, true, item);
-    m.constrainedSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, s, Inkscape::SNAPSOURCE_HANDLE, transformed_constraint);
+
+    Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+    // constrainedSnap() will first project the point p onto the constraint line and then try to snap along that line.
+    // This way the constraint is already enforced, no need to worry about that later on
+    Inkscape::Snapper::SnapConstraint transformed_constraint = Inkscape::Snapper::SnapConstraint(constraint.getPoint() * i2d, (constraint.getPoint() + constraint.getDirection()) * i2d - constraint.getPoint() * i2d);
+    m.constrainedSnapReturnByRef(s, Inkscape::SNAPSOURCE_NODE_HANDLE, transformed_constraint);
+    m.unSetup();
+
     return s * i2d.inverse();
 }
 
@@ -149,7 +158,7 @@ PatternKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &ori
 
     if (state)  {
         Geom::Point const q = p_snapped - sp_pattern_extract_trans(pat);
-        sp_item_adjust_pattern(item, Geom::Matrix(Geom::Translate(q)));
+        item->adjust_pattern(Geom::Matrix(Geom::Translate(q)));
     }
 
     item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
@@ -199,7 +208,7 @@ PatternKnotHolderEntityAngle::knot_set(Geom::Point const &p, Geom::Point const &
     Geom::Point const t = sp_pattern_extract_trans(pat);
     rot[4] = t[Geom::X];
     rot[5] = t[Geom::Y];
-    sp_item_adjust_pattern(item, rot, true);
+    item->adjust_pattern(rot, true);
     item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 }
 
@@ -233,7 +242,7 @@ PatternKnotHolderEntityScale::knot_set(Geom::Point const &p, Geom::Point const &
     Geom::Point const t = sp_pattern_extract_trans(pat);
     rot[4] = t[Geom::X];
     rot[5] = t[Geom::Y];
-    sp_item_adjust_pattern(item, rot, true);
+    item->adjust_pattern(rot, true);
     item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
 }
 
@@ -263,4 +272,4 @@ PatternKnotHolderEntityScale::knot_get()
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :