[cairo-commit] goocanvas/src goocanvasitem.c, 1.15, 1.16 goocanvasitem.h, 1.10, 1.11 goocanvasitemmodel.c, 1.5, 1.6 goocanvasitemmodel.h, 1.3, 1.4 goocanvastable.c, 1.4, 1.5

Damon Chaplin commit at pdx.freedesktop.org
Thu Feb 8 14:56:51 PST 2007


Committed by: damon

Update of /cvs/cairo/goocanvas/src
In directory kemper:/tmp/cvs-serv23550/src

Modified Files:
	goocanvasitem.c goocanvasitem.h goocanvasitemmodel.c 
	goocanvasitemmodel.h goocanvastable.c 
Log Message:
2007-02-08  Damon Chaplin  <damon at gnome.org>

	* src/goocanvasitemmodel.c
	(goo_canvas_item_model_set_simple_transform): 
	* src/goocanvasitem.c (goo_canvas_item_set_simple_transform): new
	convenience functions to set the position, scale and rotation easily.

	* demo/demo.c (move_ellipse_clicked): added tests for
	goo_canvas_item_set_simple_transform().

	* */*: more documentation updates. I've started adding a few
	introductory sections, tidied up a few bits, and tried to update all
	the docs that referred to the old model/view terminology.



Index: goocanvasitem.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitem.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- goocanvasitem.c	8 Feb 2007 17:54:26 -0000	1.15
+++ goocanvasitem.c	8 Feb 2007 22:56:45 -0000	1.16
@@ -823,6 +823,33 @@
 
 
 /**
+ * goo_canvas_item_set_simple_transform:
+ * @item: an item.
+ * @x: the x coordinate of the origin of the item's coordinate space.
+ * @y: the y coordinate of the origin of the item's coordinate space.
+ * @scale: the scale of the item.
+ * @rotation: the clockwise rotation of the item, in degrees.
+ * 
+ * A convenience function to set the item's transformation matrix.
+ **/
+void
+goo_canvas_item_set_simple_transform (GooCanvasItem   *item,
+				      gdouble          x,
+				      gdouble          y,
+				      gdouble          scale,
+				      gdouble          rotation)
+{
+  GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
+  cairo_matrix_t new_matrix = { 1, 0, 0, 1, 0, 0 };
+
+  cairo_matrix_translate (&new_matrix, x, y);
+  cairo_matrix_scale (&new_matrix, scale, scale);
+  cairo_matrix_rotate (&new_matrix, rotation);
+  iface->set_transform (item, &new_matrix);
+}
+
+
+/**
  * goo_canvas_item_translate:
  * @item: an item.
  * @tx: the amount to move the origin in the horizontal direction.
@@ -832,8 +859,8 @@
  **/
 void
 goo_canvas_item_translate      (GooCanvasItem *item,
-				double         tx,
-				double         ty)
+				gdouble        tx,
+				gdouble        ty)
 {
   GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
   cairo_matrix_t *matrix, new_matrix = { 1, 0, 0, 1, 0, 0 };
@@ -856,8 +883,8 @@
  **/
 void
 goo_canvas_item_scale          (GooCanvasItem *item,
-				double         sx,
-				double         sy)
+				gdouble        sx,
+				gdouble        sy)
 {
   GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
   cairo_matrix_t *matrix, new_matrix = { 1, 0, 0, 1, 0, 0 };
@@ -882,9 +909,9 @@
  **/
 void
 goo_canvas_item_rotate         (GooCanvasItem *item,
-				double         degrees,
-				double         cx,
-				double         cy)
+				gdouble        degrees,
+				gdouble        cx,
+				gdouble        cy)
 {
   GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
   cairo_matrix_t *matrix, new_matrix = { 1, 0, 0, 1, 0, 0 };
@@ -912,9 +939,9 @@
  **/
 void
 goo_canvas_item_skew_x         (GooCanvasItem *item,
-				double         degrees,
-				double         cx,
-				double         cy)
+				gdouble        degrees,
+				gdouble        cx,
+				gdouble        cy)
 {
   GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
   cairo_matrix_t *matrix, tmp, new_matrix = { 1, 0, 0, 1, 0, 0 };
@@ -943,9 +970,9 @@
  **/
 void
 goo_canvas_item_skew_y         (GooCanvasItem *item,
-				double         degrees,
-				double         cx,
-				double         cy)
+				gdouble        degrees,
+				gdouble        cx,
+				gdouble        cy)
 {
   GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);
   cairo_matrix_t *matrix, tmp, new_matrix = { 1, 0, 0, 1, 0, 0 };
