Decorations: truncate window titles so they never draw over the title-bar buttons
CI / test (push) Successful in 25s
CI / test (push) Successful in 25s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9e7687bea8
commit
ee698c9846
1 file changed
+15
-13
+15
-13
@@ -353,19 +353,6 @@ pub fn build_breeze_decoration(
|
|||||||
Line(border, title_h - 1, outer_w - border, title_h - 1, p.border, 1),
|
Line(border, title_h - 1, outer_w - border, title_h - 1, p.border, 1),
|
||||||
]
|
]
|
||||||
|
|
||||||
let label = if title.length() > 0 { title } else { app_id }
|
|
||||||
ops.push(
|
|
||||||
Text(
|
|
||||||
14,
|
|
||||||
title_h / 2,
|
|
||||||
label,
|
|
||||||
tokens.font_size,
|
|
||||||
title_fg,
|
|
||||||
Left,
|
|
||||||
focused,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
// Window control buttons on the right: [ _ ] [ [] ] [ X ]
|
// Window control buttons on the right: [ _ ] [ [] ] [ X ]
|
||||||
let btn_size = 18
|
let btn_size = 18
|
||||||
let btn_y = (title_h - btn_size) / 2
|
let btn_y = (title_h - btn_size) / 2
|
||||||
@@ -373,6 +360,21 @@ pub fn build_breeze_decoration(
|
|||||||
let max_x = close_x - 8 - btn_size
|
let max_x = close_x - 8 - btn_size
|
||||||
let min_x = max_x - 8 - btn_size
|
let min_x = max_x - 8 - btn_size
|
||||||
|
|
||||||
|
// Title: truncated so it never runs under the buttons or past the window edge.
|
||||||
|
let label = if title.length() > 0 { title } else { app_id }
|
||||||
|
let char_w = if tokens.font_size >= 14 { 12 } else { 6 }
|
||||||
|
let max_chars = (min_x - 8 - 14) / char_w
|
||||||
|
let shown = if max_chars < 3 {
|
||||||
|
""
|
||||||
|
} else if label.length() <= max_chars {
|
||||||
|
label
|
||||||
|
} else {
|
||||||
|
label[:max_chars - 2].to_string() + ".."
|
||||||
|
}
|
||||||
|
ops.push(
|
||||||
|
Text(14, title_h / 2, shown, tokens.font_size, title_fg, Left, focused),
|
||||||
|
)
|
||||||
|
|
||||||
let close_bg = if focused {
|
let close_bg = if focused {
|
||||||
Rgba::new(218, 68, 83, 255)
|
Rgba::new(218, 68, 83, 255)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in new issue
Block a user