From be9339472e0c5799a18458131721eb54e0afeba9 Mon Sep 17 00:00:00 2001 From: er888kh Date: Tue, 6 Jul 2021 08:31:31 +0000 Subject: [PATCH] First nodes that GraphView::add_node creates, get pushed to the left side of the screen. So by adding a constant offset, we can avoid having possible links that are partly out of the view just after starting the program --- src/view/graph_view.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/view/graph_view.rs b/src/view/graph_view.rs index 7798022..749991a 100644 --- a/src/view/graph_view.rs +++ b/src/view/graph_view.rs @@ -237,8 +237,8 @@ impl GraphView { // Place widgets in colums of 4, growing down, then right. // TODO: Make a better positioning algorithm. - let x = (private.nodes.borrow().len() / 4) as f32 * 400.0; // This relies on integer division rounding down. - let y = private.nodes.borrow().len() as f32 % 4.0 * 100.0; + let x = ((private.nodes.borrow().len() / 4) as f32 * 400.0) + 20.0; // This relies on integer division rounding down. + let y = (private.nodes.borrow().len() as f32 % 4.0 * 100.0) + 20.0; self.move_node(&node.clone().upcast(), x, y);