@@ -1110,12 +1137,12 @@
  **/
 void
 goo_canvas_item_animate        (GooCanvasItem *item,
-				double         x,
-				double         y,
-				double         scale,
-				double         degrees,
-				int            duration,
-				int            step_time,
+				gdouble        x,
+				gdouble        y,
+				gdouble        scale,
+				gdouble        degrees,
+				gint           duration,
+				gint           step_time,
 				GooCanvasAnimateType type)
 {
   GooCanvasItemIface *iface = GOO_CANVAS_ITEM_GET_IFACE (item);

Index: goocanvasitem.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitem.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- goocanvasitem.h	8 Feb 2007 17:54:26 -0000	1.10
+++ goocanvasitem.h	8 Feb 2007 22:56:45 -0000	1.11
@@ -320,35 +320,40 @@
 cairo_matrix_t*    goo_canvas_item_get_transform  (GooCanvasItem   *item);
 void               goo_canvas_item_set_transform  (GooCanvasItem   *item,
 						   cairo_matrix_t  *matrix);
+void               goo_canvas_item_set_simple_transform (GooCanvasItem   *item,
+							 gdouble          x,
+							 gdouble          y,
+							 gdouble          scale,
+							 gdouble          rotation);
 
 void               goo_canvas_item_translate      (GooCanvasItem   *item,
-						   double           tx,
-						   double           ty);
+						   gdouble          tx,
+						   gdouble          ty);
 void               goo_canvas_item_scale          (GooCanvasItem   *item,
-						   double           sx,
-						   double           sy);
+						   gdouble          sx,
+						   gdouble          sy);
 void               goo_canvas_item_rotate         (GooCanvasItem   *item,
-						   double           degrees,
-						   double           cx,
-						   double           cy);
+						   gdouble          degrees,
+						   gdouble          cx,
+						   gdouble          cy);
 void               goo_canvas_item_skew_x         (GooCanvasItem   *item,
-						   double           degrees,
-						   double           cx,
-						   double           cy);
+						   gdouble          degrees,
+						   gdouble          cx,
+						   gdouble          cy);
 void               goo_canvas_item_skew_y         (GooCanvasItem   *item,
-						   double           degrees,
-						   double           cx,
-						   double           cy);
+						   gdouble          degrees,
+						   gdouble          cx,
+						   gdouble          cy);
 
 GooCanvasStyle*    goo_canvas_item_get_style      (GooCanvasItem   *item);
 void               goo_canvas_item_set_style      (GooCanvasItem   *item,
 						   GooCanvasStyle  *style);
 
 void               goo_canvas_item_animate        (GooCanvasItem   *item,
-						   double           x,
-						   double           y,
-						   double           scale,
-						   double           degrees,
+						   gdouble           x,
+						   gdouble           y,
+						   gdouble           scale,
+						   gdouble           degrees,
 						   gint             duration,
 						   gint             step_time,
 						   GooCanvasAnimateType type);

