pub struct DragAndDropManager {
undraggable_items: ItemCollection,
feedback: AtomicCell<DragAndDropFeedback>,
}
Expand description
Helper to handle drag-and-drop operations.
This helper must be constructed at the beginning of the frame and disposed of at the end.
Its Self::payload_cursor_ui
method should be called late during the frame (after the rest of
the UI has a chance to update the feedback).
Fields§
§undraggable_items: ItemCollection
Items that may not be dragged, e.g., because they are not movable nor copiable.
feedback: AtomicCell<DragAndDropFeedback>
Implementations§
source§impl DragAndDropManager
impl DragAndDropManager
sourcepub fn new(undraggable_items: impl Into<ItemCollection>) -> Self
pub fn new(undraggable_items: impl Into<ItemCollection>) -> Self
Create a DragAndDropManager
by providing a list of undraggable items.
sourcepub fn set_feedback(&self, feedback: DragAndDropFeedback)
pub fn set_feedback(&self, feedback: DragAndDropFeedback)
Set the feedback to display to the user based on drop acceptability for the UI currently hovered.
By default, the feedback is unset and the pill/cursor are displayed in a “neutral” way, indicating that the current drag-and-drop payload is valid but not hovered over a related UI.
If the payload type is compatible with the hovered UI element, that element should set the
feedback to either DragAndDropFeedback::Accept
or DragAndDropFeedback::Reject
, based
on whether the actual payload content may meaningfully be dropped.
For example, a view generally accepts a dragged entity but may occasionally reject it if it already contains it.
sourcepub fn are_items_draggable(&self, items: &ItemCollection) -> bool
pub fn are_items_draggable(&self, items: &ItemCollection) -> bool
Checks if items are draggable based on the list of undraggable items.
sourcepub fn payload_cursor_ui(&self, ctx: &Context)
pub fn payload_cursor_ui(&self, ctx: &Context)
Display the currently dragged payload as a pill in the UI.
This should be called once per frame.
Auto Trait Implementations§
impl !Freeze for DragAndDropManager
impl RefUnwindSafe for DragAndDropManager
impl Send for DragAndDropManager
impl Sync for DragAndDropManager
impl Unpin for DragAndDropManager
impl UnwindSafe for DragAndDropManager
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> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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
.§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
.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request