GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git
Add vertical safety buffer to prevent clipping of rotated labels in ButtonStrip
src/widget/input/button_strip.rs | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/widget/input/button_strip.rs b/src/widget/input/button_strip.rs
index 3c7366c..ee43d4c 100644
--- a/src/widget/input/button_strip.rs
+++ b/src/widget/input/button_strip.rs
@@ -113,8 +113,9 @@ impl ButtonStrip {
let y_offset = if has_icon { padding_y + 12.0 } else { 0.0 };
let usable_h = (r.3 - y_offset).max(1.0);
+ let vertical_buffer = 8.0;
let w_px = (r.2 * scale) as u32;
- let h_px = (usable_h * scale) as u32;
+ let h_px = ((usable_h + 2.0 * vertical_buffer) * scale) as u32;
if w_px == 0 || h_px == 0 {
self.tab_text_quads.push(Vec::new());
@@ -132,12 +133,12 @@ impl ButtonStrip {
<text x="{}" y="{}" font-family="{}" font-size="{}" fill="{}" text-anchor="middle" dominant-baseline="middle" transform="rotate(-90 {} {})">{}</text>
</svg>"##,
w_px, h_px,
- r.2, usable_h,
- r.2 / 2.0, usable_h / 2.0,
+ r.2, usable_h + 2.0 * vertical_buffer,
+ r.2 / 2.0, usable_h / 2.0 + vertical_buffer,
font_fam,
font_size,
hex_color,
- r.2 / 2.0, usable_h / 2.0,
+ r.2 / 2.0, usable_h / 2.0 + vertical_buffer,
label_text
);
@@ -347,7 +348,7 @@ impl Element for ButtonStrip {
for &(qx, qy, qw, qh, qc) in &self.tab_text_quads[i] {
let absolute_x = r.0 + qx;
- let absolute_y = r.1 + y_offset + qy;
+ let absolute_y = r.1 + y_offset + qy - 8.0;
let ry1 = absolute_y.max(min_y);
let ry2 = (absolute_y + qh).min(max_y);