mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 23:08:05 +08:00
* Add proc-macro crate with two macros * Let cargo recalculate the Cargo.lock * Add tests and refactor some code to allow testing also the impl for parse_hint_helper_attrs now preserves order (which is essential for testing)
56 lines
1019 B
Rust
56 lines
1019 B
Rust
#[macro_use]
|
|
mod macros;
|
|
|
|
mod color;
|
|
mod dispatcher;
|
|
mod error;
|
|
pub mod hint;
|
|
pub mod tools;
|
|
pub mod workspace;
|
|
|
|
#[doc(inline)]
|
|
pub use error::EditorError;
|
|
|
|
#[doc(inline)]
|
|
pub use color::Color;
|
|
|
|
#[doc(inline)]
|
|
pub use dispatcher::events;
|
|
|
|
#[doc(inline)]
|
|
pub use dispatcher::Callback;
|
|
|
|
use dispatcher::Dispatcher;
|
|
use document_core::Document;
|
|
use tools::ToolFsmState;
|
|
use workspace::Workspace;
|
|
|
|
pub struct EditorState {
|
|
tool_state: ToolFsmState,
|
|
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 {
|
|
state: EditorState {
|
|
tool_state: ToolFsmState::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.state, &event)
|
|
}
|
|
}
|