119
goo_canvas_group_dispose (GObject *object)
121
GooCanvasGroup *group = (GooCanvasGroup*) object;
124
/* Unref all the items in the group. */
125
for (i = 0; i < group->items->len; i++)
127
GooCanvasItem *item = group->items->pdata[i];
128
goo_canvas_item_set_parent (item, NULL);
129
g_object_unref (item);
132
g_ptr_array_set_size (group->items, 0);
134
G_OBJECT_CLASS (goo_canvas_group_parent_class)->dispose (object);
117
139
goo_canvas_group_finalize (GObject *object)
119
141
GooCanvasGroup *group = (GooCanvasGroup*) object;
122
/* Unref all the items in the group. */
123
for (i = 0; i < group->items->len; i++)
125
GooCanvasItem *item = group->items->pdata[i];
126
goo_canvas_item_set_parent (item, NULL);
127
g_object_unref (item);
130
143
g_ptr_array_free (group->items, TRUE);
396
static GooCanvasItem*
397
goo_canvas_group_get_item_at (GooCanvasItem *item,
401
gboolean is_pointer_event,
402
gboolean parent_visible)
410
goo_canvas_group_get_items_at (GooCanvasItem *item,
414
gboolean is_pointer_event,
415
gboolean parent_visible,
404
418
GooCanvasItemSimple *simple = (GooCanvasItemSimple*) item;
405
419
GooCanvasItemSimpleData *simple_data = simple->simple_data;
406
420
GooCanvasGroup *group = (GooCanvasGroup*) item;
407
GooCanvasItem *found_item = NULL;
408
421
gboolean visible = parent_visible;
411
424
if (simple->need_update)
412
425
goo_canvas_item_ensure_updated (item);
427
/* Skip the item if the point isn't in the item's bounds. */
428
if (simple->bounds.x1 > x || simple->bounds.x2 < x
429
|| simple->bounds.y1 > y || simple->bounds.y2 < y)
414
432
if (simple_data->visibility <= GOO_CANVAS_ITEM_INVISIBLE
415
433
|| (simple_data->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
416
434
&& simple->canvas->scale < simple_data->visibility_threshold))
421
439
&& (simple_data->pointer_events == GOO_CANVAS_EVENTS_NONE
422
440
|| ((simple_data->pointer_events & GOO_CANVAS_EVENTS_VISIBLE_MASK)
426
/* Step down from the top item to the bottom in the stack/layer, and return
427
the first item found that contains the given point. */
429
445
if (simple_data->transform)
430
446
cairo_transform (cr, simple_data->transform);
432
for (i = group->items->len - 1; i >= 0; i--)
448
/* If the group has a clip path, check if the point is inside it. */
449
if (simple_data->clip_path_commands)
451
double user_x = x, user_y = y;
453
cairo_device_to_user (cr, &user_x, &user_y);
454
goo_canvas_create_path (simple_data->clip_path_commands, cr);
455
cairo_set_fill_rule (cr, simple_data->clip_fill_rule);
456
if (!cairo_in_fill (cr, user_x, user_y))
463
/* Step up from the bottom of the children to the top, adding any items
464
found to the start of the list. */
465
for (i = 0; i < group->items->len; i++)
434
467
GooCanvasItem *child = group->items->pdata[i];
436
found_item = goo_canvas_item_get_item_at (child, x, y, cr,
437
is_pointer_event, visible);
469
found_items = goo_canvas_item_get_items_at (child, x, y, cr,
470
is_pointer_event, visible,
441
473
cairo_restore (cr);
448
goo_canvas_group_paint (GooCanvasItem *item,
450
GooCanvasBounds *bounds,
480
goo_canvas_group_paint (GooCanvasItem *item,
482
const GooCanvasBounds *bounds,
453
485
GooCanvasItemSimple *simple = (GooCanvasItemSimple*) item;
454
486
GooCanvasItemSimpleData *simple_data = simple->simple_data;
455
487
GooCanvasGroup *group = (GooCanvasGroup*) item;
490
/* Skip the item if the bounds don't intersect the expose rectangle. */
491
if (simple->bounds.x1 > bounds->x2 || simple->bounds.x2 < bounds->x1
492
|| simple->bounds.y1 > bounds->y2 || simple->bounds.y2 < bounds->y1)
458
495
/* Check if the item should be visible. */
459
496
if (simple_data->visibility <= GOO_CANVAS_ITEM_INVISIBLE
460
497
|| (simple_data->visibility == GOO_CANVAS_ITEM_VISIBLE_ABOVE_THRESHOLD
466
503
if (simple_data->transform)
467
504
cairo_transform (cr, simple_data->transform);
506
/* Clip with the group's clip path, if it is set. */
507
if (simple_data->clip_path_commands)
509
goo_canvas_create_path (simple_data->clip_path_commands, cr);
510
cairo_set_fill_rule (cr, simple_data->clip_fill_rule);
469
514
for (i = 0; i < group->items->len; i++)
471
516
GooCanvasItem *child = group->items->pdata[i];
487
532
iface->move_child = goo_canvas_group_move_child;
488
533
iface->remove_child = goo_canvas_group_remove_child;
490
iface->get_item_at = goo_canvas_group_get_item_at;
535
iface->get_items_at = goo_canvas_group_get_items_at;
491
536
iface->update = goo_canvas_group_update;
492
537
iface->paint = goo_canvas_group_paint;
525
570
* (See goo_canvas_get_item() and #GooCanvas::item-created.)
527
572
static void item_model_interface_init (GooCanvasItemModelIface *iface);
573
static void goo_canvas_group_model_dispose (GObject *object);
528
574
static void goo_canvas_group_model_finalize (GObject *object);
530
576
G_DEFINE_TYPE_WITH_CODE (GooCanvasGroupModel, goo_canvas_group_model,
602
649
g_object_unref (child);
652
g_ptr_array_set_size (gmodel->children, 0);
654
G_OBJECT_CLASS (goo_canvas_group_model_parent_class)->dispose (object);
659
goo_canvas_group_model_finalize (GObject *object)
661
GooCanvasGroupModel *gmodel = (GooCanvasGroupModel*) object;
605
663
g_ptr_array_free (gmodel->children, TRUE);
607
665
G_OBJECT_CLASS (goo_canvas_group_model_parent_class)->finalize (object);