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.
This commit is contained in:
Tom A. Wagner
2023-07-17 02:49:11 +02:00
parent 84570f44bf
commit 0e699288e1

View File

@@ -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),
);