Struct ScrollRegion

Source
pub struct ScrollRegion { /* private fields */ }
Expand description

Bounded content registry with the existing UI’s press/release capture rules. Construction reserves storage once; update/navigation/drag do not grow it. Focus survives scrolling and cancellation. Resize/reflow cancels a pending press, preserves eligible focus IDs, and clamps the offset without activation.

Implementations§

Source§

impl ScrollRegion

Source

pub fn new(capacity: usize) -> ScrollRegion

Reserve at most SCROLL_ITEM_CAPACITY items; zero capacity is legal. See the module recipe for the update-before-paint lifecycle.

Source

pub fn capacity(&self) -> usize

Source

pub fn scroll(&self) -> &ScrollState

Source

pub fn bounds(&self) -> Rect

Source

pub fn focused(&self) -> Option<u64>

Source

pub fn activated(&self, id: u64) -> bool

Source

pub fn set_gamepad(&mut self, pad: u8) -> Result<(), UiError>

Select the player’s controller (0..4). New/reconnected pads need a fresh edge after their first update, matching the existing Ui adapter.

Source

pub fn update( &mut self, viewport: Viewport, bounds: Rect, content_extent: f32, items: &[ScrollItem], enabled: bool, ) -> Result<(), UiError>

Validate/rebuild content, then handle the current host journal once.

Wheel uses 40 logical units per host notch, positive host wheel meaning up. Mouse/one-touch drags start anywhere inside the region, cancel child clicks after six logical units of movement, and continue outside it. Tab/arrows and selected-pad D-pad reveal focus; Page Up/Down move one viewport, Home/End move to the boundaries. Enter/pad A confirm. Feed remapped edges through focus_next, page, and activate_focused.

Bounds must be inside viewport.bounds(). Items must be unique and fully inside the declared content. Errors preserve the old layout/offset/focus but cancel capture/activation and disable acceptance until a valid update. Hidden, disabled, host-unfocused, journal-overflow and settings-editor frames cancel gestures. Duplicate calls in a host frame do not replay events and clear the previous activation result.

Source

pub fn focus_next(&mut self, reverse: bool) -> Option<u64>

Submission-order navigation including offscreen items, with wrap and disabled/zero-area skipping inherited from UiState. Reveals the result before the next paint; does not activate it or change another UI’s focus.

Source

pub fn reveal(&mut self, id: u64) -> bool

Reveal a registered enabled, nonempty item without selecting or activating it. Unknown/disabled IDs return false. Returns whether the offset changed.

Source

pub fn scroll_by(&mut self, delta: f32) -> Result<bool, UiError>

Explicit/remapped scroll input. Cancels a pending click even at an exhausted boundary. Nonfinite deltas fail without moving or canceling anything.

Source

pub fn page(&mut self, reverse: bool) -> bool

Explicit/remapped Page Up/Down, retaining focus without activating a row.

Source

pub fn activate_focused(&mut self) -> Option<u64>

Confirm the focused visible item while input is enabled. If focus is entirely clipped (for example after Page Down), reveal it and return None; another edge is required to activate. No focus is auto-created.

Source

pub fn rect(&self, id: u64) -> Option<Rect>

Current translated geometry; clip it against bounds() for paint.

Source

pub fn button( &self, ui: &mut Ui, id: u64, label: &str, style: ButtonStyle, ) -> Result<(), UiError>

Queue a registered item using the existing fixed-size HUD button and clip stack. The focused item uses the style’s focus fill and original fill ink. This is paint only: inspect this region’s activated, not Ui::activated. On queue failure the clip is still popped; earlier paint commands remain.

Source

pub fn cancel(&mut self)

Cancel mouse/touch capture and the pending activation, preserving focus and offset. Call on consumer context changes even without another update.

Source

pub fn reset(&mut self)

Reset offset, focus, content registration and input acceptance while retaining allocated capacity and the once-per-host-frame input guard.

Auto Trait Implementations§

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