From 6601a7e2c274fa1ed0a53680b068e864c67c89ec Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 28 Apr 2012 05:43:00 +0000 Subject: Fix vertical module port layout. git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@4302 a436a847-0d15-0410-975c-d299462d15a1 --- src/module.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) (limited to 'src/module.c') diff --git a/src/module.c b/src/module.c index 7a45908..c9e2644 100644 --- a/src/module.c +++ b/src/module.c @@ -237,21 +237,19 @@ place_title(GanvModule* module, GanvDirection dir) return; } else if (dir == GANV_DIRECTION_RIGHT) { ganv_item_set(GANV_ITEM(canvas_title), - "x", ((ganv_box_get_width(box) / 2.0) - - (title_w / 2.0)), + "x", (ganv_box_get_width(box) - title_w) / 2.0, "y", 2.0, NULL); } else { ganv_item_set(GANV_ITEM(canvas_title), - "x", ((ganv_box_get_width(box) / 2.0) - - (title_w / 2.0)), - "y", ganv_module_get_empty_port_depth(module) + 2.0, + "x", (ganv_box_get_width(box) - title_w) / 2.0, + "y", ganv_module_get_empty_port_depth(module) + 1.0, NULL); } } static void -resize_horiz(GanvModule* module) +resize_right(GanvModule* module) { GanvCanvas* canvas = GANV_CANVAS(GANV_ITEM(module)->canvas); GanvModuleImpl* impl = module->impl; @@ -328,7 +326,7 @@ resize_horiz(GanvModule* module) } static void -resize_vert(GanvModule* module) +resize_down(GanvModule* module) { GanvCanvas* canvas = GANV_CANVAS(GANV_ITEM(module)->canvas); GanvModuleImpl* impl = module->impl; @@ -355,9 +353,8 @@ resize_vert(GanvModule* module) + impl->embed_height + (port_depth * 2.0); // Move ports to appropriate locations - int i = 0; - gboolean last_was_input = FALSE; - double x = 0.0; + guint in_count = 0; + guint out_count = 0; FOREACH_PORT(impl->ports, pi) { GanvPort* const p = (*pi); GanvBox* const pbox = GANV_BOX(p); @@ -365,23 +362,13 @@ resize_vert(GanvModule* module) ganv_box_set_width(pbox, port_breadth); ganv_box_set_height(pbox, port_depth); if (p->impl->is_input) { - x = PAD + (i * (port_breadth + PAD)); - ++i; + const double x = PAD + (in_count++ * (port_breadth + PAD)); ganv_node_move_to(pnode, x, 0); - last_was_input = TRUE; - ganv_canvas_for_each_edge_to(canvas, pnode, ganv_edge_update_location); } else { - if (!last_was_input) { - x = PAD + (i * (port_breadth + PAD)); - ++i; - } - ganv_node_move_to(pnode, - x, - height - ganv_box_get_height(pbox)); - last_was_input = FALSE; - + double x = PAD + (out_count++ * (port_breadth + PAD)); + ganv_node_move_to(pnode, x, height - ganv_box_get_height(pbox)); ganv_canvas_for_each_edge_from(canvas, pnode, ganv_edge_update_location); } @@ -439,10 +426,10 @@ layout(GanvNode* self) switch (canvas->direction) { case GANV_DIRECTION_RIGHT: - resize_horiz(module); + resize_right(module); break; case GANV_DIRECTION_DOWN: - resize_vert(module); + resize_down(module); break; } -- cgit v1.2.1