Struct Atom

Source
pub struct Atom<'a> {
    pub size: Option<Vec2>,
    pub max_size: Vec2,
    pub grow: bool,
    pub shrink: bool,
    pub kind: AtomKind<'a>,
}
Expand description

A low-level ui building block.

Implements From for String, str, crate::Image and much more for convenience. You can directly call the atom_* methods on anything that implements Into<Atom>.

use egui::AtomExt as _;
let string_atom = "Hello".atom_grow(true);
let image_atom = Image::new("some_image_url").atom_size(Vec2::splat(20.0));

Fields§

§size: Option<Vec2>§max_size: Vec2§grow: bool§shrink: bool§kind: AtomKind<'a>

The atom type

Implementations§

Source§

impl<'a> Atom<'a>

Source

pub fn grow() -> Self

Create an empty Atom marked as grow.

This will expand in size, allowing all preceding atoms to be left-aligned, and all following atoms to be right-aligned

Source

pub fn custom(id: Id, size: impl Into<Vec2>) -> Self

Create a AtomKind::Custom with a specific size.

Source

pub fn into_sized( self, ui: &Ui, available_size: Vec2, wrap_mode: Option<TextWrapMode>, ) -> SizedAtom<'a>

Turn this into a SizedAtom.

Trait Implementations§

Source§

impl<'a> Clone for Atom<'a>

Source§

fn clone(&self) -> Atom<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Atom<'a>

Source§

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

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

impl Default for Atom<'_>

Source§

fn default() -> Self

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

impl<'a, T> From<T> for Atom<'a>
where T: Into<AtomKind<'a>>,

Source§

fn from(value: T) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> Freeze for Atom<'a>

§

impl<'a> RefUnwindSafe for Atom<'a>

§

impl<'a> Send for Atom<'a>

§

impl<'a> Sync for Atom<'a>

§

impl<'a> Unpin for Atom<'a>

§

impl<'a> UnwindSafe for Atom<'a>

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<'a, T> AtomExt<'a> for T
where T: Into<Atom<'a>>,

Source§

fn atom_size(self, size: Vec2) -> Atom<'a>

Set the atom to a fixed size. Read more
Source§

fn atom_grow(self, grow: bool) -> Atom<'a>

Grow this atom to the available space. Read more
Source§

fn atom_shrink(self, shrink: bool) -> Atom<'a>

Shrink this atom if there isn’t enough space. Read more
Source§

fn atom_max_size(self, max_size: Vec2) -> Atom<'a>

Set the maximum size of this atom. Read more
Source§

fn atom_max_width(self, max_width: f32) -> Atom<'a>

Set the maximum width of this atom. Read more
Source§

fn atom_max_height(self, max_height: f32) -> Atom<'a>

Set the maximum height of this atom.
Source§

fn atom_max_height_font_size(self, ui: &Ui) -> Atom<'a>
where Self: Sized,

Set the max height of this atom to match the font size. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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<'a, T> IntoAtoms<'a> for T
where T: Into<Atom<'a>>,

Source§

fn collect(self, atoms: &mut Atoms<'a>)

Source§

fn into_atoms(self) -> Atoms<'a>
where Self: Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> SerializableAny for T
where T: 'static + Any + Clone + for<'a> Send + Sync,