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
impl Event
Sourcepub fn same_variant(&self, other: &Self) -> bool
pub fn same_variant(&self, other: &Self) -> bool
Check whether two events are of the same variant
Sourcepub fn canvas_effect(&self) -> CanvasEffect
pub fn canvas_effect(&self) -> CanvasEffect
Returns the CanvasEffect caused by this event
Sourcepub fn repeatable(&self) -> bool
pub fn repeatable(&self) -> bool
Whether this event can happen twice in a roll
Sourcepub fn type_repeatable(&self) -> bool
pub fn type_repeatable(&self) -> bool
Whether this kind of event can happen twice in a roll
Sourcepub fn clears_selection(&self) -> bool
pub fn clears_selection(&self) -> bool
Whether this event causes the selection to be cleared
Sourcepub fn triggers_anchoring(&self) -> bool
pub fn triggers_anchoring(&self) -> bool
Whether this event causes any FreeImage to be anchored to the canvas
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Event
impl<'de> Deserialize<'de> for Event
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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> 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,
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