Skip to main content

ZoneRegistry

Struct ZoneRegistry 

Source
pub struct ZoneRegistry<T: Clone + 'static> { /* private fields */ }
Expand description

Registry of the currently mounted drop zones, in mount order.

Implementations§

Source§

impl<T: Clone + 'static> ZoneRegistry<T>

Source

pub fn from_signal(zones: Signal<Vec<ZoneRecord<T>>>) -> Self

Wrap an existing signal. Prefer crate::core::hooks::use_dnd_provider.

Source

pub fn register(&mut self, record: ZoneRecord<T>)

Add (or replace, by id) a zone.

Source

pub fn sync_label(&mut self, id: ZoneId, label: Option<String>)

Update a zone’s label in place (no-op if unchanged or unknown).

Source

pub fn unregister(&mut self, id: ZoneId)

Remove a zone (call when its component unmounts).

Source

pub fn get(&self, id: ZoneId) -> Option<ZoneRecord<T>>

Look up a zone by id.

Source

pub fn contains(&self, id: ZoneId) -> bool

Is a zone with this id registered here? The parent-zone context is shared across payload types, so a record’s parent can name a zone living in another type’s registry - check before navigating to one.

Source

pub fn ascend(&self, current: ZoneId) -> Option<ZoneId>

The zone keyboard navigation should enter when ascending from current: its parent, but only when that parent is registered in this registry. A DropZone<A> nested inside a DropZone<B> records B’s id as its parent, and entering an id this registry can’t resolve would leave the drag hovering a zone that can never receive it.

Source

pub fn acceptable(&self, payload: &T) -> Vec<ZoneRecord<T>>

All zones accepting payload, in registration order.

Source

pub fn step_zone( &self, current: Option<ZoneId>, payload: &T, step: isize, ) -> Option<ZoneId>

The next/previous zone (cyclic) relative to current among zones that accept payload. step is +1 or -1.

Order is spatial (top-to-bottom, then left-to-right) for zones with measured rects - call Self::refresh_rects first, as the built-in keyboard interaction does on pickup. Unmeasured zones keep registration order, after the measured ones.

Source

pub fn parent_of(&self, id: ZoneId) -> Option<ZoneId>

The parent of a zone, if it’s nested.

Source

pub fn children_of( &self, parent: Option<ZoneId>, payload: &T, ) -> Vec<ZoneRecord<T>>

Zones directly inside parent (None = root level) that accept payload, in spatial order (top-to-bottom, left-to-right; unmeasured zones keep registration order at the end).

Source

pub fn step_sibling( &self, current: Option<ZoneId>, payload: &T, step: isize, ) -> Option<ZoneId>

Next/previous zone (cyclic) among the siblings of current - zones sharing its parent. With no current, cycles the root level.

Source

pub fn first_child(&self, id: ZoneId, payload: &T) -> Option<ZoneId>

The first (spatially) acceptable zone nested inside id.

Source

pub fn hit_test(&self, point: Point) -> Option<ZoneId>

Topmost zone containing point (client coordinates), using cached rects - call Self::refresh_rects when a drag starts. Later-mounted zones win, approximating DOM paint order.

Source

pub fn hit_test_closest( &self, point: Point, payload: &T, max_distance: f64, ) -> Option<ZoneId>

Like Self::hit_test, but acceptance-aware: it returns the topmost zone that both contains the point and accepts payload, and when no such zone contains the point, falls back to the acceptable zone whose center is nearest - within max_distance CSS px. Skipping zones that reject the payload lets a drop land on an accepting zone sitting under a rejecting (or decorative) one, and is friendlier for imprecise (touch) drops that land in the gutter between zones.

Source

pub async fn measure_all(&self)

Re-measure every mounted zone’s client rect and wait for the measurements to land - unlike Self::refresh_rects, which fires and forgets. Use before a hit-test that must see fresh geometry (e.g. retrying a missed touch drop after a layout change).

Source

pub fn refresh_rects(&self)

Re-measure every mounted zone’s client rect (async, spawned).

Trait Implementations§

Source§

impl<T: Clone + 'static> Clone for ZoneRegistry<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Clone + 'static> Copy for ZoneRegistry<T>

Source§

impl<T: Clone + 'static> PartialEq for ZoneRegistry<T>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for ZoneRegistry<T>

§

impl<T> !Send for ZoneRegistry<T>

§

impl<T> !Sync for ZoneRegistry<T>

§

impl<T> !UnwindSafe for ZoneRegistry<T>

§

impl<T> Freeze for ZoneRegistry<T>

§

impl<T> Unpin for ZoneRegistry<T>

§

impl<T> UnsafeUnpin for ZoneRegistry<T>

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

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DependencyElement for T
where T: 'static + PartialEq + Clone,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> InitializeFromFunction<T> for T

Source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
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<Ret> SpawnIfAsync<(), Ret> for Ret

Source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Source§

fn super_from(input: T) -> O

Convert from a type to another type.
Source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Source§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. 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