Merge branch 'red/rc-canvas-w8' into area/canvas-fw

This commit is contained in:
Martin Ball
2026-11-18 15:13:45 +00:00
3 changed files with 20 additions and 4 deletions
@@ -800,7 +800,8 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
if !real && is_open && props.end.is_some() {
let mut end_cx = BodyCx::new(body_id, line_env.view(), resolved, regions.end, &mut *cx.core.memory, &mut open, gate.as_mut())
.with_field_message(field_message.clone())
.with_owner(owner);
.with_owner(owner)
.with_exiting(self.exiting);
close = close.or(self.end_region(comp, ui, &mut end_cx, &end_frame, &props, regions.end, None));
}
let beside =
@@ -1057,7 +1058,8 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
if real && props.end.is_some() {
let mut end_cx = BodyCx::new(body_id, line_env.view(), resolved, regions.end, &mut *cx.core.memory, &mut open, gate.as_mut())
.with_field_message(field_message.clone())
.with_owner(owner);
.with_owner(owner)
.with_exiting(self.exiting);
// The end region shares the body's line, above a scroll bar under the body: its children sit on the
// members' line, from the body's top (a label may stand above the body).
let mut end = regions.end;
+13 -1
View File
@@ -28,6 +28,7 @@ pub struct BodyCx<'a> {
gate: Option<&'a mut bool>,
gate_mixed: bool,
close: Option<CloseReason>,
exiting: bool,
field_message: Option<(Message, craft_theme::variant::Tone)>,
owner: Option<BodyOwner<'a>>,
}
@@ -43,7 +44,7 @@ impl<'a> BodyCx<'a> {
gate: Option<&'a mut bool>,
) -> Self {
memory.claim(id);
BodyCx { id, env, resolved, rect, memory, open, gate, gate_mixed: false, close: None, field_message: None, owner: None }
BodyCx { id, env, resolved, rect, memory, open, gate, gate_mixed: false, close: None, exiting: false, field_message: None, owner: None }
}
/// Asks the platform to open `url`, in a new tab where the platform has tabs and `new_tab` is set: the opener
@@ -61,6 +62,17 @@ impl<'a> BodyCx<'a> {
self.env.host()?.files().take_answer(ticket)
}
pub(crate) fn with_exiting(mut self, exiting: bool) -> Self {
self.exiting = exiting;
self
}
/// Whether the container has closed and its body only stays on screen while it fades out. `is_open` reads true
/// then; a region that belongs to the open container (a companion layer) is not shown.
pub fn is_exiting(&self) -> bool {
self.exiting
}
pub(crate) fn with_gate_mixed(mut self, mixed: bool) -> Self {
self.gate_mixed = mixed;
self
+3 -1
View File
@@ -416,7 +416,9 @@ impl Container for Menu<'_> {
/// menu.
fn end(&mut self, ui: &mut Ui, cx: &mut BodyCx<'_>) {
let Some(bar) = self.companion.as_mut() else { return };
eprintln!("DIAG a_press_on_the_companion_bar_or_its_popup_does_not_close_the_menu_and_the_bar_closes_with_the_menu: companion end, open={}", cx.is_open());
if cx.is_exiting() {
return;
}
let label = Env::of(ui).words::<MenuWords>().bar_companion.clone();
let _ = CompanionLayer::new(label).show(ui, |ui, _| bar(ui));
}