summaryrefslogtreecommitdiffstats
path: root/src/port.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-02-11 04:59:38 +0000
committerDavid Robillard <d@drobilla.net>2015-02-11 04:59:38 +0000
commit3d6bb8063387331e9e8acb2423632a0c722c3038 (patch)
tree671e0c8ce17aba2ad5d5bd6ef99bc7ab7c540a6e /src/port.c
parent6b28131cfd12437d5b5967bd37ad3bc0fcc12088 (diff)
downloadganv-3d6bb8063387331e9e8acb2423632a0c722c3038.tar.gz
ganv-3d6bb8063387331e9e8acb2423632a0c722c3038.tar.bz2
ganv-3d6bb8063387331e9e8acb2423632a0c722c3038.zip
Join connections precisely at port borders.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5553 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/port.c')
-rw-r--r--src/port.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/port.c b/src/port.c
index f632a7a..8871f54 100644
--- a/src/port.c
+++ b/src/port.c
@@ -170,19 +170,20 @@ ganv_port_tail_vector(const GanvNode* self,
GanvItem* item = &port->box.node.item;
GanvCanvas* canvas = ganv_item_get_canvas(item);
- const double px = item->impl->x;
- const double py = item->impl->y;
+ const double px = item->impl->x;
+ const double py = item->impl->y;
+ const double border_width = GANV_NODE(port)->impl->border_width;
switch (ganv_canvas_get_direction(canvas)) {
case GANV_DIRECTION_RIGHT:
- *x = px + ganv_box_get_width(&port->box);
+ *x = px + ganv_box_get_width(&port->box) + (border_width / 2.0);
*y = py + ganv_box_get_height(&port->box) / 2.0;
*dx = 1.0;
*dy = 0.0;
break;
case GANV_DIRECTION_DOWN:
*x = px + ganv_box_get_width(&port->box) / 2.0;
- *y = py + ganv_box_get_height(&port->box);
+ *y = py + ganv_box_get_height(&port->box) + (border_width / 2.0);
*dx = 0.0;
*dy = 1.0;
break;
@@ -203,19 +204,20 @@ ganv_port_head_vector(const GanvNode* self,
GanvItem* item = &port->box.node.item;
GanvCanvas* canvas = ganv_item_get_canvas(item);
- const double px = item->impl->x;
- const double py = item->impl->y;
+ const double px = item->impl->x;
+ const double py = item->impl->y;
+ const double border_width = GANV_NODE(port)->impl->border_width;
switch (ganv_canvas_get_direction(canvas)) {
case GANV_DIRECTION_RIGHT:
- *x = px;
+ *x = px - (border_width / 2.0);
*y = py + ganv_box_get_height(&port->box) / 2.0;
*dx = -1.0;
*dy = 0.0;
break;
case GANV_DIRECTION_DOWN:
*x = px + ganv_box_get_width(&port->box) / 2.0;
- *y = 0.0;
+ *y = py - (border_width / 2.0);
*dx = 0.0;
*dy = -1.0;
break;