[glom] Print Layouts: Make corner and edges snap to the grid too.



commit ffa9858aa38079e1b50dc7c45245d20988933ca8
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Aug 4 18:26:28 2011 +0200

    Print Layouts: Make corner and edges snap to the grid too.
    
    	* glom/utility_widgets/canvas/canvas_group_resizable.[h|cc]:
    	Add a set_grid() override(), as in CanvasGroupMovable, so that the
    	manipulator items also know about it, even though the manipulators
    	were created earlier, in the constructor.
    
    	Previously snapping to the grid only worked while moving whole items.

 ChangeLog                                          |   11 ++++++++++
 .../canvas/canvas_group_resizable.cc               |   22 ++++++++++++++++++++
 .../canvas/canvas_group_resizable.h                |    2 +
 3 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f970166..7843ee5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-08-04  Murray Cumming  <murrayc murrayc com>
+
+	Print Layouts: Make corner and edges snap to the grid too.
+
+	* glom/utility_widgets/canvas/canvas_group_resizable.[h|cc]:
+	Add a set_grid() override(), as in CanvasGroupMovable, so that the 
+	manipulator items also know about it, even though the manipulators 
+	were created earlier, in the constructor.
+
+	Previously snapping to the grid only worked while moving whole items.
+
 1.19.9:
 
 2011-07-25  Murray Cumming  <murrayc murrayc com>
diff --git a/glom/utility_widgets/canvas/canvas_group_resizable.cc b/glom/utility_widgets/canvas/canvas_group_resizable.cc
index 2527413..22dbc0e 100644
--- a/glom/utility_widgets/canvas/canvas_group_resizable.cc
+++ b/glom/utility_widgets/canvas/canvas_group_resizable.cc
@@ -854,5 +854,27 @@ CanvasGroupResizable::type_signal_resized CanvasGroupResizable::signal_resized()
   return m_signal_resized;
 }
 
+void CanvasGroupResizable::set_grid(const Glib::RefPtr<const CanvasGroupGrid>& grid)
+{
+  //Call the base class:
+  CanvasItemMovable::set_grid(grid);
+
+  //Apply the grid to all the manipulators:
+  if(!m_group_manipulators)
+    return;
+
+  const int count = m_group_manipulators->get_n_children();
+  for(int i = 0; i < count; ++i)
+  {
+    Glib::RefPtr<Goocanvas::Item> child = m_group_manipulators->get_child(i);
+    Glib::RefPtr<CanvasItemMovable> movable = CanvasItemMovable::cast_to_movable(child);
+    if(movable)
+    {
+      movable->set_grid(grid);
+    }
+  }
+}
+
+
 } //namespace Glom
 
diff --git a/glom/utility_widgets/canvas/canvas_group_resizable.h b/glom/utility_widgets/canvas/canvas_group_resizable.h
index b3695df..dfda646 100644
--- a/glom/utility_widgets/canvas/canvas_group_resizable.h
+++ b/glom/utility_widgets/canvas/canvas_group_resizable.h
@@ -59,6 +59,8 @@ public:
   virtual void set_xy(double x_offet, double y_offset);
   virtual void get_width_height(double& width, double& height) const;
   virtual void set_width_height(double width, double height);
+  virtual void set_grid(const Glib::RefPtr<const CanvasGroupGrid>& grid);
+
 
   typedef sigc::signal<void> type_signal_resized;
 



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