Restore previous theme when reselecting High Contrast
This commit is contained in:
parent
f57a301de8
commit
b922531337
|
|
@ -548,7 +548,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "canvas-pilot"
|
||||
version = "0.9.22"
|
||||
version = "0.9.23"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"craft-dwg",
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue