slint
slint copied to clipboard
Fix compiler panic when using `%` size in a flickable
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
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)
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.
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