pub struct Ply<CustomElementData: Clone + Default + Debug = ()> { /* private fields */ }Implementations§
Source§impl<CustomElementData: Clone + Default + Debug> Ply<CustomElementData>
impl<CustomElementData: Clone + Default + Debug> 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 async fn new(default_font: &'static FontAsset) -> Self
pub async fn new(default_font: &'static FontAsset) -> Self
Create a new Ply engine with the given default font.
Sourcepub fn new_headless(dimensions: Dimensions) -> Self
pub fn new_headless(dimensions: Dimensions) -> Self
Create a new Ply engine without text measurement.
Use Ply::set_measure_text_function to configure text measurement
before rendering any text elements.
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.