pub enum AtomKind<'a> {
Empty,
Text(WidgetText),
Image(Image<'a>),
Closure(Box<dyn FnOnce(&Ui, IntoSizedArgs) -> IntoSizedResult<'static> + 'a>),
Paint(Arc<dyn Fn(&Ui, AtomPaintArgs) + 'a>),
Widget(Box<WidgetAtom<'a>>),
Container(Box<ContainerAtom<'a>>),
}egui only.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::WidgetAtom 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::ContainerAtom::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(Box<dyn FnOnce(&Ui, IntoSizedArgs) -> IntoSizedResult<'static> + '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.
Paint(Arc<dyn Fn(&Ui, AtomPaintArgs) + 'a>)
A closure that paints the atom at the Rect the layout gives it.
It has no size of its own, so set one with crate::AtomExt::atom_size, or use
crate::Atom::paint, which does that for you. If the size depends on the Ui,
return a SizedAtomKind::Paint from an AtomKind::Closure instead.
Use this for widgets that draw their own shapes, like the check mark of
crate::Checkbox.
Widget(Box<WidgetAtom<'a>>)
A nested WidgetAtom, letting you embed an atom-based widget as a single atom
inside another WidgetAtom.
The nested widget is measured (sized) when the parent is sized, and painted (and interacted with) at the cell rect the parent computes for it.
Use Self::Container instead if you don’t need the nested layout to interact.
Container(Box<ContainerAtom<'a>>)
A nested ContainerAtom, letting you embed a non-interactive atom-based layout as a
single atom inside another WidgetAtom.
Like Self::Widget, the nested layout is measured when the parent is sized and painted
at the cell rect the parent computes for it. Unlike Self::Widget, a ContainerAtom
has no Id or Sense, so it is never interacted with.
Implementations§
Source§impl<'a> AtomKind<'a>
impl<'a> AtomKind<'a>
Sourcepub fn text(text: impl Into<WidgetText>) -> AtomKind<'a>
pub fn text(text: impl Into<WidgetText>) -> AtomKind<'a>
See Self::Text
Sourcepub fn paint(func: impl Fn(&Ui, AtomPaintArgs) + 'a) -> AtomKind<'a>
pub fn paint(func: impl Fn(&Ui, AtomPaintArgs) + 'a) -> AtomKind<'a>
See Self::Paint
Sourcepub fn closure(
func: impl FnOnce(&Ui, IntoSizedArgs) -> IntoSizedResult<'static> + 'a,
) -> AtomKind<'a>
pub fn closure( func: impl FnOnce(&Ui, IntoSizedArgs) -> IntoSizedResult<'static> + 'a, ) -> AtomKind<'a>
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<ContainerAtom<'a>> for AtomKind<'a>
impl<'a> From<ContainerAtom<'a>> for AtomKind<'a>
Source§fn from(container: ContainerAtom<'a>) -> AtomKind<'a>
fn from(container: ContainerAtom<'a>) -> AtomKind<'a>
Source§impl<'a> From<ImageSource<'a>> for AtomKind<'a>
impl<'a> From<ImageSource<'a>> for AtomKind<'a>
Source§fn from(value: ImageSource<'a>) -> AtomKind<'a>
fn from(value: ImageSource<'a>) -> AtomKind<'a>
Source§impl<'a> From<WidgetAtom<'a>> for AtomKind<'a>
impl<'a> From<WidgetAtom<'a>> for AtomKind<'a>
Source§fn from(layout: WidgetAtom<'a>) -> AtomKind<'a>
fn from(layout: WidgetAtom<'a>) -> AtomKind<'a>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for AtomKind<'a>
impl<'a> !Send for AtomKind<'a>
impl<'a> !Sync for AtomKind<'a>
impl<'a> !UnwindSafe for AtomKind<'a>
impl<'a> Forget for AtomKind<'a>
impl<'a> Freeze for AtomKind<'a>where
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const ArcInner<RichText> is !null: Freeze,
PhantomData<ArcInner<RichText>>: Freeze,
*const ArcInner<LayoutJob> is !null: Freeze,
PhantomData<ArcInner<LayoutJob>>: Freeze,
*const ArcInner<Galley> is !null: Freeze,
PhantomData<ArcInner<Galley>>: Freeze,
&'a str: Freeze,
String: Freeze,
&'static str: Freeze,
&'static [u8]: Freeze,
*const ArcInner<[u8]> is !null: Freeze,
PhantomData<ArcInner<[u8]>>: Freeze,
*const dyn FnOnce(&Ui, IntoSizedArgs) -> IntoSizedResult<'static> + 'a is !null: Freeze,
PhantomData<dyn FnOnce(&Ui, IntoSizedArgs) -> IntoSizedResult<'static> + 'a>: Freeze,
*const ArcInner<dyn Fn(&Ui, AtomPaintArgs) + 'a> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(&Ui, AtomPaintArgs) + 'a>>: Freeze,
*const WidgetAtom<'a> is !null: Freeze,
PhantomData<WidgetAtom<'a>>: Freeze,
*const ContainerAtom<'a> is !null: Freeze,
PhantomData<ContainerAtom<'a>>: Freeze,
impl<'a> Move for AtomKind<'a>
impl<'a> Unpin for AtomKind<'a>where
*const u8 is !null: Unpin,
Arc<RichText>: Unpin,
Arc<LayoutJob>: Unpin,
Arc<Galley>: Unpin,
&'a str: Unpin,
String: Unpin,
&'static str: Unpin,
&'static [u8]: Unpin,
Arc<[u8]>: Unpin,
Box<dyn FnOnce(&Ui, IntoSizedArgs) -> IntoSizedResult<'static> + 'a>: Unpin,
Arc<dyn Fn(&Ui, AtomPaintArgs) + 'a>: Unpin,
Box<WidgetAtom<'a>>: Unpin,
Box<ContainerAtom<'a>>: Unpin,
impl<'a> UnsafeUnpin for AtomKind<'a>where
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<RichText> is !null: UnsafeUnpin,
PhantomData<ArcInner<RichText>>: UnsafeUnpin,
*const ArcInner<LayoutJob> is !null: UnsafeUnpin,
PhantomData<ArcInner<LayoutJob>>: UnsafeUnpin,
*const ArcInner<Galley> is !null: UnsafeUnpin,
PhantomData<ArcInner<Galley>>: UnsafeUnpin,
&'a str: UnsafeUnpin,
String: UnsafeUnpin,
&'static str: UnsafeUnpin,
&'static [u8]: UnsafeUnpin,
*const ArcInner<[u8]> is !null: UnsafeUnpin,
PhantomData<ArcInner<[u8]>>: UnsafeUnpin,
*const dyn FnOnce(&Ui, IntoSizedArgs) -> IntoSizedResult<'static> + 'a is !null: UnsafeUnpin,
PhantomData<dyn FnOnce(&Ui, IntoSizedArgs) -> IntoSizedResult<'static> + 'a>: UnsafeUnpin,
*const ArcInner<dyn Fn(&Ui, AtomPaintArgs) + 'a> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(&Ui, AtomPaintArgs) + 'a>>: UnsafeUnpin,
*const WidgetAtom<'a> is !null: UnsafeUnpin,
PhantomData<WidgetAtom<'a>>: UnsafeUnpin,
*const ContainerAtom<'a> is !null: UnsafeUnpin,
PhantomData<ContainerAtom<'a>>: UnsafeUnpin,
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 moreSource§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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§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