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>
impl<'ui, C: Context, S> Ui<'ui, C, S>
Sourcepub fn interact<K: Interact<C>>(&mut self, interaction: K) -> K::Response
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
Sourcepub fn animate(
&mut self,
target: f32,
animation: impl Into<Animation>,
options: AnimationOptions,
) -> f32
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
pub fn animate_loop(&mut self, tween: Tween) -> f32
Sourcepub fn timer(&mut self, duration: Duration) -> Timer<'_>
pub fn timer(&mut self, duration: Duration) -> Timer<'_>
fires once, duration after the target first calls it from this site or after a reset
Sourcepub fn interval(&mut self, period: Duration) -> Timer<'_>
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
Sourcepub fn focus(&mut self)
pub fn focus(&mut self)
focuses the target from the next build while it requests an interaction
Sourcepub fn focus_moved(&self) -> bool
pub fn focus_moved(&self) -> bool
whether focus changed from the previous build
Sourcepub fn clear_focus(&mut self)
pub fn clear_focus(&mut self)
clears focus from the next build
Sourcepub fn context_mut(&mut self) -> &mut C
pub fn context_mut(&mut self) -> &mut C
access mutable context during frame construction
Sourcepub fn mouse_position(&self) -> Option<Point<C::Scalar>>
pub fn mouse_position(&self) -> Option<Point<C::Scalar>>
the mouse cursor position, independent of touches
Sourcepub fn contact_position(&self, id: ContactId) -> Option<Point<C::Scalar>>
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
Sourcepub fn input(&self) -> &Input<C::Scalar>
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.
pub fn screen(&self) -> Rect<C::Scalar>
pub fn time(&self) -> Duration
pub fn request_frame(&mut self)
Source§impl<'ui, C: Context, S: Local> Ui<'ui, C, S>
impl<'ui, C: Context, S: Local> Ui<'ui, C, S>
Sourcepub fn node(&mut self, id: Id) -> Ui<'_, C, Ref>
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
Sourcepub fn resolve(&mut self, scope: Scope, key: impl Key) -> Id
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
Sourcepub fn scope(&mut self) -> Scope
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
Sourcepub fn insert<W: Widget<C, Insert>>(&mut self, widget: W) -> W::Response
pub fn insert<W: Widget<C, Insert>>(&mut self, widget: W) -> W::Response
inserts content into the current node
Sourcepub fn measure<R, F>(&mut self, measure: F)
pub fn measure<R, F>(&mut self, measure: F)
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.
Sourcepub fn focus_within(&self) -> Option<Id>
pub fn focus_within(&self) -> Option<Id>
the focused node, if it was beneath this one in the previous layout
Sourcepub fn scratch(&self) -> &'ui ScratchBuffer
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>
impl<'ui, C: Context, S: Owned> Ui<'ui, C, S>
Sourcepub fn constrain(self, limits: Constraints<C::Scalar>) -> Self
pub fn constrain(self, limits: Constraints<C::Scalar>) -> Self
sets this node’s size limits
Sourcepub fn place<P: Place<C>>(&mut self, target: Id, place: P) -> Ui<'_, C, Build>
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
Sourcepub fn place_in<P: Place<C>>(
&mut self,
scope: Scope,
key: impl Key,
target: Id,
place: P,
) -> Ui<'_, C, Build>
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
pub fn motion(self, motion: Motion) -> Self
Sourcepub fn parent(self, target: Id) -> Self
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
Sourcepub fn clip(self, radius: impl Into<Corners<C::Scalar>>) -> Self
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
Sourcepub fn z_index(self, z_index: i16) -> Self
pub fn z_index(self, z_index: i16) -> Self
sets this node’s paint order among its visual siblings
pub fn hit(self, hit: Sides<C::Scalar>) -> Self
Source§impl<'ui, C: Context, L: Layout<C>> Ui<'ui, C, Open<L>>
impl<'ui, C: Context, L: Layout<C>> Ui<'ui, C, Open<L>>
Sourcepub fn child(&mut self) -> Ui<'_, C, Child<L::Item>>
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
Sourcepub fn child_in(
&mut self,
scope: Scope,
key: impl Key,
) -> Ui<'_, C, Child<L::Item>>
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
Sourcepub fn layout_child(
&mut self,
child: Id,
bounds: Constraints<C::Scalar>,
) -> Size<C::Scalar>
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