summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ganv/canvas-base.h2
-rw-r--r--src/box.c4
-rw-r--r--src/circle.c4
-rw-r--r--src/group.c17
-rw-r--r--src/text.c2
5 files changed, 21 insertions, 8 deletions
diff --git a/ganv/canvas-base.h b/ganv/canvas-base.h
index b036a15..6f5f16e 100644
--- a/ganv/canvas-base.h
+++ b/ganv/canvas-base.h
@@ -221,7 +221,7 @@ void ganv_item_grab_focus(GanvItem* item);
/* Fetch the bounding box of the item. The bounding box may not be exactly
* tight, but the canvas items will do the best they can. The returned bounding
- * box is in the coordinate system of the item's parent.
+ * box is in item relative coordinates.
*/
void ganv_item_get_bounds(GanvItem* item,
double* x1, double* y1, double* x2, double* y2);
diff --git a/src/box.c b/src/box.c
index 40352e4..8847066 100644
--- a/src/box.c
+++ b/src/box.c
@@ -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;
diff --git a/src/text.c b/src/text.c
index 3d14c64..137bfa5 100644
--- a/src/text.c
+++ b/src/text.c
@@ -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;