authorgravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-10-03 01:42:34-07:00
committergravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-10-03 05:19:31-07:00
log1035fa1f6367df0e9e86af83631aef9356ab593c
tree851c9033de3ae92ef4fd00f2fc993879f95944f7
parent5c06254186b809c75c62d772681c40f0cb9152d4
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

fix: the Themes dialog says what taking a theme away leaves: the section's theme, the notebook's, or the pages as they are

Assisted-by: claude-opus-5.5

1 files changed, 19 insertions(+), 5 deletions(-)

crates/snowbound/src/themes.rs+19-5
......@@ -29,6 +29,16 @@ impl Scope {
2929 Self::Notebook => "This Notebook",
3030 }
3131 }
32
33 /// What taking away the scope's own theme leaves it wearing.
34 fn without(self) -> &'static str {
35 match self {
36 Self::Page => "Use Section's Theme",
37 Self::Section => "Use Notebook's Theme",
38 // Pages keep the styles the theme gave them.
39 Self::Notebook => "Remove Notebook Theme",
40 }
41 }
3242}
3343
3444/// The Themes dialog while it is open.
......@@ -226,7 +236,7 @@ impl State {
226236 }
227237
228238 /// Builds the Themes dialog while it is open. Save keeps the edits and gives the theme to
229 /// the scope it then asks for, This Page first; No Theme takes that scope's own away;
239 /// the scope it then asks for, This Page first; Remove Theme takes that scope's own away;
230240 /// Cancel, Escape or a press outside leave everything as it was.
231241 pub(crate) fn themes_dialog(&mut self) {
232242 let Some(dialog) = &mut self.themes else {
......@@ -601,7 +611,7 @@ impl State {
601611 );
602612 // Each button gives its choice to the one place there is, else asks where.
603613 let targets = &dialog.targets;
604 let place = |ui: &mut Ui, part: &str, label: &str| -> Option<usize> {
614 let place = |ui: &mut Ui, part: &str, label: &str, item: fn(Scope) -> &'static str| {
605615 let clicked = ui::button(ui, part, label).clicked;
606616 if targets.len() == 1 {
607617 return clicked.then_some(0);
......@@ -614,7 +624,7 @@ impl State {
614624 .iter()
615625 .enumerate()
616626 .map(|(at, (scope, _))| Item {
617 text: scope.name(),
627 text: item(*scope),
618628 icon: Some(match scope {
619629 Scope::Page => crate::art::PAGE,
620630 Scope::Section => crate::art::SECTION,
......@@ -627,7 +637,11 @@ impl State {
627637 let anchor = Anchor::Below(ui.rect(ui.id(part)).unwrap_or_default());
628638 ui::popup::menu(ui, menu, anchor, &items, None)
629639 };
630 let none = place(ui, "none", "No Theme");
640 let remove = match targets[..] {
641 [(scope, _)] => scope.without(),
642 _ => "Remove Theme",
643 };
644 let none = place(ui, "none", remove, Scope::without);
631645 ui.leaf(
632646 "space",
633647 Spec {
......@@ -636,7 +650,7 @@ impl State {
636650 },
637651 );
638652 let cancel = ui::button(ui, "cancel", "Cancel").clicked;
639 let save = place(ui, "save", "Save");
653 let save = place(ui, "save", "Save", Scope::name);
640654 ui.close();
641655 ui.close();
642656