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: LayoutMenuConfigMenu sizing.
autosave: boolWhether 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
impl LayoutMenu
Sourcepub const AUTOSAVE_DELAY: Duration
pub const AUTOSAVE_DELAY: Duration
How long the layout stays unchanged before autosave_due asks
for a save.
Sourcepub fn set_storage(&mut self, storage: Arc<dyn Storage>)
pub fn set_storage(&mut self, storage: Arc<dyn Storage>)
Keep layouts in storage and list them from it.
Sourcepub fn set_sharing(&mut self, sharing: Arc<dyn Sharing>)
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.
Sourcepub fn save(&mut self, name: &str, layout: &SavedLayout)
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.
Sourcepub fn rename(&mut self, name: &str, layout: &SavedLayout)
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.
Sourcepub fn poll(&mut self, ctx: &Context) -> Option<(String, SavedLayout)>
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.
Sourcepub fn autosave_due(&mut self, ctx: &Context, edits: u64) -> bool
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.
Sourcepub fn take_error(&mut self) -> Option<String>
pub fn take_error(&mut self) -> Option<String>
The error of a failed storage request since the last call, to show to the user.
Sourcepub fn show(&mut self, ui: &mut Ui) -> LayoutAction
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.
Named layout menu contents, shared with the save dropdown.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for LayoutMenu
impl !UnwindSafe for LayoutMenu
impl Freeze for LayoutMenu
impl Send for LayoutMenu
impl Sync for LayoutMenu
impl Unpin for LayoutMenu
impl UnsafeUnpin for LayoutMenu
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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