Struct FileExplorer

Source
pub struct FileExplorer<A = ()> { /* private fields */ }
Expand description

Snapshot-backed, URI-identified filesystem tree with editing and context menus.

Input snapshots are recursively sorted directory-first on each build and projected into an intent-only TreeView. The widget emits actions but does not mutate a filesystem. Default rendering is non-virtualized and vertically scrollable. A is the surrounding application’s action type.

§Examples

use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::{FileExplorer, FileExplorerNode};
let nodes = [FileExplorerNode::directory(FileUri::parse("file:///repo")?, "repo")];
let explorer = FileExplorer::<()>::new(nodes);
let _ = explorer;

Implementations§

Source§

impl<A: 'static> FileExplorer<A>

Source

pub fn width(self, value: impl Into<Length>) -> Self

Sets preferred width from a logical-pixel or length value.

§Examples
use ailloli_ui_widgets::layout::Container;
let widget: Container<()> = Container::new().width(120.0);
let _ = widget;
Source

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;
Source

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;
Source

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;
Source

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;
Source

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;
Source

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;
Source

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;
Source

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;
Source

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;
Source

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;
Source

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;
Source

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;
Source

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;
Source

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;
Source

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> FileExplorer<A>

Source

pub fn new(nodes: impl IntoIterator<Item = FileExplorerNode>) -> Self

Collects a static recursive snapshot with default interaction/style state.

Input order is not retained during rendering: sibling nodes are sorted recursively. Duplicate URIs are accepted but make identity ambiguous.

§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::{FileExplorer, FileExplorerNode};
let explorer = FileExplorer::<()>::new([
    FileExplorerNode::file(FileUri::parse("file:///a")?, "a"),
]);
let _ = explorer;
Source

pub fn bind_nodes(self, nodes: impl Into<Signal<Vec<FileExplorerNode>>>) -> Self

Binds the recursive snapshot to live shared state.

Bound nodes take precedence over constructor nodes. Each build reads, clones, and recursively sorts the current vector.

§Examples
use ailloli_ui_runtime::component::State;
use ailloli_ui_widgets::files::{FileExplorer, FileExplorerNode};
let explorer = FileExplorer::<()>::default().bind_nodes(State::new(Vec::<FileExplorerNode>::new()));
let _ = explorer;
Source

pub fn selected(self, selected: impl Into<Binding<FileUri>>) -> Self

Sets static/generic selected-URI input and clears writable selection state.

User selection still emits callbacks, but only Self::bind_selected installs the writable signal that the inner tree updates automatically.

§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorer;
let explorer = FileExplorer::<()>::default().selected(FileUri::parse("file:///a")?);
let _ = explorer;
Source

pub fn bind_selected(self, selected: impl Into<Signal<FileUri>>) -> Self

Binds selection to writable shared state.

The inner tree writes the URI on user selection before callbacks.

§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_runtime::component::State;
use ailloli_ui_widgets::files::FileExplorer;
let selected = State::new(FileUri::parse("file:///a")?);
let explorer = FileExplorer::<()>::default().bind_selected(selected);
let _ = explorer;
Source

pub fn expanded(self, expanded: impl Into<Binding<Vec<FileUri>>>) -> Self

Sets static/generic expanded URIs and clears writable expansion state.

This input takes precedence over default expansion. Only a signal installed by Self::bind_expanded is automatically written on toggles.

§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorer;
let explorer = FileExplorer::<()>::default().expanded(vec![FileUri::parse("file:///repo")?]);
let _ = explorer;
Source

pub fn bind_expanded(self, expanded: impl Into<Signal<Vec<FileUri>>>) -> Self

Binds expansion to writable shared state.

§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_runtime::component::State;
use ailloli_ui_widgets::files::FileExplorer;
let expanded = State::new(vec![FileUri::parse("file:///repo")?]);
let explorer = FileExplorer::<()>::default().bind_expanded(expanded);
let _ = explorer;
Source

pub fn default_expanded(self, uri: FileUri) -> Self

Appends one unique initial expansion URI.

Defaults apply only when neither Self::expanded nor Self::bind_expanded supplies controlled state.

§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorer;
let explorer = FileExplorer::<()>::default().default_expanded(FileUri::parse("file:///repo")?);
let _ = explorer;
Source

pub fn default_expanded_many( self, uris: impl IntoIterator<Item = FileUri>, ) -> Self

Replaces initial expansion URIs, preserving first-occurrence order.

§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorer;
let root = FileUri::parse("file:///repo")?;
let explorer = FileExplorer::<()>::default().default_expanded_many([root.clone(), root]);
let _ = explorer;
Source

pub fn disabled(self, disabled: impl Into<Binding<bool>>) -> Self

Binds whether tree interaction is disabled.

§Examples
use ailloli_ui_runtime::component::State;
use ailloli_ui_widgets::files::FileExplorer;
let explorer = FileExplorer::<()>::default().disabled(State::new(true));
let _ = explorer;
Source

