Skip to main content

PlyContext

Struct PlyContext 

Source
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: u32

Implementations§

Source§

impl<CustomElementData: Clone + Default + Debug> PlyContext<CustomElementData>

Source

pub fn new(dimensions: Dimensions) -> Self

Source

pub fn get_open_element_id(&self) -> u32

Returns the internal u32 id of the currently open element.

Source

pub fn get_parent_element_id(&self) -> u32

Source

pub fn store_text_element_config(&mut self, config: TextConfig) -> usize

Source

pub fn open_element(&mut self)

Source

pub fn open_element_with_id(&mut self, element_id: &Id)

Source

pub fn configure_open_element( &mut self, declaration: &ElementDeclaration<CustomElementData>, )

Source

pub fn close_element(&mut self)

Source

pub fn open_text_element(&mut self, text: &str, text_config_index: usize)

Source

pub fn begin_layout(&mut self)

Source

pub fn end_layout(&mut self) -> &[InternalRenderCommand<CustomElementData>]

Source

pub fn set_layout_dimensions(&mut self, dimensions: Dimensions)

Source

pub fn set_pointer_state(&mut self, position: Vector2, is_down: bool)

Source

pub fn update_scroll_containers( &mut self, enable_drag_scrolling: bool, scroll_delta: Vector2, delta_time: f32, )

Source

pub fn hovered(&self) -> bool

Source

pub fn on_hover(&mut self, callback: Box<dyn FnMut(Id, PointerData)>)

Source

pub fn pressed(&self) -> bool

Source

pub fn set_press_callbacks( &mut self, on_press: Option<Box<dyn FnMut(Id, PointerData)>>, on_release: Option<Box<dyn FnMut(Id, PointerData)>>, )

Source

pub fn focused(&self) -> bool

Returns true if the currently open element has focus.

Source

pub fn focused_element(&self) -> Option<Id>

Returns the currently focused element’s ID, or None.

Source

pub fn set_focus(&mut self, element_id: u32)

Sets focus to the element with the given ID, firing on_unfocus/on_focus callbacks.

Source

pub fn clear_focus(&mut self)

Clears focus (no element is focused).

Source

pub fn set_focus_callbacks( &mut self, on_focus: Option<Box<dyn FnMut(Id)>>, on_unfocus: Option<Box<dyn FnMut(Id)>>, )

Source

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.

Source

pub fn is_text_input_focused(&self) -> bool

Returns true if the currently focused element is a text input.

Source

pub fn is_focused_text_input_multiline(&self) -> bool

Returns true if the currently focused text input is multiline.

Source

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.

Source

pub fn set_text_value(&mut self, element_id: u32, value: &str)

Sets the text value for a text input element.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn is_element_pressed(&self, element_id: u32) -> bool

Returns true if the given element ID is currently pressed.

Source

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.

Source

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.

Update blink timers for all text input states.

Source

pub fn update_text_input_scroll(&mut self)

Update scroll offsets for text inputs to ensure cursor visibility.

Source

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.

Source

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].

Source

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.

Source

pub fn arrow_focus(&mut self, direction: ArrowDirection)

Move focus based on arrow key direction, using focus_left/right/up/down overrides.

Source

pub fn handle_keyboard_activation(&mut self, pressed: bool, released: bool)

Handle keyboard activation (Enter/Space) on the focused element.

Source

pub fn pointer_over(&self, element_id: Id) -> bool

Source

pub fn get_pointer_over_ids(&self) -> &[Id]

Source

pub fn get_element_data(&self, id: Id) -> Option<BoundingBox>

Source

pub fn get_scroll_container_data(&self, id: Id) -> ScrollContainerData

Source

pub fn get_scroll_offset(&self) -> Vector2

Source

pub fn set_max_element_count(&mut self, count: i32)

Source

pub fn set_max_measure_text_cache_word_count(&mut self, count: i32)

Source

pub fn set_debug_mode_enabled(&mut self, enabled: bool)

Source

pub fn is_debug_mode_enabled(&self) -> bool

Source

pub fn set_culling_enabled(&mut self, enabled: bool)

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more