Skip to main content

DrawSession

Struct DrawSession 

Source
pub struct DrawSession { /* private fields */ }
Expand description

Drawing session holding shapes plus undo/redo stacks.

Implementations§

Source§

impl DrawSession

Source

pub fn new() -> Self

Source

pub fn shapes(&self) -> &[Shape]

Source

pub fn add(&mut self, shape: Shape)

Add a shape; clears the redo stack.

Source

pub fn remove(&mut self, index: usize) -> bool

Remove shape at index.

Source

pub fn clear(&mut self)

Remove all shapes.

Source

pub fn can_undo(&self) -> bool

Source

pub fn can_redo(&self) -> bool

Source

pub fn undo(&mut self) -> bool

Undo the last operation. Returns false if nothing to undo.

Source

pub fn redo(&mut self) -> bool

Redo the last undone operation. Returns false if nothing to redo.

Trait Implementations§

Source§

impl Debug for DrawSession

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DrawSession

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
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.