forked from 1b-agent/opencadstudio-upstream
Add the Fusion Black and Fusion White themes
Fusion Black pairs near-black chrome with a paper-white canvas, so the drawing is the only bright thing on screen. That breaks the assumption in theme_canvas_background that the canvas follows the chrome, hence the explicit lookup: falling through to the palette would paint model space black and undo the point of the theme. Both keep a blue accent rather than going fully greyscale. Selection highlight defaults to the theme primary, and a white primary would be invisible against a white canvas. These are Theme::Custom values and so are absent from iced's Theme::ALL. all_themes() is the list to enumerate from now; the picker in the options dialog uses it, and parse_theme_name resolves both by name.
This commit is contained in:
4 files changed
+163
-4
No files matched your search
+21
-3
@@ -176,11 +176,20 @@ impl UiThemePalette {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn builtin_theme(name: &str) -> Option<iced::Theme> {
|
||||
/// Every theme the user may pick: iced's built-ins followed by the Fusion
|
||||
/// pair. The Fusion themes are `Theme::Custom`, so they are not in
|
||||
/// `iced::Theme::ALL`; anything enumerating themes for display or for test
|
||||
/// coverage must use this instead, or they silently vanish from the list.
|
||||
pub fn all_themes() -> Vec<iced::Theme> {
|
||||
iced::Theme::ALL
|
||||
.iter()
|
||||
.find(|theme| theme.to_string() == name)
|
||||
.cloned()
|
||||
.chain(crate::ui::style::fusion_theme::fusion_themes())
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn builtin_theme(name: &str) -> Option<iced::Theme> {
|
||||
all_themes().into_iter().find(|theme| theme.to_string() == name)
|
||||
}
|
||||
|
||||
fn color_to_rgb(color: iced::Color) -> [u8; 3] {
|
||||
@@ -376,7 +385,14 @@ pub fn theme_canvas_background(theme: &iced::Theme) -> [u8; 3] {
|
||||
iced::Theme::Nightfly => [1, 22, 39],
|
||||
iced::Theme::Oxocarbon => [22, 22, 22],
|
||||
iced::Theme::Ferra => [43, 41, 46],
|
||||
_ => color_to_rgb(theme.palette().background.base.color),
|
||||
// The Fusion pair deliberately breaks the "canvas follows chrome"
|
||||
// rule: black chrome is paired with a white canvas, so falling
|
||||
// through to the palette below would paint model space black and
|
||||
// undo the whole point of the theme.
|
||||
other => match crate::ui::style::fusion_theme::fusion_canvas(other) {
|
||||
Some(rgb) => rgb,
|
||||
None => color_to_rgb(other.palette().background.base.color),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,6 +423,8 @@ pub fn parse_theme_name(s: &str) -> Option<iced::Theme> {
|
||||
"NIGHTFLY" => Some(iced::Theme::Nightfly),
|
||||
"OXOCARBON" => Some(iced::Theme::Oxocarbon),
|
||||
"FERRA" => Some(iced::Theme::Ferra),
|
||||
"FUSIONBLACK" => Some(crate::ui::style::fusion_theme::fusion_black()),
|
||||
"FUSIONWHITE" => Some(crate::ui::style::fusion_theme::fusion_white()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user