From 5b61a30c2a5999aa0667e2cfefd0b7c029d7459a Mon Sep 17 00:00:00 2001 From: 0hypercube <0hypercube@gmail.com> Date: Sun, 30 Jul 2023 12:03:56 +0100 Subject: [PATCH] Fix artboard thumbnails --- .../input_preprocessor_message_handler.rs | 3 +++ .../document/node_graph/node_graph_message_handler.rs | 3 +-- editor/src/node_graph_executor.rs | 11 +++++------ 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/editor/src/messages/input_preprocessor/input_preprocessor_message_handler.rs b/editor/src/messages/input_preprocessor/input_preprocessor_message_handler.rs index e6670191..52df78ff 100644 --- a/editor/src/messages/input_preprocessor/input_preprocessor_message_handler.rs +++ b/editor/src/messages/input_preprocessor/input_preprocessor_message_handler.rs @@ -24,6 +24,9 @@ impl MessageHandler for InputP assert_eq!(bounds_of_viewports.len(), 1, "Only one viewport is currently supported"); for bounds in bounds_of_viewports { + let new_size = bounds.size(); + let existing_size = self.viewport_bounds.size(); + // TODO: Extend this to multiple viewports instead of setting it to the value of this last loop iteration self.viewport_bounds = bounds; diff --git a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs index c23284b2..0f8d65e7 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs @@ -345,8 +345,7 @@ impl NodeGraphMessageHandler { }); let primary_output = outputs.next(); - let graph_identifier = GraphIdentifier::new(layer_id); - let thumbnail_svg = executor.thumbnails.get(&graph_identifier).and_then(|thumbnails| thumbnails.get(id)).map(|svg| svg.to_string()); + let thumbnail_svg = executor.thumbnails.get(&layer_id).and_then(|thumbnails| thumbnails.get(id)).map(|svg| svg.to_string()); nodes.push(FrontendNode { id: *id, diff --git a/editor/src/node_graph_executor.rs b/editor/src/node_graph_executor.rs index b9149863..fbea2041 100644 --- a/editor/src/node_graph_executor.rs +++ b/editor/src/node_graph_executor.rs @@ -52,7 +52,7 @@ pub struct NodeRuntime { sender: InternalNodeGraphUpdateSender, wasm_io: Option, imaginate_preferences: ImaginatePreferences, - pub(crate) thumbnails: HashMap>, + pub(crate) thumbnails: HashMap, HashMap>, canvas_cache: HashMap, SurfaceId>, } @@ -73,7 +73,7 @@ pub(crate) struct GenerationResponse { generation_id: u64, result: Result, updates: VecDeque, - new_thumbnails: HashMap>, + new_thumbnails: HashMap, HashMap>, } enum NodeGraphUpdate { @@ -224,8 +224,7 @@ impl NodeRuntime { render.format_svg(min, max); if let Some(node_id) = node_path.get(node_path.len() - 2).copied() { - let graph_identifier = GraphIdentifier::new(layer_path.last().copied()); - let old_thumbnail = self.thumbnails.entry(graph_identifier).or_default().entry(node_id).or_default(); + let old_thumbnail = self.thumbnails.entry(layer_path.last().copied()).or_default().entry(node_id).or_default(); if *old_thumbnail != render.svg { *old_thumbnail = render.svg; thumbnails_changed = true; @@ -279,7 +278,7 @@ pub struct NodeGraphExecutor { receiver: Receiver, // TODO: This is a memory leak since layers are never removed pub(crate) last_output_type: HashMap, Option>, - pub(crate) thumbnails: HashMap>, + pub(crate) thumbnails: HashMap, HashMap>, futures: HashMap, } @@ -529,7 +528,7 @@ impl NodeGraphExecutor { /// When a blob url for a thumbnail is loaded, update the state and the UI. pub fn insert_thumbnail_blob_url(&mut self, blob_url: String, layer_id: Option, node_id: NodeId, responses: &mut VecDeque) { - if let Some(layer) = self.thumbnails.get_mut(&GraphIdentifier::new(layer_id)) { + if let Some(layer) = self.thumbnails.get_mut(&layer_id) { if let Some(segment) = layer.values_mut().flat_map(|segments| segments.iter_mut()).find(|segment| **segment == SvgSegment::BlobUrl(node_id)) { *segment = SvgSegment::String(blob_url); responses.add(NodeGraphMessage::SendGraph { should_rerender: false });