Skip to content

Commit

Permalink
take z index into account when linking widgets
Browse files Browse the repository at this point in the history
- fixes #356
  • Loading branch information
mrDIMAS committed Jun 1, 2024
1 parent 3953a9e commit 96b0756
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fyrox-ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2765,6 +2765,15 @@ impl UserInterface {
self.isolate_node(child_handle);
self.nodes[child_handle].set_parent(parent_handle);
self.nodes[parent_handle].add_child(child_handle, in_front);

// Sort by Z index. This uses stable sort, so every child node with the same z index will
// remain on its position.
let mbc = self.nodes.begin_multi_borrow();
if let Ok(mut parent) = mbc.try_get_mut(parent_handle) {
parent
.children
.sort_by_key(|handle| mbc.try_get(*handle).map(|c| *c.z_index).unwrap_or_default());
};
}

#[inline]
Expand Down

0 comments on commit 96b0756

Please sign in to comment.