diff --git a/Cargo.lock b/Cargo.lock index 208acd4..d2f51a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -548,7 +548,7 @@ dependencies = [ [[package]] name = "canvas-pilot" -version = "0.9.22" +version = "0.9.23" dependencies = [ "base64", "craft-dwg", diff --git a/Cargo.toml b/Cargo.toml index c8b3444..608475a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ default-members = ["crates/canvas-pilot"] resolver = "3" [workspace.package] -version = "0.9.22" +version = "0.9.23" edition = "2024" license = "MIT" repository = "https://proxy.dandaedre.com/gitea/idle-org/canvas-pilot" diff --git a/crates/canvas-pilot/src/menu_ui.rs b/crates/canvas-pilot/src/menu_ui.rs index fea05f2..2f09dbc 100644 --- a/crates/canvas-pilot/src/menu_ui.rs +++ b/crates/canvas-pilot/src/menu_ui.rs @@ -174,7 +174,7 @@ impl Editor { .stable_selectable_label(current == choice, choice.name()) .clicked() { - choice.apply(ui.ctx()); + choice.select(ui.ctx()); ui.close(); } } @@ -262,7 +262,7 @@ impl Editor { }); }); if let Some(choice) = selected { - choice.apply(ctx); + choice.select(ctx); self.settings.save(&self.application_settings(ctx)); } } @@ -501,13 +501,22 @@ mod tests { click_label(&mut app, &ctx, "Theme: Midra Dark"); click_label(&mut app, &ctx, "More themes…"); click_label(&mut app, &ctx, "Corporate Light"); + click_label(&mut app, &ctx, "High Contrast"); + assert_eq!(theme::Theme::current(&ctx), theme::Theme::HighContrast); + click_label(&mut app, &ctx, "High Contrast"); + assert_eq!(theme::Theme::current(&ctx), theme::Theme::CorporateLight); + assert!(app.themes_open); let (store, saved) = settings::Store::at(path); assert!(store.error.is_none()); let fresh_ctx = egui::Context::default(); let restored = Editor::with_settings(&fresh_ctx, store, saved); assert_eq!( theme::Theme::recent(&fresh_ctx), - vec![theme::Theme::CorporateLight, theme::Theme::Midra] + vec![ + theme::Theme::CorporateLight, + theme::Theme::HighContrast, + theme::Theme::Midra + ] ); assert!(restored.show_toolbar_icon_names); assert!(!restored.keep_aspect_ratio); diff --git a/crates/canvas-pilot/src/preferences_ui.rs b/crates/canvas-pilot/src/preferences_ui.rs index 0b98516..c19d224 100644 --- a/crates/canvas-pilot/src/preferences_ui.rs +++ b/crates/canvas-pilot/src/preferences_ui.rs @@ -325,14 +325,14 @@ impl Editor { ui.weak(tr(ctx, "access.text-help")); } if scaling_before != (self.ui_scale, self.text_scale) { apply_scaling(ctx, self.ui_scale, self.text_scale); } - if ui.button(tr(ctx, "access.contrast")).clicked() { theme::Theme::HighContrast.apply(ctx); } + if ui.button(tr(ctx, "access.contrast")).clicked() { theme::Theme::HighContrast.select(ctx); } ui.separator(); ui.label(rust_i18n::t!("theme.current", locale = &localization::locale(ctx), name = theme::Theme::current(ctx).name()).into_owned()); if ui.button(tr(ui.ctx(), "ui.browse-all-themes")).clicked() { self.themes_open = true; } ui.label(tr(ui.ctx(), "ui.recently-used")); for choice in theme::Theme::recent(ctx) { if ui.stable_selectable_label(choice == theme::Theme::current(ctx), choice.name()).clicked() { - choice.apply(ctx); + choice.select(ctx); } } ui.separator(); diff --git a/crates/canvas-pilot/src/theme.rs b/crates/canvas-pilot/src/theme.rs index 4ea23dc..8b2ab26 100644 --- a/crates/canvas-pilot/src/theme.rs +++ b/crates/canvas-pilot/src/theme.rs @@ -280,6 +280,19 @@ impl Theme { }, } } + /// Apply a user choice; selecting active High Contrast restores the previous theme. + pub fn select(self, ctx: &egui::Context) { + let choice = if self == Self::HighContrast && Self::current(ctx) == self { + Self::recent(ctx) + .into_iter() + .find(|theme| *theme != Self::HighContrast) + .unwrap_or_default() + } else { + self + }; + choice.apply(ctx); + } + pub fn apply(self, ctx: &egui::Context) { let mut recent = Self::recent(ctx); recent.retain(|theme| *theme != self); diff --git a/docs/canvas-pilot/changelog.md b/docs/canvas-pilot/changelog.md index 18a8111..d329795 100644 --- a/docs/canvas-pilot/changelog.md +++ b/docs/canvas-pilot/changelog.md @@ -4,6 +4,12 @@ ## Unreleased +### v0.9.23 + +- Clicking High Contrast again restores the previous theme in the theme browser, + recent-theme menus and Appearance settings. The saved theme history supplies + the previous choice, with Midra Dark as the fallback. + ### v0.9.22 - Fix High Contrast source-helper coordinates disappearing on white checkerboard diff --git a/docs/canvas-pilot/guide/preferences.md b/docs/canvas-pilot/guide/preferences.md index d9c5c8d..6bdc07f 100644 --- a/docs/canvas-pilot/guide/preferences.md +++ b/docs/canvas-pilot/guide/preferences.md @@ -86,6 +86,8 @@ Open **Menu → Open all settings… → Appearance**: **50% to 200%**. Canvas artwork and fixed-size labels follow interface scale only. - **Use high contrast:** select a black-based theme with white text, bright accents and stronger control borders. It also appears as **High Contrast** in the theme browser. + Click it again while active to return to your previous theme. This also works in + the recent-theme menu; if there is no previous theme, it returns to Midra Dark. Scale values update while dragging, but resizing applies only after releasing the pointer. Typed values apply after finishing text entry. Preferences are