pub struct UploadDropzone<A = ()> { /* private fields */ }Expand description
A file drop target with reactive labels and caller-owned actions.
Dragged files are filtered using [UploadAccept]. With multiple(false),
only the first accepted file in producer order reaches the drop handler.
Empty accepted sets do not invoke it. The browse button merely runs the
installed action; opening a native picker remains the consumer’s job.
§Examples
use ailloli_ui_widgets::controls::UploadDropzone;
let dropzone: UploadDropzone<()> = UploadDropzone::new().accept([".png", "image/*"]);
let _ = dropzone;Implementations§
Source§impl<A: 'static> UploadDropzone<A>
impl<A: 'static> UploadDropzone<A>
Sourcepub fn height(self, value: impl Into<Length>) -> Self
pub fn height(self, value: impl Into<Length>) -> Self
Sets preferred height from a logical-pixel or length value.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().height(40.0);
let _ = widget;Sourcepub fn min_width(self, value: impl Into<Length>) -> Self
pub fn min_width(self, value: impl Into<Length>) -> Self
Sets the minimum width bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().min_width(40.0);
let _ = widget;Sourcepub fn max_width(self, value: impl Into<Length>) -> Self
pub fn max_width(self, value: impl Into<Length>) -> Self
Sets the maximum width bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().max_width(320.0);
let _ = widget;Sourcepub fn min_height(self, value: impl Into<Length>) -> Self
pub fn min_height(self, value: impl Into<Length>) -> Self
Sets the minimum height bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().min_height(24.0);
let _ = widget;Sourcepub fn max_height(self, value: impl Into<Length>) -> Self
pub fn max_height(self, value: impl Into<Length>) -> Self
Sets the maximum height bound.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().max_height(240.0);
let _ = widget;Sourcepub fn fill(self) -> Self
pub fn fill(self) -> Self
Sets both preferred axes to parent fill.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().fill();
let _ = widget;Sourcepub fn fill_width(self) -> Self
pub fn fill_width(self) -> Self
Sets preferred width to parent fill.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().fill_width();
let _ = widget;Sourcepub fn fill_height(self) -> Self
pub fn fill_height(self) -> Self
Sets preferred height to parent fill.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().fill_height();
let _ = widget;Sourcepub fn margin(self, value: f32) -> Self
pub fn margin(self, value: f32) -> Self
Sets uniform outer margin in logical pixels.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().margin(8.0);
let _ = widget;Sourcepub fn padding(self, value: f32) -> Self
pub fn padding(self, value: f32) -> Self
Sets uniform inner padding in logical pixels.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().padding(8.0);
let _ = widget;Sourcepub fn flex_grow(self) -> Self
pub fn flex_grow(self) -> Self
Sets flex-grow weight to one.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_grow();
let _ = widget;Sourcepub fn flex_grow_by(self, value: f32) -> Self
pub fn flex_grow_by(self, value: f32) -> Self
Sets a dimensionless flex-grow weight.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_grow_by(2.0);
let _ = widget;Sourcepub fn flex_shrink(self, value: f32) -> Self
pub fn flex_shrink(self, value: f32) -> Self
Sets a dimensionless flex-shrink weight.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_shrink(1.0);
let _ = widget;Sourcepub fn flex_basis(self, value: impl Into<Length>) -> Self
pub fn flex_basis(self, value: impl Into<Length>) -> Self
Sets the preferred main-axis flex basis.
§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().flex_basis(80.0);
let _ = widget;Sourcepub fn align_self(self, value: AlignItems) -> Self
pub fn align_self(self, value: AlignItems) -> Self
Overrides cross-axis alignment for this flex item.
§Examples
use ailloli_ui_core::style::AlignItems;
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().align_self(AlignItems::Center);
let _ = widget;Source§impl<A: 'static> UploadDropzone<A>
impl<A: 'static> UploadDropzone<A>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a single-file dropzone accepting every file.
It starts enabled with default English labels and no callbacks. Without callbacks it is not focusable, though it still paints drag-hover state.
§Examples
use ailloli_ui_widgets::controls::UploadDropzone;
let dropzone: UploadDropzone<()> = UploadDropzone::new();
let _ = dropzone;Sourcepub fn title(self, value: impl Into<Binding<String>>) -> Self
pub fn title(self, value: impl Into<Binding<String>>) -> Self
Replaces the static or reactive primary label.
Empty text is valid and simply produces no visible glyphs.
§Examples
use ailloli_ui_widgets::controls::UploadDropzone;
let dropzone: UploadDropzone<()> = UploadDropzone::new().title("Drop images here");
let _ = dropzone;Sourcepub fn description(self, value: impl Into<Binding<String>>) -> Self
pub fn description(self, value: impl Into<Binding<String>>) -> Self
Replaces the static or reactive secondary label.
§Examples
use ailloli_ui_widgets::controls::UploadDropzone;
let dropzone: UploadDropzone<()> = UploadDropzone::new().description("PNG or JPEG");
let _ = dropzone;Sourcepub fn disabled(self, value: impl Into<Binding<bool>>) -> Self
pub fn disabled(self, value: impl Into<Binding<bool>>) -> Self
Sets a static or reactive disabled binding.
Disabled dropzones ignore pointer and file events, are not focusable, clear hover visually, and apply the style’s disabled alpha.
§Examples
use ailloli_ui_widgets::controls::UploadDropzone;
let dropzone: UploadDropzone<()> = UploadDropzone::new().disabled(true);
let _ = dropzone;Sourcepub fn multiple(self, value: bool) -> Self
pub fn multiple(self, value: bool) -> Self
Controls whether a drop delivers all accepted files.
false (the default) truncates the filtered list to one; true keeps
every accepted file in the producer’s original order.
§Examples
use ailloli_ui_widgets::controls::UploadDropzone;
let dropzone: UploadDropzone<()> = UploadDropzone::new().multiple(true);
let _ = dropzone;Sourcepub fn accept(
self,
patterns: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn accept( self, patterns: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Replaces accepted extension and MIME patterns.
Supported forms are .ext, exact MIME values, and top-level wildcards
such as image/*; matching behavior is defined by [UploadAccept]. An
empty iterator accepts every file. This filter applies to drag events;
the browse action receives no automatic native-picker configuration.
§Examples
use ailloli_ui_widgets::controls::UploadDropzone;
let dropzone: UploadDropzone<()> = UploadDropzone::new().accept([".pdf", "image/*"]);
let _ = dropzone;Sourcepub fn upload_style(self, style: UploadDropzoneStyle) -> Self
pub fn upload_style(self, style: UploadDropzoneStyle) -> Self
Replaces the complete resolved style without clamping its values.
§Examples
use ailloli_ui_core::Theme;
use ailloli_ui_widgets::controls::{UploadDropzone, UploadDropzoneStyle, UploadDropzoneVariant};
let style = UploadDropzoneStyle::from_theme(Theme::dark(), UploadDropzoneVariant::Compact);
let dropzone: UploadDropzone<()> = UploadDropzone::new().upload_style(style);
let _ = dropzone;Sourcepub fn upload_variant(self, variant: UploadDropzoneVariant) -> Self
pub fn upload_variant(self, variant: UploadDropzoneVariant) -> Self
Replaces the complete style with the default-theme variant.
This discards any previously customized style values. Explicit layout width and height builders may still override its intrinsic dimensions.
§Examples
use ailloli_ui_widgets::controls::{UploadDropzone, UploadDropzoneVariant};
let dropzone: UploadDropzone<()> =
UploadDropzone::new().upload_variant(UploadDropzoneVariant::Compact);
let _ = dropzone;Sourcepub fn on_browse(self, action: impl IntoClickAction<A>) -> Self
pub fn on_browse(self, action: impl IntoClickAction<A>) -> Self
Installs the action run by a left-button release inside the browse button.
A later call replaces the action. Keyboard activation is not currently synthesized by this widget.
§Examples
use ailloli_ui_widgets::controls::UploadDropzone;
#[derive(Clone)]
enum Action { Browse }
let dropzone = UploadDropzone::new().on_browse(Action::Browse);
let _ = dropzone;Sourcepub fn on_drop(self, f: impl Fn(Vec<UploadFile>) -> A + 'static) -> Self
pub fn on_drop(self, f: impl Fn(Vec<UploadFile>) -> A + 'static) -> Self
Maps accepted files to one action and dispatches it.
The mapper runs only for a non-empty accepted drop inside the widget. A later drop-handler builder replaces it.
§Examples
use ailloli_ui_core::UploadFile;
use ailloli_ui_widgets::controls::UploadDropzone;
enum Action { Dropped(Vec<UploadFile>) }
let dropzone = UploadDropzone::new().on_drop(Action::Dropped);
let _ = dropzone;Sourcepub fn on_drop_ctx(
self,
f: impl Fn(&mut EventCtx<A>, Vec<UploadFile>) + 'static,
) -> Self
pub fn on_drop_ctx( self, f: impl Fn(&mut EventCtx<A>, Vec<UploadFile>) + 'static, ) -> Self
Installs a context-aware handler for accepted files.
The handler may dispatch zero or more actions and request runtime effects. It runs only for a non-empty accepted drop and replaces any prior handler.
§Examples
use ailloli_ui_widgets::controls::UploadDropzone;
let dropzone = UploadDropzone::<()>::new().on_drop_ctx(|ctx, files| {
if !files.is_empty() { ctx.request_repaint(); }
});
let _ = dropzone;