]> git.cworth.org Git - wordgame/blobdiff - demo-item.c
Increase the window size a bit
[wordgame] / demo-item.c
index 99c45fb8b380de280e2a1dd215ddea8f920d6872..198857ed5206c50412abadbe4e585207c6a5fba9 100644 (file)
@@ -18,7 +18,8 @@ G_DEFINE_TYPE (GooDemoItem, goo_demo_item, GOO_TYPE_CANVAS_ITEM_SIMPLE)
     static void
 goo_demo_item_init (GooDemoItem *demo_item)
 {
-    demo_item->size = 0.0;
+    demo_item->width = 0.0;
+    demo_item->height = 0.0;
 }
 
 /* The convenience function to create new items. This should start with a 
@@ -26,7 +27,10 @@ goo_demo_item_init (GooDemoItem *demo_item)
    in with the standard canvas items. */
 GooCanvasItem*
 goo_demo_item_new (GooCanvasItem       *parent,
-                  gdouble               size,
+                  gdouble               x,
+                  gdouble               y,
+                  gdouble               width,
+                  gdouble               height,
                   GooDemoItemPaintFunc  paint,
                   void                 *closure,
                   ...)
@@ -35,11 +39,13 @@ goo_demo_item_new (GooCanvasItem    *parent,
     GooDemoItem *demo_item;
     const char *first_property;
     va_list var_args;
+    cairo_matrix_t matrix;
 
     item = g_object_new (GOO_TYPE_DEMO_ITEM, NULL);
 
     demo_item = (GooDemoItem*) item;
-    demo_item->size = size;
+    demo_item->width = width;
+    demo_item->height = height;
     demo_item->paint = paint;
     demo_item->closure = closure;
 
@@ -55,6 +61,9 @@ goo_demo_item_new (GooCanvasItem      *parent,
        g_object_unref (item);
     }
 
+    cairo_matrix_init_translate (&matrix, x, y);
+    goo_canvas_item_set_transform (item, &matrix);
+
     return item;
 }
 
@@ -71,8 +80,8 @@ goo_demo_item_update  (GooCanvasItemSimple *simple,
     /* Compute the new bounds. */
     simple->bounds.x1 = 0;
     simple->bounds.y1 = 0;
-    simple->bounds.x2 = demo_item->size;
-    simple->bounds.y2 = demo_item->size;
+    simple->bounds.x2 = demo_item->width;
+    simple->bounds.y2 = demo_item->height;
 
     /* Convert to device coordinates. */
     goo_canvas_item_simple_user_bounds_to_device (simple, cr, &simple->bounds);
@@ -87,7 +96,7 @@ goo_demo_item_paint (GooCanvasItemSimple *simple,
 {
     GooDemoItem *item = (GooDemoItem*) simple;
 
-    item->paint (cr, item->closure);
+    item->paint (cr, item->closure, item->width, item->height);
 }
 
 /* Hit detection. This should check if the given coordinate (in the item's
@@ -102,8 +111,8 @@ goo_demo_item_get_item_at (GooCanvasItemSimple *simple,
 {
     GooDemoItem *demo_item = (GooDemoItem*) simple;
 
-    if (x < 0 || (x > demo_item->size)
-       || y < 0 || (y > demo_item->size))
+    if (x < 0 || (x > demo_item->width)
+       || y < 0 || (y > demo_item->height))
        return NULL;
 
     return (GooCanvasItem*) simple;