mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-07-22 23:25:01 +00:00
Vue initialization and FloatingMenu codebase refactoring and cleanup (#649)
* Clean up Vue initialization-related code * Rename folder: dispatcher -> interop * Rename folder: state -> providers * Comments and clarification * Rename JS dispatcher to subscription router * Assorted cleanup and renaming * Rename: js-messages.ts -> messages.ts * Comments * Remove unused Vue component injects * Clean up coming soon and add warning about freezing the app * Further cleanup * Dangerous changes * Simplify App.vue code * Move more disparate init code from components into managers * Rename folder: providers -> state-providers * Other * Move Document panel options bar separator to backend * Add destructors to managers to fix HMR * Comments and code style * Rename variable: font -> font_file_url * Fix async font loading; refactor janky floating menu openness and min-width measurement; fix Vetur errors * Fix misaligned canvas in viewport until panning on page (re)load * Add Vue bidirectional props documentation * More folder renaming for better terminology; add some documentation
This commit is contained in:
parent
4c3c925c2c
commit
fc2d983bd7
73 changed files with 1572 additions and 1462 deletions
|
@ -1,6 +1,6 @@
|
|||
// This file is where functions are defined to be called directly from JS.
|
||||
// It serves as a thin wrapper over the editor backend API that relies
|
||||
// on the dispatcher messaging system and more complex Rust data types.
|
||||
//! This file is where functions are defined to be called directly from JS.
|
||||
//! It serves as a thin wrapper over the editor backend API that relies
|
||||
//! on the dispatcher messaging system and more complex Rust data types.
|
||||
|
||||
use crate::helpers::{translate_key, Error};
|
||||
use crate::{EDITOR_HAS_CRASHED, EDITOR_INSTANCES, JS_EDITOR_HANDLES};
|
||||
|
@ -84,10 +84,34 @@ impl JsEditorHandle {
|
|||
// the backend from the web frontend.
|
||||
// ========================================================================
|
||||
|
||||
pub fn init_app(&self) {
|
||||
let message = PortfolioMessage::UpdateOpenDocumentsList;
|
||||
self.dispatch(message);
|
||||
|
||||
let message = PortfolioMessage::UpdateDocumentWidgets;
|
||||
self.dispatch(message);
|
||||
|
||||
let message = ToolMessage::InitTools;
|
||||
self.dispatch(message);
|
||||
|
||||
let message = FrontendMessage::TriggerFontLoadDefault;
|
||||
self.dispatch(message);
|
||||
|
||||
let message = MovementMessage::TranslateCanvas { delta: (0., 0.).into() };
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
/// Intentionally panic for debugging purposes
|
||||
pub fn intentional_panic(&self) {
|
||||
panic!();
|
||||
}
|
||||
|
||||
/// Answer whether or not the editor has crashed
|
||||
pub fn has_crashed(&self) -> bool {
|
||||
EDITOR_HAS_CRASHED.load(Ordering::SeqCst)
|
||||
}
|
||||
|
||||
/// Request that the Node Graph panel be shown or hidden by toggling the visibility state
|
||||
pub fn toggle_node_graph_visibility(&self) {
|
||||
self.dispatch(WorkspaceMessage::NodeGraphToggleVisibility);
|
||||
}
|
||||
|
@ -109,11 +133,6 @@ impl JsEditorHandle {
|
|||
self.dispatch(message);
|
||||
}
|
||||
|
||||
pub fn get_open_documents_list(&self) {
|
||||
let message = PortfolioMessage::UpdateOpenDocumentsList;
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
pub fn request_new_document_dialog(&self) {
|
||||
let message = DialogMessage::RequestNewDocumentDialog;
|
||||
self.dispatch(message);
|
||||
|
@ -301,8 +320,8 @@ impl JsEditorHandle {
|
|||
}
|
||||
|
||||
/// A font has been downloaded
|
||||
pub fn on_font_load(&self, font: String, data: Vec<u8>, is_default: bool) -> Result<(), JsValue> {
|
||||
let message = DocumentMessage::FontLoaded { font, data, is_default };
|
||||
pub fn on_font_load(&self, font_file_url: String, data: Vec<u8>, is_default: bool) -> Result<(), JsValue> {
|
||||
let message = DocumentMessage::FontLoaded { font_file_url, data, is_default };
|
||||
self.dispatch(message);
|
||||
|
||||
Ok(())
|
||||
|
@ -467,19 +486,10 @@ impl JsEditorHandle {
|
|||
let message = DocumentMessage::ToggleLayerExpansion { layer_path };
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
// TODO: Replace with initialization system, issue #524
|
||||
pub fn init_app(&self) {
|
||||
let message = PortfolioMessage::UpdateDocumentWidgets;
|
||||
self.dispatch(message);
|
||||
|
||||
let message = ToolMessage::InitTools;
|
||||
self.dispatch(message);
|
||||
}
|
||||
}
|
||||
|
||||
// Needed to make JsEditorHandle functions pub to rust. Do not fully
|
||||
// understand reason but has to do with #[wasm_bindgen] procedural macro.
|
||||
// Needed to make JsEditorHandle functions pub to Rust.
|
||||
// The reason is not fully clear but it has to do with the #[wasm_bindgen] procedural macro.
|
||||
impl JsEditorHandle {
|
||||
pub fn handle_response_rust_proxy(&self, message: FrontendMessage) {
|
||||
self.handle_response(message);
|
||||
|
@ -499,12 +509,6 @@ pub fn set_random_seed(seed: u64) {
|
|||
editor::communication::set_uuid_seed(seed)
|
||||
}
|
||||
|
||||
/// Intentionally panic for debugging purposes
|
||||
#[wasm_bindgen]
|
||||
pub fn intentional_panic() {
|
||||
panic!();
|
||||
}
|
||||
|
||||
/// Access a handle to WASM memory
|
||||
#[wasm_bindgen]
|
||||
pub fn wasm_memory() -> JsValue {
|
||||
|
|
|
@ -19,8 +19,10 @@ thread_local! {
|
|||
/// Initialize the backend
|
||||
#[wasm_bindgen(start)]
|
||||
pub fn init() {
|
||||
// Set up the panic hook
|
||||
panic::set_hook(Box::new(panic_hook));
|
||||
|
||||
// Set up the logger with a default level of debug
|
||||
log::set_logger(&LOGGER).expect("Failed to set logger");
|
||||
log::set_max_level(log::LevelFilter::Debug);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue