diff options
author | lecoanet | 2003-10-02 07:45:24 +0000 |
---|---|---|
committer | lecoanet | 2003-10-02 07:45:24 +0000 |
commit | e72a91a7ecd15c6201f54bd0c2172d5bba8a0858 (patch) | |
tree | 182e7ef4d93e0ba95b9eabc0d0bfce0752555fc7 | |
parent | a354fc49fa1070bd2912cc7ec683322ba4f886fb (diff) | |
download | tkzinc-e72a91a7ecd15c6201f54bd0c2172d5bba8a0858.zip tkzinc-e72a91a7ecd15c6201f54bd0c2172d5bba8a0858.tar.gz tkzinc-e72a91a7ecd15c6201f54bd0c2172d5bba8a0858.tar.bz2 tkzinc-e72a91a7ecd15c6201f54bd0c2172d5bba8a0858.tar.xz |
Tiles are updated when their images are changed, the tk image
update mecanism is now fully fonctional.
Picking of shaped icons is know correct in all cases including
rotated icons in both X and GL environments.
-rw-r--r-- | generic/Icon.c | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/generic/Icon.c b/generic/Icon.c index c243311..678e63f 100644 --- a/generic/Icon.c +++ b/generic/Icon.c @@ -148,7 +148,7 @@ Clone(ZnItem item) IconItem icon = (IconItem) item; if (icon->image != ZnUnspecifiedImage) { - icon->image = ZnGetImageByValue(icon->image); + icon->image = ZnGetImageByValue(icon->image, ZnUpdateItemImage, item); } icon->color = ZnGetGradientByValue(icon->color); } @@ -167,7 +167,7 @@ Destroy(ZnItem item) IconItem icon = (IconItem) item; if (icon->image != ZnUnspecifiedImage) { - ZnFreeImage(icon->image); + ZnFreeImage(icon->image, ZnUpdateItemImage, item); icon->image = ZnUnspecifiedImage; } ZnFreeGradient(icon->color); @@ -190,7 +190,7 @@ Configure(ZnItem item, ZnItem old_connected; old_connected = item->connected_item; - if (ZnConfigureAttributes(item->wi, item, icon_attrs, + if (ZnConfigureAttributes(item->wi, item, item, icon_attrs, argc, argv, flags) == TCL_ERROR) { return TCL_ERROR; } @@ -520,9 +520,30 @@ Pick(ZnItem item, ZnWInfo *wi = item->wi; double dist; double off_dist = MAX(1, wi->pick_aperture+1); - ZnPoint *p = ps->point; + int x, y, width, height; + + if (wi->render) { + ZnPoint p; + ZnBBox bbox; + ZnTransfo t; + + ZnTransfoInvert(wi->current_transfo, &t); + ZnTransformPoint(&t, ps->point, &p); + ZnTransformPoint(&t, &icon->dev[0], &bbox.orig); + ZnSizeOfImage(icon->image, &width, &height); + bbox.corner.x = bbox.orig.x + width; + bbox.corner.y = bbox.orig.y + height; + dist = ZnRectangleToPointDist(&bbox, &p); + x = (int) (p.x - bbox.orig.x); + y = (int) (p.y - bbox.orig.y); + /*printf("dist: %g\n", dist);*/ + } + else { + dist = ZnRectangleToPointDist(&item->item_bounding_box, ps->point); + x = (int) (ps->point->x - item->item_bounding_box.orig.x); + y = (int) (ps->point->y - item->item_bounding_box.orig.y); + } - dist = ZnRectangleToPointDist(&item->item_bounding_box, p); /* * If inside the icon rectangle, try to see if the point * is actually on the image or not. If it lies in an @@ -533,40 +554,26 @@ Pick(ZnItem item, * no means to compute the real distance in the icon's * vicinity. */ - if (dist <= 0.0) { - ZnPoint dp; - int x, y, w, h, stride; - char *bpixels; - + if (dist <= 0) { dist = 0.0; - dp.x = p->x - icon->dev->x; - dp.y = p->y - icon->dev->y; if (icon->image != ZnUnspecifiedImage) { - ZnSizeOfImage(icon->image, &w, &h); - bpixels = ZnImageMask(icon->image, &stride); - if (!bpixels) { + if (ZnPointInImage(icon->image, x, y)) { /* - * The image has no bitmap pattern - * (i.e, it is rectangular and not a bitmap). + * The point is actually on the image shape. */ return dist; } - else if ((dp.x >= w) || (dp.y >= h)) { + else { + /* + * The point is not on the shape but still + * inside the image's bounding box. + */ return off_dist; } } else { return dist; } - /* BUG: when images can be scaled/rotated (openGL) this doesn't. - * work. We must compute the invert transform and find the point - * coordinate in the image space. - */ - x = (int) dp.x; - y = (int) dp.y; - if (! ZnGetBitmapPixel(bpixels, stride, x, y)) { - dist = off_dist; - } } else if (dist < off_dist) { dist = off_dist; |