git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commit7454c153eda369db03bbe9fd8bc3214179f10534
parentac300d97b9
authorLucas Galante <[email protected]>
date2026-07-17 16:37
fix: section title box measures the real label run so long titles fit

The title-box width used a rough char-count estimate that under-measured
the monospace (Berkeley Mono) label font, so long titles like "Network
Settings" spilled past the border. Measure the actual run with
measure_text_width in the label font; box width = text + 16 keeps the
fixed 8px-inset label centered with matching padding on both sides.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

 src/widget/container/parameters_bg.rs | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/widget/container/parameters_bg.rs b/src/widget/container/parameters_bg.rs
index 84ce14c..4464878 100644
--- a/src/widget/container/parameters_bg.rs
+++ b/src/widget/container/parameters_bg.rs
@@ -534,10 +534,17 @@ impl ParametersBg {
             let r_hdr = rects[hdr];
 
             // Title box, wrapping the header label (drawn at rect.x + 12,
-            // 13px). Width is estimated from the label length since glyph
-            // metrics aren't available in the quad pass.
+            // 13px). The label sits 8px in from the box's left edge; matching
+            // that 8px on the right (box width = text + 16) centers the text
+            // in the box. Measure the run in the actual (monospace) label font
+            // so long titles no longer spill past the border.
             let title = &self.display_params[hdr].0;
-            let title_w = (title.chars().count() as f32 * 7.0 + 16.0).min(full_w);
+            let text_w = crate::widget::display::measure_text_width(
+                title,
+                &crate::layout::control_label_font(),
+                13.0,
+            );
+            let title_w = (text_w + 16.0).min(full_w);
             let tb_x = self.rect.x + 4.0;
             let tb_y = r_hdr.1 - 2.0;
             let tb_h = 22.0;