[glom] Print Layout: Snap to rules even when the grid is not shown.



commit 0acbd7626682685250a93ae75638b112226362ec
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat Aug 13 14:25:06 2011 +0200

    Print Layout: Snap to rules even when the grid is not shown.
    
    * glom/utility_widgets/canvas/canvas_group_grid.cc: Don't make snapping
    to rules dependent on whether the grid is showing.

 ChangeLog                                        |    7 ++++
 glom/utility_widgets/canvas/canvas_group_grid.cc |   39 +++++++++++----------
 2 files changed, 27 insertions(+), 19 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 22d533e..b957192 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-08-13  Murray Cumming  <murrayc murrayc com>
+
+	Print Layout: Snap to rules even when the grid is not shown.
+
+	* glom/utility_widgets/canvas/canvas_group_grid.cc: Don't make snapping 
+	to rules dependent on whether the grid is showing.
+
 2011-08-12  Murray Cumming  <murrayc murrayc com>
 
 	Print Layout: Work around some weirdness in portal tables.
diff --git a/glom/utility_widgets/canvas/canvas_group_grid.cc b/glom/utility_widgets/canvas/canvas_group_grid.cc
index 02942f6..a915a1a 100644
--- a/glom/utility_widgets/canvas/canvas_group_grid.cc
+++ b/glom/utility_widgets/canvas/canvas_group_grid.cc
@@ -135,18 +135,19 @@ double CanvasGroupGrid::snap_position_grid(double a) const
 
 void CanvasGroupGrid::snap_position(double& x, double& y) const
 {
-  //printf("%s: x=%f, y=%f\n", __FUNCTION__, x, y);
+  double offset_x = 0;
+  double offset_y = 0;
+  double offset_x_min = 0;
+  double offset_y_min = 0;
+
   if(m_grid_gap)
   {
-    double offset_x_min = 0;
-    double offset_y_min = 0;
-
     //Try snapping to the grid:
     double temp_x = snap_position_grid(x);
     double temp_y = snap_position_grid(y);
    
-    double offset_x = temp_x - x;
-    double offset_y = temp_y - y;
+    offset_x = temp_x - x;
+    offset_y = temp_y - y;
 
     //Use the smallest offset, preferring some offset to no offset:
     if(offset_x)
@@ -154,24 +155,24 @@ void CanvasGroupGrid::snap_position(double& x, double& y) const
 
     if(offset_y)
       offset_y_min = offset_y;
+  }
 
-    //Try snapping to the rules:
-    temp_x = snap_position_rules_x(x);
-    temp_y = snap_position_rules_y(y);
+  //Try snapping to the rules, if any:
+  double temp_x = snap_position_rules_x(x);
+  double temp_y = snap_position_rules_y(y);
 
-    offset_x = temp_x - x;
-    offset_y = temp_y - y;
+  offset_x = temp_x - x;
+  offset_y = temp_y - y;
 
-    //Use the smallest offset, preferring some offset to no offset:
-    if(offset_x && ((std::abs((long)offset_x) < std::abs((long)offset_x_min)) || !offset_x_min))
-      offset_x_min = offset_x;
+  //Use the smallest offset, preferring some offset to no offset:
+  if(offset_x && ((std::abs((long)offset_x) < std::abs((long)offset_x_min)) || !offset_x_min))
+    offset_x_min = offset_x;
 
-    if(offset_y && ((std::abs((long)offset_y) < std::abs((long)offset_y_min)) || !offset_y_min))
-      offset_y_min = offset_y;
+  if(offset_y && ((std::abs((long)offset_y) < std::abs((long)offset_y_min)) || !offset_y_min))
+    offset_y_min = offset_y;
 
-    x += offset_x_min;
-    y += offset_y_min;
-  }
+  x += offset_x_min;
+  y += offset_y_min;
 }
 
 Glib::RefPtr<CanvasLineMovable> CanvasGroupGrid::create_rule_line(double pos, bool horizontal)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]