zng::scroll

Struct SCROLL

source
pub struct SCROLL;
Expand description

Controls the parent scroll.

Implementations§

source§

impl SCROLL

source

pub fn try_id(&self) -> Option<WidgetId>

Gets the ID of the scroll ancestor represented by the SCROLL.

source

pub fn id(&self) -> WidgetId

Gets the ID of the scroll ancestor represented by the SCROLL.

§Panics

Panics if not inside a scroll.

source

pub fn config_node(&self, child: impl UiNode) -> impl UiNode

New node that holds data for the SCROLL context.

Scroll implementers must add this node to their context.

source

pub fn mode(&self) -> ReadOnlyVar<ScrollMode, ContextVar<ScrollMode>>

Scroll mode of the parent scroll.

source

pub fn vertical_offset(&self) -> ContextVar<Factor>

Vertical offset of the parent scroll.

The value is a percentage of content.height - viewport.height.

This variable is usually read-write, but you should avoid modifying it directly as direct assign as the value is not validated and does not participate in smooths scrolling. Prefer the scroll methods of this service to scroll.

source

pub fn horizontal_offset(&self) -> ContextVar<Factor>

Horizontal offset of the parent scroll.

The value is a percentage of content.width - viewport.width.

This variable is usually read-write, but you should avoid modifying it directly as direct assign as the value is not validated and does not participate in smooths scrolling. Prefer the scroll methods of this service to scroll.

source

pub fn zoom_scale(&self) -> ContextVar<Factor>

Zoom scale factor of the parent scroll.

This variable is usually read-write, but you should avoid modifying it directly as direct assign as the value is not validated and does not participate in smooths scrolling. Prefer the zoom methods of this service to change scale.

source

pub fn rendered_offset(&self) -> Factor2d

Latest rendered offset.

source

pub fn rendered_zoom_scale(&self) -> Factor

Latest rendered zoom scale factor.

source

pub fn vertical_overscroll(&self) -> ReadOnlyVar<Factor, ContextVar<Factor>>

Extra vertical offset, requested by touch gesture, that could not be fulfilled because vertical_offset is already at 0.fct() or 1.fct().

The factor is between in the -1.0..=1.0 range and represents the overscroll offset in pixels divided by the viewport width.

source

pub fn horizontal_overscroll(&self) -> ReadOnlyVar<Factor, ContextVar<Factor>>

Extra horizontal offset requested that could not be fulfilled because horizontal_offset is already at 0.fct() or 1.fct().

The factor is between in the -1.0..=1.0 range and represents the overscroll offset in pixels divided by the viewport width.

source

pub fn vertical_ratio(&self) -> ReadOnlyVar<Factor, ContextVar<Factor>>

Ratio of the scroll parent viewport height to its content.

The value is viewport.height / content.height.

source

pub fn horizontal_ratio(&self) -> ReadOnlyVar<Factor, ContextVar<Factor>>

Ratio of the scroll parent viewport width to its content.

The value is viewport.width / content.width.

source

pub fn vertical_content_overflows(&self) -> ReadOnlyVar<bool, ContextVar<bool>>

If the vertical scrollbar should be visible.

source

pub fn horizontal_content_overflows( &self, ) -> ReadOnlyVar<bool, ContextVar<bool>>

If the horizontal scrollbar should be visible.

source

pub fn viewport_size( &self, ) -> ReadOnlyVar<Size2D<Px, Px>, ContextVar<Size2D<Px, Px>>>

Latest computed viewport size of the parent scroll.

source

pub fn content_size( &self, ) -> ReadOnlyVar<Size2D<Px, Px>, ContextVar<Size2D<Px, Px>>>

Latest computed content size of the parent scroll.

source

pub fn scroll_vertical(&self, delta: ScrollFrom)

Applies the delta to the vertical offset.

If smooth scrolling is enabled it is used to update the offset.

source

pub fn scroll_horizontal(&self, delta: ScrollFrom)

Applies the delta to the horizontal offset.

If smooth scrolling is enabled the chase animation is created or updated by this call.

source

pub fn scroll_vertical_clamp(&self, delta: ScrollFrom, min: f32, max: f32)

Applies the delta to the vertical offset, but clamps the final offset by the inclusive min and max.

If smooth scrolling is enabled it is used to update the offset.

source

pub fn scroll_horizontal_clamp(&self, delta: ScrollFrom, min: f32, max: f32)

Applies the delta to the horizontal offset, but clamps the final offset by the inclusive min and max.

