Struct DropdownFace
pub struct DropdownFace<'a> { /* private fields */ }Expand description
An immediate-mode dropdown: the closed Dropdown look for a painted
host (a camera’s controls, a reader’s settings) that owns its own
hit-testing. Pair it with an option crate::widget::Popover
(Popover::new().with_items(..), opened with
open_at(face.field_rect(theme), Some(selected))) for the list.
Size the rect from the face, so rect and glyphs agree at every scale:
DropdownFace::outer_height (the field, plus a caption when it has
one) and DropdownFace::intrinsic_width for the widest option.
Implementations§
§impl<'a> DropdownFace<'a>
impl<'a> DropdownFace<'a>
pub fn new(rect: Rect, value: &'a str) -> DropdownFace<'a>
pub fn new(rect: Rect, value: &'a str) -> DropdownFace<'a>
A closed dropdown at rect showing value.
pub fn placeholder(self, placeholder: &'a str) -> DropdownFace<'a>
pub fn placeholder(self, placeholder: &'a str) -> DropdownFace<'a>
Shown, in the weaker placeholder ink, while value is empty.
pub fn caption(self, caption: &'a str) -> DropdownFace<'a>
pub fn caption(self, caption: &'a str) -> DropdownFace<'a>
A short label stacked above the field (“Level”, “Source”).
pub fn leading_icon(self, icon: Icon) -> DropdownFace<'a>
pub fn leading_icon(self, icon: Icon) -> DropdownFace<'a>
A glyph before the value that says what the choice is.
pub fn control_size(self, size: ControlSize) -> DropdownFace<'a>
pub fn control_size(self, size: ControlSize) -> DropdownFace<'a>
The field’s height and label role.
pub fn open(self, open: bool) -> DropdownFace<'a>
pub fn open(self, open: bool) -> DropdownFace<'a>
Its option list is showing: the field lifts and the chevron turns.
pub fn hovered(self, hovered: bool) -> DropdownFace<'a>
pub fn focused(self, focused: bool) -> DropdownFace<'a>
pub fn disabled(self, disabled: bool) -> DropdownFace<'a>
pub fn height(size: ControlSize, theme: &Theme) -> f64
pub fn height(size: ControlSize, theme: &Theme) -> f64
The field’s height at size in theme.
pub fn outer_height(&self, theme: &Theme) -> f64
pub fn outer_height(&self, theme: &Theme) -> f64
This face’s whole height: the field, and its caption above it.
pub fn intrinsic_width<'s>(
&self,
options: impl IntoIterator<Item = &'s str>,
text: &mut TextRenderer,
theme: &Theme,
) -> f64
pub fn intrinsic_width<'s>( &self, options: impl IntoIterator<Item = &'s str>, text: &mut TextRenderer, theme: &Theme, ) -> f64
The narrowest rect that shows every one of options (and the
placeholder) beside the icon and the chevron, and the caption above.
pub fn field_rect(&self, theme: &Theme) -> Rect
pub fn field_rect(&self, theme: &Theme) -> Rect
The field below the caption: what the option list anchors to and what a pointer opens.
pub fn contains(&self, theme: &Theme, point: Point) -> bool
pub fn contains(&self, theme: &Theme, point: Point) -> bool
Whether point opens the list: the field, grown to the minimum
pointer target.
pub fn paint(
&self,
scene: &mut Scene,
transform: Affine,
text: &mut TextRenderer,
theme: &Theme,
)
pub fn paint( &self, scene: &mut Scene, transform: Affine, text: &mut TextRenderer, theme: &Theme, )
Paint the face.
Auto Trait Implementations§
impl<'a> Freeze for DropdownFace<'a>
impl<'a> RefUnwindSafe for DropdownFace<'a>
impl<'a> Send for DropdownFace<'a>
impl<'a> Sync for DropdownFace<'a>
impl<'a> Unpin for DropdownFace<'a>
impl<'a> UnsafeUnpin for DropdownFace<'a>
impl<'a> UnwindSafe for DropdownFace<'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