summaryrefslogtreecommitdiffstats
path: root/src/group.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/group.c')
-rw-r--r--src/group.c93
1 files changed, 48 insertions, 45 deletions
diff --git a/src/group.c b/src/group.c
index fdcb1f6..4e7731a 100644
--- a/src/group.c
+++ b/src/group.c
@@ -37,6 +37,12 @@ static GanvItemClass* group_parent_class;
static void
ganv_group_init(GanvGroup* group)
{
+ GanvGroupImpl* impl = G_TYPE_INSTANCE_GET_PRIVATE(
+ group, GANV_TYPE_GROUP, GanvGroupImpl);
+
+ group->impl = impl;
+ group->impl->item_list = NULL;
+ group->impl->item_list_end = NULL;
}
static void
@@ -74,9 +80,9 @@ ganv_group_destroy(GtkObject* object)
group = GANV_GROUP(object);
- while (group->item_list) {
+ while (group->impl->item_list) {
// child is unref'ed by the child's group_remove().
- gtk_object_destroy(GTK_OBJECT(group->item_list->data));
+ gtk_object_destroy(GTK_OBJECT(group->impl->item_list->data));
}
if (GTK_OBJECT_CLASS(group_parent_class)->destroy) {
(*GTK_OBJECT_CLASS(group_parent_class)->destroy)(object);
@@ -86,11 +92,7 @@ ganv_group_destroy(GtkObject* object)
static void
ganv_group_update(GanvItem* item, int flags)
{
- GanvGroup* group;
- GList* list;
- GanvItem* i;
-
- group = GANV_GROUP(item);
+ GanvGroup* group = GANV_GROUP(item);
(*group_parent_class->update)(item, flags);
@@ -99,20 +101,20 @@ ganv_group_update(GanvItem* item, int flags)
double max_x = 0.0;
double max_y = 0.0;
- for (list = group->item_list; list; list = list->next) {
- i = (GanvItem*)list->data;
+ for (GList* list = group->impl->item_list; list; list = list->next) {
+ GanvItem* i = (GanvItem*)list->data;
ganv_item_invoke_update(i, flags);
- min_x = fmin(min_x, fmin(i->x1, i->x2));
- min_y = fmin(min_y, fmin(i->y1, i->y2));
- max_x = fmax(max_x, fmax(i->x1, i->x2));
- max_y = fmax(max_y, fmax(i->y2, i->y2));
+ min_x = fmin(min_x, fmin(i->impl->x1, i->impl->x2));
+ min_y = fmin(min_y, fmin(i->impl->y1, i->impl->y2));
+ max_x = fmax(max_x, fmax(i->impl->x1, i->impl->x2));
+ max_y = fmax(max_y, fmax(i->impl->y2, i->impl->y2));
}
- item->x1 = min_x;
- item->y1 = min_y;
- item->x2 = max_x;
- item->y2 = max_y;
+ item->impl->x1 = min_x;
+ item->impl->y1 = min_y;
+ item->impl->x2 = max_x;
+ item->impl->y2 = max_y;
}
static void
@@ -124,7 +126,7 @@ ganv_group_realize(GanvItem* item)
group = GANV_GROUP(item);
- for (list = group->item_list; list; list = list->next) {
+ for (list = group->impl->item_list; list; list = list->next) {
i = (GanvItem*)list->data;
if (!(i->object.flags & GANV_ITEM_REALIZED)) {
@@ -144,7 +146,7 @@ ganv_group_unrealize(GanvItem* item)
group = GANV_GROUP(item);
- for (list = group->item_list; list; list = list->next) {
+ for (list = group->impl->item_list; list; list = list->next) {
i = (GanvItem*)list->data;
if (i->object.flags & GANV_ITEM_REALIZED) {
@@ -164,7 +166,7 @@ ganv_group_map(GanvItem* item)
group = GANV_GROUP(item);
- for (list = group->item_list; list; list = list->next) {
+ for (list = group->impl->item_list; list; list = list->next) {
i = (GanvItem*)list->data;
if (!(i->object.flags & GANV_ITEM_MAPPED)) {
@@ -184,7 +186,7 @@ ganv_group_unmap(GanvItem* item)
group = GANV_GROUP(item);
- for (list = group->item_list; list; list = list->next) {
+ for (list = group->impl->item_list; list; list = list->next) {
i = (GanvItem*)list->data;
if (i->object.flags & GANV_ITEM_MAPPED) {
@@ -200,7 +202,6 @@ ganv_group_draw(GanvItem* item,
cairo_t* cr, double cx, double cy, double cw, double ch)
{
GanvGroup* group = GANV_GROUP(item);
- GanvItem* child = NULL;
// Draw background
cairo_set_source_rgba(cr, 0, 0, 0, 1.0);
@@ -209,14 +210,14 @@ ganv_group_draw(GanvItem* item,
// TODO: Layered drawing
- for (GList* list = group->item_list; list; list = list->next) {
- child = (GanvItem*)list->data;
+ for (GList* list = group->impl->item_list; list; list = list->next) {
+ GanvItem* child = (GanvItem*)list->data;
if (((child->object.flags & GANV_ITEM_VISIBLE)
- && ((child->x1 < (cx + cw))
- && (child->y1 < (cy + ch))
- && (child->x2 > cx)
- && (child->y2 > cy)))) {
+ && ((child->impl->x1 < (cx + cw))
+ && (child->impl->y1 < (cy + ch))
+ && (child->impl->x2 > cx)
+ && (child->impl->y2 > cy)))) {
if (GANV_ITEM_GET_CLASS(child)->draw) {
(*GANV_ITEM_GET_CLASS(child)->draw)(
child, cr, cx, cy, cw, ch);
@@ -240,9 +241,9 @@ ganv_group_point(GanvItem* item, double x, double y, GanvItem** actual_item)
*actual_item = NULL;
- for (GList* list = group->item_list; list; list = list->next) {
+ for (GList* list = group->impl->item_list; list; list = list->next) {
GanvItem* child = (GanvItem*)list->data;
- if ((child->x1 > x2) || (child->y1 > y2) || (child->x2 < x1) || (child->y2 < y1)) {
+ if ((child->impl->x1 > x2) || (child->impl->y1 > y2) || (child->impl->x2 < x1) || (child->impl->y2 < y1)) {
continue;
}
@@ -253,7 +254,7 @@ ganv_group_point(GanvItem* item, double x, double y, GanvItem** actual_item)
&& GANV_ITEM_GET_CLASS(child)->point) {
dist = GANV_ITEM_GET_CLASS(child)->point(
child,
- x - child->x, y - child->y,
+ x - child->impl->x, y - child->impl->y,
&point_item);
has_point = TRUE;
}
@@ -281,10 +282,10 @@ get_child_bounds(GanvItem* child, double* x1, double* y1, double* x2, double* y2
ganv_item_get_bounds(child, x1, y1, x2, y2);
// Make bounds relative to the item's parent coordinate system
- *x1 -= child->x;
- *y1 -= child->y;
- *x2 -= child->x;
- *y2 -= child->y;
+ *x1 -= child->impl->x;
+ *y1 -= child->impl->y;
+ *x2 -= child->impl->x;
+ *y2 -= child->impl->y;
}
static void
@@ -305,7 +306,7 @@ ganv_group_bounds(GanvItem* item, double* x1, double* y1, double* x2, double* y2
set = FALSE;
- for (list = group->item_list; list; list = list->next) {
+ for (list = group->impl->item_list; list; list = list->next) {
child = (GanvItem*)list->data;
if (child->object.flags & GANV_ITEM_VISIBLE) {
@@ -364,11 +365,11 @@ ganv_group_add(GanvItem* parent, GanvItem* item)
GanvGroup* group = GANV_GROUP(parent);
g_object_ref_sink(G_OBJECT(item));
- if (!group->item_list) {
- group->item_list = g_list_append(group->item_list, item);
- group->item_list_end = group->item_list;
+ if (!group->impl->item_list) {
+ group->impl->item_list = g_list_append(group->impl->item_list, item);
+ group->impl->item_list_end = group->impl->item_list;
} else {
- group->item_list_end = g_list_append(group->item_list_end, item)->next;
+ group->impl->item_list_end = g_list_append(group->impl->item_list_end, item)->next;
}
if (group->item.object.flags & GANV_ITEM_REALIZED) {
@@ -391,7 +392,7 @@ ganv_group_remove(GanvItem* parent, GanvItem* item)
g_return_if_fail(GANV_IS_GROUP(group));
g_return_if_fail(GANV_IS_ITEM(item));
- for (children = group->item_list; children; children = children->next) {
+ for (children = group->impl->item_list; children; children = children->next) {
if (children->data == item) {
if (item->object.flags & GANV_ITEM_MAPPED) {
(*GANV_ITEM_GET_CLASS(item)->unmap)(item);
@@ -403,16 +404,16 @@ ganv_group_remove(GanvItem* parent, GanvItem* item)
/* Unparent the child */
- item->parent = NULL;
+ item->impl->parent = NULL;
g_object_unref(G_OBJECT(item));
/* Remove it from the list */
- if (children == group->item_list_end) {
- group->item_list_end = children->prev;
+ if (children == group->impl->item_list_end) {
+ group->impl->item_list_end = children->prev;
}
- group->item_list = g_list_remove_link(group->item_list, children);
+ group->impl->item_list = g_list_remove_link(group->impl->item_list, children);
g_list_free(children);
break;
}
@@ -432,6 +433,8 @@ ganv_group_class_init(GanvGroupClass* klass)
group_parent_class = (GanvItemClass*)g_type_class_peek_parent(klass);
+ g_type_class_add_private(klass, sizeof(GanvGroupImpl));
+
gobject_class->set_property = ganv_group_set_property;
gobject_class->get_property = ganv_group_get_property;