Skip to content

Commit fcd379a

Browse files
committed
WIP: Thumbnails
1 parent 8b665d1 commit fcd379a

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

+1206
-1051
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
@@ -442,7 +442,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
442442
DocumentMessage::EnterNestedNetwork { node_id } => {
443443
self.breadcrumb_network_path.push(node_id);
444444
self.selection_network_path.clone_from(&self.breadcrumb_network_path);
445-
responses.add(NodeGraphMessage::UnloadWires);
445+
responses.add(NodeGraphMessage::UnloadWirePaths);
446446
responses.add(NodeGraphMessage::SendGraph);
447447
responses.add(DocumentMessage::ZoomCanvasToFitAll);
448448
responses.add(NodeGraphMessage::SetGridAlignedEdges);
@@ -472,7 +472,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
472472
self.breadcrumb_network_path.pop();
473473
self.selection_network_path.clone_from(&self.breadcrumb_network_path);
474474
}
475-
responses.add(NodeGraphMessage::UnloadWires);
475+
responses.add(NodeGraphMessage::UnloadWirePaths);
476476
responses.add(NodeGraphMessage::SendGraph);
477477
responses.add(DocumentMessage::PTZUpdate);
478478
responses.add(NodeGraphMessage::SetGridAlignedEdges);
@@ -539,7 +539,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
539539
responses.add(DocumentMessage::RenderRulers);
540540
responses.add(DocumentMessage::RenderScrollbars);
541541
if opened {
542-
responses.add(NodeGraphMessage::UnloadWires);
542+
responses.add(NodeGraphMessage::UnloadWirePaths);
543543
}
544544
if open {
545545
responses.add(ToolMessage::DeactivateTools);
@@ -1424,7 +1424,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
14241424
center: Key::Alt,
14251425
duplicate: Key::Alt,
14261426
}));
1427-
responses.add(PortfolioMessage::EvaluateActiveDocument);
1427+
responses.add(PortfolioMessage::EvaluateActiveDocumentWithThumbnails);
14281428
} else {
14291429
let Some(network_metadata) = self.network_interface.network_metadata(&self.breadcrumb_network_path) else {
14301430
return;
@@ -1440,7 +1440,8 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
14401440
responses.add(NodeGraphMessage::UpdateEdges);
14411441
responses.add(NodeGraphMessage::UpdateBoxSelection);
14421442
responses.add(NodeGraphMessage::UpdateImportsExports);
1443-
1443+
responses.add(NodeGraphMessage::UpdateVisibleNodes);
1444+
responses.add(NodeGraphMessage::SendWirePaths);
14441445
responses.add(FrontendMessage::UpdateNodeGraphTransform {
14451446
transform: Transform {
14461447
scale: transform.matrix2.x_axis.x,
@@ -1909,10 +1910,7 @@ impl DocumentMessageHandler {
19091910
responses.add(PortfolioMessage::CompileActiveDocument);
19101911
responses.add(Message::StartEvaluationQueue);
19111912
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
1912-
responses.add(NodeGraphMessage::SelectedNodesUpdated);
1913-
responses.add(NodeGraphMessage::SetGridAlignedEdges);
1914-
responses.add(NodeGraphMessage::UnloadWires);
1915-
responses.add(NodeGraphMessage::SendWires);
1913+
responses.add(NodeGraphMessage::SendGraph);
19161914
responses.add(Message::EndEvaluationQueue);
19171915
Some(previous_network)
19181916
}
@@ -1944,8 +1942,8 @@ impl DocumentMessageHandler {
19441942
// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
19451943
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
19461944
responses.add(NodeGraphMessage::SelectedNodesUpdated);
1947-
responses.add(NodeGraphMessage::UnloadWires);
1948-
responses.add(NodeGraphMessage::SendWires);
1945+
responses.add(NodeGraphMessage::UnloadWirePaths);
1946+
responses.add(NodeGraphMessage::SendWirePaths);
19491947
responses.add(Message::EndEvaluationQueue);
19501948
Some(previous_network)
19511949
}
@@ -2576,7 +2574,7 @@ impl DocumentMessageHandler {
25762574
layout: Layout::WidgetLayout(document_bar_layout),
25772575
layout_target: LayoutTarget::DocumentBar,
25782576
});
2579-
responses.add(PortfolioMessage::EvaluateActiveDocument);
2577+
responses.add(PortfolioMessage::EvaluateActiveDocumentWithThumbnails);
25802578
}
25812579

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

0 commit comments

Comments
 (0)