summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-09-18 03:39:19 +0000
committerDavid Robillard <d@drobilla.net>2012-09-18 03:39:19 +0000
commit420bbe77f4b382cc36b21caab5e28710bc7b712f (patch)
tree669aeb33beb670f210e65be4901868bdb002d39b
parentdf5f31a628df0240aba6c9f7ae0586e77ec127ac (diff)
downloadganv-420bbe77f4b382cc36b21caab5e28710bc7b712f.tar.gz
ganv-420bbe77f4b382cc36b21caab5e28710bc7b712f.tar.bz2
ganv-420bbe77f4b382cc36b21caab5e28710bc7b712f.zip
Fix full zoom when circles are on the canvas.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@4791 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/Canvas.cpp26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/Canvas.cpp b/src/Canvas.cpp
index d3055d1..0fa494e 100644
--- a/src/Canvas.cpp
+++ b/src/Canvas.cpp
@@ -1814,16 +1814,22 @@ ganv_canvas_zoom_full(GanvCanvas* canvas)
double bottom = DBL_MAX;
FOREACH_ITEM(canvas->impl->_items, i) {
- double x = 0.0, y = 0.0, w = 0.0, h = 0.0;
- g_object_get(G_OBJECT(*i), "x", &x, "y", &y, "w", &w, "h", &h, NULL);
- if (x < left)
- left = x;
- if (x + w > right)
- right = x + w;
- if (y < bottom)
- bottom = y;
- if (y + h > top)
- top = y + h;
+ GObject* const obj = G_OBJECT(*i);
+ if (GANV_IS_CIRCLE(*i)) {
+ double x = 0.0, y = 0.0, r = 0.0;
+ g_object_get(obj, "x", &x, "y", &y, "radius", &r, NULL);
+ left = MIN(left, x - r);
+ right = MAX(right, x + r);
+ bottom = MIN(bottom, y - r);
+ top = MAX(top, y + r);
+ } else {
+ double x = 0.0, y = 0.0, w = 0.0, h = 0.0;
+ g_object_get(obj, "x", &x, "y", &y, "w", &w, "h", &h, NULL);
+ left = MIN(left, x);
+ right = MAX(right, x + w);
+ bottom = MIN(bottom, y);
+ top = MAX(top, y + h);
+ }
}
static const double pad = 8.0;