summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-10-14 18:56:22 -0400
committerDavid Robillard <d@drobilla.net>2016-10-14 18:56:22 -0400
commit1c1f35cf8914de40cd6db435af764067344d258f (patch)
tree1e936be6419bb9c2cdd877d6b9438285d0ebf46b
parent3f89dacefc55b94e7188c8ba919c9c700599bcf8 (diff)
downloadganv-1c1f35cf8914de40cd6db435af764067344d258f.tar.gz
ganv-1c1f35cf8914de40cd6db435af764067344d258f.tar.bz2
ganv-1c1f35cf8914de40cd6db435af764067344d258f.zip
Fix port position on modules with embedded widgets
-rw-r--r--NEWS3
-rw-r--r--src/module.c31
2 files changed, 19 insertions, 15 deletions
diff --git a/NEWS b/NEWS
index 7a37812..4abfd45 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
ganv (1.4.3) unstable;
* Fix positioning of embedded widgets when changing layout.
+ * Fix port position on modules with embedded widgets.
* Fix unexpected node jumping when dragging new connections.
* Preserve selection for quickly making several connections.
* Dampen sprung layout energy over time to prevent oscillation.
@@ -19,7 +20,7 @@ ganv (1.4.3) unstable;
* Fix crash when destroying canvas.
* Upgrade to waf 1.8.14
- -- David Robillard <d@drobilla.net> Mon, 26 Oct 2015 13:30:01 -0400
+ -- David Robillard <d@drobilla.net> Fri, 14 Oct 2016 18:55:26 -0400
ganv (1.4.2) stable;
diff --git a/src/module.c b/src/module.c
index 0094663..5310191 100644
--- a/src/module.c
+++ b/src/module.c
@@ -201,9 +201,11 @@ measure(GanvModule* module, Metrics* m)
m->width = (canvas_title) ? title_w + 10.0 : 1.0;
- // Title is wide, put inputs and outputs beside each other
- m->horiz = (impl->widest_input + impl->widest_output + 10.0
- < MAX(m->width, impl->embed_width));
+ // Title is wide or there is an embedded widget,
+ // put inputs and outputs beside each other
+ m->horiz = (impl->embed_item ||
+ (impl->widest_input + impl->widest_output + 10.0
+ < MAX(m->width, impl->embed_width)));
// Fit ports to module (or vice-versa)
m->input_width = impl->widest_input;
@@ -299,8 +301,8 @@ resize_right(GanvModule* module)
}
// Move ports to appropriate locations
- gboolean last_was_input = FALSE;
- double y = header_height;
+ double in_y = header_height;
+ double out_y = header_height;
FOREACH_PORT(impl->ports, pi) {
GanvPort* const p = (*pi);
GanvBox* const pbox = GANV_BOX(p);
@@ -312,29 +314,30 @@ resize_right(GanvModule* module)
pnode->impl->border_width) / 2.0;
if (p->impl->is_input) {
- ganv_node_move_to(pnode, -border_off, y + 1.0);
+ ganv_node_move_to(pnode, -border_off, in_y + 1.0);
ganv_box_set_width(pbox, m.input_width);
- last_was_input = TRUE;
- y += h + pnode->impl->border_width + 1.0;
+ in_y += h + pnode->impl->border_width + 1.0;
ganv_canvas_for_each_edge_to(
canvas, pnode,
(GanvEdgeFunc)ganv_edge_update_location, NULL);
} else {
- ganv_node_move_to(pnode, m.width - m.output_width + border_off, y + 1.0);
+ ganv_node_move_to(pnode, m.width - m.output_width + border_off, out_y + 1.0);
ganv_box_set_width(pbox, m.output_width);
- last_was_input = FALSE;
- if (!m.horiz || !last_was_input) {
- y += h + pnode->impl->border_width + 1.0;
- }
+ out_y += h + pnode->impl->border_width + 1.0;
ganv_canvas_for_each_edge_from(
canvas, pnode,
(GanvEdgeFunc)ganv_edge_update_location, NULL);
}
+
+ if (!m.horiz) {
+ in_y = MAX(in_y, out_y);
+ out_y = MAX(in_y, out_y);
+ }
}
- double height = y + EDGE_PAD;
+ double height = MAX(in_y, out_y) + EDGE_PAD;
if (impl->embed_item && m.embed_between)
height = MAX(height, impl->embed_height + header_height + 2.0);