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
impl ScrollRegion
Sourcepub fn new(capacity: usize) -> ScrollRegion
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.
pub fn capacity(&self) -> usize
pub fn scroll(&self) -> &ScrollState
pub fn bounds(&self) -> Rect
pub fn focused(&self) -> Option<u64>
pub fn activated(&self, id: u64) -> bool
Sourcepub fn set_gamepad(&mut self, pad: u8) -> Result<(), UiError>
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.
Sourcepub fn update(
&mut self,
viewport: Viewport,
bounds: Rect,
content_extent: f32,
items: &[ScrollItem],
enabled: bool,
) -> Result<(), UiError>
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.
Sourcepub fn focus_next(&mut self, reverse: bool) -> Option<u64>
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.
Sourcepub fn reveal(&mut self, id: u64) -> bool
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.
Sourcepub fn scroll_by(&mut self, delta: f32) -> Result<bool, UiError>
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.
Sourcepub fn page(&mut self, reverse: bool) -> bool
pub fn page(&mut self, reverse: bool) -> bool
Explicit/remapped Page Up/Down, retaining focus without activating a row.
Sourcepub fn activate_focused(&mut self) -> Option<u64>
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.
Sourcepub fn rect(&self, id: u64) -> Option<Rect>
pub fn rect(&self, id: u64) -> Option<Rect>
Current translated geometry; clip it against bounds() for paint.
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.