mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-25 01:28:12 +08:00
Implement svg layer structure (#59)
* Add folder struct * Add file system like structure to interface with svgs * Add primitive undo functionality * Restructure layer system
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::events::{Event, Response};
|
||||
use crate::events::{MouseKeys, ViewportPosition};
|
||||
use crate::events::{Key, MouseKeys, ViewportPosition};
|
||||
use crate::tools::{Fsm, Tool};
|
||||
use crate::Document;
|
||||
use document_core::Operation;
|
||||
@@ -45,12 +45,20 @@ impl Fsm for EllipseToolFsmState {
|
||||
data.drag_start = mouse_state.position;
|
||||
EllipseToolFsmState::LmbDown
|
||||
}
|
||||
(EllipseToolFsmState::Ready, Event::KeyDown(Key::KeyZ)) => {
|
||||
if let Some(id) = document.root.list_layers().last() {
|
||||
operations.push(Operation::DeleteLayer { path: vec![*id] })
|
||||
}
|
||||
EllipseToolFsmState::Ready
|
||||
}
|
||||
|
||||
// TODO - Check for left mouse button
|
||||
(EllipseToolFsmState::LmbDown, Event::MouseUp(mouse_state)) => {
|
||||
let r = data.drag_start.distance(&mouse_state.position);
|
||||
log::info!("draw ellipse with radius: {:.2}", r);
|
||||
operations.push(Operation::AddCircle {
|
||||
path: vec![],
|
||||
insert_index: -1,
|
||||
cx: data.drag_start.x as f64,
|
||||
cy: data.drag_start.y as f64,
|
||||
r: data.drag_start.distance(&mouse_state.position),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::events::{Event, Response};
|
||||
use crate::events::{MouseKeys, ViewportPosition};
|
||||
use crate::events::{Key, MouseKeys, ViewportPosition};
|
||||
use crate::tools::{Fsm, Tool};
|
||||
use crate::Document;
|
||||
use document_core::Operation;
|
||||
@@ -45,6 +45,12 @@ impl Fsm for RectangleToolFsmState {
|
||||
data.drag_start = mouse_state.position;
|
||||
RectangleToolFsmState::LmbDown
|
||||
}
|
||||
(RectangleToolFsmState::Ready, Event::KeyDown(Key::KeyZ)) => {
|
||||
if let Some(id) = document.root.list_layers().last() {
|
||||
operations.push(Operation::DeleteLayer { path: vec![*id] })
|
||||
}
|
||||
RectangleToolFsmState::Ready
|
||||
}
|
||||
|
||||
// TODO - Check for left mouse button
|
||||
(RectangleToolFsmState::LmbDown, Event::MouseUp(mouse_state)) => {
|
||||
@@ -53,6 +59,8 @@ impl Fsm for RectangleToolFsmState {
|
||||
let start = data.drag_start;
|
||||
let end = mouse_state.position;
|
||||
operations.push(Operation::AddRect {
|
||||
path: vec![],
|
||||
insert_index: -1,
|
||||
x0: start.x as f64,
|
||||
y0: start.y as f64,
|
||||
x1: end.x as f64,
|
||||
|
||||
Reference in New Issue
Block a user