slint icon indicating copy to clipboard operation
slint copied to clipboard

ScrollView viewport-width and viewport-height are not calculated automatically

Open Gremious opened this issue 1 month ago • 1 comments

Bug Description

The documentation for ScrollView states

The viewport-width and viewport-height are calculated automatically to create a scrollable view except for when using a for loop to populate the elements.

So, I copy pasted the example given, and commented out the vieweport-width and height - and it did not calculate automatically. It did not have scrollbars, instead just being a 200 x 200 square.

Image

Expected outcome is that it know that the farthest rectangle is at x: 247px + 30px width/height and creates a view for that.

Reproducible Code (if applicable)

import { ScrollView } from "std-widgets.slint";
export component Example inherits Window {
    width: 200px;
    height: 200px;
    ScrollView {
        width: 200px;
        height: 200px;
        // viewport-width: 300px;
        // viewport-height: 300px;
        Rectangle { width: 30px; height: 30px; x: 275px; y: 50px; background: blue; }
        Rectangle { width: 30px; height: 30px; x: 175px; y: 130px; background: red; }
        Rectangle { width: 30px; height: 30px; x: 25px; y: 210px; background: yellow; }
        Rectangle { width: 30px; height: 30px; x: 98px; y: 55px; background: orange; }
    }
}

Environment Details

  • Slint Version: 1.14.1
  • Platform/OS: Linux, EndeavourOS (Arch Based)
  • Programming Language: Rust
  • Backend/Renderer: winit, I think?

Product Impact

Not sure. Probably not super critical since you can calculate the view-port sizing yourself in code, which you already have to do when using many elements in for loops anyway.

Gremious avatar Nov 30 '25 13:11 Gremious

Thanks for filing a bug report. You're right, the documentation was not accurate. I have rewritten the documentation to match the actual behavior.

Now, it's true that it would be nice if it could be actually calculated automatically without layout as well. So I'll keep this issue open as a feature request.

ogoffart avatar Dec 01 '25 11:12 ogoffart