mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-27 16:59:56 +01:00
A root that reopens during its fade is raised in egui's area order
end_pass stamped a root only when the last pass did not have it, and a layer that shows again while its exit fade runs was in that pass. A layer left to egui's own area order, a floating window or a popup that stands among them such as a dock column's flyout, got no raise either: egui raises an area when it first shows or when it is pressed, and this area showed in the pass before. A flyout opened again in its fade therefore stayed under a window the fade had let over it. The pass reads the last pass's entries with their exiting flag now: a root that appears, or that faded out then and is open again, is stamped, and one that stands in the floating windows' order goes into the pass's raise list, which reaches move_to_top. A root that first shows asks no raise, since egui raises it itself and a pass whose last one was skipped has every root missing. Trial, beside a_flyout_stands_among_the_floating_windows_in_their_order: a_flyout_opened_again_during_its_fade_is_above_the_window_over_it closes the flyout with a floating window over its tab, which takes the top in the fade, opens the flyout again over the nine frames of the fade, and reads the top layer at its tab.
This commit is contained in:
1 parent
86f19be818
commit
7c78ddc28e
2 files changed
+62
-8
No files matched your search
@@ -885,13 +885,16 @@ fn families(entries: &[OpenEntry], raised: &IdMap<u64>) -> Vec<Vec<OpenEntry>> {
|
||||
groups.into_iter().map(|(_, members)| members).collect()
|
||||
}
|
||||
|
||||
/// The end hook: raises the families that appeared, were pressed or were asked to (`raise`), hands egui the order of
|
||||
/// every layer above the floating windows (which keep egui's own area order, where an asked raise moves them to the
|
||||
/// top), and records the open-modal fact.
|
||||
/// The end hook: raises the families that appeared, also one that reopened during its own exit fade, those that were
|
||||
/// pressed and those that were asked to (`raise`), hands egui the order of every layer above the floating windows
|
||||
/// (which keep egui's own area order, where an asked raise moves them to the top), and records the open-modal fact.
|
||||
/// A family that stands in the floating windows' order is raised there when it reopens during its fade: egui showed its
|
||||
/// area in the pass before, so egui raises none.
|
||||
pub(crate) fn end_pass(ctx: &Context) {
|
||||
let viewport = pass::current_viewport(ctx);
|
||||
let (current, last_ids, raise) =
|
||||
with_pass(ctx, |pass| (pass.current.clone(), pass.last.iter().map(|entry| entry.id).collect::<Vec<_>>(), pass.raise.clone()));
|
||||
let (current, last, raise) = with_pass(ctx, |pass| {
|
||||
(pass.current.clone(), pass.last.iter().map(|entry| (entry.id, entry.exiting)).collect::<Vec<_>>(), pass.raise.clone())
|
||||
});
|
||||
let pressed = pointer::frame_raw(ctx).press.map(|press| press.origin);
|
||||
let now = pass::root_frame_nr(ctx);
|
||||
let (order, to_top, floats, asked) = with_persist(ctx, viewport, |persist| {
|
||||
@@ -906,12 +909,23 @@ pub(crate) fn end_pass(ctx: &Context) {
|
||||
.filter(|entry| entry.parent.is_none_or(|parent| !current.iter().any(|other| other.id == parent)))
|
||||
.map(|entry| entry.id)
|
||||
.collect();
|
||||
let mut asked: Vec<Id> = Vec::new();
|
||||
for root in &roots {
|
||||
if !last_ids.contains(root) {
|
||||
stamp(*root, persist);
|
||||
let shown = current.iter().find(|entry| entry.id == *root);
|
||||
// A root the last pass did not have appears, and so does one that faded out then and is open again
|
||||
// (`reopened`): it shows over whatever the fade let over it.
|
||||
let kept = last.iter().any(|(id, _)| id == root);
|
||||
let reopened = last.iter().any(|(id, exiting)| id == root && *exiting) && shown.is_none_or(|entry| !entry.exiting);
|
||||
if kept && !reopened {
|
||||
continue;
|
||||
}
|
||||
stamp(*root, persist);
|
||||
// A root that reopens during its own fade is raised in egui's area order as a press raises it: egui showed
|
||||
// its area in the pass before, so it raises none. A root that first shows there is raised by egui itself.
|
||||
if reopened && shown.is_some_and(|entry| !entry.window && (entry.rank == Rank::Window || entry.among_windows)) {
|
||||
asked.push(*root);
|
||||
}
|
||||
}
|
||||
let mut asked: Vec<Id> = Vec::new();
|
||||
for id in raise {
|
||||
let mut at = current.iter().find(|entry| entry.id == id);
|
||||
while let Some(parent) = at.and_then(|entry| entry.parent).and_then(|parent| current.iter().find(|other| other.id == parent)) {
|
||||
|
||||
@@ -522,6 +522,46 @@ fn a_flyout_stands_among_the_floating_windows_in_their_order() {
|
||||
assert_eq!(clicks.get(), 1, "and a press at the button now reaches it");
|
||||
}
|
||||
|
||||
/// A flyout closed and opened again while its exit fade runs is raised over the window the fade let in front of it. A
|
||||
/// flyout stands in the floating windows' order, where egui raises a layer when it first shows and when it is pressed,
|
||||
/// and it does neither for a layer that shows again while its area is still up.
|
||||
#[trial]
|
||||
fn a_flyout_opened_again_during_its_fade_is_above_the_window_over_it() {
|
||||
let workspace = Rc::new(RefCell::new(flyout_dock(None)));
|
||||
let flyout = Rc::new(Cell::new(None));
|
||||
let mut panels = UnderWindow { flyout: Rc::clone(&flyout), clicks: Rc::new(Cell::new(0)) };
|
||||
let (held, specs, pass_rect) = (Rc::clone(&workspace), Tracked::new(Sides), Rc::clone(&flyout));
|
||||
let mut fixture = Fixture::new(move |ui| {
|
||||
// The cell holds this pass's flyout rect, so a flyout that does not show reads as `None`.
|
||||
pass_rect.set(None);
|
||||
let config = DockConfig::default().native_windows(false);
|
||||
let shown = Bind::given(Arc::clone(&held.borrow()));
|
||||
DockArea::new("Flyout dock", shown, &specs, &mut panels, config).show(ui);
|
||||
});
|
||||
fixture.room(Vec2::new(900.0, 600.0)).settle();
|
||||
let icon = fixture.by_label("Alpha").expect("Alpha's icon").rect.center();
|
||||
fixture.click_at(icon).settle();
|
||||
let open = flyout.get().expect("Alpha's flyout shows its group");
|
||||
// A point of the flyout's own top that the floating window covers too.
|
||||
let tab = Pos2::new(open.left() + 60.0, open.top() + 40.0);
|
||||
let ctx = fixture.ctx().clone();
|
||||
let flyout_layer = ctx.layer_id_at(tab).expect("the flyout shows at its tab");
|
||||
|
||||
// The floating window shows over the flyout, as the newest layer, so it is on top where they overlap.
|
||||
*workspace.borrow_mut() = flyout_dock(Some(window_over(open)));
|
||||
fixture.settle();
|
||||
let window_layer = ctx.layer_id_at(tab).expect("the window over the flyout shows");
|
||||
assert_ne!(window_layer, flyout_layer, "the window over the flyout is the layer on top at its tab");
|
||||
|
||||
// Closed, the flyout fades out over the nine frames of its 150 ms fade at 1/60 s rather than at once.
|
||||
fixture.frame(vec![pointer::moved(icon)]).frame(vec![pointer::press(icon)]).frame(vec![pointer::release(icon)]);
|
||||
assert!(flyout.get().is_some(), "the closed flyout still shows while its exit fade runs");
|
||||
// Opened again in the fade, the flyout is the newer layer and takes the top back.
|
||||
fixture.frame(vec![pointer::moved(icon)]).frame(vec![pointer::press(icon)]).frame(vec![pointer::release(icon)]).frame(Vec::new());
|
||||
assert!(flyout.get().is_some(), "the icon opens the flyout again while it fades");
|
||||
assert_eq!(ctx.layer_id_at(tab), Some(flyout_layer), "the flyout opened again during its fade is above the window over it");
|
||||
}
|
||||
|
||||
#[derive(PlainData)]
|
||||
struct RailWithMenu;
|
||||
|
||||
|
||||
Reference in new issue
Block a user