glom r2027 - in trunk: . glom/utility_widgets/canvas



Author: murrayc
Date: Wed Mar 25 21:57:22 2009
New Revision: 2027
URL: http://svn.gnome.org/viewvc/glom?rev=2027&view=rev

Log:
2009-03-25  Murray Cumming  <murrayc murrayc com>

* glom/utility_widgets/canvas/canvas_line_movable.cc: get_xy(), 
set_xy(), get_width_height(), set_width_height():
* glom/utility_widgets/canvas/canvas_text_movable.cc
get_width_height, set_width_height(): Use the new properties instead 
of our custom implementations.

Modified:
   trunk/ChangeLog
   trunk/glom/utility_widgets/canvas/canvas_image_movable.cc
   trunk/glom/utility_widgets/canvas/canvas_line_movable.cc
   trunk/glom/utility_widgets/canvas/canvas_text_movable.cc

Modified: trunk/glom/utility_widgets/canvas/canvas_image_movable.cc
==============================================================================
--- trunk/glom/utility_widgets/canvas/canvas_image_movable.cc	(original)
+++ trunk/glom/utility_widgets/canvas/canvas_image_movable.cc	Wed Mar 25 21:57:22 2009
@@ -85,9 +85,6 @@
   //TODO: This only works when it is on a canvas already,
   //and this is apparently incorrect when the "coordinate space" of the item changes, whatever that means. murrayc.
   
-  //We don't use this because it's only useful when you force a width, instead of allowing _enough_ width: 
-  //height = property_height();
-
   width = property_width();
   height = property_height();
 }

Modified: trunk/glom/utility_widgets/canvas/canvas_line_movable.cc
==============================================================================
--- trunk/glom/utility_widgets/canvas/canvas_line_movable.cc	(original)
+++ trunk/glom/utility_widgets/canvas/canvas_line_movable.cc	Wed Mar 25 21:57:22 2009
@@ -50,64 +50,28 @@
 
 void CanvasLineMovable::get_xy(double& x, double& y) const
 {
-  Goocanvas::Points points = property_points();
-  points.get_coordinate(0, x, y);
+  x = property_x();
+  y = property_y();
 }
 
 void CanvasLineMovable::set_xy(double x, double y)
 {
-  //Discover the offset:
-  double old_x = 0;
-  double old_y = 0;
-  Goocanvas::Points old_points = property_points();
-  old_points.get_coordinate(0, old_x, old_y);
-
-  const double offset_x = x - old_x;
-  const double offset_y = y - old_y;
-
-  //Apply the offset to all points:
-  const int count = old_points.get_num_points();
-  Goocanvas::Points new_points(count);
-  for(int i = 0; i < count; ++i)
-  {
-    double this_x = 0;
-    double this_y = 0;
-    old_points.get_coordinate(i, this_x, this_y);
-    new_points.set_coordinate(i, this_x + offset_x, this_y + offset_y);
-  }
-    
-  property_points() = new_points;
+  property_x() = x;
+  property_y() = y;
 }
 
 void CanvasLineMovable::get_width_height(double& width, double& height) const
 {
-  //width/height still makes sense for a line
-  //(it can be thought of as a diagonal line between two rectangle corners):
-  Goocanvas::Points points = property_points();
-  double x1 = 0;
-  double y1 = 0;
-  points.get_coordinate(0, x1, y1);
-
-  double x2 = 0;
-  double y2 = 0;
-  points.get_coordinate(1, x2, y2);
-
-  width = x2 -x1;
-  height = y2 - y1;
+  width = property_width();
+  height = property_height();
 
   //std::cout << "CanvasLineMovable::get_width_height(): width=" << width << std::endl;
 }
 
 void CanvasLineMovable::set_width_height(double width, double height)
 {
-  //width/height still makes sense for a line
-  //(it can be thought of as a diagonal line between two rectangle corners):
-  Goocanvas::Points points = property_points();
-  double x1 = 0;
-  double y1 = 0;
-  points.get_coordinate(0, x1, y1);
-  points.set_coordinate(1, x1+width, y1+height);
-  property_points() = points;
+  property_width() = width;
+  property_height() = height;
 
   //std::cout << "CanvasLineMovable::set_width_height(): end x=" << x1+width << std::endl;
 }

Modified: trunk/glom/utility_widgets/canvas/canvas_text_movable.cc
==============================================================================
--- trunk/glom/utility_widgets/canvas/canvas_text_movable.cc	(original)
+++ trunk/glom/utility_widgets/canvas/canvas_text_movable.cc	Wed Mar 25 21:57:22 2009
@@ -71,29 +71,14 @@
   //TODO: This only works when it is on a canvas already,
   //and this is apparently incorrect when the "coordinate space" of the item changes, whatever that means. murrayc.
   
-  //We don't use this because it's only useful when you force a width, instead of allowing _enough_ width: 
-  //height = property_height();
-
   width = property_width();
-
-  Goocanvas::Bounds bounds = get_bounds();
- 
-  if(width == -1) //-1 means unlimited.
-    width = bounds.get_x2() - bounds.get_x1();
-
-  if(m_fake_height == 0)
-    height = bounds.get_y2() - bounds.get_y1();
-  else
-    height = m_fake_height;
+  height = property_height();
 }
 
 void CanvasTextMovable::set_width_height(double width, double height)
 {
   property_width() = width;
-
-  //There is no height property:
-  //property_height() = height;
-  m_fake_height = height;
+  property_height() = height;
 }
 
 void CanvasTextMovable::snap_position(double& x, double& y) const



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