Struct SegmentedFace
pub struct SegmentedFace<'a> { /* private fields */ }Expand description
An immediate-mode segmented strip over caller-owned segment rects (the
rects must be contiguous, except a multi-select strip’s). The caller owns
the hit-test; this paints the themed look over them. Size the strip with
SegmentedFace::height and SegmentedFace::intrinsic_width, and
split it with SegmentedFace::partition_segments.
Implementations§
§impl<'a> SegmentedFace<'a>
impl<'a> SegmentedFace<'a>
pub fn new(
segments: &'a [Rect],
labels: &'a [&'a str],
selected: usize,
) -> SegmentedFace<'a>
pub fn new( segments: &'a [Rect], labels: &'a [&'a str], selected: usize, ) -> SegmentedFace<'a>
A strip of plain labels; selected may be NONE_CHOSEN.
pub fn of_segments(
segments: &'a [Rect],
items: &'a [Segment],
selected: usize,
) -> SegmentedFace<'a>
pub fn of_segments( segments: &'a [Rect], items: &'a [Segment], selected: usize, ) -> SegmentedFace<'a>
A strip of Segments: a segment whose label does not fit its rect
shows its short form, an icon segment its icon.
pub fn selection(self, selection: Option<usize>) -> SegmentedFace<'a>
pub fn selection(self, selection: Option<usize>) -> SegmentedFace<'a>
Choose selection, or nothing.
pub fn chosen(self, chosen: &'a [bool]) -> SegmentedFace<'a>
pub fn chosen(self, chosen: &'a [bool]) -> SegmentedFace<'a>
A multi-select strip: each segment on where chosen says so, each
its own toggle.
pub fn style(self, style: SegmentedStyle) -> SegmentedFace<'a>
pub fn hovered(self, idx: Option<usize>) -> SegmentedFace<'a>
pub fn focused(self, focused: bool) -> SegmentedFace<'a>
pub fn focused(self, focused: bool) -> SegmentedFace<'a>
Draw the focus ring, in your colour, round the strip.
pub fn disabled(self, disabled: bool) -> SegmentedFace<'a>
pub fn disabled(self, disabled: bool) -> SegmentedFace<'a>
The strip takes no input: it paints under the disabled alpha, with no hover and no focus ring.
pub fn control_size(self, size: ControlSize) -> SegmentedFace<'a>
pub fn control_size(self, size: ControlSize) -> SegmentedFace<'a>
Label role; the host sizes the rects with Self::height.
pub fn height(size: ControlSize, theme: &Theme) -> f64
pub fn height(size: ControlSize, theme: &Theme) -> f64
The height of a strip of size in theme.
pub fn intrinsic_width(
labels: &[&str],
size: ControlSize,
text: &mut TextRenderer,
theme: &Theme,
) -> f64
pub fn intrinsic_width( labels: &[&str], size: ControlSize, text: &mut TextRenderer, theme: &Theme, ) -> f64
The narrowest strip that shows every full label in theme.
pub fn partition(
rect: Rect,
labels: &[&str],
size: ControlSize,
text: &mut TextRenderer,
theme: &Theme,
) -> Vec<Rect>
pub fn partition( rect: Rect, labels: &[&str], size: ControlSize, text: &mut TextRenderer, theme: &Theme, ) -> Vec<Rect>
The segment rects of a strip in rect: equal while every label fits
an equal share, otherwise each as wide as its label needs with the
rest shared, as a ToggleGroup partitions itself.
pub fn partition_segments(
rect: Rect,
segments: &[Segment],
style: SegmentedStyle,
size: ControlSize,
text: &mut TextRenderer,
theme: &Theme,
) -> Vec<Rect>
pub fn partition_segments( rect: Rect, segments: &[Segment], style: SegmentedStyle, size: ControlSize, text: &mut TextRenderer, theme: &Theme, ) -> Vec<Rect>
The segment rects of a strip of Segments in rect, as a
ToggleGroup of style partitions itself: short forms where the full
labels cannot fit, icon segments square, tabs packed from the leading
edge.
Auto Trait Implementations§
impl<'a> Freeze for SegmentedFace<'a>
impl<'a> RefUnwindSafe for SegmentedFace<'a>
impl<'a> Send for SegmentedFace<'a>
impl<'a> Sync for SegmentedFace<'a>
impl<'a> Unpin for SegmentedFace<'a>
impl<'a> UnsafeUnpin for SegmentedFace<'a>
impl<'a> UnwindSafe for SegmentedFace<'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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more