Logo: an option to draw it in the theme's accent (#8133)
* Logo: an option to draw it in the theme's accent Preferences > Interface > Logo: Theme's colours (the default, as before) or Accent, three shades of the theme's accent. ui.prefs logo_accent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Logo: US spelling for the option's label, as upstream's English catalog uses Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Translations for the new options in the five complete catalogs (ar, he, ja, vi, zh) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"en": {
|
||||
"prefs.logo": "Logo",
|
||||
"prefs.logo_theme": "Theme's colors",
|
||||
"prefs.logo_accent": "Accent"
|
||||
},
|
||||
"ar": {
|
||||
"prefs.logo": "الشعار",
|
||||
"prefs.logo_theme": "ألوان السمة",
|
||||
"prefs.logo_accent": "لون التمييز"
|
||||
},
|
||||
"he": {
|
||||
"prefs.logo": "לוגו",
|
||||
"prefs.logo_theme": "צבעי ערכת הנושא",
|
||||
"prefs.logo_accent": "צבע הדגשה"
|
||||
},
|
||||
"ja": {
|
||||
"prefs.logo": "ロゴ",
|
||||
"prefs.logo_theme": "テーマの色",
|
||||
"prefs.logo_accent": "アクセント"
|
||||
},
|
||||
"vi": {
|
||||
"prefs.logo": "Logo",
|
||||
"prefs.logo_theme": "Màu của chủ đề",
|
||||
"prefs.logo_accent": "Màu nhấn"
|
||||
},
|
||||
"zh": {
|
||||
"prefs.logo": "标志",
|
||||
"prefs.logo_theme": "主题颜色",
|
||||
"prefs.logo_accent": "强调色"
|
||||
}
|
||||
}
|
||||
@@ -289,3 +289,34 @@ fn every_engine_colour_tag_is_placed() {
|
||||
placed.sort_unstable();
|
||||
assert_eq!(names, placed, "an engine colour tag must be mapped to a token in `viewport::sketch_color` or listed as neutral");
|
||||
}
|
||||
|
||||
/// Preferences › Interface › Logo: the logo in shades of the theme's accent (the accent itself in
|
||||
/// the middle, a lighter and a darker face), in a built-in theme and a theme file alike, and back
|
||||
/// to the theme's own logo colours.
|
||||
#[test]
|
||||
fn the_logo_can_take_the_themes_accent() {
|
||||
struct Reset;
|
||||
impl Drop for Reset {
|
||||
fn drop(&mut self) {
|
||||
crate::theme::set_logo_accent(false);
|
||||
}
|
||||
}
|
||||
let _reset = Reset;
|
||||
let mut h = crate::scenario::Harness::new();
|
||||
for theme in ["dark", "gruvbox-dark"] {
|
||||
h.call("ui.prefs", serde_json::json!({"theme": theme, "logo_accent": false}));
|
||||
h.frames(1);
|
||||
let own = Tokens::get();
|
||||
h.call("ui.prefs", serde_json::json!({"logo_accent": true}));
|
||||
h.frames(1);
|
||||
let t = Tokens::get();
|
||||
let accent = t.accent.to_opaque();
|
||||
assert_eq!(t.logo[1], accent, "{theme}");
|
||||
let lum = |c: Color32| u32::from(c.r()) + u32::from(c.g()) + u32::from(c.b());
|
||||
assert!(lum(t.logo[0]) > lum(accent) && lum(t.logo[2]) < lum(accent), "{theme}: {:?}", t.logo);
|
||||
assert_eq!(Tokens { logo: own.logo, ..t }, own, "{theme}: only the logo changes");
|
||||
h.call("ui.prefs", serde_json::json!({"logo_accent": false}));
|
||||
h.frames(1);
|
||||
assert_eq!(Tokens::get().logo, own.logo, "{theme}: the theme's own again");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -833,6 +833,8 @@ preference_settings! {
|
||||
/// The 3D view's colours: the theme's own, or the Light or Dark theme's whatever the window
|
||||
/// uses (#4146).
|
||||
viewport_theme: crate::theme::ViewportTheme = crate::theme::ViewportTheme::Theme, PAGE_INTERFACE;
|
||||
/// The application bar's logo in the theme's accent instead of the theme's logo colours.
|
||||
logo_accent: bool = false, PAGE_INTERFACE;
|
||||
/// Imported theme files (`theme_files`), kept here so they also work in the browser.
|
||||
custom_themes: Vec<crate::theme_files::ThemeFile> = Vec::new();
|
||||
/// Desktop: a `solidcraft-theme/1` file another tool writes, followed as the theme and
|
||||
@@ -1525,6 +1527,9 @@ pub fn apply(app: &mut SolveApp, ctx: &egui::Context) {
|
||||
if crate::theme::set_custom(custom) {
|
||||
app.styled = false;
|
||||
}
|
||||
if crate::theme::set_logo_accent(app.preferences.logo_accent) {
|
||||
app.styled = false;
|
||||
}
|
||||
// egui's end-of-frame shortcuts only change its context; the saved preference would
|
||||
// overwrite that change next frame. Consume the desktop shortcuts into the preference.
|
||||
if ctx.options(|o| o.zoom_with_keyboard) && !crate::keymap::capturing(app) {
|
||||
|
||||
@@ -45,6 +45,15 @@ pub(super) fn interface(app: &mut SolveApp, ui: &mut egui::Ui, t: &Tokens) {
|
||||
app.preferences.viewport_theme = *view;
|
||||
}
|
||||
});
|
||||
// The logo in the theme's own logo colours or in its accent.
|
||||
let label = app.tr("prefs.logo");
|
||||
ui_kit::row(ui, label, |ui| {
|
||||
let labels = [crate::i18n::tr("prefs.logo_theme"), crate::i18n::tr("prefs.logo_accent")];
|
||||
let mut selected = usize::from(app.preferences.logo_accent);
|
||||
if ui_kit::settings_segments(ui, label, &mut selected, &labels) {
|
||||
app.preferences.logo_accent = selected == 1;
|
||||
}
|
||||
});
|
||||
// A theme file another tool writes, reloaded when it changes (#7573).
|
||||
if FOLLOW_AVAILABLE {
|
||||
follow_row(app, ui);
|
||||
|
||||
@@ -25,6 +25,9 @@ thread_local! {
|
||||
/// The palette of a theme file (`theme_files`) in place of the built-in one of its base
|
||||
/// (dark or light), per thread like the rest. `None`: the built-in palettes.
|
||||
static CUSTOM: Cell<Option<Custom>> = const { Cell::new(None) };
|
||||
/// The application bar's logo in the theme's accent instead of its own logo colours
|
||||
/// (Preferences › Interface › Logo), per thread like the rest.
|
||||
static LOGO_ACCENT: Cell<bool> = const { Cell::new(false) };
|
||||
/// The 3D view's own dark or light when Preferences give it one ([`ViewportTheme`], #4146),
|
||||
/// per thread like the rest. `None`: the view is as dark as the window.
|
||||
static VIEWPORT_DARK: Cell<Option<bool>> = const { Cell::new(None) };
|
||||
@@ -230,6 +233,12 @@ pub fn set_custom(custom: Option<Custom>) -> bool {
|
||||
CUSTOM.with(|c| c.replace(custom) != custom)
|
||||
}
|
||||
|
||||
/// Draw the logo in the theme's accent (`true`) or its own logo colours. Returns whether that
|
||||
/// changed anything (the visuals follow on the next [`apply`]).
|
||||
pub fn set_logo_accent(on: bool) -> bool {
|
||||
LOGO_ACCENT.with(|c| c.replace(on) != on)
|
||||
}
|
||||
|
||||
/// Isolated widget tests restore the thread's theme even when an assertion fails.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn scoped_tokens(tokens: Tokens) -> impl Drop {
|
||||
@@ -944,7 +953,17 @@ impl Tokens {
|
||||
/// that base ([`set_custom`]), else the built-in one; the colour vision mode on top.
|
||||
pub fn themed(dark: bool, mode: ColorVision) -> Tokens {
|
||||
let custom = CUSTOM.get().filter(|c| c.dark == dark).map(|c| c.tokens);
|
||||
custom.unwrap_or(if dark { Tokens::dark() } else { Tokens::light() }).with_vision(dark, mode)
|
||||
let t = custom.unwrap_or(if dark { Tokens::dark() } else { Tokens::light() });
|
||||
let t = if LOGO_ACCENT.get() { t.with_accent_logo() } else { t };
|
||||
t.with_vision(dark, mode)
|
||||
}
|
||||
|
||||
/// These tokens with the logo's three faces in shades of the accent: lighter, the accent
|
||||
/// itself, darker (as the built-in logo's blues are).
|
||||
pub fn with_accent_logo(mut self) -> Tokens {
|
||||
let accent = self.accent.to_opaque();
|
||||
self.logo = [accent.lerp_to_gamma(Color32::WHITE, 0.22), accent, accent.lerp_to_gamma(Color32::BLACK, 0.2)];
|
||||
self
|
||||
}
|
||||
|
||||
/// These tokens with a colour vision mode's values on top (the tables in `palettes.rs`); Off
|
||||
|
||||
@@ -157,7 +157,7 @@ History at the bottom is unchanged.
|
||||
### Colour themes
|
||||
|
||||
Interface › **Theme** lists Dark, Light and System (follows the operating system), the built-in
|
||||
themes and any themes you have imported. A choice applies at once. Under the themes, **Viewport** draws the 3D view in the Light or Dark theme's colours whatever the window uses, for example the model on a light view in a dark window (**Follow theme**, the default, keeps the theme's own). The built-in themes are Gruvbox
|
||||
themes and any themes you have imported. A choice applies at once. Under the themes, **Viewport** draws the 3D view in the Light or Dark theme's colours whatever the window uses, for example the model on a light view in a dark window (**Follow theme**, the default, keeps the theme's own). **Logo** draws the SolidCraft logo at the top left in shades of the theme's accent instead of the theme's logo colours. The built-in themes are Gruvbox
|
||||
(dark and light, each in hard, normal and soft contrast), SolidCraft 95, Platinum 9, Cupertino,
|
||||
Green Phosphor, Amber Phosphor, Blueprint, One Dark, Tokyo Night, Solarized Light, Nord, High
|
||||
Contrast, Graphite, Nosferatu, Catppuccin Mocha, Okibi and Akari (dark and light, from the
|
||||
|
||||
@@ -336,6 +336,7 @@ One setting per line, sorted by name. A change that adds a setting adds its own
|
||||
- `hole_snaps` (default false: a Single hole snaps to its face's middle and round edges' centres)
|
||||
- `language` (`en`, `ar`, `ja`, `de`, `fr`, `he`, `ko`, `ms`, `ru`, `uk`, `zh`; see [localization](localization.md))
|
||||
- `length_decimals`
|
||||
- `logo_accent` (bool, default false: the application bar's logo in shades of the theme's accent instead of the theme's logo colours)
|
||||
- `look_at_anim`
|
||||
- `look_at_speed`
|
||||
- `middle_double_click` (`home` (default), `fit`, `off`)
|
||||
|
||||
Reference in New Issue
Block a user