mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-24 10:18:13 +08:00
Welcome screen, refactor to allow zero documents, and add TS typing to widgets (#702)
* unfinished implementation * Add frontend for the empty panel screen * Add an icon for Folder based on NodeFolder * fixed messages causing peicees of ui not to render on new document * Standardize nextTick syntax * WIP generisization of component subscriptions (not compiling yet) * Fix crash when loading font and there is no active document * Only advertise tool actions with a document * Fix failure to create new document * Initalise the properties panel * Fix highlight tab, canvas jump, warns and layer tree * Fix tests * Possibly fix some things? * Move WorkingColors layout definition to backend * Standardize action macro formatting * Provide typing for widgets in TS/Vue and associated cleanup * Fix viewport positioning initialization * Fix menu bar init at startup not document creation * Fix no viewport bounds bug * Change !=0 to >0 * Simplify the init system Closes #656 Co-authored-by: Keavon Chambers <keavon@keavon.com> Co-authored-by: 0hypercube <0hypercube@gmail.com>
This commit is contained in:
co-authored by
Keavon Chambers
0hypercube
parent
b6793517e2
commit
010ba5a568
@@ -5,7 +5,7 @@
|
||||
use crate::helpers::{translate_key, Error};
|
||||
use crate::{EDITOR_HAS_CRASHED, EDITOR_INSTANCES, JS_EDITOR_HANDLES};
|
||||
|
||||
use editor::consts::{DEFAULT_FONT_FAMILY, DEFAULT_FONT_STYLE, FILE_SAVE_SUFFIX, GRAPHITE_DOCUMENT_VERSION};
|
||||
use editor::consts::{FILE_SAVE_SUFFIX, GRAPHITE_DOCUMENT_VERSION};
|
||||
use editor::input::input_preprocessor::ModifierKeys;
|
||||
use editor::input::mouse::{EditorMouseState, ScrollDelta, ViewportBounds};
|
||||
use editor::message_prelude::*;
|
||||
@@ -26,7 +26,7 @@ pub fn set_random_seed(seed: u64) {
|
||||
editor::communication::set_uuid_seed(seed);
|
||||
}
|
||||
|
||||
/// Access a handle to WASM memory
|
||||
/// Provides a handle to access the raw WASM memory
|
||||
#[wasm_bindgen]
|
||||
pub fn wasm_memory() -> JsValue {
|
||||
wasm_bindgen::memory()
|
||||
@@ -105,29 +105,8 @@ 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 = PropertiesPanelMessage::Init;
|
||||
self.dispatch(message);
|
||||
|
||||
let message = ToolMessage::InitTools;
|
||||
self.dispatch(message);
|
||||
|
||||
// A default font
|
||||
let font = graphene::layers::text_layer::Font::new(DEFAULT_FONT_FAMILY.into(), DEFAULT_FONT_STYLE.into());
|
||||
let message = FrontendMessage::TriggerFontLoad { font, is_default: true };
|
||||
self.dispatch(message);
|
||||
|
||||
let message = MovementMessage::TranslateCanvas { delta: (0., 0.).into() };
|
||||
self.dispatch(message);
|
||||
|
||||
let message = MenuBarMessage::SendLayout;
|
||||
self.dispatch(message);
|
||||
pub fn init_after_frontend_ready(&self) {
|
||||
self.dispatch(Message::Init);
|
||||
}
|
||||
|
||||
/// Displays a dialog with an error message
|
||||
@@ -170,6 +149,16 @@ impl JsEditorHandle {
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
pub fn new_document_dialog(&self) {
|
||||
let message = DialogMessage::RequestNewDocumentDialog;
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
pub fn open_file_upload(&self) {
|
||||
let message = FrontendMessage::TriggerFileUpload;
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
pub fn open_document_file(&self, document_name: String, document_serialized_content: String) {
|
||||
let message = PortfolioMessage::OpenDocumentFile {
|
||||
document_name,
|
||||
@@ -345,18 +334,6 @@ impl JsEditorHandle {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Swap primary and secondary color
|
||||
pub fn swap_colors(&self) {
|
||||
let message = ToolMessage::SwapColors;
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
/// Reset primary and secondary colors to their defaults
|
||||
pub fn reset_colors(&self) {
|
||||
let message = ToolMessage::ResetColors;
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
/// Paste layers from a serialized json representation
|
||||
pub fn paste_serialized_data(&self, data: String) {
|
||||
let message = PortfolioMessage::PasteSerializedData { data };
|
||||
|
||||
@@ -8,16 +8,17 @@ use wasm_bindgen::prelude::*;
|
||||
|
||||
/// When a panic occurs, notify the user and log the error to the JS console before the backend dies
|
||||
pub fn panic_hook(info: &panic::PanicInfo) {
|
||||
let panic_info = info.to_string();
|
||||
let title = "The editor crashed — sorry about that".to_string();
|
||||
let description = "An internal error occurred. Reload the editor to continue. Please report this by filing an issue on GitHub.".to_string();
|
||||
let header = "The editor crashed — sorry about that";
|
||||
let description = "An internal error occurred. Reload the editor to continue. Please report this by filing an issue on GitHub.";
|
||||
|
||||
log::error!("{}", info);
|
||||
|
||||
JS_EDITOR_HANDLES.with(|instances| {
|
||||
instances.borrow_mut().values_mut().for_each(|instance| {
|
||||
instance.send_frontend_message_to_js_rust_proxy(FrontendMessage::DisplayDialogPanic {
|
||||
panic_info: panic_info.clone(),
|
||||
title: title.clone(),
|
||||
description: description.clone(),
|
||||
panic_info: info.to_string(),
|
||||
header: header.to_string(),
|
||||
description: description.to_string(),
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user