Unify shell corner radius and speed up Settings page switching
This commit is contained in:
1 parent
ef912daeba
commit
e5e2b74a25
10 files changed
+164
-91
No files matched your search
@@ -421,7 +421,9 @@ struct ThemeGeometryConfig {
|
||||
#[serde(default = "default_window_radius")]
|
||||
window_radius: f64,
|
||||
#[serde(default)]
|
||||
top_bar_radius: f64,
|
||||
top_bar_radius: Option<f64>,
|
||||
#[serde(default)]
|
||||
shell_radius: Option<f64>,
|
||||
}
|
||||
|
||||
impl Default for ThemeGeometryConfig {
|
||||
@@ -430,7 +432,8 @@ impl Default for ThemeGeometryConfig {
|
||||
border_width: default_border_width(),
|
||||
focus_ring_width: default_focus_ring_width(),
|
||||
window_radius: default_window_radius(),
|
||||
top_bar_radius: 0.0,
|
||||
top_bar_radius: None,
|
||||
shell_radius: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1072,8 +1075,13 @@ impl Config {
|
||||
unit_theme_value(self.theme.shadow.soft.opacity, "shadow.soft.opacity")?;
|
||||
|
||||
let material_radius = nonnegative_theme_value(
|
||||
self.appearance.corner_radius.unwrap_or(14.0),
|
||||
"appearance.corner_radius",
|
||||
self.theme
|
||||
.geometry
|
||||
.shell_radius
|
||||
.or(self.appearance.corner_radius)
|
||||
.or(self.theme.geometry.top_bar_radius)
|
||||
.unwrap_or(14.0),
|
||||
"geometry.shell_radius",
|
||||
)?;
|
||||
Ok(ThemeSettings {
|
||||
border_width,
|
||||
@@ -1113,10 +1121,7 @@ impl Config {
|
||||
)?
|
||||
.min(32.0),
|
||||
material_radius,
|
||||
panel_radius: nonnegative_theme_value(
|
||||
self.theme.geometry.top_bar_radius,
|
||||
"geometry.top_bar_radius",
|
||||
)?,
|
||||
panel_radius: material_radius,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1988,6 +1993,24 @@ mod tests {
|
||||
assert!(invalid.gap_config().is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shell_radius_is_independent_of_windows_and_overrides_legacy_keys() {
|
||||
for radius in [0.0, 18.0] {
|
||||
let config = parse(&format!(
|
||||
"appearance {{\n corner-radius 9\n}}\ntheme {{\n geometry {{\n shell-radius {radius}\n top-bar-radius 5\n window-radius 23\n }}\n}}"
|
||||
));
|
||||
let theme = config.theme_settings().unwrap();
|
||||
assert_eq!(theme.material_radius, radius);
|
||||
assert_eq!(theme.panel_radius, radius);
|
||||
assert_eq!(theme.window_radius, 23.0);
|
||||
}
|
||||
assert!(
|
||||
parse("theme {\n geometry {\n shell-radius -1\n }\n}")
|
||||
.theme_settings()
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_and_validates_theme_window_tokens() {
|
||||
let configured = parse(
|
||||
@@ -2024,7 +2047,7 @@ mod tests {
|
||||
material_style: MaterialStyle::Translucent,
|
||||
backdrop_blur: 12.0,
|
||||
material_radius: 14.0,
|
||||
panel_radius: 0.0,
|
||||
panel_radius: 14.0,
|
||||
}
|
||||
);
|
||||
assert!(invalid_color.theme_settings().is_err());
|
||||
|
||||
Reference in new issue
Block a user