pub struct HistoryService { /* private fields */ }Expand description
History service for undo/redo operations
Implementations§
Source§impl HistoryService
impl HistoryService
Sourcepub fn with_max_size(max_size: usize) -> Self
pub fn with_max_size(max_size: usize) -> Self
Create a history that keeps at most max_size undo steps, dropping the oldest first;
0 keeps every step.
Sourcepub fn push_snapshot(&mut self, drawings: Vec<(usize, Drawing)>)
pub fn push_snapshot(&mut self, drawings: Vec<(usize, Drawing)>)
Record the drawings a bulk edit changes or removes, each with its list index before the edit, as one undo step. Undo restores only these drawings.
Sourcepub fn push_delete(&mut self, drawing: Drawing, index: usize)
pub fn push_delete(&mut self, drawing: Drawing, index: usize)
Record that a drawing was deleted from list index index
Sourcepub fn push_modify(&mut self, id: usize, old_state: Drawing)
pub fn push_modify(&mut self, id: usize, old_state: Drawing)
Record that a drawing was modified
Sourcepub fn undo(&mut self, drawings: &mut Vec<Drawing>) -> Option<usize>
pub fn undo(&mut self, drawings: &mut Vec<Drawing>) -> Option<usize>
Undo the last operation
Returns the ID of the affected drawing, if any.
Sourcepub fn redo(&mut self, drawings: &mut Vec<Drawing>) -> Option<usize>
pub fn redo(&mut self, drawings: &mut Vec<Drawing>) -> Option<usize>
Redo the last undone operation
Returns the ID of the affected drawing, if any.
Sourcepub fn undo_count(&self) -> usize
pub fn undo_count(&self) -> usize
Get the number of undo operations available
Sourcepub fn redo_count(&self) -> usize
pub fn redo_count(&self) -> usize
Get the number of redo operations available
Sourcepub fn shift_bar_indices(&mut self, from: f32, delta: f32)
pub fn shift_bar_indices(&mut self, from: f32, delta: f32)
Shift the bar indices at or after from in history (for bars inserted in front of them)
Sourcepub fn prune(&mut self, existing_ids: &HashSet<usize>)
pub fn prune(&mut self, existing_ids: &HashSet<usize>)
Prune undo history entries for drawings that no longer exist.
Only the undo stack is pruned against the live id set. The redo stack is
intentionally left intact: a redo entry legitimately references a drawing
that is absent from the live set. After an Add is undone, the drawing
is removed from the live set but its re-adding command sits on the redo
stack; pruning the redo stack against live ids would silently drop that
entry and lose the redo. The redo stack is the authoritative record of
what redo would restore, so it is the wrong place to enforce live-id
membership.
Sourcepub fn last_undo_description(&self) -> Option<&'static str>
pub fn last_undo_description(&self) -> Option<&'static str>
Get description of the last undoable action (for UI)
Sourcepub fn last_redo_description(&self) -> Option<&'static str>
pub fn last_redo_description(&self) -> Option<&'static str>
Get description of the last redoable action (for UI)
Trait Implementations§
Source§impl Clone for HistoryService
impl Clone for HistoryService
Source§fn clone(&self) -> HistoryService
fn clone(&self) -> HistoryService
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HistoryService
impl Debug for HistoryService
Source§impl Default for HistoryService
impl Default for HistoryService
Source§fn default() -> HistoryService
fn default() -> HistoryService
Auto Trait Implementations§
impl Freeze for HistoryService
impl RefUnwindSafe for HistoryService
impl Send for HistoryService
impl Sync for HistoryService
impl Unpin for HistoryService
impl UnsafeUnpin for HistoryService
impl UnwindSafe for HistoryService
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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