Launcher: one place reads the pinned appearance (theme::pinned_dark)

The title bar and the theme both resolved HORIZON_LAUNCHER_APPEARANCE and the
Settings choice; titlebar::apply_appearance now uses the theme's helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-25 15:14:48 +01:00
parent 3740de5116
commit 98bebd26bd
2 changed files with 32 additions and 28 deletions
+25 -14
View File
@@ -74,22 +74,33 @@ fn c(hex: u32) -> Hsla {
rgb(hex).into()
}
/// Whether the launcher is pinned dark (`Some(true)`) or light, or follows the system (`None`):
/// `HORIZON_LAUNCHER_APPEARANCE=light` or `dark` (for screenshots and tests), else the player's
/// choice in Settings.
pub fn pinned_dark(choice: Appearance) -> Option<bool> {
match std::env::var("HORIZON_LAUNCHER_APPEARANCE").as_deref() {
Ok("light") => Some(false),
Ok("dark") => Some(true),
_ => match choice {
Appearance::Dark => Some(true),
Appearance::Light => Some(false),
Appearance::System => None,
},
}
}
impl Theme {
/// The player's choice in Settings (dark unless they picked another), the system's when they
/// asked to follow it. `HORIZON_LAUNCHER_APPEARANCE=light` or `dark` overrides both (for
/// screenshots and tests).
/// The pinned look (`pinned_dark`: dark unless the player picked another), the system's when
/// they asked to follow it.
pub fn for_appearance(choice: Appearance, system: WindowAppearance) -> Self {
match std::env::var("HORIZON_LAUNCHER_APPEARANCE").as_deref() {
Ok("light") => return Self::light(),
Ok("dark") => return Self::dark(),
_ => {}
}
match (choice, system) {
(Appearance::Light, _) => Self::light(),
(Appearance::System, WindowAppearance::Light | WindowAppearance::VibrantLight) => {
Self::light()
}
_ => Self::dark(),
let system_dark = !matches!(
system,
WindowAppearance::Light | WindowAppearance::VibrantLight
);
if pinned_dark(choice).unwrap_or(system_dark) {
Self::dark()
} else {
Self::light()
}
}