-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Z-ordering of shapes #2482
Z-ordering of shapes #2482
Conversation
Thanks for working on this! 🙏 I'm heading off to a long vacation, so it will be at least a month until I will get to reviewing this. Just a heads-up! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really nice - thanks for working on this!
Most of my comments is about naming, but there is one real blocker which is the sorting of the layers. It should be done once, instead of on each interaction.
for &(prev_id, prev_rect) in rects.iter().rev() { | ||
if prev_id == id { | ||
if let Some(rects) = slf.layer_rects_prev_frame.get_mut(&layer.area_layer) { | ||
rects.sort_by_key(|(_id, z, ..)| *z); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-sorting this on each interaction is unnecessary. Better to sort once at the end of each frame instead.
painter.rect_filled(response.rect, Rounding::none(), Color32::BLUE); | ||
|
||
if response.clicked() { | ||
log::info!("Clicked blue"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really nice that you test interaction too ⭐
Continued in #2633 |
Closes #1516.
This PR implements the feature in the exact way described by @emilk. Library consumers are expected to set z-index using
ui.with_z(...)
.I've added an example to
examples
demonstrating the feature.