From 1e73d9839e79807324f6c002502411377b44e69e Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 22 Feb 2015 00:15:01 +0000 Subject: Fix offset of graph layout with circles. git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5594 a436a847-0d15-0410-975c-d299462d15a1 --- src/Canvas.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Canvas.cpp b/src/Canvas.cpp index 3dbf8df..6b9c25c 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -2535,15 +2535,22 @@ ganv_canvas_arrange(GanvCanvas* canvas) /* Dot node positions are supposedly node centers, but things only match up if x is interpreted as center and y as top... */ - const double x = cx - (w / 2.0); - const double y = -cy - (h / 2.0); + double x = cx - (w / 2.0); + double y = -cy - (h / 2.0); ganv_node_move_to(i->first, x, y); + if (GANV_IS_CIRCLE(i->first)) { + // Offset least x and y to avoid cutting off circles at origin + const double r = ganv_circle_get_radius(GANV_CIRCLE(i->first)); + x -= r; + y -= r; + } + least_x = std::min(least_x, x); least_y = std::min(least_y, y); - most_x = std::max(most_x, x); - most_y = std::max(most_y, y); + most_x = std::max(most_x, x + w); + most_y = std::max(most_y, y + h); } // Reset numeric locale to original value -- cgit v1.2.1