From 0e699288e11590e5742a254582374dd42b73c00e Mon Sep 17 00:00:00 2001 From: "Tom A. Wagner" Date: Mon, 17 Jul 2023 02:49:11 +0200 Subject: [PATCH] graph: Allocate proper size to nodes when zoomed Previously, the allocated height and width to a node on the graph was divided by the zoom factor, to account for the changed size from them being zoomed. To zoom each node, we `size_allocate` it with a GskTransform that scales it. However, using a scaling transform to allocate the node already takes care of scaling the height and width, so us also scaling the height and width manually means we were overcompensating. This resulted in the allocation becoming to big when zooming out, and to small when zooming in. This is observable as labels will become smaller when zooming in and ellipsize their content. The commit removes the extra manual scaling so nodes get allocated properly when zoomed. --- src/view/graph_view.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/view/graph_view.rs b/src/view/graph_view.rs index 975137a..7b154a1 100644 --- a/src/view/graph_view.rs +++ b/src/view/graph_view.rs @@ -153,8 +153,6 @@ mod imp { fn size_allocate(&self, _width: i32, _height: i32, baseline: i32) { let widget = &*self.obj(); - let zoom_factor = self.zoom_factor.get(); - for (node, point) in self.nodes.borrow().values() { let (_, natural_size) = node.preferred_size(); @@ -163,8 +161,8 @@ mod imp { .translate(point); node.allocate( - (natural_size.width() as f64 / zoom_factor).ceil() as i32, - (natural_size.height() as f64 / zoom_factor).ceil() as i32, + natural_size.width(), + natural_size.height(), baseline, Some(transform), );