mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-26 04:22:38 +01:00
pdf-comments-w6: net change of 2 commits
- pdf-comments-w6: written from its sheet - pdf-comments-w6: repair 1
This commit is contained in:
4 files changed
+27
-5
No files matched your search
@@ -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<'_>) {
|
||||
|
||||
@@ -136,11 +136,15 @@ pub struct FooterHost<'s, 'a> {
|
||||
pub settle: &'s mut Option<ButtonState<'a>>,
|
||||
}
|
||||
|
||||
/// 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<'_>) {
|
||||
|
||||
@@ -44,6 +44,8 @@ type SettleFn<'a> = Box<dyn FnMut(&mut BodyCx<'_>, &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> {
|
||||
|
||||
@@ -65,6 +65,9 @@ pub fn hosted_with<D: StackDialog, K: PartialEq + 'static>(
|
||||
/// 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]);
|
||||
|
||||
Reference in new issue
Block a user