| ... | ... | @@ -29,6 +29,16 @@ impl Scope { |
| 29 | 29 | Self::Notebook => "This Notebook", |
| 30 | 30 | } |
| 31 | 31 | } |
| 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 | } |
| 32 | 42 | } |
| 33 | 43 | |
| 34 | 44 | /// The Themes dialog while it is open. |
| ... | ... | @@ -226,7 +236,7 @@ impl State { |
| 226 | 236 | } |
| 227 | 237 | |
| 228 | 238 | /// 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; |
| 230 | 240 | /// Cancel, Escape or a press outside leave everything as it was. |
| 231 | 241 | pub(crate) fn themes_dialog(&mut self) { |
| 232 | 242 | let Some(dialog) = &mut self.themes else { |
| ... | ... | @@ -601,7 +611,7 @@ impl State { |
| 601 | 611 | ); |
| 602 | 612 | // Each button gives its choice to the one place there is, else asks where. |
| 603 | 613 | 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| { |
| 605 | 615 | let clicked = ui::button(ui, part, label).clicked; |
| 606 | 616 | if targets.len() == 1 { |
| 607 | 617 | return clicked.then_some(0); |
| ... | ... | @@ -614,7 +624,7 @@ impl State { |
| 614 | 624 | .iter() |
| 615 | 625 | .enumerate() |
| 616 | 626 | .map(|(at, (scope, _))| Item { |
| 617 | | text: scope.name(), |
| 627 | text: item(*scope), |
| 618 | 628 | icon: Some(match scope { |
| 619 | 629 | Scope::Page => crate::art::PAGE, |
| 620 | 630 | Scope::Section => crate::art::SECTION, |
| ... | ... | @@ -627,7 +637,11 @@ impl State { |
| 627 | 637 | let anchor = Anchor::Below(ui.rect(ui.id(part)).unwrap_or_default()); |
| 628 | 638 | ui::popup::menu(ui, menu, anchor, &items, None) |
| 629 | 639 | }; |
| 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); |
| 631 | 645 | ui.leaf( |
| 632 | 646 | "space", |
| 633 | 647 | Spec { |
| ... | ... | @@ -636,7 +650,7 @@ impl State { |
| 636 | 650 | }, |
| 637 | 651 | ); |
| 638 | 652 | let cancel = ui::button(ui, "cancel", "Cancel").clicked; |
| 639 | | let save = place(ui, "save", "Save"); |
| 653 | let save = place(ui, "save", "Save", Scope::name); |
| 640 | 654 | ui.close(); |
| 641 | 655 | ui.close(); |
| 642 | 656 | |