pub struct DropZone<C> { /* private fields */ }Expand description
A dashed area around any content, which takes files dropped on it and shows when they are
over the window. Unlike FileUpload it keeps no list: the files go to
DropZone::on_files, and what it holds and how it looks are up to the content.
A dropped file lands in the zone under the pointer. While it is being dragged, every zone
on the screen lights up, because the platforms say only that files are over the window, and
not where. A keyboard cannot drop anything, so DropZone::choosable is there for that.
use ravenrs_widgets::{DropZone, Text, Ui};
let zone = DropZone::new(Text::new("Photos of the session"))
.accept(["jpg", "png"])
.on_files(|files| println!("{} files", files.len()));
let mut ui = Ui::new(zone, ravenrs_style::Theme::raven_dark());
ui.update();Implementations§
Source§impl<C> DropZone<C>where
C: View,
impl<C> DropZone<C>where
C: View,
Sourcepub fn on_files(
self,
handler: impl Fn(Vec<PickedFile>) + 'static,
) -> DropZone<C>
pub fn on_files( self, handler: impl Fn(Vec<PickedFile>) + 'static, ) -> DropZone<C>
Called with the files it took. It is not called when all of them were refused.
Sourcepub fn on_refused(self, handler: impl Fn(Vec<String>) + 'static) -> DropZone<C>
pub fn on_refused(self, handler: impl Fn(Vec<String>) + 'static) -> DropZone<C>
Called with one sentence for each refused file, in the words of crate::Labels, for
showing them elsewhere. Without it they show inside the zone, under the content.
Sourcepub fn accept(
self,
extensions: impl IntoIterator<Item = impl Into<String>>,
) -> DropZone<C>
pub fn accept( self, extensions: impl IntoIterator<Item = impl Into<String>>, ) -> DropZone<C>
Only these extensions, such as ["pdf", "png"]. Any file by default.
Sourcepub fn most_bytes(self, bytes: u64) -> DropZone<C>
pub fn most_bytes(self, bytes: u64) -> DropZone<C>
The largest file taken, in bytes. 100 MiB by default.
Sourcepub fn most_files(self, files: usize) -> DropZone<C>
pub fn most_files(self, files: usize) -> DropZone<C>
The most files taken from one drop. No limit by default.
Sourcepub fn label(self, label: impl Into<String>) -> DropZone<C>
pub fn label(self, label: impl Into<String>) -> DropZone<C>
The name screen readers announce. By default, the words of the hint.
Sourcepub fn hint(self, hint: impl Into<String>) -> DropZone<C>
pub fn hint(self, hint: impl Into<String>) -> DropZone<C>
What shows over the content while files are over the window. By default,
file_drop of the labels.
Sourcepub fn no_hint(self) -> DropZone<C>
pub fn no_hint(self) -> DropZone<C>
Shows nothing over the content while files are over the window, only the stronger edge.
Sourcepub fn choosable(self) -> DropZone<C>
pub fn choosable(self) -> DropZone<C>
Makes the whole zone a button that opens the system’s chooser, with a click, Enter or Space, so that the keyboard can bring files too. Leave it off when the content has its own way of choosing.
Sourcepub fn quiet(self) -> DropZone<C>
pub fn quiet(self) -> DropZone<C>
Draws the dashes only while files are over the window, for a zone that is a whole screen and should not look like one until then.
Sourcepub fn padding(self, padding: f32) -> DropZone<C>
pub fn padding(self, padding: f32) -> DropZone<C>
The space around the content, in logical pixels (space-4 by default).
Sourcepub fn min_height(self, height: f32) -> DropZone<C>
pub fn min_height(self, height: f32) -> DropZone<C>
The shortest it gets, in logical pixels.
Trait Implementations§
Auto Trait Implementations§
impl<C> !RefUnwindSafe for DropZone<C>
impl<C> !Send for DropZone<C>
impl<C> !Sync for DropZone<C>
impl<C> !UnwindSafe for DropZone<C>
impl<C> Freeze for DropZone<C>where
C: Freeze,
impl<C> Unpin for DropZone<C>where
C: Unpin,
impl<C> UnsafeUnpin for DropZone<C>where
C: UnsafeUnpin,
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
impl<T, U> ToSample<U> for Twhere
U: FromSample<T>,
fn to_sample_(self) -> U
Source§impl<V> ViewExt for Vwhere
V: View,
impl<V> ViewExt for Vwhere
V: View,
Source§fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
fn padding(self, padding: impl Into<Insets>) -> Styled<Self>
Source§fn background(self, fill: impl Into<Fill>) -> Styled<Self>
fn background(self, fill: impl Into<Fill>) -> Styled<Self>
Source§fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
fn frame(self, width: Option<f32>, height: Option<f32>) -> Styled<Self>
None keeps the content size.