pub struct ScrollingComponent {
pub viewport_height: f32,
pub content_height: f32,
pub scroll_offset: f32,
pub track: Option<ComponentId>,
pub track_base_pos: [f32; 3],
pub drag_scope: Option<ComponentId>,
/* private fields */
}Expand description
Generic scroll state for moving a content track inside a clipped viewport.
ScrollingComponent does not own clipping; it only tracks viewport/content sizes,
current offset, which transform should be moved by the scroll runtime, and the
drag scope currently bridged into scroll events.
Expected topology:
viewport_root ← usually clipped by StyleComponent::overflow
└── ScrollingComponent ← owned by ScrollingSystem
└── scroll_track ← moved in +Y as scroll_offset increases
├── child_0
├── child_1
└── ...If no explicit track is assigned, ScrollingSystem now creates an internal Router plus an
owned __scroll_track transform under the ScrollingComponent, and routed children are sent
there both at init time and on later direct attaches.
Fields§
§viewport_height: f32Height of the clipped viewport in scroll-local/layout units.
content_height: f32Height of the scrollable content in scroll-local/layout units.
scroll_offset: f32Current scroll offset in scroll-local/layout units. 0.0 = top.
track: Option<ComponentId>Transform moved by the scroll runtime.
If unset at init time, the runtime will create an owned internal track by default.
track_base_pos: [f32; 3]Base local-space position of track before any scrolling is applied.
drag_scope: Option<ComponentId>Ancestor scope currently forwarding drag motion into this scrolling component.
Implementations§
Source§impl ScrollingComponent
impl ScrollingComponent
pub fn new(viewport_height: f32, content_height: f32) -> Self
pub fn set_track(&mut self, track: ComponentId, base_pos: [f32; 3])
pub fn set_drag_scope(&mut self, drag_scope: ComponentId)
pub fn set_content_height(&mut self, content_height: f32) -> bool
Sourcepub fn max_scroll(&self) -> f32
pub fn max_scroll(&self) -> f32
Maximum scroll distance in scroll-local/layout units.
Sourcepub fn apply_drag(&mut self, delta_y: f32) -> bool
pub fn apply_drag(&mut self, delta_y: f32) -> bool
Update scroll_offset by a scroll-local Y drag delta.
Sign convention: dragging up (positive delta_y) reveals content lower in the list.
Sourcepub fn track_translation(&self) -> [f32; 3]
pub fn track_translation(&self) -> [f32; 3]
Current translation that should be applied to the scroll track.
Sourcepub fn clamp_to_content(&mut self) -> bool
pub fn clamp_to_content(&mut self) -> bool
Clamp scroll after content size changes. Returns true if the position changed.
Trait Implementations§
Source§impl Clone for ScrollingComponent
impl Clone for ScrollingComponent
Source§fn clone(&self) -> ScrollingComponent
fn clone(&self) -> ScrollingComponent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Component for ScrollingComponent
impl Component for ScrollingComponent
Source§fn name(&self) -> &'static str
fn name(&self) -> &'static str
fn set_id(&mut self, id: ComponentId)
fn as_any(&self) -> &dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Source§fn init(&mut self, emit: &mut dyn SignalEmitter, component: ComponentId)
fn init(&mut self, emit: &mut dyn SignalEmitter, component: ComponentId)
Source§fn to_mms_ast(&self, _world: &World) -> ComponentExpression
fn to_mms_ast(&self, _world: &World) -> ComponentExpression
Source§fn cleanup(&mut self, _emit: &mut dyn SignalEmitter, _component: ComponentId)
fn cleanup(&mut self, _emit: &mut dyn SignalEmitter, _component: ComponentId)
Auto Trait Implementations§
impl Freeze for ScrollingComponent
impl RefUnwindSafe for ScrollingComponent
impl Send for ScrollingComponent
impl Sync for ScrollingComponent
impl Unpin for ScrollingComponent
impl UnsafeUnpin for ScrollingComponent
impl UnwindSafe for ScrollingComponent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.