pub fn clipboard_can_paste(self, can_paste: impl Into<Binding<bool>>) -> Self

Binds whether keyboard/blank-area paste actions are eligible.

A row context menu can still emit PasteInto when an aggregate action handler exists; this flag primarily gates shortcuts and blank menus.

§Examples
use ailloli_ui_widgets::files::FileExplorer;
let explorer = FileExplorer::<()>::default().clipboard_can_paste(true);
let _ = explorer;
Source

pub fn file_style(self, style: FileExplorerStyle) -> Self

Replaces the complete tree style.

§Examples
use ailloli_ui_widgets::files::{FileExplorer, FileExplorerStyle};
let explorer = FileExplorer::<()>::default().file_style(FileExplorerStyle::default());
let _ = explorer;
Source

pub fn file_size(self, size: FileExplorerSize) -> Self

Applies a density preset using the default theme.

This replaces the entire existing style.

§Examples
use ailloli_ui_widgets::files::{FileExplorer, FileExplorerSize};
let explorer = FileExplorer::<()>::default().file_size(FileExplorerSize::Compact);
let _ = explorer;
Source

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

Enables viewport-driven row virtualization in the inner tree.

The default is false; this changes rendering work, not snapshot contents.

§Examples
use ailloli_ui_widgets::files::FileExplorer;
let explorer = FileExplorer::<()>::default().virtualized(true);
let _ = explorer;
Source

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

Wraps the tree in a vertical ScrollView when true.

Scrolling is enabled by default. When disabled, explorer layout builders apply directly to the tree.

§Examples
use ailloli_ui_widgets::files::FileExplorer;
let explorer = FileExplorer::<()>::default().scrollable(false);
let _ = explorer;
Source

