Skip to main content

Ui

Struct Ui 

Source
pub struct Ui<'ui, C: Context, S = Build> { /* private fields */ }
Expand description

scoped handle for building a tree node

its state mode determines which operations are available

Implementations§

Source§

impl<'ui, C: Context, S> Ui<'ui, C, S>

Source

pub fn id(&self) -> Id

the target’s stable id

Source

pub fn area(&self) -> Option<Rect<C::Scalar>>

the target’s area from the previous layout

Source

pub fn interact<K: Interact<C>>(&mut self, interaction: K) -> K::Response

adds interaction to the target and returns its latest response

one interaction of each kind per target, repeated requests share it

Source

pub fn animate( &mut self, target: f32, animation: impl Into<Animation>, options: AnimationOptions, ) -> f32

animates toward target, keyed by the target and call site, then by call order within a frame

Source

pub fn animate_loop(&mut self, tween: Tween) -> f32

Source

pub fn timer(&mut self, duration: Duration) -> Timer<'_>

fires once, duration after the target first calls it from this site or after a reset

Source

pub fn interval(&mut self, period: Duration) -> Timer<'_>

fires every period, counting from when the target first calls it from this site or from a reset

Source

pub fn focus(&mut self)

focuses the target from the next build while it requests an interaction

Source

pub fn focused(&self) -> bool

whether the target holds focus as this build began

Source

pub fn focus_moved(&self) -> bool

whether focus changed from the previous build

Source

pub fn clear_focus(&mut self)

clears focus from the next build

Source

pub fn context(&self) -> &C

access context during frame construction

Source

pub fn context_mut(&mut self) -> &mut C

access mutable context during frame construction

Source

pub fn mouse_position(&self) -> Option<Point<C::Scalar>>

the mouse cursor position, independent of touches

Source

pub fn contact_position(&self, id: ContactId) -> Option<Point<C::Scalar>>

the position of a contact in this frame

ended and cancelled contacts remain available until the next build

Source

pub fn input(&self) -> &Input<C::Scalar>

this frame’s input regardless of focus or claims

handle keyboard shortcuts through an interaction to respect input routing.

Source

pub fn screen(&self) -> Rect<C::Scalar>

Source

pub fn time(&self) -> Duration

Source

pub fn request_frame(&mut self)

Source§

impl<'ui, C: Context, S: Local> Ui<'ui, C, S>

Source

pub fn node(&mut self, id: Id) -> Ui<'_, C, Ref>

refers to the node with id, which may be built later, and keeps its id through this build

Source

pub fn resolve(&mut self, scope: Scope, key: impl Key) -> Id

resolves key in scope to its id, taking a slot if nothing holds it yet

Source

pub fn scope(&mut self) -> Scope

a scope for keys of this node and call site, so keys of unrelated code never meet

scopes made at one call site repeat within a build, told apart by their order

Source

pub fn insert<W: Widget<C, Insert>>(&mut self, widget: W) -> W::Response

inserts content into the current node

Source

pub fn paint<F>(&mut self, paint: F)
where F: Fn(&mut PaintCx<'_, C>, Rect<C::Scalar>) + 'static,

schedules a deferred paint closure on the current node

Source

pub fn measure<R, F>(&mut self, measure: F)
where R: Into<Fit<Size<C::Scalar>>>, F: Fn(&mut C, Constraints<C::Scalar>) -> R + 'static,

registers a deferred measurement closure on the current node

measurement may be skipped under tight constraints or when widened past natural width. painting must not depend on prior measurement.

Source

pub fn focus_within(&self) -> Option<Id>

the focused node, if it was beneath this one in the previous layout

Source

pub fn parent_id(&self) -> Id

the id of this node’s structural parent, or its own for the root

Source

pub fn scratch(&self) -> &'ui ScratchBuffer

temporary storage that stays usable while building this node

Source§

impl<'ui, C: Context, S: Owned> Ui<'ui, C, S>

Source

pub fn constrain(self, limits: Constraints<C::Scalar>) -> Self

sets this node’s size limits

Source

pub fn place<P: Place<C>>(&mut self, target: Id, place: P) -> Ui<'_, C, Build>

creates a child placed against target outside its parent’s flow

a target not built before this node places it against its parent

Source

pub fn place_in<P: Place<C>>( &mut self, scope: Scope, key: impl Key, target: Id, place: P, ) -> Ui<'_, C, Build>

creates the child keyed key in scope, placed against target outside its parent’s flow

a target not built before this node places it against its parent

Source

pub fn motion(self, motion: Motion) -> Self

Source

pub fn parent(self, target: Id) -> Self

selects the parent for stacking, clipping and containing size

positioning stays with its anchor. a target not built before this node leaves its own parent

Source

pub fn clip(self, radius: impl Into<Corners<C::Scalar>>) -> Self

clips drawing and hit testing of this node and its visual descendants to its rounded area

Source

pub fn z_index(self, z_index: i16) -> Self

sets this node’s paint order among its visual siblings

Source

pub fn hit(self, hit: Sides<C::Scalar>) -> Self

Source§

impl<'ui, C: Context, S: NoLayout> Ui<'ui, C, S>

Source

pub fn build<W: Widget<C>>(self, widget: W) -> W::Response

builds a widget in this node

Source

pub fn layout<L: Layout<C>>(self, layout: L) -> Ui<'ui, C, Open<L>>

establishes the current node’s layout

Source§

impl<'ui, C: Context, I: 'static> Ui<'ui, C, Child<I>>

Source

pub fn item(self, item: I) -> Ui<'ui, C, Build>

sets this child’s layout item

Source§

impl<'ui, C: Context, L: Layout<C>> Ui<'ui, C, Open<L>>

Source

pub fn child(&mut self) -> Ui<'_, C, Child<L::Item>>

creates a child identified by where it is built

children built from one place are told apart by the order they are built in

Source

pub fn child_in( &mut self, scope: Scope, key: impl Key, ) -> Ui<'_, C, Child<L::Item>>

creates the child keyed key in scope rather than one identified by where it is built

it keeps its state as its siblings change or it moves to another parent, as its key stays. Ui::resolve with the same scope and key returns its id before it is built

Source

pub fn layout_child( &mut self, child: Id, bounds: Constraints<C::Scalar>, ) -> Size<C::Scalar>

lays out a built child now and returns its current animated size under bounds

the layout pass lays it out again with whatever bounds this node’s layout gives it

Source

pub fn pad(self, padding: impl Into<Sides<C::Scalar>>) -> Self

insets this node’s children while painted content keeps the full box

Auto Trait Implementations§

§

impl<'ui, C, S = Build> !RefUnwindSafe for Ui<'ui, C, S>

§

impl<'ui, C, S = Build> !Send for Ui<'ui, C, S>

§

impl<'ui, C, S = Build> !Sync for Ui<'ui, C, S>

§

impl<'ui, C, S = Build> !UnwindSafe for Ui<'ui, C, S>

§

impl<'ui, C, S> Forget for Ui<'ui, C, S>

§

impl<'ui, C, S> Freeze for Ui<'ui, C, S>

§

impl<'ui, C, S> Move for Ui<'ui, C, S>

§

impl<'ui, C, S> Unpin for Ui<'ui, C, S>
where S: Unpin, &'ui mut Tree<C>: Unpin, &'ui mut C: Unpin, &'ui ScratchBuffer: Unpin, NonZero<u32>: Unpin,

§

impl<'ui, C, S> UnsafeUnpin for Ui<'ui, C, S>

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<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> 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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.