Skip to main content

LayoutMenu

Struct LayoutMenu 

Source
pub struct LayoutMenu {
    pub curr_layout: Option<String>,
    pub layouts: Vec<String>,
    pub config: LayoutMenuConfig,
    pub autosave: bool,
    pub favorites: Vec<String>,
    /* private fields */
}
Expand description

Named layout menu. The host handles the returned intents, capturing a SavedLayout for each save. With set_storage the menu lists the layouts of StoreKind::Layouts and save, open, rename and delete keep them there; without it the host supplies layouts and keeps them itself.

Fields§

§curr_layout: Option<String>

Name of the current layout.

§layouts: Vec<String>

The layouts available to open, sorted by name when read from storage.

§config: LayoutMenuConfig

Menu sizing.

§autosave: bool

Whether the current layout is saved after each change; see autosave_due.

§favorites: Vec<String>

Names of the starred layouts. The menu stars and unstars them, moves a name on a rename and drops it on a delete; keep it between sessions in UserSettings::layout_favorites.

Implementations§

Source§

impl LayoutMenu

Source

pub const AUTOSAVE_DELAY: Duration

How long the layout stays unchanged before autosave_due asks for a save.

Source

pub fn new() -> Self

Creates an unnamed layout menu.

Source

pub fn set_storage(&mut self, storage: Arc<dyn Storage>)

Keep layouts in storage and list them from it.

Source

pub fn set_sharing(&mut self, sharing: Arc<dyn Sharing>)

Offers copy-link and save-a-copy on the current stored layout, as sharing reports them. A saved copy is read back from the Storage given to set_storage, where the host writes it.

Source

pub fn save(&mut self, name: &str, layout: &SavedLayout)

Saves layout as name, which becomes the current layout. With a layout of that name, replaces it.

Source

pub fn open(&mut self, name: &str)

Reads the layout name; poll returns it to restore.

Source

pub fn rename(&mut self, name: &str, layout: &SavedLayout)

Renames the current layout to name by saving layout, the current layout, under it and then deleting the old one.

Source

pub fn delete(&mut self, name: &str)

Deletes the layout name.

Source

pub fn poll(&mut self, ctx: &Context) -> Option<(String, SavedLayout)>

Receives storage’s answers, updating the list, and wakes the UI on the next answer. Returns a layout open read, now the current layout, for the host to restore before its next autosave_due.

Source

pub fn autosave_due(&mut self, ctx: &Context, edits: u64) -> bool

Call every frame with a count that changes whenever the layout does, such as the sum of Chart::edit_count over its charts. Returns true when the host should save the current layout: autosave is on, the layout is stored, and the count changed and then stayed the same for AUTOSAVE_DELAY.

Source

pub fn take_error(&mut self) -> Option<String>

The error of a failed storage request since the last call, to show to the user.

Source

pub fn width(&self, ui: &Ui) -> f32

Width of the named trigger.

Source

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

Shows the current name and an anchored menu. Actions do not mutate the host’s catalog.

Source

pub fn show_menu(&mut self, ui: &mut Ui) -> LayoutAction

Named layout menu contents, shared with the save dropdown.

Trait Implementations§

Source§

impl Default for LayoutMenu

Source§

fn default() -> Self

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

Auto Trait Implementations§

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<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,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

impl<T> MaybeSend for T
where T: Send + Sync + ?Sized,

§

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

§

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.