diff --git a/crates/ui-canvas/src/canvas/full_window.rs b/crates/ui-canvas/src/canvas/full_window.rs index b1831d66c..b1126c09e 100644 --- a/crates/ui-canvas/src/canvas/full_window.rs +++ b/crates/ui-canvas/src/canvas/full_window.rs @@ -278,7 +278,7 @@ impl Container for FullWindowDialog<'_> { if self.props.outer_edit { outer::keep(ui.ctx(), cx); } - frame::header(ui, cx, frame::close_action(self.closable), None); // P3(pdf-comments-w6): CM-C27 + frame::header(ui, cx, frame::close_action(self.closable), None); } fn end(&mut self, ui: &mut Ui, cx: &mut BodyCx<'_>) { diff --git a/crates/ui-panels/src/dialog/frame.rs b/crates/ui-panels/src/dialog/frame.rs index c0d9d29cd..7b537b411 100644 --- a/crates/ui-panels/src/dialog/frame.rs +++ b/crates/ui-panels/src/dialog/frame.rs @@ -136,11 +136,15 @@ pub struct FooterHost<'s, 'a> { pub settle: &'s mut Option>, } -/// Fills the header region: the title and, for a closable shell, the close action. +/// Fills the header region: the title, the muted `note` after it when there is one and, for a closable shell, the +/// close action. #[doc(hidden)] pub fn header(ui: &mut Ui, cx: &mut BodyCx<'_>, actions: &[HeaderAction], note: Option<&Label>) { - let _ = note; - let shown = TitleRow::new(cx.label()).strength(HeaderStrength::Heading).level(TITLE_LEVEL).actions(actions.iter().copied()).show(ui); + let mut row = TitleRow::new(cx.label()).strength(HeaderStrength::Heading).level(TITLE_LEVEL); + if let Some(note) = note { + row = row.note(note.clone()); + } + let shown = row.actions(actions.iter().copied()).show(ui); if shown.action == Some(HeaderAction::Close) { cx.request_close(); } @@ -319,7 +323,7 @@ impl Component for DialogFrame<'_> { impl Container for DialogFrame<'_> { fn header(&mut self, ui: &mut Ui, cx: &mut BodyCx<'_>) { - header(ui, cx, close_action(self.closable), None); // P3(pdf-comments-w6): CM-C27 + header(ui, cx, close_action(self.closable), None); } fn footer(&mut self, ui: &mut Ui, cx: &mut BodyCx<'_>) { diff --git a/crates/ui-panels/src/dialog/modal.rs b/crates/ui-panels/src/dialog/modal.rs index 4f004a0f1..d0ef9c3d0 100644 --- a/crates/ui-panels/src/dialog/modal.rs +++ b/crates/ui-panels/src/dialog/modal.rs @@ -44,6 +44,8 @@ type SettleFn<'a> = Box, &mut [FooterButton]) + 'a>; /// - A modal dialog blocks input below it in every window; a press outside does nothing. /// - Escape closes a modal dialog, and a modeless one with a footer; a modeless tool window without one ignores it. /// - Focus starts on the body's first text or number field, else on the default button, else nowhere. +/// - A [`title_note`](Dialog::title_note) runs on after the title in muted text ("· 3 comments selected"), and is +/// dropped before the title elides. #[derive(crate::contract::Component, crate::contract::Props)] #[component(container)] pub struct Dialog<'a> { diff --git a/crates/ui-panels/src/dialog/stories.rs b/crates/ui-panels/src/dialog/stories.rs index 45aae2a16..a5efaf300 100644 --- a/crates/ui-panels/src/dialog/stories.rs +++ b/crates/ui-panels/src/dialog/stories.rs @@ -65,6 +65,9 @@ pub fn hosted_with( /// The opener of the Grid options dialogs. const GRID_OPTIONS: &str = "Grid Options…"; +/// The opener of the dialog with a title note. +const COMMENT_PROPERTIES: &str = "Comment Properties…"; + /// The open state a story's dialog binds, behind the button that opens it: dialogs start closed, and the button opens /// the real one. fn opener<'d>(ui: &mut Ui, data: &'d mut StoryData, label: &'static str) -> &'d mut bool { @@ -111,6 +114,19 @@ fn dialog_with_footer(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { shown } +/// Dialog with a title note. +#[story(Dialog<'static>, covers = [], drive = Drive::Never)] +fn dialog_with_title_note(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { + let mut checks = *data.value("checks", [true, false]); + let shown: StoryOutput = Dialog::new("Comment Properties") + .title_note("3 comments selected") + .opened(Bind::bound(opener(ui, data, COMMENT_PROPERTIES))) + .show(ui, |ui, _| body(ui, &mut checks)) + .into(); + *data.value("checks", [true, false]) = checks; + shown +} + #[story(Dialog<'static>, covers = [], drive = Drive::Never)] fn dialog_with_side_buttons(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { let mut checks = *data.value("checks", [true, false]);