Commit 6d463702 authored by Alberto Fanjul's avatar Alberto Fanjul
Browse files

show example of group clipping and child move

parent 274a9e77
......@@ -77,9 +77,13 @@ on_motion_notify_event_cb (GooCanvasItem *item,
gdouble rel_x = event->x - drag_x;
gdouble rel_y = event->y - drag_y;
GooCanvasGroup *group;
group = g_object_get_data (G_OBJECT (item), "group");
if (drag_mode == MODE_MOVE)
{
g_object_set (G_OBJECT (item), "x", item_x + rel_x, "y", item_y + rel_y, NULL);
if (group)
g_object_set (G_OBJECT (group), "x", item_x + rel_x, "y", item_y + rel_y, NULL);
}
else
{
......@@ -87,6 +91,8 @@ on_motion_notify_event_cb (GooCanvasItem *item,
gdouble new_height = MAX (item_height + rel_y, 5.0);
g_object_set (G_OBJECT (item), "width", new_width, "height", new_height, NULL);
if (group)
g_object_set (G_OBJECT (group), "width", new_width, "height", new_height, NULL);
}
return TRUE;
......@@ -110,6 +116,7 @@ void
setup_canvas (GtkWidget *canvas)
{
GooCanvasItem *root;
GooCanvasGroup *group;
GooCanvasItem *item;
GdkPixbuf *pixbuf;
GtkWidget *button;
......@@ -119,33 +126,38 @@ setup_canvas (GtkWidget *canvas)
/* Test clipping of GooCanvasGroup: We put the rectangle and the ellipse into
* a group with width=200 and height=200. */
item = goo_canvas_group_new (root, "x", 50.0, "y", 350.0, "width", 200.0, "height", 200.0, NULL);
/*goo_canvas_item_rotate(item, 45.0, 150.0, 450.0);*/
group = goo_canvas_group_new (root, "x", 50.0, "y", 350.0, "width", 200.0, "height", 200.0, NULL);
setup_dnd_handlers (GOO_CANVAS (canvas), group);
goo_canvas_item_rotate(group, 45.0, 150.0, 450.0);
item = goo_canvas_rect_new (root, 50.0, 350.0, 200.0, 200.0, "stroke-color", "black", "line-width", 2.0, NULL);
g_object_set_data (G_OBJECT (item), "group", group);
setup_dnd_handlers (GOO_CANVAS (canvas), item);
goo_canvas_item_rotate(item, 45.0, 150.0, 450.0);
child = goo_canvas_rect_new (item, 0.0, 0.0, 100, 100, "fill-color", "blue", NULL);
child = goo_canvas_rect_new (group, 0.0, 0.0, 100, 100, "fill-color", "blue", NULL);
setup_dnd_handlers (GOO_CANVAS (canvas), child);
goo_canvas_item_rotate(child, 45.0, 50.0, 50.0);
child = goo_canvas_ellipse_new (item, 150, 00, 50, 50, "fill-color", "red", NULL);
child = goo_canvas_ellipse_new (group, 150, 00, 50, 50, "fill-color", "red", NULL);
setup_dnd_handlers (GOO_CANVAS (canvas), child);
item = goo_canvas_polyline_new (root, FALSE, 5.0, 250.0, 350.0, 275.0, 400.0, 300.0, 350.0, 325.0, 400.0, 350.0, 350.0, "stroke-color", "cyan", "line-width", 5.0, NULL);
item = goo_canvas_polyline_new (group, FALSE, 5.0, 250.0, 350.0, 275.0, 400.0, 300.0, 350.0, 325.0, 400.0, 350.0, 350.0, "stroke-color", "cyan", "line-width", 5.0, NULL);
setup_dnd_handlers (GOO_CANVAS (canvas), item);
item = goo_canvas_path_new (root, "M20,500 C20,450 100,450 100,500", "stroke-color", "green", "line-width", 5.0, NULL);
item = goo_canvas_path_new (group, "M20,500 C20,450 100,450 100,500", "stroke-color", "green", "line-width", 5.0, NULL);
setup_dnd_handlers (GOO_CANVAS (canvas), item);
pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
"dialog-warning", 48, 0, NULL);
item = goo_canvas_image_new (root, pixbuf, 150, 450, /*"fill-color", "yellow", */NULL);
item = goo_canvas_image_new (group, pixbuf, 50, 50, /*"fill-color", "yellow", */NULL);
g_object_unref (pixbuf);
setup_dnd_handlers (GOO_CANVAS (canvas), item);
item = goo_canvas_text_new (root, "Hello, World!", 250, 450, -1, GOO_CANVAS_ANCHOR_NW, "fill-color", "magenta", "wrap", PANGO_WRAP_WORD_CHAR, NULL);
item = goo_canvas_text_new (group, "Hello, World!", 75, 75, -1, GOO_CANVAS_ANCHOR_NW, "fill-color", "magenta", "wrap", PANGO_WRAP_WORD_CHAR, NULL);
setup_dnd_handlers (GOO_CANVAS (canvas), item);
button = gtk_label_new ("GtkLabel");
item = goo_canvas_widget_new (root, button, 50, 550, -1, -1, NULL);
item = goo_canvas_widget_new (group, button, 50, 550, -1, -1, NULL);
setup_dnd_handlers (GOO_CANVAS (canvas), item);
item = goo_canvas_table_new (root, "horz-grid-line-width", 2.0, "vert-grid-line-width", 2.0, "row-spacing", 2.0, "column-spacing", 2.0, NULL);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment