pub struct UndoManager { /* private fields */ }Expand description
Unified manager for undo and redo stacks. Supports grouping of actions, max undo depth clamping, and coalescing.
Implementations§
Source§impl UndoManager
impl UndoManager
Sourcepub fn new(max_depth: usize, coalesce_window: f32) -> Self
pub fn new(max_depth: usize, coalesce_window: f32) -> Self
Create a new UndoManager with custom settings.
Sourcepub fn push(
&mut self,
label: &str,
undo: impl Fn() + Send + Sync + 'static,
redo: impl Fn() + Send + Sync + 'static,
)
pub fn push( &mut self, label: &str, undo: impl Fn() + Send + Sync + 'static, redo: impl Fn() + Send + Sync + 'static, )
Push a new undo/redo group to the stack, clearing any forward redo history.
Sourcepub fn undo(&mut self) -> Option<Arc<dyn Fn() + Send + Sync>>
pub fn undo(&mut self) -> Option<Arc<dyn Fn() + Send + Sync>>
Perform the undo action if possible, moving the position back. Returns the undo closure to be executed outside of any state lock.
Sourcepub fn redo(&mut self) -> Option<Arc<dyn Fn() + Send + Sync>>
pub fn redo(&mut self) -> Option<Arc<dyn Fn() + Send + Sync>>
Perform the redo action if possible, moving the position forward. Returns the redo closure to be executed outside of any state lock.
Sourcepub fn push_coalesceable(
&mut self,
label: &str,
undo: impl Fn() + Send + Sync + 'static,
redo: impl Fn() + Send + Sync + 'static,
)
pub fn push_coalesceable( &mut self, label: &str, undo: impl Fn() + Send + Sync + 'static, redo: impl Fn() + Send + Sync + 'static, )
Push a new coalesceable action. If the last action in the stack matches the label, is within the coalesce window, and the position is at the end of the stack, their undo/redo functions will be combined instead of creating a new group.
Trait Implementations§
Source§impl Clone for UndoManager
impl Clone for UndoManager
Source§impl Debug for UndoManager
impl Debug for UndoManager
Auto Trait Implementations§
impl !RefUnwindSafe for UndoManager
impl !UnwindSafe for UndoManager
impl Freeze for UndoManager
impl Send for UndoManager
impl Sync for UndoManager
impl Unpin for UndoManager
impl UnsafeUnpin for UndoManager
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<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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn 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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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.Source§fn as_any(&self) -> &(dyn Any + 'static)
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.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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.