pub struct SegmentedControl<'a> { /* private fields */ }Expand description
A row of mutually-exclusive segments sharing a single rounded track.
Bind to a &mut usize index. Click selects; the selected index is
updated in place and the response is marked changed. Use
SegmentedControl::new for plain text segments and
SegmentedControl::from_segments when you need icons, dots, counts,
or per-segment disabled state.
let mut selected = 1usize;
ui.add(SegmentedControl::new(&mut selected, ["Day", "Week", "Month"]));
ui.add(
SegmentedControl::new(&mut selected, ["Compact", "Comfortable", "Spacious"])
.size(SegmentedSize::Small),
);Rich segments with status dots and counts:
let mut selected = 0usize;
ui.add(
SegmentedControl::from_segments(
&mut selected,
[
Segment::text("Open").dot(SegmentDot::Amber).count("12"),
Segment::text("Triaged").dot(SegmentDot::Neutral).count("84"),
Segment::text("Resolved").dot(SegmentDot::Green).count("1,204"),
Segment::text("Rejected").dot(SegmentDot::Red).count("31"),
],
)
.fill(),
);Implementations§
Source§impl<'a> SegmentedControl<'a>
impl<'a> SegmentedControl<'a>
Sourcepub fn new<I, S>(selected: &'a mut usize, items: I) -> Self
pub fn new<I, S>(selected: &'a mut usize, items: I) -> Self
Build a text-only segmented control. Each item is converted into a
plain-label Segment.
Sourcepub fn from_segments(
selected: &'a mut usize,
segments: impl IntoIterator<Item = Segment>,
) -> Self
pub fn from_segments( selected: &'a mut usize, segments: impl IntoIterator<Item = Segment>, ) -> Self
Build a segmented control from explicit Segments. Use this when
you need icons, dots, counts, or disabled states.
Sourcepub fn size(self, size: SegmentedSize) -> Self
pub fn size(self, size: SegmentedSize) -> Self
Pick a size preset. Default: SegmentedSize::Medium.
Trait Implementations§
Source§impl<'a> Debug for SegmentedControl<'a>
impl<'a> Debug for SegmentedControl<'a>
Auto Trait Implementations§
impl<'a> Freeze for SegmentedControl<'a>
impl<'a> RefUnwindSafe for SegmentedControl<'a>
impl<'a> Send for SegmentedControl<'a>
impl<'a> Sync for SegmentedControl<'a>
impl<'a> Unpin for SegmentedControl<'a>
impl<'a> UnsafeUnpin for SegmentedControl<'a>
impl<'a> !UnwindSafe for SegmentedControl<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more