Skip to content

Commit 2d4173f

Browse files
committed
WIP: Thumbnails
1 parent 98cd288 commit 2d4173f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1204
-1040
lines changed

editor/src/dispatcher.rs

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,11 @@ impl DispatcherMessageHandlers {
4444
/// In addition, these messages do not change any state in the backend (aside from caches).
4545
const SIDE_EFFECT_FREE_MESSAGES: &[MessageDiscriminant] = &[
4646
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::CompileActiveDocument),
47-
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::EvaluateActiveDocument),
48-
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::IntrospectActiveDocument),
47+
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::EvaluateActiveDocumentWithThumbnails),
48+
// MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::IntrospectActiveDocument),
49+
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::PropertiesPanel(
50+
PropertiesPanelMessageDiscriminant::Refresh,
51+
))),
4952
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::PropertiesPanel(
5053
PropertiesPanelMessageDiscriminant::Refresh,
5154
))),
@@ -123,13 +126,13 @@ impl Dispatcher {
123126
}
124127
}
125128

126-
// Add all messages to the queue if queuing messages (except from the end queue message)
127-
if !matches!(message, Message::EndIntrospectionQueue) {
128-
if self.queueing_introspection_messages {
129-
self.introspection_queue.push(message);
130-
return;
131-
}
132-
}
129+
// // Add all messages to the queue if queuing messages (except from the end queue message)
130+
// if !matches!(message, Message::EndIntrospectionQueue) {
131+
// if self.queueing_introspection_messages {
132+
// self.introspection_queue.push(message);
133+
// return;
134+
// }
135+
// }
133136
// Print the message at a verbosity level of `info`
134137
self.log_message(&message, &self.message_queues, self.message_handlers.debug_message_handler.message_logging_verbosity);
135138

