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: View> DropZone<C>
impl<C: View> DropZone<C>
Sourcepub fn on_files(self, handler: impl Fn(Vec<PickedFile>) + 'static) -> Self
pub fn on_files(self, handler: impl Fn(Vec<PickedFile>) + 'static) -> Self
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) -> Self
pub fn on_refused(self, handler: impl Fn(Vec<String>) + 'static) -> Self
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>>,
) -> Self
pub fn accept( self, extensions: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Only these extensions, such as ["pdf", "png"]. Any file by default.
Sourcepub fn most_bytes(self, bytes: u64) -> Self
pub fn most_bytes(self, bytes: u64) -> Self
The largest file taken, in bytes. 100 MiB by default.
Sourcepub fn most_files(self, files: usize) -> Self
pub fn most_files(self, files: usize) -> Self
The most files taken from one drop. No limit by default.
Sourcepub fn label(self, label: impl Into<String>) -> Self
pub fn label(self, label: impl Into<String>) -> Self
The name screen readers announce. By default, the words of the hint.
Sourcepub fn hint(self, hint: impl Into<String>) -> Self
pub fn hint(self, hint: impl Into<String>) -> Self
What shows over the content while files are over the window. By default,
file_drop of the labels.
Sourcepub fn no_hint(self) -> Self
pub fn no_hint(self) -> Self
Shows nothing over the content while files are over the window, only the stronger edge.
Sourcepub fn choosable(self) -> Self
pub fn choosable(self) -> Self
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) -> Self
pub fn quiet(self) -> Self
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) -> Self
pub fn padding(self, padding: f32) -> Self
The space around the content, in logical pixels (space-4 by default).
Sourcepub fn min_height(self, height: f32) -> Self
pub fn min_height(self, height: f32) -> Self
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§
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<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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.