summaryrefslogtreecommitdiffstats
path: root/src/module.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-04-28 05:43:00 +0000
committerDavid Robillard <d@drobilla.net>2012-04-28 05:43:00 +0000
commit6601a7e2c274fa1ed0a53680b068e864c67c89ec (patch)
treed703f090919ef10907a4da00e2aaaf668487323e /src/module.c
parentb3bdfe12e965f321ec03553970bd5407d78a8c63 (diff)
downloadganv-6601a7e2c274fa1ed0a53680b068e864c67c89ec.tar.gz
ganv-6601a7e2c274fa1ed0a53680b068e864c67c89ec.tar.bz2
ganv-6601a7e2c274fa1ed0a53680b068e864c67c89ec.zip
Fix vertical module port layout.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@4302 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/module.c')
-rw-r--r--src/module.c37
1 files changed, 12 insertions, 25 deletions
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;
}