pub struct ZoneRegistry<T: Clone + 'static> { /* private fields */ }Expand description
Registry of the currently registered drop zones, in registration order.
Implementations§
Source§impl<T: Clone + 'static> ZoneRegistry<T>
impl<T: Clone + 'static> ZoneRegistry<T>
Sourcepub fn from_signal(zones: Signal<Vec<ZoneRecord<T>>>) -> Self
pub fn from_signal(zones: Signal<Vec<ZoneRecord<T>>>) -> Self
Wrap an existing signal. Prefer crate::core::hooks::use_dnd_provider.
Sourcepub fn release_policy(&self) -> ReleasePolicy<T>
pub fn release_policy(&self) -> ReleasePolicy<T>
Current collision and release policy.
Sourcepub fn set_release_policy(&mut self, policy: ReleasePolicy<T>)
pub fn set_release_policy(&mut self, policy: ReleasePolicy<T>)
Synchronize the provider’s collision and release policy.
Sourcepub fn set_direction(&mut self, dir: Direction)
pub fn set_direction(&mut self, dir: Direction)
Set the layout direction (no-op if unchanged; safe to call every
render). DndProvider’s dir prop calls this for you.
Sourcepub fn register(&mut self, record: ZoneRecord<T>) -> ZoneRegistration
pub fn register(&mut self, record: ZoneRecord<T>) -> ZoneRegistration
Add (or replace, by id) a zone.
Sourcepub fn sync_label(&mut self, id: ZoneId, label: Option<String>)
pub fn sync_label(&mut self, id: ZoneId, label: Option<String>)
Update a zone’s label in place (no-op if unchanged or unknown).
Sourcepub fn unregister(&mut self, id: ZoneId)
pub fn unregister(&mut self, id: ZoneId)
Remove a zone (call when its component unmounts).
Sourcepub fn unregister_registration(&mut self, registration: ZoneRegistration)
pub fn unregister_registration(&mut self, registration: ZoneRegistration)
Remove this exact registration if it is still current.
A keyed Dioxus replacement may mount a new record with the same id before the old component’s cleanup runs. Token-aware cleanup prevents that stale cleanup from deleting the replacement.
Sourcepub fn set_mounted(
&mut self,
registration: ZoneRegistration,
mounted: Rc<MountedData>,
)
pub fn set_mounted( &mut self, registration: ZoneRegistration, mounted: Rc<MountedData>, )
Attach the mounted element to this exact registration. A stale registration token is ignored.
Sourcepub fn set_rect_if_present(
&mut self,
registration: ZoneRegistration,
rect: Rect,
)
pub fn set_rect_if_present( &mut self, registration: ZoneRegistration, rect: Rect, )
Store a rect only while the registration that requested it is still current. This never inserts a missing zone and therefore cannot resurrect one that unmounted during an async measurement.
Sourcepub fn set_rect(&mut self, id: ZoneId, rect: Rect)
pub fn set_rect(&mut self, id: ZoneId, rect: Rect)
Set geometry for the current registration of id. This is the
synchronous/manual counterpart to Self::set_rect_if_present, used
by custom layout adapters and the headless test driver.
Sourcepub fn get(&self, id: ZoneId) -> Option<ZoneRecord<T>>
pub fn get(&self, id: ZoneId) -> Option<ZoneRecord<T>>
Look up a zone by id.
Sourcepub fn cached_rect(&self, id: ZoneId) -> Option<Rect>
pub fn cached_rect(&self, id: ZoneId) -> Option<Rect>
The zone’s cached client rect, read without subscribing. Returns
None when unmeasured, unknown, or the provider is already gone.
Sourcepub fn mounted_handle(&self, id: ZoneId) -> Option<Rc<MountedData>>
pub fn mounted_handle(&self, id: ZoneId) -> Option<Rc<MountedData>>
The zone’s mounted element, read without subscribing. Returns None
before mount, for an unknown zone, or after provider teardown.
Sourcepub fn records(&self) -> Vec<ZoneRecord<T>>
pub fn records(&self) -> Vec<ZoneRecord<T>>
Every registered zone, in registration order. Unlike the peeking lookups around it this is a subscribing read - a component rendering from it re-renders when zones mount or unmount - because its consumers (the debug overlay, your own devtools) are renderers.
Sourcepub fn contains(&self, id: ZoneId) -> bool
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.
Sourcepub fn ascend(&self, current: ZoneId) -> Option<ZoneId>
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.
Sourcepub fn acceptable(&self, payload: &T) -> Vec<ZoneRecord<T>>
pub fn acceptable(&self, payload: &T) -> Vec<ZoneRecord<T>>
All zones accepting payload, in registration order.
Sourcepub fn acceptable_query(&self, query: &DropQuery<T>) -> Vec<ZoneRecord<T>>
pub fn acceptable_query(&self, query: &DropQuery<T>) -> Vec<ZoneRecord<T>>
All zones accepting a complete drop query.
Sourcepub fn step_zone(
&self,
current: Option<ZoneId>,
payload: &T,
step: isize,
) -> Option<ZoneId>
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; tops within one CSS pixel form a row so sub-pixel
layout jitter cannot override horizontal reading order. Call
Self::refresh_rects first, as the built-in keyboard interaction
does on pickup. Unmeasured zones keep registration order afterwards.
pub fn step_zone_query( &self, current: Option<ZoneId>, query: &DropQuery<T>, step: isize, ) -> Option<ZoneId>
Sourcepub fn children_of(
&self,
parent: Option<ZoneId>,
payload: &T,
) -> Vec<ZoneRecord<T>>
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, then left-to-right within
a one-CSS-pixel row band; unmeasured zones keep registration order at
the end).
pub fn children_of_query( &self, parent: Option<ZoneId>, query: &DropQuery<T>, ) -> Vec<ZoneRecord<T>>
Sourcepub fn step_sibling(
&self,
current: Option<ZoneId>,
payload: &T,
step: isize,
) -> Option<ZoneId>
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.
pub fn step_sibling_query( &self, current: Option<ZoneId>, query: &DropQuery<T>, step: isize, ) -> Option<ZoneId>
Sourcepub fn first_child(&self, id: ZoneId, payload: &T) -> Option<ZoneId>
pub fn first_child(&self, id: ZoneId, payload: &T) -> Option<ZoneId>
The first (spatially) acceptable zone nested inside id.
pub fn first_child_query( &self, id: ZoneId, query: &DropQuery<T>, ) -> Option<ZoneId>
Sourcepub fn hit_test(&self, point: Point) -> Option<ZoneId>
pub fn hit_test(&self, point: Point) -> Option<ZoneId>
Last record in registry order containing point (client coordinates),
using cached rects - call Self::refresh_rects when a drag starts.
This only approximates DOM paint order; CSS stacking and portals are
not inspected. Replacing a same-id record retains its existing slot.
Sourcepub fn hit_test_closest(
&self,
point: Point,
payload: &T,
max_distance: f64,
) -> Option<ZoneId>
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 last
record in registry order that both contains the point and accepts
payload, and when no such zone contains the point, falls back to the
acceptable zone whose rect is nearest - within max_distance CSS px
of its closest edge, not its center, so a large zone snaps a release
right beside it even though its center sits far away. Skipping zones
that reject the payload lets a drop land on an earlier accepting
overlap, and is friendlier for imprecise (touch) drops that land in the
gutter between zones.
Sourcepub fn resolve(
&self,
query: &DropQuery<T>,
point: Point,
active_rect: Option<Rect>,
max_distance: f64,
) -> Option<(ZoneId, DropEffect)>
pub fn resolve( &self, query: &DropQuery<T>, point: Point, active_rect: Option<Rect>, max_distance: f64, ) -> Option<(ZoneId, DropEffect)>
Resolve a target with this registry’s collision policy and return the target-negotiated effect. Candidates are filtered by the full query before collision ranking, so hover and release share acceptance.
Sourcepub fn resolve_hover(
&self,
query: &DropQuery<T>,
point: Point,
active_rect: Option<Rect>,
current: Option<ZoneId>,
) -> Option<(ZoneId, DropEffect)>
pub fn resolve_hover( &self, query: &DropQuery<T>, point: Point, active_rect: Option<Rect>, current: Option<ZoneId>, ) -> Option<(ZoneId, DropEffect)>
Resolve live hover with optional sticky retention. Exact collisions always win. On an exact miss, a sticky policy may retain only the current acceptable target while the pointer remains inside its recovery radius.
Sourcepub async fn measure_all(&self)
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).
Sourcepub fn refresh_rects(&self)
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>
impl<T: Clone + 'static> Clone for ZoneRegistry<T>
impl<T: Clone + 'static> Copy for ZoneRegistry<T>
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>where
Signal<Vec<ZoneRecord<T>>>: Freeze,
Signal<Vec<(ZoneRegistration, ZonePolicy<T>)>>: Freeze,
Signal<ReleasePolicy<T>>: Freeze,
impl<T> Unpin for ZoneRegistry<T>where
Signal<Vec<ZoneRecord<T>>>: Unpin,
Signal<Vec<(ZoneRegistration, ZonePolicy<T>)>>: Unpin,
Signal<ReleasePolicy<T>>: Unpin,
impl<T> UnsafeUnpin for ZoneRegistry<T>where
Signal<Vec<ZoneRecord<T>>>: UnsafeUnpin,
Signal<Vec<(ZoneRegistration, ZonePolicy<T>)>>: UnsafeUnpin,
Signal<ReleasePolicy<T>>: UnsafeUnpin,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DependencyElement for T
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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