pub struct Ui<'ply, CustomElementData: Clone + Default + Debug = ()> { /* private fields */ }Implementations§
Source§impl<'ply, CustomElementData: Clone + Default + Debug> Ui<'ply, CustomElementData>
impl<'ply, CustomElementData: Clone + Default + Debug> Ui<'ply, CustomElementData>
Sourcepub fn element(&mut self) -> ElementBuilder<'_, CustomElementData>
pub fn element(&mut self) -> ElementBuilder<'_, CustomElementData>
Creates a new element builder for configuring and adding an element.
Finalize with .children(|ui| {...}) or .empty().
Sourcepub fn text(
&mut self,
text: &str,
config_fn: impl FnOnce(&mut TextConfig) -> &mut TextConfig,
)
pub fn text( &mut self, text: &str, config_fn: impl FnOnce(&mut TextConfig) -> &mut TextConfig, )
Adds a text element to the current open element or to the root layout.
Sourcepub fn scroll_offset(&self) -> Vector2
pub fn scroll_offset(&self) -> Vector2
Returns the current scroll offset of the open scroll container.
Methods from Deref<Target = Ply<CustomElementData>>§
Sourcepub fn begin(&mut self) -> Ui<'_, CustomElementData>
pub fn begin(&mut self) -> Ui<'_, CustomElementData>
Starts a new frame, returning a Ui handle for building the element tree.
Sourcepub fn pointer_over(&self, cfg: impl Into<Id>) -> bool
pub fn pointer_over(&self, cfg: impl Into<Id>) -> bool
Returns true if the pointer is currently over the element with the given ID.
Sourcepub fn pointer_over_ids(&self) -> Vec<Id>
pub fn pointer_over_ids(&self) -> Vec<Id>
Z-sorted list of element IDs that the cursor is currently over
Sourcepub fn set_measure_text_function<F>(&mut self, callback: F)
pub fn set_measure_text_function<F>(&mut self, callback: F)
Set the callback for text measurement
Sourcepub fn max_element_count(&mut self, max_element_count: u32)
pub fn max_element_count(&mut self, max_element_count: u32)
Sets the maximum number of elements that ply supports Use only if you know what you are doing or you’re getting errors from ply
Sourcepub fn max_measure_text_cache_word_count(&mut self, count: u32)
pub fn max_measure_text_cache_word_count(&mut self, count: u32)
Sets the capacity of the cache used for text in the measure text function Use only if you know what you are doing or you’re getting errors from ply
Sourcepub fn set_debug_mode(&mut self, enable: bool)
pub fn set_debug_mode(&mut self, enable: bool)
Enables or disables the debug mode of ply
Sourcepub fn is_debug_mode(&self) -> bool
pub fn is_debug_mode(&self) -> bool
Returns if debug mode is enabled
Sourcepub fn set_culling(&mut self, enable: bool)
pub fn set_culling(&mut self, enable: bool)
Enables or disables culling
Sourcepub fn set_layout_dimensions(&mut self, dimensions: Dimensions)
pub fn set_layout_dimensions(&mut self, dimensions: Dimensions)
Sets the dimensions of the global layout. Use if, for example the window size you render changed.
Sourcepub fn pointer_state(&mut self, position: Vector2, is_down: bool)
pub fn pointer_state(&mut self, position: Vector2, is_down: bool)
Updates the state of the pointer for ply. Used to update scroll containers and for interactions functions.
Sourcepub fn update_scroll_containers(
&mut self,
drag_scrolling_enabled: bool,
scroll_delta: Vector2,
delta_time: f32,
)
pub fn update_scroll_containers( &mut self, drag_scrolling_enabled: bool, scroll_delta: Vector2, delta_time: f32, )
Processes scroll containers using the current pointer state and scroll delta.
Sourcepub fn focused_element(&self) -> Option<Id>
pub fn focused_element(&self) -> Option<Id>
Returns the ID of the currently focused element, or None.
Sourcepub fn clear_focus(&mut self)
pub fn clear_focus(&mut self)
Clears focus (no element is focused).
Sourcepub fn get_text_value(&self, id: impl Into<Id>) -> &str
pub fn get_text_value(&self, id: impl Into<Id>) -> &str
Returns the text value of a text input element. Returns an empty string if the element is not a text input or doesn’t exist.
Sourcepub fn set_text_value(&mut self, id: impl Into<Id>, value: &str)
pub fn set_text_value(&mut self, id: impl Into<Id>, value: &str)
Sets the text value of a text input element.
Sourcepub fn get_cursor_pos(&self, id: impl Into<Id>) -> usize
pub fn get_cursor_pos(&self, id: impl Into<Id>) -> usize
Returns the cursor position of a text input element. Returns 0 if the element is not a text input or doesn’t exist.
Sourcepub fn set_cursor_pos(&mut self, id: impl Into<Id>, pos: usize)
pub fn set_cursor_pos(&mut self, id: impl Into<Id>, pos: usize)
Sets the cursor position of a text input element. Clamps to the text length and clears any selection.
Sourcepub fn get_selection_range(&self, id: impl Into<Id>) -> Option<(usize, usize)>
pub fn get_selection_range(&self, id: impl Into<Id>) -> Option<(usize, usize)>
Returns the selection range (start, end) for a text input element, or None.
Sourcepub fn set_selection(&mut self, id: impl Into<Id>, anchor: usize, cursor: usize)
pub fn set_selection(&mut self, id: impl Into<Id>, anchor: usize, cursor: usize)
Sets the selection range for a text input element.
anchor is where selection started, cursor is where it ends.
Sourcepub fn is_pressed(&self, id: impl Into<Id>) -> bool
pub fn is_pressed(&self, id: impl Into<Id>) -> bool
Returns true if the given element is currently pressed.
Sourcepub fn bounding_box(&self, id: impl Into<Id>) -> Option<BoundingBox>
pub fn bounding_box(&self, id: impl Into<Id>) -> Option<BoundingBox>
Returns the bounding box of the element with the given ID, if it exists.
Sourcepub fn scroll_container_data(
&self,
id: impl Into<Id>,
) -> Option<ScrollContainerData>
pub fn scroll_container_data( &self, id: impl Into<Id>, ) -> Option<ScrollContainerData>
Returns scroll container state for the element with the given ID, if it is a scroll container.
Sourcepub fn eval(&mut self) -> Vec<RenderCommand<CustomElementData>>
pub fn eval(&mut self) -> Vec<RenderCommand<CustomElementData>>
Evaluate the layout and return all render commands.
Sourcepub async fn show(
&mut self,
handle_custom_command: impl Fn(&RenderCommand<CustomElementData>),
)
pub async fn show( &mut self, handle_custom_command: impl Fn(&RenderCommand<CustomElementData>), )
Evaluate the layout and render all commands.
Trait Implementations§
Auto Trait Implementations§
impl<'ply, CustomElementData> Freeze for Ui<'ply, CustomElementData>
impl<'ply, CustomElementData = ()> !RefUnwindSafe for Ui<'ply, CustomElementData>
impl<'ply, CustomElementData = ()> !Send for Ui<'ply, CustomElementData>
impl<'ply, CustomElementData = ()> !Sync for Ui<'ply, CustomElementData>
impl<'ply, CustomElementData> Unpin for Ui<'ply, CustomElementData>
impl<'ply, CustomElementData> UnsafeUnpin for Ui<'ply, CustomElementData>
impl<'ply, CustomElementData = ()> !UnwindSafe for Ui<'ply, CustomElementData>
Blanket Implementations§
Source§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
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
impl<T, U> RoundInto<U> for Twhere
U: RoundFrom<T>,
Source§fn round_into(self) -> U
fn round_into(self) -> U
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.