mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-27 16:59:56 +01:00
Read a popup window's appearance where the layer is stamped
A layer shown in a popup window of a palette window is stamped as appearing in the popup window's pass, but host_in_popup read the opener's record, which never holds the layer. So `appears` was true in every palette pass and the layer's memory was reset each pass. For a context menu hung at the pointer, the reset anchor followed the pointer: a move onto another context target carried the open menu and its anchor there, so the absorb zone the palette pass set held that point, the right-click on it was not recorded as an outside press, and the open menu never closed. host_in_popup now reads the popup viewport's appearance (`overlay::appears_in`), so the memory it keeps survives while the layer shows. This is the part of the popup layer memory change that the outside press guard needs; that change keeps its own timeout trial. Trial: a_context_menu_a_palette_opens_is_not_closed_by_the_press_that_opened_it.
This commit is contained in:
1 parent
41675ba15a
commit
804220fe90
2 files changed
+14
-3
No files matched your search
@@ -284,7 +284,11 @@ pub(crate) fn host(ctx: &Context, layer: &Layer<'_>, body: &mut dyn FnMut(&mut U
|
||||
/// laid out in the popup's pass first, in the room its unplaced form has, and placed by the size it took there.
|
||||
/// A popup that takes keys (a menu, a flyout) takes the OS focus; a tooltip takes none and lets the pointer through.
|
||||
fn host_in_popup(ctx: &Context, layer: &Layer<'_>, popup: PopupRoom, body: &mut dyn FnMut(&mut Ui)) -> LayerOut {
|
||||
let appears = overlay::appears(ctx, layer.id, layer.exiting);
|
||||
// The layer's body runs in the popup window's pass, which stamps the layer's appearance in that window's record:
|
||||
// this pass, which decides the window, reads it there. The opener's own record never holds the layer, so a layer
|
||||
// that appeared once would read as appearing in every pass.
|
||||
let viewport = crate::runtime::egui::viewports::viewport_id(layer.id);
|
||||
let appears = overlay::appears_in(ctx, viewport, layer.id, layer.exiting);
|
||||
let mut memory = if appears { LayerMemory::default() } else { recall(layer, ctx) };
|
||||
let opened = opened_overlay(ctx, layer.overlay, memory.opening);
|
||||
if let Some((_, opening)) = &opened {
|
||||
@@ -314,7 +318,6 @@ fn host_in_popup(ctx: &Context, layer: &Layer<'_>, popup: PopupRoom, body: &mut
|
||||
// The popup's pass runs nested in this one and its begin pass stamps a layer's first appearance with its own
|
||||
// number: read that number before the pass runs, so this pass tells a layer appearing in it from one that appeared
|
||||
// in an earlier pass of the frame.
|
||||
let viewport = crate::runtime::egui::viewports::viewport_id(layer.id);
|
||||
let popup_pass = crate::runtime::egui::pass::pass_nr(ctx, viewport);
|
||||
let mut shown = None;
|
||||
windows::show_popup(ctx, &open, |ui| {
|
||||
|
||||
@@ -556,7 +556,15 @@ fn reopened(ctx: &Context, id: Id, exiting: bool) -> bool {
|
||||
/// faded out and is open again. What the layer remembers starts fresh then; a discard pass that repeats the frame
|
||||
/// keeps what the first pass of the frame recorded.
|
||||
pub(crate) fn appears(ctx: &Context, id: Id, exiting: bool) -> bool {
|
||||
reopened(ctx, id, exiting) || with_persist(ctx, pass::current_viewport(ctx), |persist| !persist.appeared.contains_key(&id))
|
||||
appears_in(ctx, pass::current_viewport(ctx), id, exiting)
|
||||
}
|
||||
|
||||
/// Whether the layer `id` appears in [`begin_layer`]'s pass of `viewport`, read before it: a layer shown in a popup
|
||||
/// window is stamped there, by the popup's own pass, so its host reads that viewport's record rather than its opener's,
|
||||
/// which stamps nothing for it. A layer that faded out is seen in the stack of the running pass, whose host shows the
|
||||
/// window that decides it.
|
||||
pub(crate) fn appears_in(ctx: &Context, viewport: ViewportId, id: Id, exiting: bool) -> bool {
|
||||
reopened(ctx, id, exiting) || with_persist(ctx, viewport, |persist| !persist.appeared.contains_key(&id))
|
||||
}
|
||||
|
||||
/// Marks the layer `id`'s body as running, so layers opened from inside it become its children, with the `side` of
|
||||
|
||||
Reference in new issue
Block a user