feat(segmented_button): Support adding divider above items in vertical segmented button

This commit is contained in:
Jeremy Soller 2024-09-11 12:51:19 -06:00
parent 05da0a83b2
commit 2faaeddb05
No known key found for this signature in database
GPG key ID: D02FD439211AF56F
4 changed files with 44 additions and 2 deletions

View file

@ -58,6 +58,9 @@ pub struct Model<SelectionMode: Default> {
/// The content used for drawing segmented items.
pub(super) items: SlotMap<Entity, Settings>,
/// Divider optionally-defined for each item.
pub(super) divider_aboves: SecondaryMap<Entity, bool>,
/// Icons optionally-defined for each item.
pub(super) icons: SecondaryMap<Entity, Icon>,
@ -200,6 +203,22 @@ where
.and_then(|storage| storage.remove(id));
}
pub fn divider_above(&self, id: Entity) -> Option<bool> {
self.divider_aboves.get(id).copied()
}
pub fn divider_above_set(&mut self, id: Entity, divider_above: bool) -> Option<bool> {
if !self.contains_item(id) {
return None;
}
self.divider_aboves.insert(id, divider_above)
}
pub fn divider_above_remove(&mut self, id: Entity) -> Option<bool> {
self.divider_aboves.remove(id)
}
/// Enable or disable an item.
///
/// ```ignore