diff options
author | David Robillard <d@drobilla.net> | 2015-02-22 00:15:01 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2015-02-22 00:15:01 +0000 |
commit | 1e73d9839e79807324f6c002502411377b44e69e (patch) | |
tree | d1a7c3c7b6176d0e3f23bd591c5849a0ca33fc22 | |
parent | ef71a1da33a3c68cad782029cacbc1d01328b4d6 (diff) | |
download | ganv-1e73d9839e79807324f6c002502411377b44e69e.tar.gz ganv-1e73d9839e79807324f6c002502411377b44e69e.tar.bz2 ganv-1e73d9839e79807324f6c002502411377b44e69e.zip |
Fix offset of graph layout with circles.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5594 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/Canvas.cpp | 15 |
1 files 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 |