Index: goocanvasitemmodel.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemmodel.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- goocanvasitemmodel.c	8 Feb 2007 17:54:26 -0000	1.5
+++ goocanvasitemmodel.c	8 Feb 2007 22:56:45 -0000	1.6
@@ -259,12 +259,12 @@
 
 /**
  * goo_canvas_item_model_add_child:
- * @model: the container to add the item to.
- * @child: the item to add.
- * @position: the position of the item, or -1 to place it last (at the top of
+ * @model: an item model.
+ * @child: the child to add.
+ * @position: the position of the child, or -1 to place it last (at the top of
  *  the stacking order).
  * 
- * Adds a child item to a container item at the given stack position.
+ * Adds a child at the given stack position.
  **/
 void
 goo_canvas_item_model_add_child      (GooCanvasItemModel  *model,
@@ -281,11 +281,11 @@
 
 /**
  * goo_canvas_item_model_move_child:
- * @model: a container item.
- * @old_position: the current position of the child item.
- * @new_position: the new position of the child item.
+ * @model: an item model.
+ * @old_position: the current position of the child.
+ * @new_position: the new position of the child.
  * 
- * Moves a child item to a new stack position within the container.
+ * Moves a child to a new stack position.
  **/
 void
 goo_canvas_item_model_move_child     (GooCanvasItemModel  *model,
@@ -302,10 +302,10 @@
 
 /**
  * goo_canvas_item_model_remove_child:
- * @model: a container item.
- * @child_num: the position of the child item to remove.
+ * @model: an item model.
+ * @child_num: the position of the child to remove.
  * 
- * Removes the child item at the given position.
+ * Removes the child at the given position.
  **/
 void
 goo_canvas_item_model_remove_child   (GooCanvasItemModel  *model,
@@ -321,12 +321,12 @@
 
 /**
  * goo_canvas_item_model_find_child:
- * @model: a container item.
- * @child: the child item to find.
+ * @model: an item model.
+ * @child: the child to find.
  * 
- * Attempts to find the given child item with the container's stack.
+ * Attempts to find the given child with the container's stack.
  * 
- * Returns: the position of the given @child item, or -1 if it isn't found.
+ * Returns: the position of the given @child, or -1 if it isn't found.
  **/
 gint
 goo_canvas_item_model_find_child     (GooCanvasItemModel *model,
@@ -351,9 +351,9 @@
  * goo_canvas_item_model_is_container:
  * @model: an item model.
  * 
- * Tests to see if the given item is a container.
+ * Tests to see if the given item model is a container.
  * 
- * Returns: %TRUE if the item is a container.
+ * Returns: %TRUE if the item model is a container.
  **/
 gboolean
 goo_canvas_item_model_is_container (GooCanvasItemModel       *model)
@@ -366,7 +366,7 @@
 
 /**
  * goo_canvas_item_model_get_n_children:
- * @model: a container item.
+ * @model: an item model.
  * 
  * Gets the number of children of the container.
  * 
@@ -383,12 +383,12 @@
 
 /**
  * goo_canvas_item_model_get_child:
- * @model: a container item.
+ * @model: an item model.
  * @child_num: the position of a child in the container's stack.
  * 
- * Gets the child item at the given stack position.
+ * Gets the child at the given stack position.
  * 
- * Returns: the child item at the given stack position.
+ * Returns: the child at the given stack position.
  **/
 GooCanvasItemModel*
 goo_canvas_item_model_get_child (GooCanvasItemModel  *model,
@@ -433,7 +433,7 @@
 /**
  * goo_canvas_item_model_raise:
  * @model: an item model.
- * @above: the item to raise @model above, or %NULL to raise @model to the top
+ * @above: the item model to raise @model above, or %NULL to raise @model to the top
  *  of the stack.
  * 
  * Raises a model in the stacking order.
@@ -476,7 +476,7 @@
 /**
  * goo_canvas_item_model_lower:
  * @model: an item model.
- * @below: the item to lower @model below, or %NULL to lower @model to the
+ * @below: the item model to lower @model below, or %NULL to lower @model to the
  *  bottom of the stack.
  * 
  * Lowers a model in the stacking order.
@@ -550,6 +550,33 @@
 
 
 /**
+ * goo_canvas_item_model_set_simple_transform:
+ * @model: an item model.
+ * @x: the x coordinate of the origin of the model's coordinate space.
+ * @y: the y coordinate of the origin of the model's coordinate space.
+ * @scale: the scale of the model.
+ * @rotation: the clockwise rotation of the model, in degrees.
+ * 
+ * A convenience function to set the item model's transformation matrix.
+ **/
+void
+goo_canvas_item_model_set_simple_transform (GooCanvasItemModel *model,
+					    gdouble             x,
+					    gdouble             y,
+					    gdouble             scale,
+					    gdouble             rotation)
+{
+  GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
+  cairo_matrix_t new_matrix = { 1, 0, 0, 1, 0, 0 };
+
+  cairo_matrix_translate (&new_matrix, x, y);
+  cairo_matrix_scale (&new_matrix, scale, scale);
+  cairo_matrix_rotate (&new_matrix, rotation);
+  iface->set_transform (model, &new_matrix);
+}
+
+
+/**
  * goo_canvas_item_model_translate:
  * @model: an item model.
  * @tx: the amount to move the origin in the horizontal direction.
@@ -559,8 +586,8 @@
  **/
 void
 goo_canvas_item_model_translate      (GooCanvasItemModel *model,
-				      double              tx,
-				      double              ty)
+				      gdouble             tx,
+				      gdouble             ty)
 {
   GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
   cairo_matrix_t *matrix, new_matrix = { 1, 0, 0, 1, 0, 0 };
@@ -583,8 +610,8 @@
  **/
 void
 goo_canvas_item_model_scale          (GooCanvasItemModel *model,
-				      double              sx,
-				      double              sy)
+				      gdouble             sx,
+				      gdouble             sy)
 {
   GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
   cairo_matrix_t *matrix, new_matrix = { 1, 0, 0, 1, 0, 0 };
@@ -609,9 +636,9 @@
  **/
 void
 goo_canvas_item_model_rotate         (GooCanvasItemModel *model,
-				      double              degrees,
-				      double              cx,
-				      double              cy)
+				      gdouble             degrees,
+				      gdouble             cx,
+				      gdouble             cy)
 {
   GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
   cairo_matrix_t *matrix, new_matrix = { 1, 0, 0, 1, 0, 0 };
@@ -639,9 +666,9 @@
  **/
 void
 goo_canvas_item_model_skew_x         (GooCanvasItemModel *model,
-				      double              degrees,
-				      double              cx,
-				      double              cy)
+				      gdouble             degrees,
+				      gdouble             cx,
+				      gdouble             cy)
 {
   GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
   cairo_matrix_t *matrix, tmp, new_matrix = { 1, 0, 0, 1, 0, 0 };
@@ -670,9 +697,9 @@
  **/
 void
 goo_canvas_item_model_skew_y         (GooCanvasItemModel *model,
-				      double              degrees,
-				      double              cx,
-				      double              cy)
+				      gdouble             degrees,
+				      gdouble             cx,
+				      gdouble             cy)
 {
   GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);
   cairo_matrix_t *matrix, tmp, new_matrix = { 1, 0, 0, 1, 0, 0 };
@@ -837,12 +864,12 @@
  **/
 void
 goo_canvas_item_model_animate        (GooCanvasItemModel  *model,
-				      double               x,
-				      double               y,
-				      double               scale,
-				      double               degrees,
-				      int                  duration,
-				      int                  step_time,
+				      gdouble              x,
+				      gdouble              y,
+				      gdouble              scale,
+				      gdouble              degrees,
+				      gint                 duration,
+				      gint                 step_time,
 				      GooCanvasAnimateType type)
 {
   GooCanvasItemModelIface *iface = GOO_CANVAS_ITEM_MODEL_GET_IFACE (model);

Index: goocanvasitemmodel.h
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvasitemmodel.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- goocanvasitemmodel.h	8 Feb 2007 17:54:26 -0000	1.3
+++ goocanvasitemmodel.h	8 Feb 2007 22:56:45 -0000	1.4
@@ -186,35 +186,40 @@
 cairo_matrix_t*     goo_canvas_item_model_get_transform  (GooCanvasItemModel *model);
 void                goo_canvas_item_model_set_transform  (GooCanvasItemModel *model,
 							  cairo_matrix_t     *matrix);
+void                goo_canvas_item_model_set_simple_transform (GooCanvasItemModel *item,
+								gdouble             x,
+								gdouble             y,
+								gdouble             scale,
+								gdouble             rotation);
 
 void                goo_canvas_item_model_translate      (GooCanvasItemModel *model,
-							  double              tx,
-							  double              ty);
+							  gdouble             tx,
+							  gdouble             ty);
 void                goo_canvas_item_model_scale          (GooCanvasItemModel *model,
-							  double              sx,
-							  double              sy);
+							  gdouble             sx,
+							  gdouble             sy);
 void                goo_canvas_item_model_rotate         (GooCanvasItemModel *model,
-							  double              degrees,
-							  double              cx,
-							  double              cy);
+							  gdouble             degrees,
+							  gdouble             cx,
+							  gdouble             cy);
 void                goo_canvas_item_model_skew_x         (GooCanvasItemModel *model,
-							  double              degrees,
-							  double              cx,
-							  double              cy);
+							  gdouble             degrees,
+							  gdouble             cx,
+							  gdouble             cy);
 void                goo_canvas_item_model_skew_y         (GooCanvasItemModel *model,
-							  double              degrees,
-							  double              cx,
-							  double              cy);
+							  gdouble             degrees,
+							  gdouble             cx,
+							  gdouble             cy);
 
 GooCanvasStyle*     goo_canvas_item_model_get_style      (GooCanvasItemModel *model);
 void                goo_canvas_item_model_set_style      (GooCanvasItemModel *model,
 							  GooCanvasStyle  *style);
 
 void                goo_canvas_item_model_animate        (GooCanvasItemModel *model,
-							  double              x,
-							  double              y,
-							  double              scale,
-							  double              degrees,
+							  gdouble             x,
+							  gdouble             y,
+							  gdouble             scale,
+							  gdouble             degrees,
 							  gint                duration,
 							  gint                step_time,
 							  GooCanvasAnimateType type);

