slint icon indicating copy to clipboard operation
slint copied to clipboard

Fix compiler panic when using `%` size in a flickable

Open ogoffart opened this issue 1 year ago • 2 comments

The viewport of a flickable is of ElementType::Native, and lookup_property don't query the builtin reserved properties in that case.

This commit fix the assert by allowing Type::Invalid as well.

Fixes #4163

ogoffart avatar Dec 27 '23 10:12 ogoffart

The question is if we should not change the meading of 100% to be the "semantic" parent: So to be the size of the flickable and not the viewport (see test)

ogoffart avatar Dec 27 '23 10:12 ogoffart

Oops, I made indeed a mistake in terminology and expression.

I thought about it again.

I think it's good that parent refers to the Flickable (instead of that invisible Rect "inside"). That's consistent.

I can't imagine what a mess it would be to document and explain that % in this context is not equivalent to an expression that uses parent, so I'm very much in favor of aligning % with parent and keeping the current meaning of parent to refer to the Flickable itself.

In terms of use cases for parent here I'm a bit at a loss. I'd imagine a lot more folks wanting to express sizes relative to the content width/height (what's currently called viewport-{width/height}. That's easily done with a binding expression and that's very readable.

tronical avatar Dec 29 '23 12:12 tronical

Updated the commit to change the behavior.

ChangeLog entry from the commit message:

ChangeLog: width and height expressed in % unit for an element in a Flickable now refer to the size of the Flickable instead of that of the viewport

ogoffart avatar Sep 11 '24 16:09 ogoffart