@@ -144,33 +147,20 @@ impl Dispatcher {
144147
Message::EndEvaluationQueue => {
145148
self.queueing_evaluation_messages = false;
146149
}
147-
Message::ProcessEvaluationQueue(render_output_metadata) => {
150+
Message::ProcessEvaluationQueue(render_output_metadata, introspected_nodes) => {
148151
let update_message = PortfolioMessage::ProcessEvaluationResponse {
149152
evaluation_metadata: render_output_metadata,
153+
introspected_nodes,
150154
}
151155
.into();
152156
// Update the state with the render output and introspected inputs
153157
Self::schedule_execution(&mut self.message_queues, true, [update_message]);
154158

155159
// Schedule all queued messages to be run, which use the introspected inputs (in the order they were added)
156160
Self::schedule_execution(&mut self.message_queues, true, std::mem::take(&mut self.evaluation_queue));
157-
}
158-
Message::StartIntrospectionQueue => {
159-
self.queueing_introspection_messages = true;
160-
}
161-
Message::EndIntrospectionQueue => {
162-
self.queueing_introspection_messages = false;
163-
}
164-
Message::ProcessIntrospectionQueue(introspection_response) => {
165-
let update_message = PortfolioMessage::ProcessIntrospectionResponse { introspection_response }.into();
166-
// Update the state with the render output and introspected inputs
167-
Self::schedule_execution(&mut self.message_queues, true, [update_message]);
168-
169-
// Schedule all queued messages to be run, which use the introspected inputs (in the order they were added)
170-
Self::schedule_execution(&mut self.message_queues, true, std::mem::take(&mut self.introspection_queue));
171161

162+
// Clear all introspected data after the queued messages are execucted
172163
let clear_message = PortfolioMessage::ClearIntrospectedData.into();
173-
// Clear the introspected inputs since they are no longer required, and will cause a memory leak if not removed
174164
Self::schedule_execution(&mut self.message_queues, true, [clear_message]);
175165
}
176166
Message::NoOp => {}

editor/src/messages/animation/animation_message_handler.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl MessageHandler<AnimationMessage, ()> for AnimationMessageHandler {
8484
}
8585
AnimationMessage::SetFrameIndex(frame) => {
8686
self.frame_index = frame;
87-
responses.add(PortfolioMessage::EvaluateActiveDocument);
87+
responses.add(PortfolioMessage::EvaluateActiveDocumentWithThumbnails);
8888
// Update the restart and pause/play buttons
8989
responses.add(PortfolioMessage::UpdateDocumentWidgets);
9090
}
@@ -100,7 +100,7 @@ impl MessageHandler<AnimationMessage, ()> for AnimationMessageHandler {
100100
}
101101
AnimationMessage::UpdateTime => {
102102
if self.is_playing() {
103-
responses.add(PortfolioMessage::EvaluateActiveDocument);
103+
responses.add(PortfolioMessage::EvaluateActiveDocumentWithThumbnails);
104104

105105
if self.live_preview_recently_zero {
106106
// Update the restart and pause/play buttons
@@ -116,7 +116,7 @@ impl MessageHandler<AnimationMessage, ()> for AnimationMessageHandler {
116116
_ => AnimationState::Stopped,
117117
};
118118
self.live_preview_recently_zero = true;
119-
responses.add(PortfolioMessage::EvaluateActiveDocument);
119+
responses.add(PortfolioMessage::EvaluateActiveDocumentWithThumbnails);
120120
// Update the restart and pause/play buttons
121121
responses.add(PortfolioMessage::UpdateDocumentWidgets);
122122
}

editor/src/messages/dialog/new_document_dialog/new_document_dialog_message_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ impl MessageHandler<NewDocumentDialogMessage, ()> for NewDocumentDialogMessageHa
3131
}
3232
responses.add(Message::StartEvaluationQueue);
3333
responses.add(DocumentMessage::ZoomCanvasToFitAll);
34-
responses.add(Message::EndEvaluationQueue);
3534
responses.add(DocumentMessage::DeselectAllLayers);
35+
responses.add(Message::EndEvaluationQueue);
3636
}
3737
}
3838

editor/src/messages/frontend/frontend_message.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
use super::utility_types::{FrontendDocumentDetails, MouseCursorIcon};
22
use crate::messages::layout::utility_types::widget_prelude::*;
33
use crate::messages::portfolio::document::node_graph::utility_types::{
4-
BoxSelection, ContextMenuInformation, FrontendClickTargets, FrontendGraphInput, FrontendGraphOutput, FrontendNode, FrontendNodeType, Transform,
4+
BoxSelection, ContextMenuInformation, FrontendClickTargets, FrontendGraphInput, FrontendGraphOutput, FrontendNode, FrontendNodeSNIUpdate, FrontendNodeType, Transform,
55
};
66
use crate::messages::portfolio::document::utility_types::nodes::{JsRawBuffer, LayerPanelEntry, RawBuffer};
7-
use crate::messages::portfolio::document::utility_types::wires::{WirePath, WirePathUpdate};
7+
use crate::messages::portfolio::document::utility_types::wires::{WirePath, WirePathUpdate, WireSNIUpdate};
88
use crate::messages::prelude::*;
99
use crate::messages::tool::utility_types::HintData;
10-
use graphene_std::uuid::NodeId;
1110
use graphene_std::raster::color::Color;
1211
use graphene_std::text::Font;
12+
use graphene_std::uuid::{NodeId, SNI};
1313

1414
#[impl_message(Message, Frontend)]
1515
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
@@ -128,6 +128,10 @@ pub enum FrontendMessage {
128128
#[serde(rename = "box")]
129129
box_selection: Option<BoxSelection>,
130130
},
131+
UpdateContextDuringEvaluation {
132+
#[serde(rename = "contextDuringEvaluation")]
133+
context_during_evaluation: Vec<(SNI, usize, String)>,
134+
},
131135
UpdateContextMenuInformation {
132136
#[serde(rename = "contextMenuInformation")]
133137
context_menu_information: Option<ContextMenuInformation>,
@@ -224,6 +228,10 @@ pub enum FrontendMessage {
224228
#[serde(rename = "setColorChoice")]
225229
set_color_choice: Option<String>,
226230
},
231+
UpdateGraphBreadcrumbPath {
232+
#[serde(rename = "breadcrumbPath")]
233+
breadcrumb_path: Vec<NodeId>,
234+
},
227235
UpdateGraphFadeArtwork {
228236
percentage: f64,
229237
},
@@ -263,7 +271,7 @@ pub enum FrontendMessage {
263271
UpdateNodeGraphWires {
264272
wires: Vec<WirePathUpdate>,
265273
},
266-
ClearAllNodeGraphWires,
274+
ClearAllNodeGraphWirePaths,
267275
UpdateNodeGraphControlBarLayout {
268276
#[serde(rename = "layoutTarget")]
269277
layout_target: LayoutTarget,
@@ -287,7 +295,10 @@ pub enum FrontendMessage {
287295
UpdateThumbnails {
288296
add: Vec<(NodeId, String)>,
289297
clear: Vec<NodeId>,
290-
// remove: Vec<NodeId>,
298+
#[serde(rename = "wireSNIUpdates")]
299+
wire_sni_updates: Vec<WireSNIUpdate>,
300+
#[serde(rename = "layerSNIUpdates")]
301+
layer_sni_updates: Vec<FrontendNodeSNIUpdate>,
291302
},
292303
UpdateToolOptionsLayout {
293304
#[serde(rename = "layoutTarget")]

editor/src/messages/message.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ pub enum Message {
1313
EndEvaluationQueue,
1414
// Processes all messages that are queued to be run after evaluation, which occurs on the evaluation response. This allows a message to be run with data from after the evaluation is complete
1515
#[serde(skip)]
16-
ProcessEvaluationQueue(graphene_std::renderer::RenderMetadata),
17-
StartIntrospectionQueue,
18-
EndIntrospectionQueue,
19-
// Processes all messages that are queued to be run after introspection, which occurs on the evaluation response. This allows a message to be run with data from after the evaluation is complete
20-
#[serde(skip)]
21-
ProcessIntrospectionQueue(IntrospectionResponse),
16+
ProcessEvaluationQueue(graphene_std::renderer::RenderMetadata, IntrospectionResponse),
2217
#[child]
2318
Animation(AnimationMessage),
2419
#[child]

editor/src/messages/portfolio/document/document_message_handler.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
443443
DocumentMessage::EnterNestedNetwork { node_id } => {
444444
self.breadcrumb_network_path.push(node_id);
445445
self.selection_network_path.clone_from(&self.breadcrumb_network_path);
446-
responses.add(NodeGraphMessage::UnloadWires);
446+
responses.add(NodeGraphMessage::UnloadWirePaths);
447447
responses.add(NodeGraphMessage::SendGraph);
448448
responses.add(DocumentMessage::ZoomCanvasToFitAll);
449449
responses.add(NodeGraphMessage::SetGridAlignedEdges);
@@ -473,7 +473,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
473473
self.breadcrumb_network_path.pop();
474474
self.selection_network_path.clone_from(&self.breadcrumb_network_path);
475475
}
476-
responses.add(NodeGraphMessage::UnloadWires);
476+
responses.add(NodeGraphMessage::UnloadWirePaths);
477477
responses.add(NodeGraphMessage::SendGraph);
478478
responses.add(DocumentMessage::PTZUpdate);
479479
responses.add(NodeGraphMessage::SetGridAlignedEdges);
@@ -540,7 +540,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
540540
responses.add(DocumentMessage::RenderRulers);
541541
responses.add(DocumentMessage::RenderScrollbars);
542542
if opened {
543-
responses.add(NodeGraphMessage::UnloadWires);
543+
responses.add(NodeGraphMessage::UnloadWirePaths);
544544
}
545545
if open {
546546
responses.add(ToolMessage::DeactivateTools);
@@ -1425,7 +1425,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
14251425
center: Key::Alt,
14261426
duplicate: Key::Alt,
14271427
}));
1428-
responses.add(PortfolioMessage::EvaluateActiveDocument);
1428+
responses.add(PortfolioMessage::EvaluateActiveDocumentWithThumbnails);
14291429
} else {
14301430
let Some(network_metadata) = self.network_interface.network_metadata(&self.breadcrumb_network_path) else {
14311431
return;
@@ -1441,7 +1441,8 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
14411441
responses.add(NodeGraphMessage::UpdateEdges);
14421442
responses.add(NodeGraphMessage::UpdateBoxSelection);
14431443
responses.add(NodeGraphMessage::UpdateImportsExports);
1444-
1444+
responses.add(NodeGraphMessage::UpdateVisibleNodes);
1445+
responses.add(NodeGraphMessage::SendWirePaths);
14451446
responses.add(FrontendMessage::UpdateNodeGraphTransform {
14461447
transform: Transform {
14471448
scale: transform.matrix2.x_axis.x,
@@ -1905,10 +1906,7 @@ impl DocumentMessageHandler {
19051906
responses.add(PortfolioMessage::CompileActiveDocument);
19061907
responses.add(Message::StartEvaluationQueue);
19071908
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
1908-
responses.add(NodeGraphMessage::SelectedNodesUpdated);
1909-
responses.add(NodeGraphMessage::SetGridAlignedEdges);
1910-
responses.add(NodeGraphMessage::UnloadWires);
1911-
responses.add(NodeGraphMessage::SendWires);
1909+
responses.add(NodeGraphMessage::SendGraph);
19121910
responses.add(Message::EndEvaluationQueue);
19131911
Some(previous_network)
19141912
}
@@ -1940,8 +1938,8 @@ impl DocumentMessageHandler {
19401938
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
19411939
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
19421940
responses.add(NodeGraphMessage::SelectedNodesUpdated);
1943-
responses.add(NodeGraphMessage::UnloadWires);
1944-
responses.add(NodeGraphMessage::SendWires);
1941+
responses.add(NodeGraphMessage::UnloadWirePaths);
1942+
responses.add(NodeGraphMessage::SendWirePaths);
19451943
responses.add(Message::EndEvaluationQueue);
19461944
Some(previous_network)
19471945
}
@@ -2572,7 +2570,7 @@ impl DocumentMessageHandler {
25722570
layout: Layout::WidgetLayout(document_bar_layout),
25732571
layout_target: LayoutTarget::DocumentBar,
25742572
});
2575-
responses.add(PortfolioMessage::EvaluateActiveDocument);
2573+
responses.add(PortfolioMessage::EvaluateActiveDocumentWithThumbnails);
25762574
}
25772575

25782576
pub fn update_layers_panel_control_bar_widgets(&self, responses: &mut VecDeque<Message>) {

0 commit comments

Comments
 (0)