Implement basic circle stamping (#53)

This commit is contained in:
T0mstone
2021-03-29 01:44:34 +02:00
committed by GitHub
parent c437f1bd22
commit 94f50377a3
10 changed files with 85 additions and 46 deletions
+15 -5
View File
@@ -17,25 +17,35 @@ pub use dispatcher::events;
pub use dispatcher::Callback;
use dispatcher::Dispatcher;
use document_core::Document;
use tools::ToolState;
use workspace::Workspace;
// TODO: serialize with serde to save the current editor state
pub struct Editor {
pub struct EditorState {
tools: ToolState,
workspace: Workspace,
document: Document,
}
// TODO: serialize with serde to save the current editor state
pub struct Editor {
state: EditorState,
dispatcher: Dispatcher,
}
impl Editor {
pub fn new(callback: Callback) -> Self {
Self {
tools: ToolState::new(),
workspace: Workspace::new(),
state: EditorState {
tools: ToolState::new(),
workspace: Workspace::new(),
document: Document::default(),
},
dispatcher: Dispatcher::new(callback),
}
}
pub fn handle_event(&mut self, event: events::Event) -> Result<(), EditorError> {
self.dispatcher.handle_event(&mut self.tools, event)
self.dispatcher.handle_event(&mut self.state, event)
}
}