Event

Enum Event 

Source
pub enum Event {
Show 43 variants ClearCanvas, ResizeCanvas(Size<i32>), BrushStart, BrushStroke(Position<i32>), BrushEnd, SetTool(Tool), SetMainColor(Color), AddToPalette(Color), RemoveFromPalette(Color), Save(PathBuf), OpenFile(PathBuf), SaveProject(PathBuf), LoadProject(PathBuf), LoadPalette(PathBuf), Bucket(Point<i32>), EraseStart, EraseEnd, Erase(Position<i32>), LineStart(Point<i32>), LineEnd(Point<i32>), RectStart(Point<i32>), RectEnd(Point<i32>), NewLayerAbove, NewLayerBelow, SwitchLayer(usize), ChangeLayerVisibility(usize, bool), ChangeLayerOpacity(usize, u8), DeleteLayer(usize), MoveLayerDown(usize), MoveLayerUp(usize), SetSpritesheet(Size<u8>), StartSelection(Point<i32>), EndSelection(Point<i32>), ClearSelection, DeleteSelection, MoveStart(Point<i32>), MoveEnd(Point<i32>), Copy, Paste(Point<i32>), FlipHorizontal, FlipVertical, ApplyTransform(Transform), Undo,
}
Expand description

Represents an event. This is one of the key types of this crate. The main way the State of the drawing project can be modified is by sending events to it.

Variants§

§

ClearCanvas

Erase the image of the active canvas

§

ResizeCanvas(Size<i32>)

Resize the whole canvas (all layers). Parts of the image that are out of bounds will be lost, and new pixels will be transparent

§

BrushStart

This event should be triggered once the user starts drawing with the brush (i.e. mouse button is pressed)

§

BrushStroke(Position<i32>)

After a BrushStart event happens, this event should be triggered as often as possible whenever the mouse moves. It will draw a line between the last brush action position and this one. If the event is not triggered often enough, instead of smooth drawing strokes, it will draw straight lines between points.

§

BrushEnd

This event should be triggered when the brush drawing action is finished (i.e. mouse button is released)

§

SetTool(Tool)

Set the active tool

§

SetMainColor(Color)

Set the main color used by most tools

§

AddToPalette(Color)

Add a color to the palette, if it is not already there

§

RemoveFromPalette(Color)

Remove a color from the palette

§

Save(PathBuf)

Export the image to the defined path

§

OpenFile(PathBuf)

Import an image from the defined path. The image will be loaded as a free image that can be moved around, and will resize the canvas if it’s too big for it.

§

SaveProject(PathBuf)

Save the drawing project to the defined file path

§

LoadProject(PathBuf)

Load a drawing project from a path

§

LoadPalette(PathBuf)

Load a palette from a file path. The file must be an image. The image will be read and colors will be added to the palette without repetition, until a certain limit of colors is reached.

§

Bucket(Point<i32>)

Apply bucket to a point (fill with color)

§

EraseStart

Similar to BrushStart, but for eraser

§

EraseEnd

Similar to BrushEnd, but for eraser

§

Erase(Position<i32>)

Similar to BrushStroke, but for eraser. The difference is that the eraser always uses transparent as its color

§

LineStart(Point<i32>)

Begin a line at the specified point

§

LineEnd(Point<i32>)

Draw a line between this point and the previous point specified with LineStart

§

RectStart(Point<i32>)

Start drawing a rectangle at the specified point

§

RectEnd(Point<i32>)

Draw a rectangle with corners at this point and the point specified at RectStart

§

NewLayerAbove

Create a new layer above the current layer

§

NewLayerBelow

Create a new layer below the current layer

§

SwitchLayer(usize)

Swith the active layer to the one with specified index

§

ChangeLayerVisibility(usize, bool)

Make the layer specified by its index visible or invisible

§

ChangeLayerOpacity(usize, u8)

Change the alpha/opacity of the layer with the specified index

§

DeleteLayer(usize)

Delete layer at index

§

MoveLayerDown(usize)

Move the layer at specified index down (swap positions with the layer below it)

§

MoveLayerUp(usize)

Move the layer at specified index up (swap positions with the layer above it)

§

SetSpritesheet(Size<u8>)

Define how many horizontal and vertical frames this spritesheet has (default is (1, 1), that is, just one frame). This is useful for displaying animations

§

StartSelection(Point<i32>)

Start a rectangular selection at the specified point

§

EndSelection(Point<i32>)

Select a rectangle with corners at this point and the point specified by StartSelection

§

ClearSelection

Clear the selection

§

DeleteSelection

Delete the selected area or free image

§

MoveStart(Point<i32>)

This event must be triggered when the user starts dragging the selection, specifying the initial mouse coordinate

§

MoveEnd(Point<i32>)

Finishes moving an image. The move vector will be calculate from the initial mouse position defined in MoveStart and the final position defined here.

§

Copy

Copy a selection to the clipboard

§

Paste(Point<i32>)

Paste the clipboard at the specified point in the canvas

§

FlipHorizontal

Flip the selection horizontally

§

FlipVertical

Flip the selection vertically

§

ApplyTransform(Transform)

Apply an image transform

§

Undo

Undo the last undoable action

Implementations§

Source§

impl Event

Source

pub fn same_variant(&self, other: &Self) -> bool

Check whether two events are of the same variant

Source

pub fn canvas_effect(&self) -> CanvasEffect

Returns the CanvasEffect caused by this event

Source

pub fn repeatable(&self) -> bool

Whether this event can happen twice in a roll

Source

pub fn type_repeatable(&self) -> bool

Whether this kind of event can happen twice in a roll

Source

pub fn undoable(&self) -> bool

Whether this event can be undone

Source

pub fn clears_selection(&self) -> bool

Whether this event causes the selection to be cleared

Source

pub fn triggers_anchoring(&self) -> bool

Whether this event causes any FreeImage to be anchored to the canvas

Trait Implementations§

Source§

impl Clone for Event

Source§

fn clone(&self) -> Event

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Event

Source§

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

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

impl<'de> Deserialize<'de> for Event

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Event

Source§

fn eq(&self, other: &Event) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Event

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Event

Auto Trait Implementations§

§

impl Freeze for Event

§

impl RefUnwindSafe for Event

§

impl Send for Event

§

impl Sync for Event

§

impl Unpin for Event

§

impl UnwindSafe for Event

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,