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, )
pub fn hovered(&self) -> bool
pub fn on_hover(&mut self, callback: Box<dyn FnMut(Id, PointerData)>)
pub fn pressed(&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 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,
) -> bool
pub fn update_text_input_pointer_scroll( &mut self, scroll_delta: Vector2, ) -> 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.