If smooth scrolling is enabled it is used to update the offset.

source

pub fn auto_scroll(&self, velocity: Vector2D<Dip, Dip>)

Animate scroll at the direction and velocity (in DIPs per second).

source

pub fn scroll_vertical_touch(&self, delta: Px)

Applies the delta to the vertical offset without smooth scrolling and updates the vertical overscroll if it changes.

This method is used to implement touch gesture scrolling, the delta is always ScrollFrom::Var.

source

pub fn scroll_horizontal_touch(&self, delta: Px)

Applies the delta to the horizontal offset without smooth scrolling and updates the horizontal overscroll if it changes.

This method is used to implement touch gesture scrolling, the delta is always ScrollFrom::Var.

source

pub fn clear_vertical_overscroll(&self)

Quick ease vertical overscroll to zero.

source

pub fn clear_horizontal_overscroll(&self)

Quick ease horizontal overscroll to zero.

source

pub fn scroll_vertical_touch_inertia(&self, delta: Px, duration: Duration)

Animates to delta over duration.

source

pub fn scroll_horizontal_touch_inertia(&self, delta: Px, duration: Duration)

Animates to delta over duration.

source

pub fn chase_vertical(&self, modify_offset: impl FnOnce(Factor) -> Factor)

Set the vertical offset to a new offset derived from the last, blending into the active smooth scrolling chase animation, or starting a new one, or just setting the var if smooth scrolling is disabled.

source

pub fn chase_horizontal(&self, modify_offset: impl FnOnce(Factor) -> Factor)

Set the horizontal offset to a new offset derived from the last set offset, blending into the active smooth scrolling chase animation, or starting a new one, or just setting the var if smooth scrolling is disabled.

source

pub fn chase_zoom(&self, modify_scale: impl FnOnce(Factor) -> Factor)

Set the zoom scale to a new scale derived from the last set scale, blending into the active smooth scaling chase animation, or starting a new or, or just setting the var if smooth scrolling is disabled.

source

pub fn zoom( &self, modify_scale: impl FnOnce(Factor) -> Factor, origin: Point2D<Px, Px>, )

Zoom in or out keeping the origin point in the viewport aligned with the same point in the content.

source

pub fn zoom_touch( &self, phase: TouchPhase, scale: Factor, center_in_viewport: Point2D<f32, Px>, )

Applies the scale to the current zoom scale without smooth scrolling and centered on the touch point.

source

pub fn can_scroll_vertical(&self) -> impl Var<bool>

Gets a var that is true when the content height is greater then the viewport height.

source

pub fn can_scroll_horizontal(&self) -> impl Var<bool>

Gets a var that is true when the content width is greater then the viewport with.

source

pub fn can_scroll_down(&self) -> impl Var<bool>

Gets a var that is true when the content height is greater then the viewport height and the vertical offset is not at the maximum.

source

pub fn can_scroll_up(&self) -> impl Var<bool>

Gets a var that is true when the content height is greater then the viewport height and the vertical offset is not at the minimum.

source

pub fn can_scroll_left(&self) -> impl Var<bool>

Gets a var that is true when the content width is greater then the viewport width and the horizontal offset is not at the minimum.

source

pub fn can_scroll_right(&self) -> impl Var<bool>

Gets a var that is true when the content width is greater then the viewport width and the horizontal offset is not at the maximum.

source

pub fn scroll_to(&self, mode: impl Into<ScrollToMode>)

Scroll the WIDGET into view.

source

pub fn scroll_to_zoom( &self, mode: impl Into<ScrollToMode>, zoom: impl Into<Factor>, )

Scroll the WIDGET into view and adjusts the zoom scale.

source

pub fn can_zoom_in(&self) -> bool

Returns true if the content can be scaled and the current scale is less than the max.

source

pub fn can_zoom_out(&self) -> bool

Returns true if the content can be scaled and the current scale is more than the min.

source§

impl SCROLL

source

pub fn context_values_set(&self, set: &mut ContextValueSet)

Insert the context values used by SCROLL in the set.

Capturing this set plus all context vars enables using all SCROLL methods outside the scroll.

Auto Trait Implementations§

§

impl Freeze for SCROLL

§

impl RefUnwindSafe for SCROLL

§

impl Send for SCROLL

§

impl Sync for SCROLL

§

impl Unpin for SCROLL

§

impl UnwindSafe for SCROLL

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
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
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
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T

source§

impl<T> StateValue for T
where T: Any + Send + Sync,