Clean up .graphite file serde encoding

This commit is contained in:
Keavon Chambers 2023-12-06 01:39:49 -08:00
parent 8f9371dad0
commit 3e35abd377
10 changed files with 30 additions and 17 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -38,8 +38,6 @@ pub struct Document {
pub collapsed_folders: Vec<LayerNodeIdentifier>,
#[serde(skip)]
pub metadata: DocumentMetadata,
#[serde(default)]
pub commit_hash: String,
}
impl PartialEq for Document {
@ -108,7 +106,6 @@ impl Default for Document {
},
metadata: Default::default(),
collapsed_folders: Vec::new(),
commit_hash: String::new(),
}
}
}

File diff suppressed because one or more lines are too long

View file

@ -43,6 +43,8 @@ pub struct DocumentMessageHandler {
pub auto_saved_document_identifier: u64,
pub name: String,
pub version: String,
#[serde(default)]
pub commit_hash: String,
pub document_mode: DocumentMode,
pub view_mode: ViewMode,
@ -62,11 +64,13 @@ pub struct DocumentMessageHandler {
#[serde(with = "vectorize_layer_metadata")]
pub layer_metadata: HashMap<Vec<LayerId>, LayerMetadata>,
#[serde(skip)]
layer_range_selection_reference: Option<LayerNodeIdentifier>,
navigation_handler: NavigationMessageHandler,
#[serde(skip)]
overlays_message_handler: OverlaysMessageHandler,
#[serde(skip)]
properties_panel_message_handler: PropertiesPanelMessageHandler,
#[serde(skip)]
node_graph_handler: NodeGraphMessageHandler,
@ -74,16 +78,13 @@ pub struct DocumentMessageHandler {
impl Default for DocumentMessageHandler {
fn default() -> Self {
let document_legacy = DocumentLegacy {
commit_hash: crate::application::GRAPHITE_GIT_COMMIT_HASH.to_string(),
..Default::default()
};
Self {
document_legacy,
document_legacy: DocumentLegacy::default(),
saved_document_identifier: 0,
auto_saved_document_identifier: 0,
name: String::from("Untitled Document"),
version: GRAPHITE_DOCUMENT_VERSION.to_string(),
commit_hash: crate::application::GRAPHITE_GIT_COMMIT_HASH.to_string(),
document_mode: DocumentMode::DesignMode,
view_mode: ViewMode::default(),

View file

@ -13,12 +13,22 @@ use document_legacy::document::Document;
use glam::{DAffine2, DVec2};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
enum TransformOperation {
#[default]
None,
Pan { pre_commit_pan: DVec2 },
Rotate { pre_commit_tilt: f64, snap_tilt: bool, snap_tilt_released: bool },
Zoom { pre_commit_zoom: f64, snap_zoom_enabled: bool },
Pan {
pre_commit_pan: DVec2,
},
Rotate {
pre_commit_tilt: f64,
snap_tilt: bool,
snap_tilt_released: bool,
},
Zoom {
pre_commit_zoom: f64,
snap_zoom_enabled: bool,
},
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
@ -27,8 +37,11 @@ pub struct NavigationMessageHandler {
pub tilt: f64,
pub zoom: f64,
#[serde(skip)]
transform_operation: TransformOperation,
#[serde(skip)]
mouse_position: ViewportPosition,
#[serde(skip)]
finish_operation_with_click: bool,
}

View file

@ -541,7 +541,7 @@ impl NodeGraphExecutor {
"Layer"
}
.to_string(),
tooltip: format!("Layer id: {node_id}"),
tooltip: if cfg!(debug_assertions) { format!("Layer ID: {node_id}") } else { "".into() },
visible: !document.document_network.disabled.contains(&layer.to_node()),
layer_type: if document.metadata.is_artboard(layer) {
LayerDataTypeDiscriminant::Artboard

View file

@ -8,6 +8,7 @@
"scripts": {
"start": "npm run build-wasm && concurrently -k -n \"VITE,RUST\" \"vite\" \"npm run watch:wasm\" || (npm run print-building-help && exit 1)",
"profiling": "npm run build-wasm-profiling && concurrently -k -n \"VITE,RUST\" \"vite\" \"npm run watch:wasm-profiling\" || (npm run print-building-help && exit 1)",
"production": "npm run build-wasm-prod && concurrently -k -n \"VITE,RUST\" \"vite\" \"npm run watch:wasm\" || (npm run print-building-help && exit 1)",
"build": "npm run build-wasm-prod && vite build || (npm run print-building-help && exit 1)",
"build-profiling": "npm run build-wasm-profiling && vite build || (npm run print-building-help && exit 1)",
"lint": "eslint .",

View file

@ -32,7 +32,7 @@
if (!editor.instance.inDevelopmentMode()) return { name };
const tooltip = `Document ID ${doc.id}`;
const tooltip = `Document ID: ${doc.id}`;
return { name, tooltip };
});

View file

@ -52,6 +52,7 @@ export default defineConfig({
},
server: {
port: 8080,
host: "0.0.0.0",
},
build: {
rollupOptions: {