diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/box.c | 4 | ||||
-rw-r--r-- | src/circle.c | 4 | ||||
-rw-r--r-- | src/group.c | 17 | ||||
-rw-r--r-- | src/text.c | 2 |
4 files changed, 20 insertions, 7 deletions
@@ -149,7 +149,7 @@ ganv_box_request_redraw(GanvItem* item, ganv_box_bounds_item(coords, &x1, &y1, &x2, &y2); if (!world) { - // Convert from parent-relative coordinates to world coordinates + // Convert from item-relative coordinates to world coordinates ganv_item_i2w_pair(item, &x1, &y1, &x2, &y2); } @@ -170,7 +170,6 @@ ganv_box_bounds(GanvItem* item, // Note this will not be correct if children are outside the box bounds GanvBox* box = (GanvBox*)item; ganv_box_bounds_item(&box->impl->coords, x1, y1, x2, y2); - ganv_item_i2w_pair(item, x1, y1, x2, y2); } static void @@ -196,6 +195,7 @@ ganv_box_update(GanvItem* item, int flags) // Get bounding box double x1, x2, y1, y2; ganv_box_bounds(item, &x1, &y1, &x2, &y2); + ganv_item_i2w_pair(item, &x1, &y1, &x2, &y2); // Update item canvas coordinates ganv_canvas_base_w2c_d(GANV_CANVAS_BASE(item->canvas), x1, y1, &item->x1, &item->y1); diff --git a/src/circle.c b/src/circle.c index 077ecc9..0e0d096 100644 --- a/src/circle.c +++ b/src/circle.c @@ -262,7 +262,6 @@ ganv_circle_bounds(GanvItem* item, double* x2, double* y2) { ganv_circle_bounds_item(item, x1, y1, x2, y2); - ganv_item_i2w_pair(item, x1, y1, x2, y2); } static void @@ -285,9 +284,10 @@ ganv_circle_update(GanvItem* item, int flags) impl->old_coords = impl->coords; coords_i2w(item, &impl->old_coords); - // Get bounding circle + // Get bounding box double x1, x2, y1, y2; ganv_circle_bounds(item, &x1, &y1, &x2, &y2); + ganv_item_i2w_pair(item, &x1, &y1, &x2, &y2); // Update item canvas coordinates ganv_canvas_base_w2c_d(GANV_CANVAS_BASE(item->canvas), x1, y1, &item->x1, &item->y1); diff --git a/src/group.c b/src/group.c index 75183ca..2a05e5e 100644 --- a/src/group.c +++ b/src/group.c @@ -293,6 +293,19 @@ ganv_group_point(GanvItem* item, double x, double y, int cx, int cy, } } +/** Get bounds of child item in group-relative coordinates. */ +static void +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; +} + static void ganv_group_bounds(GanvItem* item, double* x1, double* y1, double* x2, double* y2) { @@ -316,7 +329,7 @@ ganv_group_bounds(GanvItem* item, double* x1, double* y1, double* x2, double* y2 if (child->object.flags & GANV_ITEM_VISIBLE) { set = TRUE; - ganv_item_get_bounds(child, &minx, &miny, &maxx, &maxy); + get_child_bounds(child, &minx, &miny, &maxx, &maxy); break; } } @@ -339,7 +352,7 @@ ganv_group_bounds(GanvItem* item, double* x1, double* y1, double* x2, double* y2 continue; } - ganv_item_get_bounds(child, &tx1, &ty1, &tx2, &ty2); + get_child_bounds(child, &tx1, &ty1, &tx2, &ty2); if (tx1 < minx) { minx = tx1; @@ -229,7 +229,6 @@ ganv_text_bounds(GanvItem* item, double* x2, double* y2) { ganv_text_bounds_item(item, x1, y1, x2, y2); - ganv_item_i2w_pair(item->parent, x1, y1, x2, y2); } static void @@ -237,6 +236,7 @@ ganv_text_update(GanvItem* item, int flags) { double x1, y1, x2, y2; ganv_text_bounds(item, &x1, &y1, &x2, &y2); + ganv_item_i2w_pair(item, &x1, &y1, &x2, &y2); // I have no idea why this is necessary item->x1 = x1; |