Skip to main content

DropZone

Struct DropZone 

Source
pub struct DropZone<F = fn(DragData) -> bool>
where F: FnMut(DragData) -> bool,
{ /* private fields */ }
Expand description

Drop zone widget

Implementations§

Source§

impl DropZone<fn(DragData) -> bool>

Source

pub fn new(placeholder: impl Into<String>) -> Self

Create a new drop zone with placeholder text

Source§

impl<F> DropZone<F>
where F: FnMut(DragData) -> bool,

Source

pub fn accepts(self, types: &[&'static str]) -> Self

Set accepted data types

Source

pub fn accepts_all(self) -> Self

Accept all data types

Source

pub fn style(self, style: DropZoneStyle) -> Self

Set visual style

Source

pub fn border_color(self, color: Color) -> Self

Set border color

Source

pub fn hover_color(self, color: Color) -> Self

Set hover color

Source

pub fn min_height(self, height: u16) -> Self

Set minimum height

Source

pub fn on_drop<G>(self, handler: G) -> DropZone<G>
where G: FnMut(DragData) -> bool,

Set drop handler

Source

pub fn set_hovered(&mut self, hovered: bool, can_accept: bool)

Set hovered state (called by drag system)

Source

pub fn id(&self) -> DragId

Get unique ID

Source

pub fn as_target(&self, bounds: Rect) -> DropTarget

Create a DropTarget for registration

Source§

impl DropZone<fn(DragData) -> bool>

Source

pub fn focused(self, focused: bool) -> Self

Set the focused state

Source

pub fn disabled(self, disabled: bool) -> Self

Set the disabled state

Source

pub fn fg(self, color: Color) -> Self

Set the foreground color

Source

pub fn bg(self, color: Color) -> Self

Set the background color

Source

pub fn is_focused(&self) -> bool

Check if the widget is focused

Source

pub fn is_disabled(&self) -> bool

Check if the widget is disabled

Source

pub fn set_focused(&mut self, focused: bool)

Set the focused state (mutable)

Trait Implementations§

Source§

impl<F> Draggable for DropZone<F>
where F: FnMut(DragData) -> bool,

Source§

fn can_drop(&self) -> bool

Check if this widget accepts drops
Source§

fn accepted_types(&self) -> &[&'static str]

Get the types this widget accepts for drops Read more
Source§

fn on_drag_enter(&mut self, data: &DragData)

Called when a drag enters this widget’s bounds
Source§

fn on_drag_leave(&mut self)

Called when a drag leaves this widget’s bounds
Source§

fn on_drop(&mut self, data: DragData) -> bool

Called when a drop occurs on this widget Read more
Source§

fn drop_bounds(&self, area: Rect) -> Rect

Get the drop zone bounds for this widget Read more
Source§

fn can_drag(&self) -> bool

Check if this widget can be dragged Read more
Source§

fn drag_data(&self) -> Option<DragData>

Get the drag data when a drag starts Read more
Source§

fn drag_preview(&self) -> Option<String>

Get a text preview for the drag operation Read more
Source§

fn on_drag_start(&mut self)

Called when drag starts
Source§

fn on_drag_end(&mut self, _result: DropResult)

Called when drag ends (regardless of outcome)
Source§

fn can_accept(&self, data: &DragData) -> bool

Check if this widget can accept specific drag data
Source§

impl StyledView for DropZone<fn(DragData) -> bool>

Source§

fn set_id(&mut self, id: impl Into<String>)

Set element ID
Source§

fn add_class(&mut self, class: impl Into<String>)

Add a CSS class
Source§

fn remove_class(&mut self, class: &str)

Remove a CSS class
Source§

fn toggle_class(&mut self, class: &str)

Toggle a CSS class
Source§

fn has_class(&self, class: &str) -> bool

Check if has class
Source§

impl<F> View for DropZone<F>
where F: FnMut(DragData) -> bool,

Source§

fn render(&self, ctx: &mut RenderContext<'_>)

Render the view to the given context Read more
Source§

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

Get element ID (for CSS #id selectors) Read more
Source§

fn classes(&self) -> &[String]

Get CSS classes (for CSS .class selectors) Read more
Source§

fn meta(&self) -> WidgetMeta

Get widget metadata for DOM Read more
Source§

fn widget_type(&self) -> &'static str

Get widget type name (for CSS type selectors) Read more
Source§

fn children(&self) -> &[Box<dyn View>]

Get child views (for container widgets) Read more

Auto Trait Implementations§

§

impl<F> Freeze for DropZone<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for DropZone<F>
where F: RefUnwindSafe,

§

impl<F> Send for DropZone<F>
where F: Send,

§

impl<F> Sync for DropZone<F>
where F: Sync,

§

impl<F> Unpin for DropZone<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for DropZone<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for DropZone<F>
where F: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.