Skip to content

Avoid overwrite ListView viewport size#12264

Open
renatofilho wants to merge 4 commits into
slint-ui:masterfrom
renatofilho:fix-5485
Open

Avoid overwrite ListView viewport size#12264
renatofilho wants to merge 4 commits into
slint-ui:masterfrom
renatofilho:fix-5485

Conversation

@renatofilho

@renatofilho renatofilho commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

When the viewport size is explicitly set, the values must not be overwrite when resizing teh listview.

  • Created helper fields on ListViewInfo structure to track at compiler time if the field was explicit set on slint code;
  • Update ListView scroll behaviour to allow scroll above items when viewport-height is bigger than items height;

Fixes: #5485

@renatofilho
renatofilho marked this pull request as draft June 26, 2026 19:43
@renatofilho
renatofilho force-pushed the fix-5485 branch 2 times, most recently from cc7f6ad to 63bfb7a Compare June 26, 2026 20:14

@ogoffart ogoffart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR.

I added some comments.
But please resolve the conflicts so we can see the CI results.

Comment thread tests/cases/elements/listview_viewport_width.slint Outdated
Comment thread internal/compiler/generator/cpp.rs Outdated
Comment on lines +2203 to +2206
let vp_w_arg = if component.prop_analysis
.get(&llr::MemberReference::from(listview.viewport_width.clone()))
.and_then(|a| a.property_init)
.is_some()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this kind of logic probably belong in the LLR instead of cpp/rust.rs. In the LLR, we can change listview.viewport_width/height to Option<...>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you point me another property on LLR similar to that so I can understand what is necessary to have it there? Changing pub viewport_height: Option<MemberReference>, causes a breakage on the API, and will require some function changes, wondering if that is what you expect

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is private API, so that's fine to change

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I choose a different path since I need to keep the original property value on both cases make it a Option will discard the value in one of the cases, so instead I created a new info field for each viewport property.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to keep the original property value on both cases

I might have missed something, but why do you need to keep the original value?
If there is a reason, then disregard my comment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

update based on discussion

Comment thread internal/interpreter/dynamic_item_tree.rs Outdated
Comment thread internal/compiler/passes/repeater_component.rs Outdated
@renatofilho
renatofilho force-pushed the fix-5485 branch 5 times, most recently from d5235ad to 665a55f Compare July 3, 2026 12:19
@renatofilho
renatofilho marked this pull request as ready for review July 3, 2026 12:47

@ogoffart ogoffart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delayed review. Please ping me to get faster review, otherwise I miss it.

Comment thread internal/core/model/repeater.rs Outdated
@@ -185,7 +178,12 @@ fn update_visible_instances(
ops.splice(0, ops.len(), 0);
viewport_height.set(zero);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this line can be removed?

Comment thread internal/core/model/repeater.rs Outdated
viewport_height: Pin<&Property<LogicalLength>>,
viewport_height_is_fixed: bool,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this

Suggested change
viewport_height_is_fixed: bool,
viewport_width: Option<Pin<&Property<LogicalLength>>>,
viewport_height: Option<Pin<&Property<LogicalLength>>>,

and explain in the function documentation what these property are for: "when set, the viewport_with is set to ..."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread internal/compiler/generator/cpp.rs Outdated
Comment on lines +2203 to +2206
let vp_w_arg = if component.prop_analysis
.get(&llr::MemberReference::from(listview.viewport_width.clone()))
.and_then(|a| a.property_init)
.is_some()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to keep the original property value on both cases

I might have missed something, but why do you need to keep the original value?
If there is a reason, then disregard my comment.

…explicity set

The view port properties width and height should not be modified if they
are explicity set so we can skip storing reference to it on info structure

Fixes: slint-ui#5485
If viewport-height is set we should be able to scroll until the end
of it even if the items does not fit it.

Fixes: slint-ui#5485
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The ListView's viewport-width is not working and no horizontal bar

2 participants