mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
* Enforce cache dirtification * Turn all shapes into one struct * Remove working folder * Remove old shapes * Major restructuring * Refactor Ellipse, Rectangle and ShapeTool * Simplify bounding box calculation for folder * Fix panic in select tool * Refactorselect tool * Refactor Align * Refactor flipping layers * Zoom to fit all * Refactor tools to avoid state keeping * Refactor more tools to use state that is passed along * Fix whitespace + change selection box style * Set viewbox of svg export based on the contents
85 lines
3.0 KiB
Rust
85 lines
3.0 KiB
Rust
//! **Graphite Editor Core Library**: `/core/editor/`
|
|
//!
|
|
//! Used by a frontend editor client to maintain GUI state and dispatch user events.
|
|
//! The official Graphite editor is the primary user,
|
|
//! but others software like game engines could embed their own customized editor implementations.
|
|
//! Depends on the Document Core Library.
|
|
|
|
// since our policy is tabs, we want to stop clippy from warning about that
|
|
#![allow(clippy::tabs_in_doc_comments)]
|
|
|
|
extern crate graphite_proc_macros;
|
|
|
|
mod communication;
|
|
#[macro_use]
|
|
pub mod misc;
|
|
mod document;
|
|
mod frontend;
|
|
mod global;
|
|
pub mod input;
|
|
pub mod tool;
|
|
|
|
pub mod consts;
|
|
|
|
#[doc(inline)]
|
|
pub use misc::EditorError;
|
|
|
|
#[doc(inline)]
|
|
pub use document_core::color::Color;
|
|
|
|
#[doc(inline)]
|
|
pub use document_core::LayerId;
|
|
|
|
#[doc(inline)]
|
|
pub use document_core::document::Document as SvgDocument;
|
|
|
|
#[doc(inline)]
|
|
pub use frontend::Callback;
|
|
|
|
use communication::dispatcher::Dispatcher;
|
|
// TODO: serialize with serde to save the current editor state
|
|
pub struct Editor {
|
|
dispatcher: Dispatcher,
|
|
}
|
|
|
|
use message_prelude::*;
|
|
|
|
impl Editor {
|
|
pub fn new(callback: Callback) -> Self {
|
|
Self {
|
|
dispatcher: Dispatcher::new(callback),
|
|
}
|
|
}
|
|
|
|
pub fn handle_message<T: Into<Message>>(&mut self, message: T) -> Result<(), EditorError> {
|
|
self.dispatcher.handle_message(message)
|
|
}
|
|
}
|
|
|
|
pub mod message_prelude {
|
|
pub use crate::communication::generate_hash;
|
|
pub use crate::communication::message::{AsMessage, Message, MessageDiscriminant};
|
|
pub use crate::communication::{ActionList, MessageHandler};
|
|
pub use crate::document::{DocumentMessage, DocumentMessageDiscriminant};
|
|
pub use crate::document::{DocumentsMessage, DocumentsMessageDiscriminant};
|
|
pub use crate::document::{MovementMessage, MovementMessageDiscriminant};
|
|
pub use crate::frontend::{FrontendMessage, FrontendMessageDiscriminant};
|
|
pub use crate::global::{GlobalMessage, GlobalMessageDiscriminant};
|
|
pub use crate::input::{InputMapperMessage, InputMapperMessageDiscriminant, InputPreprocessorMessage, InputPreprocessorMessageDiscriminant};
|
|
pub use crate::misc::derivable_custom_traits::{ToDiscriminant, TransitiveChild};
|
|
pub use crate::tool::tool_messages::*;
|
|
pub use crate::tool::tools::crop::{CropMessage, CropMessageDiscriminant};
|
|
pub use crate::tool::tools::eyedropper::{EyedropperMessage, EyedropperMessageDiscriminant};
|
|
pub use crate::tool::tools::fill::{FillMessage, FillMessageDiscriminant};
|
|
pub use crate::tool::tools::line::{LineMessage, LineMessageDiscriminant};
|
|
pub use crate::tool::tools::navigate::{NavigateMessage, NavigateMessageDiscriminant};
|
|
pub use crate::tool::tools::path::{PathMessage, PathMessageDiscriminant};
|
|
pub use crate::tool::tools::pen::{PenMessage, PenMessageDiscriminant};
|
|
pub use crate::tool::tools::rectangle::{RectangleMessage, RectangleMessageDiscriminant};
|
|
pub use crate::tool::tools::select::{SelectMessage, SelectMessageDiscriminant};
|
|
pub use crate::tool::tools::shape::{ShapeMessage, ShapeMessageDiscriminant};
|
|
pub use crate::LayerId;
|
|
pub use graphite_proc_macros::*;
|
|
pub use std::collections::VecDeque;
|
|
}
|