Index: goocanvastable.c
===================================================================
RCS file: /cvs/cairo/goocanvas/src/goocanvastable.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- goocanvastable.c	2 Feb 2007 21:54:00 -0000	1.4
+++ goocanvastable.c	8 Feb 2007 22:56:45 -0000	1.5
@@ -381,13 +381,13 @@
  *
  * <informalexample><programlisting>
  *  GooCanvasItem *table, *square, *circle, *triangle;
- *
+ *  
  *  table = goo_canvas_table_new (root,
  *                                "row-spacing", 4.0,
  *                                "column-spacing", 4.0,
  *                                NULL);
  *  goo_canvas_item_translate (table, 400, 200);
- *
+ *  
  *  square = goo_canvas_rect_new (table, 0.0, 0.0, 50.0, 50.0,
  *                                "fill-color", "red",
  *                                NULL);
@@ -395,7 +395,7 @@
  *                                        "row", 0,
  *                                        "column", 0,
  *                                        NULL);
- *
+ *  
  *  circle = goo_canvas_ellipse_new (table, 0.0, 0.0, 25.0, 25.0,
  *                                   "fill-color", "blue",
  *                                   NULL);
@@ -403,7 +403,7 @@
  *                                        "row", 0,
  *                                        "column", 1,
  *                                        NULL);
- *
+ *  
  *  triangle = goo_canvas_polyline_new (table, TRUE, 3,
  *                                      25.0, 0.0, 0.0, 50.0, 50.0, 50.0,
  *                                      "fill-color", "yellow",



More information about the cairo-commit mailing list