feat(segmented_button): add ellipsize support

This commit is contained in:
Hojjat 2026-03-19 12:18:13 -06:00 committed by Ashley Wulber
parent 7a56762422
commit dc3ebaa38e
3 changed files with 69 additions and 5 deletions

View file

@ -213,6 +213,18 @@ where
state.buttons_offset = num - state.buttons_visible;
}
// Resize paragraph bounds so that text ellipsis can take effect.
if !matches!(self.width, Length::Shrink) || state.collapsed {
let num = state.buttons_visible.max(1) as f32;
let spacing = f32::from(self.spacing);
let mut width_offset = 0.0;
if state.collapsed {
width_offset = f32::from(self.button_height) * 2.0;
}
let button_width = ((num).mul_add(-spacing, size.width - width_offset) + spacing) / num;
self.resize_paragraphs(state, button_width);
}
size
}
}