diff --git a/crates/draw/src/ui/artboard/stories.rs b/crates/draw/src/ui/artboard/stories.rs index e20b07576..5278f9ea4 100644 --- a/crates/draw/src/ui/artboard/stories.rs +++ b/crates/draw/src/ui/artboard/stories.rs @@ -64,12 +64,16 @@ fn two_artboards(ui: &mut Ui, _: &mut StoryData) -> StoryOutput { let stage = craft_ui::testing::stage(ui); let bounds = items.iter().fold(items[0].rect, |bounds, item| bounds.union(item.rect)); let view = craft_ui::testing::canvas_story::story_view(stage, ui.pixels_per_point(), bounds.center(), 100.0); - Canvas::new("Document").view(view).show_at(ui, stage, |ui, body| { + let shown = Canvas::new("Document").view(view).show_at(ui, stage, |ui, body| { craft_ui::testing::canvas_story::show_document(ui, body.rect, &craft_ui::testing::canvas_story::StoryDocument::STANDARD); - let _ = Pasteboard::new("Pasteboard", &pages).show_at(ui, body.rect); - ArtboardOverlay::new("Artboards", items, selected).show_at(ui, body.rect) + let named = Pasteboard::new("Pasteboard", &pages).show_at(ui, body.rect).name_clicked.is_some(); + let _ = ArtboardOverlay::new("Artboards", items, selected).show_at(ui, body.rect); + named }); - StoryOutput::default() + // A board's name is a button: its click is a click of the story. + let mut output = StoryOutput::default(); + output.clicked = shown.inner.unwrap_or_default(); + output } /// The bar for one board, whose size the story keeps: a preset, Make Portrait or Landscape, or W and H resize it. diff --git a/crates/draw/src/ui/brush_settings/stories.rs b/crates/draw/src/ui/brush_settings/stories.rs index d01b06138..4b53d435d 100644 --- a/crates/draw/src/ui/brush_settings/stories.rs +++ b/crates/draw/src/ui/brush_settings/stories.rs @@ -135,18 +135,21 @@ impl Brush { Brush { sections: sections(on), shown: DYNAMICS, jitter: ControlRow::new(Control::PenPressure), scatter: ControlRow::new(Control::Fade) } } + fn section(&mut self, key: u8) -> Option<&mut BrushSection> { + self.sections.iter_mut().find(|section| section.key == key) + } + /// Applies a list event as the app applies it to its brush settings. fn apply(&mut self, event: BrushSectionEvent) { - let section = |brush: &mut Brush, key: u8| brush.sections.iter_mut().find(|section| section.key == key); match event { BrushSectionEvent::Select(key) => self.shown = key, BrushSectionEvent::Enable { key, on } | BrushSectionEvent::Switch { key, on } => { - if let Some(section) = section(self, key) { + if let Some(section) = self.section(key) { section.enabled = Some(on); } } BrushSectionEvent::Lock { key, on } => { - if let Some(section) = section(self, key) { + if let Some(section) = self.section(key) { section.locked = Some(on); } }