slint
slint copied to clipboard
dynamic Z ordering
We should have a z property that allow to specify the ordering of items so they can potentially be changed dynamically.
We discussed this and started forming a plan how this could be implemented.
The basic idea is to apply the following only to items (and their children) that use dynamic z-ordering, as opposed to the currently implemented compile-time static sorting:
Suppose the following example markup:
Parent := Window {
Something{ z: ... }
for col in first_model: Foo { z: ...; }
}
This produces an item tree that looks like this:
Item | relative item index
===============================================
+ c1 : Parent 0
+ Something 1
+ for (dynamic node) 2
+ c2: Foo(1)
+ c3: Foo(2)
+ Other 3
With variable z-order the items can mix into the dynamic for element, thus creating for example the following rendering order:
// with variable z-order, it could look like this for rendering:
// + Parent
// + Foo(1) ItemRef(c2/0) | 2 -> 0
// + Something ItemRef(c1/xxx) | xxx -> -1
// + Foo(2) ItemRef(c3/0) | 2 -> 1
// + Other ItemRef(c1/yyy) | yyy -> -1
The Parent element would obtain an internal sorted_children property, which is an array of index pairs:
sorted_children: Property<Vec<(usize, usize)>>
similar to the layout cache. A binding is initialised on the sorted_children that's responsible for collecting the z values and index pairs, call a run-time function to do the sorting and produce the resulting vector.
The generated item visitation function in the Parent element's Component would then, for the children of Parent, make use of the sorted_children property - possibly just passing it to the run-time helper functions as an additional optional parameter.
For dynamic traversal the visit_dynamic mechanism also needs to be extended to visit just one particular item and its children(!) of the dynamic sub-tree, not all of them.
@ogoffart @tronical Any update?
@ThilinaTLM This issue is currently not on our short-term roadmap. If it's important to you, we encourage you to take a shot at implementing it. We'd be happy to provide mentoring, tips, and review your pull request. Our roadmap is flexible and responsive to the needs of our users and customers. If this issue is a blocker for you, please let us know by email or chat. Share details about your project, and we'll consider prioritizing it or offering it as a service.
Your docs say:
z(in float): Allows to specify a different order to stack the items with its siblings. (default value: 0)
(source)
If this property is resistent to changes or only accepts literals, this should be clarified in the docs.
@Enyium good point. Doc updated in 302b23b