Move layout metrics into theme and apply audit cleanups

This commit is contained in:
2026-11-09 15:59:13 +07:00
parent 122f9b12ae
commit 2e7711ee2e
32 changed files with 762 additions and 972 deletions
+4 -15
View File
@@ -23,13 +23,9 @@ use gpui::Decorations;
use gpui::{SharedString, px, rgba};
/// macOS traffic-lights zone: the pad a leading titlebar strip reserves.
pub const TRAFFIC_LIGHT_PAD: f32 = 78.0;
/// The width of a Windows caption button.
pub use gpui_native_theme::TRAFFIC_LIGHT_PAD;
#[cfg(target_os = "windows")]
const CAPTION_WIDTH: f32 = 36.0;
/// Windows paints its caption close hover red in every theme.
#[cfg(target_os = "windows")]
const WINDOWS_CLOSE_HOVER: (f32, f32, f32) = (232.0 / 255.0, 17.0 / 255.0, 32.0 / 255.0);
use gpui_native_theme::{WINDOWS_CAPTION_WIDTH as CAPTION_WIDTH, WINDOWS_CLOSE_HOVER_HEX};
/// The window controls for the trailing end of a titlebar strip.
#[derive(IntoElement)]
@@ -150,7 +146,7 @@ impl RenderOnce for WindowControls {
}
/// Double-click on a titlebar strip maximizes where the platform does not do it.
pub fn maximize_on_double_click() -> impl Fn(&ClickEvent, &mut Window, &mut App) + 'static {
fn maximize_on_double_click() -> impl Fn(&ClickEvent, &mut Window, &mut App) + 'static {
move |event, window, _cx| {
if event.click_count() != 2 {
return;
@@ -210,16 +206,9 @@ fn caption_button(
) -> AnyElement {
let theme = cx.theme();
let glyph_size = theme.sizes.small.caption_size;
let (close_r, close_g, close_b) = WINDOWS_CLOSE_HOVER;
let close_hover = rgba((
(close_r * 255.0) as u8,
(close_g * 255.0) as u8,
(close_b * 255.0) as u8,
0xff,
));
let hover = if close {
close_hover
rgba(WINDOWS_CLOSE_HOVER_HEX)
} else {
theme.colors.muted_hover
};