pub struct PlyContext<CustomElementData: Clone + Default + Debug = ()> {
pub max_element_count: i32,
pub max_measure_text_cache_word_count: i32,
pub debug_mode_enabled: bool,
pub culling_disabled: bool,
pub external_scroll_handling_enabled: bool,
pub debug_selected_element_id: u32,
pub generation: u32,
pub layout_dimensions: Dimensions,
pub focused_element_id: u32,
/* private fields */
}Fields§
§max_element_count: i32§max_measure_text_cache_word_count: i32§debug_mode_enabled: bool§culling_disabled: bool§external_scroll_handling_enabled: bool§debug_selected_element_id: u32§generation: u32§layout_dimensions: Dimensions§focused_element_id: u32Implementations§
Source§impl<CustomElementData: Clone + Default + Debug> PlyContext<CustomElementData>
impl<CustomElementData: Clone + Default + Debug> PlyContext<CustomElementData>
pub fn new(dimensions: Dimensions) -> Self
Sourcepub fn get_open_element_id(&self) -> u32
pub fn get_open_element_id(&self) -> u32
Returns the internal u32 id of the currently open element.
pub fn get_parent_element_id(&self) -> u32
pub fn store_text_element_config(&mut self, config: TextConfig) -> usize
pub fn open_element(&mut self)
pub fn open_element_with_id(&mut self, element_id: &Id)
pub fn configure_open_element( &mut self, declaration: &ElementDeclaration<CustomElementData>, )
pub fn close_element(&mut self)
pub fn open_text_element(&mut self, text: &str, text_config_index: usize)
pub fn begin_layout(&mut self)
pub fn end_layout(&mut self) -> &[InternalRenderCommand<CustomElementData>]
pub fn set_layout_dimensions(&mut self, dimensions: Dimensions)
pub fn set_pointer_state(&mut self, position: Vector2, is_down: bool)
pub fn update_scroll_containers( &mut self, enable_drag_scrolling: bool, scroll_delta: Vector2, delta_time: f32, touch_input_active: bool, )
pub fn hovered(&self) -> bool
pub fn on_hover(&mut self, callback: Box<dyn FnMut(Id, PointerData)>)
pub fn pressed(&self) -> bool
pub fn just_pressed(&self) -> bool
pub fn just_released(&self) -> bool
pub fn set_press_callbacks( &mut self, on_press: Option<Box<dyn FnMut(Id, PointerData)>>, on_release: Option<Box<dyn FnMut(Id, PointerData)>>, )
Sourcepub fn focused_element(&self) -> Option<Id>
pub fn focused_element(&self) -> Option<Id>
Returns the currently focused element’s ID, or None.
Sourcepub fn set_focus(&mut self, element_id: u32)
pub fn set_focus(&mut self, element_id: u32)
Sets focus to the element with the given ID, firing on_unfocus/on_focus callbacks.
Sourcepub fn clear_focus(&mut self)
pub fn clear_focus(&mut self)
Clears focus (no element is focused).
pub fn set_focus_callbacks( &mut self, on_focus: Option<Box<dyn FnMut(Id)>>, on_unfocus: Option<Box<dyn FnMut(Id)>>, )
Sourcepub fn set_text_input_callbacks(
&mut self,
on_changed: Option<Box<dyn FnMut(&str)>>,
on_submit: Option<Box<dyn FnMut(&str)>>,
)
pub fn set_text_input_callbacks( &mut self, on_changed: Option<Box<dyn FnMut(&str)>>, on_submit: Option<Box<dyn FnMut(&str)>>, )
Sets text input callbacks for the currently open element.
Sourcepub fn is_text_input_focused(&self) -> bool
pub fn is_text_input_focused(&self) -> bool
Returns true if the currently focused element is a text input.
Sourcepub fn is_focused_text_input_multiline(&self) -> bool
pub fn is_focused_text_input_multiline(&self) -> bool
Returns true if the currently focused text input is multiline.
Sourcepub fn get_text_value(&self, element_id: u32) -> &str
pub fn get_text_value(&self, element_id: u32) -> &str
Returns the text value for a text input element, or empty string if not found.
Sourcepub fn set_text_value(&mut self, element_id: u32, value: &str)
pub fn set_text_value(&mut self, element_id: u32, value: &str)
Sets the text value for a text input element.
Sourcepub fn get_cursor_pos(&self, element_id: u32) -> usize
pub fn get_cursor_pos(&self, element_id: u32) -> usize
Returns the cursor position for a text input element, or 0 if not found. When text-styling is enabled, this returns the visual position.
Sourcepub fn set_cursor_pos(&mut self, element_id: u32, pos: usize)
pub fn set_cursor_pos(&mut self, element_id: u32, pos: usize)
Sets the cursor position for a text input element.
When text-styling is enabled, pos is in visual space.
Clamps to the text length and clears any selection.
Sourcepub fn get_selection_range(&self, element_id: u32) -> Option<(usize, usize)>
pub fn get_selection_range(&self, element_id: u32) -> Option<(usize, usize)>
Returns the selection range (start, end) for a text input element, or None. When text-styling is enabled, these are visual positions.
Sourcepub fn set_selection(&mut self, element_id: u32, anchor: usize, cursor: usize)
pub fn set_selection(&mut self, element_id: u32, anchor: usize, cursor: usize)
Sets the selection range for a text input element.
anchor is where selection started, cursor is where it ends.
When text-styling is enabled, these are visual positions.
Sourcepub fn is_element_pressed(&self, element_id: u32) -> bool
pub fn is_element_pressed(&self, element_id: u32) -> bool
Returns true if the given element ID is currently pressed.
Sourcepub fn is_element_just_pressed(&self, element_id: u32) -> bool
pub fn is_element_just_pressed(&self, element_id: u32) -> bool
Returns true if the given element ID was pressed this frame.
Sourcepub fn is_element_just_released(&self, element_id: u32) -> bool
pub fn is_element_just_released(&self, element_id: u32) -> bool
Returns true if the given element ID was released this frame.
Sourcepub fn process_text_input_char(&mut self, ch: char) -> bool
pub fn process_text_input_char(&mut self, ch: char) -> bool
Process a character input event for the focused text input. Returns true if the character was consumed by a text input.
Sourcepub fn process_text_input_action(&mut self, action: TextInputAction) -> bool
pub fn process_text_input_action(&mut self, action: TextInputAction) -> bool
Process a key event for the focused text input.
action specifies which editing action to perform.
Returns true if the key was consumed.
Sourcepub fn update_text_input_blink_timers(&mut self)
pub fn update_text_input_blink_timers(&mut self)
Update blink timers for all text input states.
Sourcepub fn update_text_input_scroll(&mut self)
pub fn update_text_input_scroll(&mut self)
Update scroll offsets for text inputs to ensure cursor visibility.
Sourcepub fn update_text_input_pointer_scroll(
&mut self,
scroll_delta: Vector2,
touch_input_active: bool,
) -> bool
pub fn update_text_input_pointer_scroll( &mut self, scroll_delta: Vector2, touch_input_active: bool, ) -> bool
Handle pointer-based scrolling for text inputs: scroll wheel and drag-to-scroll.
Mobile-first: dragging scrolls the content rather than selecting text.
scroll_delta contains (x, y) scroll wheel deltas. For single-line, both axes
map to horizontal scroll. For multiline, y scrolls vertically.
Sourcepub fn clamp_text_input_scroll(&mut self)
pub fn clamp_text_input_scroll(&mut self)
Clamp text input scroll offsets to valid ranges. For multiline: clamp scroll_offset_y to [0, total_height - visible_height]. For single-line: clamp scroll_offset to [0, total_width - visible_width].
Sourcepub fn cycle_focus(&mut self, reverse: bool)
pub fn cycle_focus(&mut self, reverse: bool)
Cycle focus to the next (or previous, if reverse is true) focusable element.
This is called when Tab (or Shift+Tab) is pressed.
Sourcepub fn arrow_focus(&mut self, direction: ArrowDirection)
pub fn arrow_focus(&mut self, direction: ArrowDirection)
Move focus based on arrow key direction, using focus_left/right/up/down overrides.
Sourcepub fn handle_keyboard_activation(&mut self, pressed: bool, released: bool)
pub fn handle_keyboard_activation(&mut self, pressed: bool, released: bool)
Handle keyboard activation (Enter/Space) on the focused element.
pub fn pointer_over(&self, element_id: Id) -> bool
pub fn get_pointer_over_ids(&self) -> &[Id]
pub fn get_element_data(&self, id: Id) -> Option<BoundingBox>
pub fn get_scroll_container_data(&self, id: Id) -> ScrollContainerData
pub fn get_scroll_offset(&self) -> Vector2
pub fn set_scroll_position(&mut self, id: Id, position: Vector2)
pub fn set_max_element_count(&mut self, count: i32)
pub fn set_max_measure_text_cache_word_count(&mut self, count: i32)
pub fn set_debug_mode_enabled(&mut self, enabled: bool)
pub fn set_debug_view_width(&mut self, width: f32)
pub fn is_debug_mode_enabled(&self) -> bool
pub fn set_culling_enabled(&mut self, enabled: bool)
pub fn set_measure_text_function( &mut self, f: Box<dyn Fn(&str, &TextConfig) -> Dimensions>, )
Auto Trait Implementations§
impl<CustomElementData> Freeze for PlyContext<CustomElementData>
impl<CustomElementData = ()> !RefUnwindSafe for PlyContext<CustomElementData>
impl<CustomElementData = ()> !Send for PlyContext<CustomElementData>
impl<CustomElementData = ()> !Sync for PlyContext<CustomElementData>
impl<CustomElementData> Unpin for PlyContext<CustomElementData>where
CustomElementData: Unpin,
impl<CustomElementData> UnsafeUnpin for PlyContext<CustomElementData>
impl<CustomElementData = ()> !UnwindSafe for PlyContext<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.