-
Expanding from the plotter example in slint (I also use the plotters library), my goal would be to pass a width and height to the callback that generates the image. In the plotter example itself, the width/height is fixed, but I need the plot to respect when the window is resized. In the plotter example, the image size is hard-coded in the Rust rendering function. When I try to get a width/height by passing the property to the callback to generate the plot, so e.g.:
I get the following errors:
So, if i understand this correctly, during calculation of the properties, the image width/height itself is part of the layout calculation, so this would form a loop updating the properties along the dependent properties. So is there a way to get the width/height of the component the plot should be in (e.g. inside a VerticalLayout) and pass this to the Rust plot-rendering function so that on generation of the plot the size can be taken into account? Currently, the size of the plot is fixed and the image is scaled accordingly by slint, but as this app should be used on a variety of display sizes, it would be much better to generate the plot with the actual sizes. Is there a way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
thanks for your question. Recently a similar question was asked and I answered there: #1331 (reply in thread) |
Beta Was this translation helpful? Give feedback.
-
Unfortunately, not. I cannot break the binding loop, neither with self.width, parent.width or root.width. The Window has a side-bar similar to (or modeled after) the gallery demo, and the plot is on one of the pages. So some nested layouts are present, which I suspect create the loop somehow. The errors mention "layout-cache", "width" and "layoutinfo-h" of different Boxes/Layouts/Rectangles to be part of the binding loop. Any further tips? |
Beta Was this translation helpful? Give feedback.
-
Ha! That does indeed solve the issue! Thank you very much! |
Beta Was this translation helpful? Give feedback.
I can indeed reproduce the issue. Indeed the Slint compiler still sees a binding loop.
One way to prevent it is to wrap the Image in a Rectangle:
that rectangle will not inherit the sizes from the image so it should work.