pub struct FileEntry {
id: Id,
rect: Rectangle,
children: Vec<Box<dyn View>>,
data: FileEntryData,
}Expand description
A visual entry representing a file or directory in the file browser.
FileEntry displays file metadata in a horizontal layout with an icon, name, size, and date.
It handles user interactions such as taps to select files and long presses to perform actions
on directories.
§Fields
id- Unique identifier for this viewrect- Bounding rectangle for the entire entrychildren- Child views (labels for icon, name, size, and date)data- File entry data containing metadata (name, size, date, directory flag, path)
Fields§
§id: Id§rect: Rectangle§children: Vec<Box<dyn View>>§data: FileEntryDataImplementations§
Source§impl FileEntry
impl FileEntry
Sourcepub fn new(
rect: Rectangle,
data: FileEntryData,
context: &mut Context,
) -> FileEntry
pub fn new( rect: Rectangle, data: FileEntryData, context: &mut Context, ) -> FileEntry
Creates a new file entry with a horizontal layout displaying file metadata.
§Layout
The entry displays file information in a left-to-right layout:
- Icon (left): Directory folder (📁) or file (📄) emoji
- Name (center-left): File or directory name, truncated if necessary
- Size (center-right): Formatted file size (e.g., “1.5 MB”) or “-” if unavailable
- Date (right): Last modified date in format “Mon DD, YYYY HH:MM” or “-” if unavailable
Each element is separated by padding based on the font’s em size. The name field expands to fill available space between icon and size/date fields.
§Arguments
rect- The bounding rectangle for the entire entrydata- The file entry data containing name, size, modification date, and directory flagcontext- Mutable reference to the application context for font access
fn format_size(size: u64) -> String
fn format_date(system_time: SystemTime) -> String
Trait Implementations§
Source§impl View for FileEntry
impl View for FileEntry
Source§fn handle_event(
&mut self,
evt: &Event,
_hub: &Hub,
bus: &mut Bus,
_rq: &mut RenderQueue,
_context: &mut Context,
) -> bool
fn handle_event( &mut self, evt: &Event, _hub: &Hub, bus: &mut Bus, _rq: &mut RenderQueue, _context: &mut Context, ) -> bool
Handles events for the file entry.
This method processes user interactions with the file entry:
- Tap gesture: If the tap is within the entry’s bounds, it pushes either a
SelectDirectoryevent (for directories) or aSelectevent (for files) to the bus. - Hold gesture (short): If the hold is within the entry’s bounds and the entry
represents a directory, it pushes a
Holdevent to the bus. - Other events: Returns
falseand does not process other event types.
§Arguments
evt- The event to handle_hub- Unused hub referencebus- The event bus to push generated events to_rq- Unused render queue reference_context- Unused context reference
§Returns
true if the event was handled, false otherwise.
fn render(&self, fb: &mut dyn Framebuffer, _rect: Rectangle, _fonts: &mut Fonts)
fn rect(&self) -> &Rectangle
fn rect_mut(&mut self) -> &mut Rectangle
fn children(&self) -> &Vec<Box<dyn View>>
fn children_mut(&mut self) -> &mut Vec<Box<dyn View>>
fn id(&self) -> Id
fn render_rect(&self, _rect: &Rectangle) -> Rectangle
fn resize( &mut self, rect: Rectangle, _hub: &Hub, _rq: &mut RenderQueue, _context: &mut Context, )
fn child(&self, index: usize) -> &dyn View
fn child_mut(&mut self, index: usize) -> &mut dyn View
fn len(&self) -> usize
fn might_skip(&self, _evt: &Event) -> bool
fn might_rotate(&self) -> bool
fn is_background(&self) -> bool
fn view_id(&self) -> Option<ViewId>
Auto Trait Implementations§
impl Freeze for FileEntry
impl !RefUnwindSafe for FileEntry
impl !Send for FileEntry
impl !Sync for FileEntry
impl Unpin for FileEntry
impl !UnwindSafe for FileEntry
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
Mutably borrows from an owned value. Read more
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.