Merge branch 'red/rr-ribbon-w3' into area/ribbon-fw

This commit is contained in:
Martin Ball committed 2026-11-18 22:06:53 +00:00
commit 0cd298bf94
2 files changed
+13 -6

No files matched your search

+11 -5
View File
@@ -2,7 +2,7 @@
use super::BodyHooks;
use super::placement::opener_of;
use crate::contract::{Container, ContainerProps, Cx, Internal, Mount};
use crate::contract::{BindMut, Container, ContainerProps, Cx, Internal, Mount};
use crate::runtime::memory::{MemoryStage, SaveKey, open_slot as session_open_slot, sub};
use craft_behavior::{EditEvent, Mixed};
use egui::{Context, Id};
@@ -19,14 +19,20 @@ fn open_slot<'s>(stage: &'s mut MemoryStage, id: Id, save: Option<&SaveKey>) ->
}
}
/// Whether the container is open this pass: its binding, else its opener's state, else its slot.
/// The open binding that holds a caller's value. A kept binding holds none: the container keeps its open state where
/// a container with no binding does, in its opener's slot (where the opener's trigger applies) or its own.
fn caller_open<C: Container>(comp: &mut C) -> Option<BindMut<'_, bool>> {
comp.open().filter(|bind| !bind.is_kept())
}
/// Whether the container is open this pass: its caller's binding, else its opener's state, else its slot.
pub(super) fn open_now<C: Container>(comp: &mut C, stage: &mut MemoryStage, id: Id, props: &ContainerProps) -> bool {
// A popup's layer (`OverlayUi::show_container`) is open while the popup is: the popup's slot is the one owner.
if let Some(open) = crate::contract::overlay::popup_layer_open(stage.ctx(), id) {
return open;
}
let initially_open = props.collapse.is_none_or(|collapse| collapse.initially_open);
match comp.open() {
match caller_open(comp) {
Some(bind) => matches!(bind.get(), Some(Mixed::Same(true))),
None => match opener_of(props) {
Some(opener) => crate::contract::overlay::opener_open(stage, opener),
@@ -59,7 +65,7 @@ pub(crate) fn unshown<C: Container>(comp: &mut C, ctx: &Context, id: Id, props:
}
impl BodyHooks<'_> {
/// Writes the open state when it changed since it was read: to the binding, else to the session slot.
/// Writes the open state when it changed since it was read: to the caller's binding, else to the session slot.
pub(super) fn write_open<C: Container>(&mut self, comp: &mut C, cx: &mut Cx<'_, C>) {
if self.open == self.open_at_read {
return;
@@ -71,7 +77,7 @@ impl BodyHooks<'_> {
return;
}
let opener = opener_of(comp.props(Internal::new())).cloned();
match comp.open() {
match caller_open(comp) {
Some(mut bind) => {
let (label, doc_key) = (cx.core.label_arc(), cx.core.resolved.doc_key);
bind.apply(&EditEvent::set(Mixed::Same(self.open_at_read), self.open, label, doc_key));
+2 -1
View File
@@ -60,7 +60,8 @@ impl Outcome for PopoverOutput {
/// editor, a settings form).
///
/// - Open state: the caller's binding. Escape, a press outside, the focus leaving and the other close rules write
/// `false`, and the output's `closed` says which one.
/// `false`, and the output's `closed` says which one. A [kept](Bind::kept) binding leaves it to the popover: its
/// opener's trigger opens and closes it.
/// - Opener: [`opened_by`](Popover::opened_by) names the control it hangs from; a press on it is not outside, and
/// focus returns to it on a close by key.
/// - Focus moves into the popover on open, to [`initial_focus`](Popover::initial_focus) or the first stop.