pub enum AtomKind<'a> {
Empty,
Text(WidgetText),
Image(Image<'a>),
Closure(AtomClosure<'a>),
}Expand description
The different kinds of crate::Atoms.
Variants§
Empty
Empty, that can be used with crate::AtomExt::atom_grow to reserve space.
Text(WidgetText)
Text atom.
§Truncation within crate::AtomLayout works like this:
- if
wrap_modeis not Extend- if no atom is
shrink- the first text atom is selected and will be marked as
shrink
- the first text atom is selected and will be marked as
- the atom marked as
shrinkwill shrink / wrap based on the selected wrap mode - any other text atoms will have
wrap_modeextend
- if no atom is
- if
wrap_modeis extend, Text will extend as expected.
Unless crate::AtomExt::atom_max_width is set, wrap_mode should only be set via crate::Style or
crate::AtomLayout::wrap_mode, as setting a wrap mode on a WidgetText atom
that is not shrink will have unexpected results.
The size is determined by converting the WidgetText into a galley and using the galleys
size. You can use crate::AtomExt::atom_size to override this, and crate::AtomExt::atom_max_width
to limit the width (Causing the text to wrap or truncate, depending on the wrap_mode.
crate::AtomExt::atom_max_height has no effect on text.
Image(Image<'a>)
Image atom.
By default the size is determined via Image::calc_size.
You can use crate::AtomExt::atom_max_size or crate::AtomExt::atom_size to customize the size.
There is also a helper crate::AtomExt::atom_max_height_font_size to set the max height to the
default font height, which is convenient for icons.
Closure(AtomClosure<'a>)
A custom closure that produces a sized atom.
The vec2 passed in is the available size to this atom. The returned vec2 should be the preferred / intrinsic size.
Note: This api is experimental, expect breaking changes here.
When cloning, this will be cloned as AtomKind::Empty.
Implementations§
Source§impl<'a> AtomKind<'a>
impl<'a> AtomKind<'a>
Sourcepub fn text(text: impl Into<WidgetText>) -> Self
pub fn text(text: impl Into<WidgetText>) -> Self
See Self::Text
Sourcepub fn image(image: impl Into<Image<'a>>) -> Self
pub fn image(image: impl Into<Image<'a>>) -> Self
See Self::Image
Sourcepub fn closure(
func: impl FnOnce(&Ui, IntoSizedArgs) -> IntoSizedResult<'static> + 'a,
) -> Self
pub fn closure( func: impl FnOnce(&Ui, IntoSizedArgs) -> IntoSizedResult<'static> + 'a, ) -> Self
See Self::Closure
Sourcepub fn into_sized(self, ui: &Ui, _: IntoSizedArgs) -> IntoSizedResult<'a>
pub fn into_sized(self, ui: &Ui, _: IntoSizedArgs) -> IntoSizedResult<'a>
Turn this AtomKind into a SizedAtomKind.
This converts WidgetText into crate::Galley and tries to load and size Image.
The first returned argument is the preferred size.
Trait Implementations§
Source§impl<'a> From<ImageSource<'a>> for AtomKind<'a>
impl<'a> From<ImageSource<'a>> for AtomKind<'a>
Source§fn from(value: ImageSource<'a>) -> Self
fn from(value: ImageSource<'a>) -> Self
Auto Trait Implementations§
impl<'a> Freeze for AtomKind<'a>
impl<'a> !RefUnwindSafe for AtomKind<'a>
impl<'a> !Send for AtomKind<'a>
impl<'a> !Sync for AtomKind<'a>
impl<'a> Unpin for AtomKind<'a>
impl<'a> !UnwindSafe for AtomKind<'a>
Blanket Implementations§
Source§impl<'a, T> AtomExt<'a> for T
impl<'a, T> AtomExt<'a> for T
Source§fn atom_shrink(self, shrink: bool) -> Atom<'a>
fn atom_shrink(self, shrink: bool) -> Atom<'a>
Source§fn atom_max_size(self, max_size: Vec2) -> Atom<'a>
fn atom_max_size(self, max_size: Vec2) -> Atom<'a>
Source§fn atom_max_width(self, max_width: f32) -> Atom<'a>
fn atom_max_width(self, max_width: f32) -> Atom<'a>
Source§fn atom_max_height(self, max_height: f32) -> Atom<'a>
fn atom_max_height(self, max_height: f32) -> Atom<'a>
Source§fn atom_align(self, align: Align2) -> Atom<'a>
fn atom_align(self, align: Align2) -> Atom<'a>
emath::Align2 of a single atom within its available space. Read more