Skip to main content

ScrollableMask

Struct ScrollableMask 

Source
pub struct ScrollableMask<H = ScrollHandle>{ /* private fields */ }
Expand description

Make a scrollable mask element to cover the parent view with the mouse wheel event listening.

When the mouse wheel is scrolled, will move the scroll_handle scrolling with the axis direction. You can use this scroll_handle to control what you want to scroll. This is only can handle once axis scrolling.

Axis-dominant wheel events are consumed in the capture phase, so the mask wins over ancestor scrollers (e.g. gpui::list) that register their listeners after their children; events dominated by the other axis keep propagating. The mask stays inert while occluded.

Dominance is decided per gesture, not per event: a precise (trackpad) delta locks onto the axis its gesture started on, so mid-swipe wobble cannot flip which mask consumes the events. Line deltas keep the per-event comparison.

At the scroll edge the two axes differ, matching platform scrollers: a vertical mask hands the event over to the ancestor scroller (CSS overscroll-behavior: auto chaining), while a horizontal mask keeps consuming it — a bubbled horizontal delta would get mapped onto a vertical-only ancestor by gpui’s own wheel listener (see #2468).

Implementations§

Source§

impl<H> ScrollableMask<H>

Source

pub fn new(axis: Axis, scroll_handle: &H) -> ScrollableMask<H>

Create a new scrollable mask element.

Source

pub fn id(self, id: impl Into<ElementId>) -> ScrollableMask<H>

Set a specific element id, default is the std::panic::Location::caller.

Only needed when one call site creates several masks of the same axis, which would otherwise share their gesture axis lock.

Source

pub fn debug(self) -> ScrollableMask<H>

Enable the debug border, to show the mask bounds.

Trait Implementations§

Source§

impl<H> Element for ScrollableMask<H>

Source§

type RequestLayoutState = ()

The type of state returned from Element::request_layout. A mutable reference to this state is subsequently provided to Element::prepaint and Element::paint.
Source§

type PrepaintState = Hitbox

The type of state returned from Element::prepaint. A mutable reference to this state is subsequently provided to Element::paint.
Source§

fn id(&self) -> Option<ElementId>

If this element has a unique identifier, return it here. This is used to track elements across frames, and will cause a GlobalElementId to be passed to the request_layout, prepaint, and paint methods. Read more
Source§

fn source_location(&self) -> Option<&'static Location<'static>>

Source location where this element was constructed, used to disambiguate elements in the inspector and navigate to their source code.
Source§

fn request_layout( &mut self, _: Option<&GlobalElementId>, _: Option<&InspectorElementId>, window: &mut Window, cx: &mut App, ) -> (LayoutId, <ScrollableMask<H> as Element>::RequestLayoutState)

Before an element can be painted, we need to know where it’s going to be and how big it is. Use this method to request a layout from Taffy and initialize the element’s state.
Source§

fn prepaint( &mut self, _: Option<&GlobalElementId>, _: Option<&InspectorElementId>, bounds: Bounds<Pixels>, _: &mut <ScrollableMask<H> as Element>::RequestLayoutState, window: &mut Window, _: &mut App, ) -> <ScrollableMask<H> as Element>::PrepaintState

After laying out an element, we need to commit its bounds to the current frame for hitbox purposes. The state argument is the same state that was returned from Element::request_layout().
Source§

fn paint( &mut self, global_id: Option<&GlobalElementId>, _: Option<&InspectorElementId>, _: Bounds<Pixels>, _: &mut <ScrollableMask<H> as Element>::RequestLayoutState, hitbox: &mut <ScrollableMask<H> as Element>::PrepaintState, window: &mut Window, _: &mut App, )

Once layout has been completed, this method will be called to paint the element to the screen. The state argument is the same state that was returned from Element::request_layout().
Source§

fn a11y_role(&self) -> Option<Role>

Returns the accessible role for this element, if any. Elements that return None are not included in the accessibility tree. Read more
Source§

fn write_a11y_info(&self, _node: &mut Node)

Write accessibility properties to the given node. Called only when a11y_role() returns Some. Read more
Source§

fn a11y_synthetic_children( &mut self, _prepaint: &mut Self::PrepaintState, _builder: &mut A11ySubtreeBuilder<'_>, )

Add synthetic child nodes to an Element that has an .id() and a .role(). Read more
Source§

fn into_any(self) -> AnyElement

Convert this element into a dynamically-typed AnyElement.
Source§

impl<H> IntoElement for ScrollableMask<H>

Source§

type Element = ScrollableMask<H>

The specific type of element into which the implementing type is converted. Useful for converting other types into elements automatically, like Strings
Source§

fn into_element(self) -> <ScrollableMask<H> as IntoElement>::Element

Convert self into a type that implements Element.
Source§

fn into_any_element(self) -> AnyElement

Convert self into a dynamically-typed AnyElement.

Auto Trait Implementations§

§

impl<H> Freeze for ScrollableMask<H>
where H: Freeze,

§

impl<H> RefUnwindSafe for ScrollableMask<H>
where H: RefUnwindSafe,

§

impl<H> Send for ScrollableMask<H>
where H: Send,

§

impl<H> Sync for ScrollableMask<H>
where H: Sync,

§

impl<H> Unpin for ScrollableMask<H>
where H: Unpin,

§

impl<H> UnsafeUnpin for ScrollableMask<H>
where H: UnsafeUnpin,

§

impl<H> UnwindSafe for ScrollableMask<H>
where H: UnwindSafe,

Blanket Implementations§

Source§

impl<E> AnimationExt for E
where E: IntoElement + 'static,

Source§

fn with_animation( self, id: impl Into<ElementId>, animation: Animation, animator: impl Fn(Self, f32) -> Self + 'static, ) -> AnimationElement<Self>
where Self: Sized,

Render this component or element with an animation
Source§

fn with_animations( self, id: impl Into<ElementId>, animations: Vec<Animation>, animator: impl Fn(Self, usize, f32) -> Self + 'static, ) -> AnimationElement<Self>
where Self: Sized,

Render this component or element with a chain of animations
Source§

fn with_spring<T>( self, id: impl Into<ElementId>, animation: SpringAnimation<T>, animator: impl FnOnce(Self, <T as SpringTarget>::Output) -> Self + 'static, ) -> SpringAnimationElement<Self>
where Self: Sized, T: SpringTarget, <T as SpringTarget>::Output: 'static,

Renders this component or element at the value produced by a spring. Read more
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> FluentBuilder for T
where T: IntoElement,

Source§

fn map<U>(self, f: impl FnOnce(Self) -> U) -> U
where Self: Sized,

Imperatively modify self with the given closure.
Source§

fn when(self, condition: bool, then: impl FnOnce(Self) -> Self) -> Self
where Self: Sized,

Conditionally modify self with the given closure.
Source§

fn when_else( self, condition: bool, then: impl FnOnce(Self) -> Self, else_fn: impl FnOnce(Self) -> Self, ) -> Self
where Self: Sized,

Conditionally modify self with the given closure.
Source§

fn when_some<T>( self, option: Option<T>, then: impl FnOnce(Self, T) -> Self, ) -> Self
where Self: Sized,

Conditionally unwrap and modify self with the given closure, if the given option is Some.
Source§

fn when_none<T>( self, option: &Option<T>, then: impl FnOnce(Self) -> Self, ) -> Self
where Self: Sized,

Conditionally unwrap and modify self with the given closure, if the given option is None.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

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

Source§

fn vzip(self) -> V

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