pub fn on_action(self, f: impl Fn(FileExplorerAction) -> A + 'static) -> Self

Maps the complete explorer action stream into application actions.

Specialized callbacks run first for their committed interaction, so both may dispatch for one event.

§Examples
use ailloli_ui_widgets::files::{FileExplorer, FileExplorerAction};
enum Action { Explorer(FileExplorerAction) }
let explorer = FileExplorer::<Action>::default().on_action(Action::Explorer);
let _ = explorer;
Source

pub fn on_action_ctx( self, f: impl Fn(&mut EventCtx<A>, FileExplorerAction) + 'static, ) -> Self

Handles the complete action stream with direct event-context access.

§Examples
use ailloli_ui_widgets::files::FileExplorer;
let explorer = FileExplorer::<()>::default().on_action_ctx(|_ctx, _action| {});
let _ = explorer;
Source

pub fn on_select(self, f: impl Fn(FileUri) -> A + 'static) -> Self

Maps row selection into an application action before aggregate emission.

§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorer;
enum Action { Select(FileUri) }
let explorer = FileExplorer::<Action>::default().on_select(Action::Select);
let _ = explorer;
Source

pub fn on_select_ctx( self, f: impl Fn(&mut EventCtx<A>, FileUri) + 'static, ) -> Self

Handles row selection with direct event-context access.

§Examples
use ailloli_ui_widgets::files::FileExplorer;
let explorer = FileExplorer::<()>::default().on_select_ctx(|_ctx, _uri| {});
let _ = explorer;
Source

pub fn on_open(self, f: impl Fn(FileUri) -> A + 'static) -> Self

Maps leaf/context-menu activation before aggregate Open emission.

§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorer;
enum Action { Open(FileUri) }
let explorer = FileExplorer::<Action>::default().on_open(Action::Open);
let _ = explorer;
Source

pub fn on_open_ctx( self, f: impl Fn(&mut EventCtx<A>, FileUri) + 'static, ) -> Self

Handles leaf/context-menu activation with event-context access.

§Examples
use ailloli_ui_widgets::files::FileExplorer;
let explorer = FileExplorer::<()>::default().on_open_ctx(|_ctx, _uri| {});
let _ = explorer;
Source

pub fn on_toggle(self, f: impl Fn(FileUri, bool) -> A + 'static) -> Self

Maps branch URI/new-state transitions before aggregate emission.

§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorer;
enum Action { Toggle(FileUri, bool) }
let explorer = FileExplorer::<Action>::default().on_toggle(Action::Toggle);
let _ = explorer;
Source

pub fn on_toggle_ctx( self, f: impl Fn(&mut EventCtx<A>, FileUri, bool) + 'static, ) -> Self

Handles branch expansion transitions with event-context access.

§Examples
use ailloli_ui_widgets::files::FileExplorer;
let explorer = FileExplorer::<()>::default().on_toggle_ctx(|_ctx, _uri, _open| {});
let _ = explorer;
Source

pub fn on_rename(self, f: impl Fn(FileExplorerRename) -> A + 'static) -> Self

Maps committed inline renames before aggregate Rename emission.

Context-menu rename requests begin editing and emit RenameRequested but do not call this handler until editing commits.

§Examples
use ailloli_ui_widgets::files::{FileExplorer, FileExplorerRename};
enum Action { Rename(FileExplorerRename) }
let explorer = FileExplorer::<Action>::default().on_rename(Action::Rename);
let _ = explorer;
Source

pub fn on_rename_ctx( self, f: impl Fn(&mut EventCtx<A>, FileExplorerRename) + 'static, ) -> Self

Handles committed inline renames with event-context access.

§Examples
use ailloli_ui_widgets::files::FileExplorer;
let explorer = FileExplorer::<()>::default().on_rename_ctx(|_ctx, _rename| {});
let _ = explorer;
Source

pub fn on_remove( self, f: impl Fn(FileUri, Option<FileUri>) -> A + 'static, ) -> Self

Maps committed tree delete events before aggregate Remove emission.

Context-menu delete emits RemoveRequested through the aggregate handler; it uses this handler only to enable the item and does not call it directly.

§Examples
use ailloli_ui_fs::FileUri;
use ailloli_ui_widgets::files::FileExplorer;
enum Action { Remove(FileUri, Option<FileUri>) }
let explorer = FileExplorer::<Action>::default().on_remove(Action::Remove);
let _ = explorer;
Source

pub fn on_remove_ctx( self, f: impl Fn(&mut EventCtx<A>, FileUri, Option<FileUri>) + 'static, ) -> Self

Handles committed tree delete events with event-context access.

§Examples
use ailloli_ui_widgets::files::FileExplorer;
let explorer = FileExplorer::<()>::default().on_remove_ctx(|_ctx, _uri, _parent| {});
let _ = explorer;
Source

pub fn on_create_dir( self, f: impl Fn(FileExplorerCreateDir) -> A + 'static, ) -> Self

Maps committed directory drafts before aggregate CreateDir emission.

File drafts have no specialized callback and emit only aggregate FileExplorerAction::CreateFile.

§Examples
use ailloli_ui_widgets::files::{FileExplorer, FileExplorerCreateDir};
enum Action { Create(FileExplorerCreateDir) }
let explorer = FileExplorer::<Action>::default().on_create_dir(Action::Create);
let _ = explorer;
Source

pub fn on_create_dir_ctx( self, f: impl Fn(&mut EventCtx<A>, FileExplorerCreateDir) + 'static, ) -> Self

Handles committed directory drafts with event-context access.

§Examples
use ailloli_ui_widgets::files::FileExplorer;
let explorer = FileExplorer::<()>::default().on_create_dir_ctx(|_ctx, _event| {});
let _ = explorer;

Trait Implementations§

Source§

impl<A: 'static> Default for FileExplorer<A>

Creates an empty enabled explorer through Self::new.

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<A: 'static> IntoView<A> for FileExplorer<A>

Converts the builder into an intent-only tree, optional scroll view, and menu.

Source§

fn into_view(self) -> View<A>

Consumes a builder/value and returns its declarative view tree. Read more
Source§

impl<A: 'static> LayoutExt for FileExplorer<A>

Source§

fn layout_mut(&mut self) -> &mut LayoutStyle

Returns the widget’s mutable declarative size/inset state. Read more

Auto Trait Implementations§

§

impl<A> Freeze for FileExplorer<A>

§

impl<A = ()> !RefUnwindSafe for FileExplorer<A>

§

impl<A = ()> !Send for FileExplorer<A>

§

impl<A = ()> !Sync for FileExplorer<A>

§

impl<A> Unpin for FileExplorer<A>

§

impl<A = ()> !UnwindSafe for FileExplorer<A>

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, A> FlexItemExt<A> for T
where T: IntoView<A>,

Source§

fn flex_grow(self) -> View<A>

Sets flex-grow weight to one. Read more
Source§

fn flex_grow_by(self, value: f32) -> View<A>

Sets the dimensionless flex-grow weight. Read more
Source§

fn flex_shrink(self, value: f32) -> View<A>

Sets the dimensionless flex-shrink weight. Read more
Source§

fn flex_basis(self, value: impl Into<Length>) -> View<A>

Sets the preferred main-axis flex basis. Read more
Source§

fn align_self(self, value: AlignItems) -> View<A>

Overrides the parent cross-axis alignment for this view. Read more
Source§

fn fill_width(self) -> View<A>

Marks width as parent-fill in the view size hint. Read more
Source§

fn fill_height(self) -> View<A>

Marks height as parent-fill in the view size hint. Read more
Source§

fn fill(self) -> View<A>

Marks both axes as parent-fill in the view size hint. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T, A> IntoViewKeyExt<A> for T
where T: IntoView<A>,

§

fn key(self, key: impl Into<String>) -> View<A>

Converts self, assigns the owned key, and returns the view. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,