| libccc Reference Manual |
|---|
CCC uses a managed bounding box to easily see whether a region that needs to be redrawn or whether a click is within an item. So the first thing that you have to care about is the question "where's my item?".
static void
update_bbox (CcItem * item,
CcView * view,
gpointer user_data)
{
CcDRect bounding_box = {0.0, 0.0, 100.0, 100.0};
CcDRect* old_box = cc_hash_map_lookup (item->bounds, view);
/* here you can add your routine to measure the bounding box and
* update @bounding_box accordingly */
if (old_box && !cc_d_rect_equal (bounding_box, *old_box)) {
/* different bounding boxes; delete old one; bur before we do
* let's ask for a redraw of the old area */
cc_item_dirty (item, view, *old_box);
g_free (old_box);
old_box = NULL;
}
if (!old_box) {
/* no bounding box set: copy ours */
cc_hash_map_insert (item->bounds, view, cc_d_rect_copy (&bounding_box));
/* queue the region to be redrawn */
cc_item_dirty (item, view, bounding_box);
}
}
…
g_signal_connect (custom_item, "update-bounds",
G_CALLBACK (update_bbox), NULL);
…