Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions editor/src/messages/defer/defer_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::messages::prelude::*;
#[impl_message(Message, Defer)]
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
pub enum DeferMessage {
SetGraphSubmissionIndex(u64),
TriggerGraphRun(u64),
AfterGraphRun { messages: Vec<Message> },
TriggerNavigationReady,
Expand Down
18 changes: 13 additions & 5 deletions editor/src/messages/defer/defer_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@ impl MessageHandler<DeferMessage, ()> for DeferMessageHandler {
DeferMessage::AfterNavigationReady { messages } => {
self.after_viewport_resize.extend_from_slice(&messages);
}
DeferMessage::SetGraphSubmissionIndex(execution_id) => {
self.current_graph_submission_id = execution_id + 1;
}
DeferMessage::TriggerGraphRun(execution_id) => {
self.current_graph_submission_id = execution_id;
for message in self.after_graph_run.extract_if(.., |x| x.0 < self.current_graph_submission_id) {
responses.push_front(message.1);
if self.after_graph_run.is_empty() {
return;
}
// Find the index of the last message we can process
let num_elements_to_remove = self.after_graph_run.binary_search_by_key(&(execution_id + 1), |x| x.0).unwrap_or_else(|pos| pos - 1);
let elements = self.after_graph_run.drain(0..=num_elements_to_remove);
for (_, message) in elements.rev() {
responses.add_front(message);
}
}
DeferMessage::TriggerNavigationReady => {
for message in self.after_viewport_resize.drain(..) {
responses.push_front(message);
for message in self.after_viewport_resize.drain(..).rev() {
responses.add_front(message);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1880,14 +1880,15 @@ impl DocumentMessageHandler {

let previous_network = std::mem::replace(&mut self.network_interface, network_interface);

// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
responses.add(PortfolioMessage::UpdateOpenDocumentsList);
responses.add(NodeGraphMessage::SelectedNodesUpdated);
responses.add(NodeGraphMessage::ForceRunDocumentGraph);

// TODO: Remove once the footprint is used to load the imports/export distances from the edge
responses.push_front(NodeGraphMessage::UnloadWires.into());
responses.push_front(NodeGraphMessage::SetGridAlignedEdges.into());
responses.add(NodeGraphMessage::UnloadWires);
responses.add(NodeGraphMessage::SetGridAlignedEdges);

// Push the UpdateOpenDocumentsList message to the bus in order to update the save status of the open documents
responses.push_front(NodeGraphMessage::ForceRunDocumentGraph.into());
responses.push_front(NodeGraphMessage::SelectedNodesUpdated.into());
responses.push_front(PortfolioMessage::UpdateOpenDocumentsList.into());
Some(previous_network)
}
pub fn redo_with_history(&mut self, ipp: &InputPreprocessorMessageHandler, responses: &mut VecDeque<Message>) {
Expand Down
19 changes: 12 additions & 7 deletions editor/src/messages/portfolio/portfolio_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,15 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
self.executor.update_font_cache(self.persistent_data.font_cache.clone());
for document_id in self.document_ids.iter() {
let inspect_node = self.inspect_node_id();
let _ = self.executor.submit_node_graph_evaluation(
if let Ok(message) = self.executor.submit_node_graph_evaluation(
self.documents.get_mut(document_id).expect("Tried to render non-existent document"),
ipp.viewport_bounds.size().as_uvec2(),
timing_information,
inspect_node,
true,
);
) {
responses.add(message);
}
}

if self.active_document_mut().is_some() {
Expand Down Expand Up @@ -846,11 +848,14 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
ignore_hash,
);

if let Err(description) = result {
responses.add(DialogMessage::DisplayDialogError {
title: "Unable to update node graph".to_string(),
description,
});
match result {
Err(description) => {
responses.add(DialogMessage::DisplayDialogError {
title: "Unable to update node graph".to_string(),
description,
});
}
Ok(message) => responses.add(message),
}
}
PortfolioMessage::ToggleRulers => {
Expand Down
2 changes: 2 additions & 0 deletions editor/src/messages/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ pub trait Responses {
}

impl Responses for VecDeque<Message> {
#[inline(always)]
fn add(&mut self, message: impl Into<Message>) {
self.push_back(message.into());
}

#[inline(always)]
fn add_front(&mut self, message: impl Into<Message>) {
self.push_front(message.into());
}
Expand Down
8 changes: 6 additions & 2 deletions editor/src/messages/tool/tool_messages/path_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2229,7 +2229,9 @@ impl Fsm for PathToolFsmState {
tool_data.snapping_axis = None;
tool_data.sliding_point_info = None;

responses.add(DocumentMessage::EndTransaction);
if drag_occurred || extend_selection {
responses.add(DocumentMessage::EndTransaction);
}
responses.add(PathToolMessage::SelectedPointUpdated);
tool_data.snap_manager.cleanup(responses);
tool_data.opposite_handle_position = None;
Expand Down Expand Up @@ -2282,7 +2284,9 @@ impl Fsm for PathToolFsmState {
tool_data.saved_points_before_anchor_convert_smooth_sharp.clear();

responses.add(DocumentMessage::EndTransaction);
responses.add(PathToolMessage::SelectedPointUpdated);
responses.add(DeferMessage::AfterGraphRun {
messages: vec![PathToolMessage::SelectedPointUpdated.into()],
});
}

return PathToolFsmState::Ready;
Expand Down
10 changes: 4 additions & 6 deletions editor/src/node_graph_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ impl NodeGraphExecutor {
}

/// Adds an evaluate request for whatever current network is cached.
pub(crate) fn submit_current_node_graph_evaluation(&mut self, document: &mut DocumentMessageHandler, viewport_resolution: UVec2, time: TimingInformation) -> Result<(), String> {
pub(crate) fn submit_current_node_graph_evaluation(&mut self, document: &mut DocumentMessageHandler, viewport_resolution: UVec2, time: TimingInformation) -> Result<Message, String> {
let render_config = RenderConfig {
viewport: Footprint {
transform: document.metadata().document_to_viewport,
Expand All @@ -155,7 +155,7 @@ impl NodeGraphExecutor {

self.futures.insert(execution_id, ExecutionContext { export_config: None });

Ok(())
Ok(DeferMessage::SetGraphSubmissionIndex(execution_id).into())
}

/// Evaluates a node graph, computing the entire graph
Expand All @@ -166,11 +166,9 @@ impl NodeGraphExecutor {
time: TimingInformation,
inspect_node: Option<NodeId>,
ignore_hash: bool,
) -> Result<(), String> {
) -> Result<Message, String> {
self.update_node_graph(document, inspect_node, ignore_hash)?;
self.submit_current_node_graph_evaluation(document, viewport_resolution, time)?;

Ok(())
self.submit_current_node_graph_evaluation(document, viewport_resolution, time)
}

/// Evaluates a node graph for export
Expand Down
Loading