From 8f7482700184053df7afe30f822dd1714da365af Mon Sep 17 00:00:00 2001 From: lecoanet Date: Thu, 23 Mar 2000 14:09:54 +0000 Subject: Remanniement des routines de transformation et de clip pour utiliser la fonctionalit� fournie par Item.c --- generic/Group.c | 171 ++++++++++---------------------------------------------- 1 file changed, 30 insertions(+), 141 deletions(-) (limited to 'generic/Group.c') diff --git a/generic/Group.c b/generic/Group.c index 8d5523d..bc636be 100644 --- a/generic/Group.c +++ b/generic/Group.c @@ -161,7 +161,7 @@ Clone(Item item) * the new items. */ if (dependents) { - printf("rebuilding dependents\n"); + /*printf("rebuilding dependents\n");*/ group->dependents = NULL; items = (Item *) ZnListArray(dependents); num_items = ZnListSize(dependents); @@ -180,9 +180,9 @@ Clone(Item item) abort(); } else { - printf("item %d correspond to ", current_item->connected_item->id); + /*printf("item %d correspond to ", current_item->connected_item->id);*/ current_item->connected_item = (Item) Tcl_GetHashValue(entry); - printf("%d\n", current_item->connected_item->id); + /*printf("%d\n", current_item->connected_item->id);*/ ITEM.InsertDependentItem(current_item); } } @@ -402,89 +402,15 @@ PushClip(GroupItem group, ZnBool set_gc) { WidgetInfo *wi = ((Item) group)->wi; - int i, num_c, num_pts; + int num_pts; ZnPoint *pts; - ZnBool simple, has_clip=False; - ClipState *previous_clip=NULL; - Region reg; - XRectangle rect; - XPoint *xpts; + ZnBool simple; if ((group->clip != ZN_NO_ITEM) && ((((Item) group) != wi->top_group) || !wi->reshape)) { simple = group->clip->class->GetClipVertices(group->clip, &pts, &num_pts); - - if (num_pts != 0) { - has_clip = True; - - num_c = ZnListSize(wi->clip_stack); - if (num_c != 0) { - previous_clip = (ClipState *) ZnListAt(wi->clip_stack, ZnListTail); - } - ZnListAssertSize(wi->clip_stack, num_c+1); - wi->current_clip = (ClipState *) ZnListAt(wi->clip_stack, ZnListTail); - wi->current_clip->simple = simple; - - /* - * Compute the local region. - */ - if (simple) { - rect.x = pts[0].x; - rect.y = pts[0].y; - rect.width = pts[1].x - pts[0].x; - rect.height = pts[1].y - pts[0].y; - reg = XCreateRegion(); - XUnionRectWithRegion(&rect, reg, reg); - /*printf("Adding a simple clip: %d, %d, %d, %d\n", - rect.x, rect.y, rect.width, rect.height);*/ - } - else { - xpts = (XPoint *) ZnMalloc(num_pts * sizeof(XPoint)); - for (i = 0; i < num_pts; i++) { - xpts[i].x = pts[i].x; - xpts[i].y = pts[i].y; - } - reg = XPolygonRegion(xpts, num_pts, EvenOddRule); - ZnFree(xpts); - } - /* - * Combine with previous region if any. - */ - if (previous_clip) { - wi->current_clip->region = XCreateRegion(); - XIntersectRegion(reg, previous_clip->region, wi->current_clip->region); - XDestroyRegion(reg); - /*printf("Merging with previous clip\n");*/ - } - else { - wi->current_clip->region = reg; - } - XClipBox(wi->current_clip->region, &rect); - wi->current_clip->clip_box.orig.x = rect.x; - wi->current_clip->clip_box.orig.y = rect.y; - wi->current_clip->clip_box.corner.x = rect.x + rect.width; - wi->current_clip->clip_box.corner.y = rect.y + rect.height; - /*printf("Clip box is : %d, %d, %d, %d\n", - rect.x, rect.y, rect.width, rect.height);*/ - } - } - /* - * Set the clipping in the GC, and substitute the combined - * clip region/damaged region for the clip region. - */ - if (set_gc) { - if ((((Item) group) == wi->top_group) || has_clip) { - if (wi->current_clip) { - reg = XCreateRegion(); - XIntersectRegion(wi->current_clip->region, wi->damaged_region, reg); - XDestroyRegion(wi->current_clip->region); - wi->current_clip->region = reg; - XSetRegion(wi->dpy, wi->gc, wi->current_clip->region); - } - else { - XSetRegion(wi->dpy, wi->gc, wi->damaged_region); - } - } + /*printf("Group: PushClip group %d\n", ((Item) group)->id);*/ + ITEM_P.PushClip(wi, pts, num_pts, simple, set_gc); } } @@ -505,31 +431,8 @@ PopClip(GroupItem group, if ((group->clip != ZN_NO_ITEM) && ((((Item) group) != wi->top_group) || !wi->reshape)) { - XDestroyRegion(wi->current_clip->region); - ZnListDelete(wi->clip_stack, ZnListTail); - if (ZnListSize(wi->clip_stack) != 0) { - wi->current_clip = (ClipState *) ZnListAt(wi->clip_stack, ZnListTail); - } - else { - wi->current_clip = NULL; - } - } - - /* - * Set the clipping in the GC. - */ - if (set_gc) { - if (wi->current_clip) { - XSetRegion(wi->dpy, wi->gc, wi->current_clip->region); - } - else if (((Item) group) == wi->top_group) { - /*printf("resetting clip mask\n");*/ - XSetClipMask(wi->dpy, wi->gc, None); - } - else { - /*printf("resetting to damaged area\n");*/ - XSetRegion(wi->dpy, wi->gc, wi->damaged_region); - } + /*printf("Group: PopClip group %d\n", ((Item) group)->id);*/ + ITEM_P.PopClip(wi, set_gc); } } @@ -546,26 +449,15 @@ PopClip(GroupItem group, static void PushTransform(Item item) { - WidgetInfo *wi; - ZnTransfo *next_t; - int num_t; - if (!item->transfo && ISSET(item->flags, COMPOSE_SCALE_BIT) && ISSET(item->flags, COMPOSE_ROTATION_BIT)) { return; } - /* - * Push the current transform and concatenate - * the item transform taking into account the - * combination flags. - */ - wi = item->wi; - num_t = ZnListSize(wi->transfo_stack); - ZnListAssertSize(wi->transfo_stack, num_t+1); - next_t = (ZnTransfo *) ZnListAt(wi->transfo_stack, num_t); - ITEM.ComposeItemTransform(item, wi->current_transfo, next_t); - wi->current_transfo = next_t; + + ITEM_P.PushTransform(item->wi, item->transfo, + ISSET(item->flags, COMPOSE_SCALE_BIT), + ISSET(item->flags, COMPOSE_ROTATION_BIT)); /*printf("Pushing transfo for item: %d\n;", item->id); ZnPrintTransfo(wi->current_transfo);*/ } @@ -582,20 +474,13 @@ PushTransform(Item item) static void PopTransform(Item item) { - WidgetInfo *wi; - if (!item->transfo && ISSET(item->flags, COMPOSE_SCALE_BIT) && ISSET(item->flags, COMPOSE_ROTATION_BIT)) { return; } - - /* - * Restore the previous transform. - */ - wi = item->wi; - ZnListDelete(wi->transfo_stack, ZnListTail); - wi->current_transfo = (ZnTransfo *) ZnListAt(wi->transfo_stack, ZnListTail); + + ITEM_P.PopTransform(item->wi); /*printf("Popping transfo for item: %d\n", item->id); ZnPrintTransfo(wi->current_transfo);*/ } @@ -617,6 +502,7 @@ static void CallRegularCC(Item item) { WidgetInfo *wi = item->wi; + ZnBBox *clip_box; /* * Do some generic pre-work in behalf of the (regular) children. @@ -631,12 +517,15 @@ CallRegularCC(Item item) item->class->ComputeCoordinates(item, False); /* * If a current clipbox exists adjust the item - * bounding box accordingly. + * bounding box accordingly. When computing coordinates + * the damaged area is not pushed onto the clipstack, + * the following predicate is thus valid for testing + * a clipbox. */ - if (wi->current_clip) { + if (ITEM_P.CurrentClip(wi, NULL, &clip_box, NULL)) { ZnBBox inter; - IntersectBBox(&item->item_bounding_box, &wi->current_clip->clip_box, &inter); + IntersectBBox(&item->item_bounding_box, clip_box, &inter); item->item_bounding_box = inter; } /* @@ -882,14 +771,14 @@ Draw(Item item) GroupItem group = (GroupItem) item; WidgetInfo *wi = item->wi; Item current_item; - ZnBBox bbox; - ZnBBox old_damaged_area; + ZnBBox bbox, old_damaged_area, *clip_box; PushTransform(item); PushClip(group, True); - if ((group->clip != ZN_NO_ITEM) && wi->current_clip) { + if (group->clip != ZN_NO_ITEM) { + ITEM_P.CurrentClip(wi, NULL, &clip_box, NULL); old_damaged_area = wi->damaged_area; - IntersectBBox(&wi->damaged_area, &wi->current_clip->clip_box, &bbox); + IntersectBBox(&wi->damaged_area, clip_box, &bbox); wi->damaged_area = bbox; } @@ -926,7 +815,7 @@ Draw(Item item) current_item = current_item->previous; } - if ((group->clip != ZN_NO_ITEM) && wi->current_clip) { + if (group->clip != ZN_NO_ITEM) { wi->damaged_area = old_damaged_area; } PopClip(group, True); @@ -990,7 +879,7 @@ Pick(Item item, WidgetInfo *wi = item->wi; int p_part; double dist, best = 1e10; - ZnBBox bbox, inter; + ZnBBox bbox, inter, *clip_box; ZnBool in_depth; *a_item= ZN_NO_ITEM; @@ -1008,8 +897,8 @@ Pick(Item item, bbox.corner.x = p->x + (aperture?aperture:1); bbox.corner.y = p->y + (aperture?aperture:1); - if (wi->current_clip) { - IntersectBBox(&bbox, &wi->current_clip->clip_box, &inter); + if (ITEM_P.CurrentClip(wi, NULL, &clip_box, NULL)) { + IntersectBBox(&bbox, clip_box, &inter); if (IsEmptyBBox(&inter)) { goto out; } -- cgit v1.1