pub struct ScrollController { /* private fields */ }Expand description
LPAR-05 scroll controller.
Consumes DragStart/DragMove/DragEnd events and tick advances to drive
scroll offsets on ObjectNode-based scroll containers. Call
process on every drag event and
tick on every Event::Tick.
§Determinism
Given identical (event, tick) input sequences, the controller produces
identical emitted-event and offset sequences (LPAR-05 §8.1).
§Thread safety
ScrollController is not Send or Sync. Use it from a single thread.
Implementations§
Source§impl ScrollController
impl ScrollController
Sourcepub fn new(config: ScrollConfig) -> Self
pub fn new(config: ScrollConfig) -> Self
Create a new controller with the given configuration.
Sourcepub fn default_config() -> Self
pub fn default_config() -> Self
Create a new controller with default configuration.
Sourcepub fn tick(&mut self, root: &mut ObjectNode, sink: &mut dyn FnMut(Rect))
pub fn tick(&mut self, root: &mut ObjectNode, sink: &mut dyn FnMut(Rect))
Advance the internal tick counter and process any active throw/snap tween.
Call this once per Event::Tick. The sink callback receives each
viewport dirty rect for every effective offset change.
Sourcepub fn process(
&mut self,
root: &mut ObjectNode,
ev: &Event,
sink: &mut dyn FnMut(Rect),
)
pub fn process( &mut self, root: &mut ObjectNode, ev: &Event, sink: &mut dyn FnMut(Rect), )
Process a drag event (DragStart, DragMove, or DragEnd).
Pass the drag stream event from the DragRecognizer. Other events are
silently ignored (use tick for Event::Tick).
The sink callback receives viewport dirty rects for every effective
offset change.
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Return true when a scroll session is currently active (between
ScrollBegin and ScrollEnd, inclusive of the throw phase).
Use this from the platform layer to determine whether a drag event has been absorbed by the scroll controller so that it MUST NOT also be dispatched as a normal drag gesture (LPAR-05 §7.2).
Sourcepub fn cancel_if_active(
&mut self,
root: &mut ObjectNode,
path: &[usize],
sink: &mut dyn FnMut(Rect),
)
pub fn cancel_if_active( &mut self, root: &mut ObjectNode, path: &[usize], sink: &mut dyn FnMut(Rect), )
Notify the controller that the container at path is being invalidated
(detached, hidden, or SCROLLABLE cleared) during an active session.
If the active session targets that container, ScrollEnd is emitted
before the structural change becomes visible (LPAR-05 §7.6). Call this
before mutating the node.