Skip to main content

Segment

Struct Segment 

Source
pub struct Segment { /* private fields */ }
Expand description

A single segment inside a SegmentedControl.

Build with Segment::text, Segment::icon, or Segment::icon_text, then layer optional decorations with Segment::dot and Segment::count. Mark unavailable segments with Segment::enabled.

let seg = Segment::text("Open").dot(SegmentDot::Amber).count("12");

Implementations§

Source§

impl Segment

Source

pub fn text(label: impl Into<WidgetText>) -> Self

Text-only segment.

Source

pub fn icon(icon: impl Into<WidgetText>) -> Self

Icon-only segment. The icon is any WidgetText — typically a glyph from elegance::glyphs wrapped in egui::RichText.

Source

pub fn icon_text( icon: impl Into<WidgetText>, label: impl Into<WidgetText>, ) -> Self

Icon + label segment. The icon precedes the label.

Source

pub fn count(self, count: impl Into<WidgetText>) -> Self

Add a count badge that follows the label.

Source

pub fn dot(self, dot: SegmentDot) -> Self

Add a leading status dot.

Source

pub fn enabled(self, enabled: bool) -> Self

Disable the segment. Disabled segments render dimmed and don’t respond to clicks. Default: enabled.

Trait Implementations§

Source§

impl Debug for Segment

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Segment

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(value: T, _simd: S) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.