Skip to main content

PlacesPanel

Struct PlacesPanel 

Source
pub struct PlacesPanel<'a> { /* private fields */ }
Expand description

A side panel of places: sections, each a heading over its items, as the in-app picker lists them (an import window’s sources column). One stop for Tab; Up and Down go from item to item across the sections (through an item’s toggle, a fold’s band and the application’s content, in the order drawn), Enter or Space chooses. Each item is a button named by its name and badge, described by its line, selected or not; each title a heading, or a fold’s band when the section folds. What a chosen item does is the caller’s: PlacesOutput::chosen.

Opt-in parts (see the module): folding sections, an empty section’s line, an item’s visible line, toned badge and toggle, the application’s content under an item or a section, nested items (PlaceItem::children), dimmed items (PlaceItem::dimmed), a hook on each row (PlacesPanel::on_row) and a selection in several sections (PlacesPanel::selected_set). A panel using none of them looks as it always did.

use egui_pop_api::files::places::{PlaceItem, PlaceSection, PlacesPanel};

fn sources(ui: &mut egui::Ui, at: &mut Option<String>) {
    let sections = [PlaceSection::new("cards", "Cards")
        .item(PlaceItem::folder("EOS_DIGITAL", "/media/EOS_DIGITAL").badge("214"))];
    let out = PlacesPanel::new("import.sources", &sections)
        .selected(at.as_deref())
        .show(ui);
    if let Some((_, item)) = out.chosen {
        *at = Some(item.id);
    }
}

Need (dialog): a side panel of places, with sections of an application’s.

Implementations§

Source§

impl<'a> PlacesPanel<'a>

Source

pub fn new(name: impl Into<String>, sections: &'a [PlaceSection]) -> Self

A panel named name (its roving group’s, unique in the window) of these sections.

Source

pub fn indent_guides(self, mode: IndentGuides) -> Self

When a tree section (PlaceItem::children) draws its indent guides, a thin line down each nesting level in the kit’s list-guide (list-guide.rest.border-color, border-width): never (the default), while the pointer is over the panel, or always, as VS Code’s renderIndentGuides.

Need (data): a tree of places whose levels are easy to follow (folders nested deep).

Source

pub fn indent_guide_highlight(self, on: bool) -> Self

Whether the guide of the hovered row’s parent (the run of its siblings) is highlighted, in list-guide’s hover state (list-guide.hover.border-color); no by default.

Source

pub fn selected(self, id: Option<&'a str>) -> Self

The item shown selected, by id: where the caller is.

Source

pub fn selected_set(self, ids: &'a [&'a str]) -> Self

The items shown selected, by id, beside PlacesPanel::selected: one in each section where the application’s scopes add up (a folder, an album and a keyword chosen together).

Need (data): a side panel of places with one selection in each section (scopes chosen together).

Source

pub fn on_row( self, hook: impl FnMut(&mut Ui, &PlaceSection, &PlaceItem, &Response) + 'a, ) -> Self

A hook called with each item’s row and its response, after the panel’s own handling: the application attaches what the panel knows nothing of (a drop target or a drag source through the drag session, bus::drag; its own context menu; a tip). Called for nested items too.

Need (dialog): a side panel of places whose rows are drop targets or drag sources.

Source

pub fn menu( self, menu: impl FnMut(&mut Ui, &PlaceSection, &PlaceItem) + 'a, ) -> Self

A context menu on each item, drawn by menu (rename, eject, forget).

Source

pub fn under_item( self, add: impl FnMut(&mut Ui, &PlaceSection, &PlaceItem) + 'a, ) -> Self

The application’s content under each item, drawn by add in the room below it (an account’s albums under the account): add draws nothing for an item without any. Its widgets join the panel’s keyboard order after the item.

Source

pub fn under_section(self, add: impl FnMut(&mut Ui, &PlaceSection) + 'a) -> Self

The application’s content under each section’s items, drawn by add (a history’s past imports, each with “Import again”), inside the section’s fold when it folds. Its widgets join the panel’s keyboard order after the section’s items.

Source

pub fn show(self, ui: &mut Ui) -> PlacesOutput

Trait Implementations§

Source§

impl Debug for PlacesPanel<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for PlacesPanel<'a>

§

impl<'a> !RefUnwindSafe for PlacesPanel<'a>

§

impl<'a> !Send for PlacesPanel<'a>

§

impl<'a> !Sync for PlacesPanel<'a>

§

impl<'a> Unpin for PlacesPanel<'a>

§

impl<'a> UnsafeUnpin for PlacesPanel<'a>

§

impl<'a> !UnwindSafe for PlacesPanel<'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
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T, S> SimdFrom<T, S> for T
where S: Simd,

§

fn simd_from(_simd: S, value: T) -> T

§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

§

fn simd_into(self, simd: S) -> T

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> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,