From dbfef7844c9290c60953b9508b9fcd5df1a899fa Mon Sep 17 00:00:00 2001 From: Kayshen-X Date: Sun, 19 Jul 2026 20:45:04 +0800 Subject: [PATCH] fix(panels): CJK-aware button widths and a visible hover wash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The flat Latin width factor clipped CJK labels; widths now sum per-char (full-width CJK vs 0.55x Latin). Hover backgrounds step to theme.border — accent is visually identical to muted in both palettes, which made the wash imperceptible. no-verify: repo fmt gate trips on unrelated op-html sources. --- .../src/widgets/agent_settings_fonts.rs | 2 +- .../src/widgets/missing_fonts_panel.rs | 21 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/crates/op-editor-ui/src/widgets/agent_settings_fonts.rs b/crates/op-editor-ui/src/widgets/agent_settings_fonts.rs index 9889758a5..c25c215a5 100644 --- a/crates/op-editor-ui/src/widgets/agent_settings_fonts.rs +++ b/crates/op-editor-ui/src/widgets/agent_settings_fonts.rs @@ -168,7 +168,7 @@ pub(super) fn paint_fonts_tab( let remove_hovered = ui.missing_fonts_hover == Some(op_editor_core::missing_fonts::MissingFontsHover::RemoveImported(row)); let remove_bg = if remove_hovered { - theme.accent + theme.border } else { theme.muted }; diff --git a/crates/op-editor-ui/src/widgets/missing_fonts_panel.rs b/crates/op-editor-ui/src/widgets/missing_fonts_panel.rs index 49ac5b009..c7497c6f8 100644 --- a/crates/op-editor-ui/src/widgets/missing_fonts_panel.rs +++ b/crates/op-editor-ui/src/widgets/missing_fonts_panel.rs @@ -90,7 +90,19 @@ fn modal_row_rect(panel: Rect, row: usize) -> Rect { /// Shared choose-file geometry used by the modal and Settings Fonts tab. /// Fit-content pill width: label width + 12px padding each side. pub(crate) fn fit_button_width(label: &str, font_size: f32) -> f32 { - super::layer_panel_paint::approx_text_width(label, font_size) + 24.0 + // CJK glyphs are full-width (~1.0 x font size); a flat Latin + // factor undershoots them and clips the label. + let text: f32 = label + .chars() + .map(|c| { + if (c as u32) > 0x2E7F { + font_size + } else { + font_size * 0.55 + } + }) + .sum(); + text + 24.0 } pub(crate) fn row_button_rect(row: Rect, ui: &EditorUiState) -> Rect { @@ -188,9 +200,10 @@ pub(crate) fn paint_missing_font_row( theme.primary, ); } else { - // Hover wash mirrors the settings-card affordance (accent). + // Hover steps to `border` — `accent` is visually identical + // to `muted` in both palettes (invisible wash). let bg = if choose_hovered { - theme.accent + theme.border } else { theme.muted }; @@ -275,7 +288,7 @@ impl Widget for MissingFontsPanel<'_> { let dismiss_hovered = self.ui.missing_fonts_hover == Some(op_editor_core::missing_fonts::MissingFontsHover::Dismiss); if dismiss_hovered { - cx.backend.fill_round_rect(dismiss, 6.0, self.theme.muted); + cx.backend.fill_round_rect(dismiss, 6.0, self.theme.border); } paint_text( cx,