[glom] Print Layout: Avoid warnings about -1 width.



commit e2bbe2b4c673182c22220eb3a672c4c6d7997a25
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Aug 5 19:36:52 2011 +0200

    Print Layout: Avoid warnings about -1 width.
    
    * glom/utility_widgets/canvas/canvas_group_movable.cc: get_width_height(),
    * glom/utility_widgets/canvas/canvas_group_resizable.cc: get_width_heigh():
    Do not return -1, which groups default to, to mean some default size.
    This was not really used anyway, and was rejected when applied to non-group
    goocanvas items.

 ChangeLog                                          |   10 ++++++++++
 .../utility_widgets/canvas/canvas_group_movable.cc |   18 ++++++++++++++----
 .../canvas/canvas_group_resizable.cc               |    9 +++++++++
 3 files changed, 33 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index e9ed56f..f23d3a9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2011-08-05  Murray Cumming  <murrayc murrayc com>
 
+	Print Layout: Avoid warnings about -1 width.
+
+	* glom/utility_widgets/canvas/canvas_group_movable.cc: get_width_height(),
+	* glom/utility_widgets/canvas/canvas_group_resizable.cc: get_width_heigh():
+	Do not return -1, which groups default to, to mean some default size.
+	This was not really used anyway, and was rejected when applied to non-group 
+	goocanvas items.
+
+2011-08-05  Murray Cumming  <murrayc murrayc com>
+
 	Developer menu: Move the Developer item after Operator.
 
 	* glom/application.cc: When the user changes this, he generally changes 
diff --git a/glom/utility_widgets/canvas/canvas_group_movable.cc b/glom/utility_widgets/canvas/canvas_group_movable.cc
index dc3ca7e..8a9e7e8 100644
--- a/glom/utility_widgets/canvas/canvas_group_movable.cc
+++ b/glom/utility_widgets/canvas/canvas_group_movable.cc
@@ -104,12 +104,22 @@ void CanvasGroupMovable::get_width_height(double& width, double& height) const
     //Just return any width/height that was previously set:
     width = m_width;
     height = m_height;
-    return;
+  }
+  else
+  {
+    Glib::RefPtr<const CanvasItemMovable> movable = CanvasItemMovable::cast_const_to_movable(first_child);
+    if(movable)
+      movable->get_width_height(width, height);
   }
 
-  Glib::RefPtr<const CanvasItemMovable> movable = CanvasItemMovable::cast_const_to_movable(first_child);
-  if(movable)
-     movable->get_width_height(width, height);
+  //GooCanvasGroup allows height and width to be -1 to mean the "use the default",
+  //but other GooCanvas* items reject that as out of range,
+  //so prevent us from using it:
+  if(width == -1)
+    width = 100; //Arbitrary default.
+
+  if(height == -1)
+    height = 100; //Arbitrary default.
 }
 
 void CanvasGroupMovable::set_width_height(double width, double height)
diff --git a/glom/utility_widgets/canvas/canvas_group_resizable.cc b/glom/utility_widgets/canvas/canvas_group_resizable.cc
index 22dbc0e..29ba63a 100644
--- a/glom/utility_widgets/canvas/canvas_group_resizable.cc
+++ b/glom/utility_widgets/canvas/canvas_group_resizable.cc
@@ -749,6 +749,15 @@ void CanvasGroupResizable::get_width_height(double& width, double& height) const
     width = m_width;
     height = m_height;
   }
+
+  //GooCanvasGroup allows height and width to be -1 to mean the "use the default",
+  //but other GooCanvas* items reject that as out of range,
+  //so prevent us from using it:
+  if(width == -1)
+    width = 100; //Arbitrary default.
+
+  if(height == -1)
+    height = 100; //Arbitrary default.
 }
 
 void CanvasGroupResizable::set_width_height(double width, double height)



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