Struct UndoAccess
pub struct UndoAccess { /* private fields */ }Expand description
The undo half of a widget, as one embeddable field: the last
UndoStatus the host published, plus at most one pending
UndoRequest.
Embed it and wire the two Widget methods:
struct MyToolbar { undo: tilo_ui::UndoAccess, /* … */ }
impl Widget for MyToolbar {
fn set_undo_status(&mut self, s: &mut dyn FnMut() -> tilo_ui::UndoStatus) { self.undo.publish(&s()); }
fn take_undo_request(&mut self) -> Option<tilo_ui::UndoRequest> { self.undo.take_request() }
}Then self.undo.can_undo() decides whether the control paints enabled, and
self.undo.request(UndoRequest::Undo) on activation asks the host to do it.
Implementations§
§impl UndoAccess
impl UndoAccess
pub fn new() -> UndoAccess
pub fn new() -> UndoAccess
A fresh access with an empty history and nothing pending.
pub fn publish(&mut self, status: &UndoStatus)
pub fn publish(&mut self, status: &UndoStatus)
Host → widget: store the status published this frame.
pub fn status(&self) -> &UndoStatus
pub fn status(&self) -> &UndoStatus
The last published status.
pub fn can_undo(&self) -> bool
pub fn can_redo(&self) -> bool
pub fn can(&self, which: UndoRequest) -> bool
pub fn can(&self, which: UndoRequest) -> bool
Whether the verb which is currently available — what a control’s
enabled/disabled state must be derived from.
pub fn request(&mut self, which: UndoRequest) -> bool
pub fn request(&mut self, which: UndoRequest) -> bool
Ask the host to perform which. Returns false — and enqueues
nothing — when the verb is unavailable, so a control that somehow got
activated while empty cannot make the host attempt an undo that isn’t
there.
pub fn take_request(&mut self) -> Option<UndoRequest>
pub fn take_request(&mut self) -> Option<UndoRequest>
Widget → host: take the pending request. Rising-edge — reading clears it, so one activation produces exactly one undo.
Trait Implementations§
§impl Clone for UndoAccess
impl Clone for UndoAccess
§fn clone(&self) -> UndoAccess
fn clone(&self) -> UndoAccess
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for UndoAccess
impl Debug for UndoAccess
§impl Default for UndoAccess
impl Default for UndoAccess
§fn default() -> UndoAccess
fn default() -> UndoAccess
Auto Trait Implementations§
impl Freeze for UndoAccess
impl RefUnwindSafe for UndoAccess
impl Send for UndoAccess
impl Sync for UndoAccess
impl Unpin for UndoAccess
impl UnsafeUnpin for UndoAccess
impl UnwindSafe for UndoAccess
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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