Skip to content

Commit 229607f

Browse files
committed
merge onto master
1 parent 4c75ddf commit 229607f

File tree

60 files changed

+2825
-3240
lines changed

Some content is hidden

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

60 files changed

+2825
-3240
lines changed

editor/src/dispatcher.rs

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ use crate::messages::prelude::*;
55

66
#[derive(Debug, Default)]
77
pub struct Dispatcher {
8-
buffered_queue: Option<Vec<VecDeque<Message>>>,
8+
buffered_queue: Vec<Message>,
9+
queueing_messages: bool,
910
message_queues: Vec<VecDeque<Message>>,
1011
pub responses: Vec<FrontendMessage>,
1112
pub message_handlers: DispatcherMessageHandlers,
@@ -90,11 +91,10 @@ impl Dispatcher {
9091

9192
pub fn handle_message<T: Into<Message>>(&mut self, message: T, process_after_all_current: bool) {
9293
let message = message.into();
93-
// Add all additional messages to the buffer if it exists (except from the end buffer message)
94-
if !matches!(message, Message::EndBuffer(_)) {
95-
if let Some(buffered_queue) = &mut self.buffered_queue {
96-
Self::schedule_execution(buffered_queue, true, [message]);
97-
94+
// Add all additional messages to the queue if it exists (except from the end queue message)
95+
if !matches!(message, Message::EndQueue) {
96+
if self.queueing_messages {
97+
self.buffered_queue.push(message);
9898
return;
9999
}
100100
}
@@ -126,36 +126,22 @@ impl Dispatcher {
126126

127127
// Process the action by forwarding it to the relevant message handler, or saving the FrontendMessage to be sent to the frontend
128128
match message {
129-
Message::StartBuffer => {
130-
self.buffered_queue = Some(std::mem::take(&mut self.message_queues));
129+
Message::StartQueue => {
130+
self.queueing_messages = true;
131131
}
132-
Message::EndBuffer(render_metadata) => {
133-
// Assign the message queue to the currently buffered queue
134-
if let Some(buffered_queue) = self.buffered_queue.take() {
135-
self.cleanup_queues(false);
136-
assert!(self.message_queues.is_empty(), "message queues are always empty when ending a buffer");
137-
self.message_queues = buffered_queue;
132+
Message::EndQueue => {
133+
self.queueing_messages = false;
134+
}
135+
Message::ProcessQueue((render_output_metadata, introspected_inputs)) => {
136+
let message = PortfolioMessage::ProcessEvaluationResponse {
137+
evaluation_metadata: render_output_metadata,
138+
introspected_inputs,
138139
};
140+
// Add the message to update the state with the render output
141+
Self::schedule_execution(&mut self.message_queues, true, [message]);
139142

140-
let graphene_std::renderer::RenderMetadata {
141-
upstream_footprints: footprints,
142-
local_transforms,
143-
first_instance_source_id,
144-
click_targets,
145-
clip_targets,
146-
} = render_metadata;
147-
148-
// Run these update state messages immediately
149-
let messages = [
150-
DocumentMessage::UpdateUpstreamTransforms {
151-
upstream_footprints: footprints,
152-
local_transforms,
153-
first_instance_source_id,
154-
},
155-
DocumentMessage::UpdateClickTargets { click_targets },
156-
DocumentMessage::UpdateClipTargets { clip_targets },
157-
];
158-
Self::schedule_execution(&mut self.message_queues, false, messages.map(Message::from));
143+
// Schedule all queued messages to be run (in the order they were added)
144+
Self::schedule_execution(&mut self.message_queues, true, std::mem::take(&mut self.buffered_queue));
159145
}
160146
Message::NoOp => {}
161147
Message::Init => {

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::SubmitActiveGraphRender);
87+
responses.add(PortfolioMessage::EvaluateActiveDocument);
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::SubmitActiveGraphRender);
103+
responses.add(PortfolioMessage::EvaluateActiveDocument);
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::SubmitActiveGraphRender);
119+
responses.add(PortfolioMessage::EvaluateActiveDocument);
120120
// Update the restart and pause/play buttons
121121
responses.add(PortfolioMessage::UpdateDocumentWidgets);
122122
}

editor/src/messages/dialog/export_dialog/export_dialog_message_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl MessageHandler<ExportDialogMessage, ExportDialogMessageData<'_>> for Export
4343
ExportDialogMessage::TransparentBackground(transparent_background) => self.transparent_background = transparent_background,
4444
ExportDialogMessage::ExportBounds(export_area) => self.bounds = export_area,
4545

46-
ExportDialogMessage::Submit => responses.add_front(PortfolioMessage::SubmitDocumentExport {
46+
ExportDialogMessage::Submit => responses.add_front(PortfolioMessage::ActiveDocumentExport {
4747
file_name: portfolio.active_document().map(|document| document.name.clone()).unwrap_or_default(),
4848
file_type: self.file_type,
4949
scale_factor: self.scale_factor,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ impl MessageHandler<NewDocumentDialogMessage, ()> for NewDocumentDialogMessageHa
2424

2525
let create_artboard = !self.infinite && self.dimensions.x > 0 && self.dimensions.y > 0;
2626
if create_artboard {
27-
responses.add(Message::StartBuffer);
27+
responses.add(Message::StartQueue);
2828
responses.add(GraphOperationMessage::NewArtboard {
2929
id: NodeId::new(),
3030
artboard: graphene_std::Artboard::new(IVec2::ZERO, self.dimensions.as_ivec2()),
@@ -33,7 +33,7 @@ impl MessageHandler<NewDocumentDialogMessage, ()> for NewDocumentDialogMessageHa
3333

3434
// TODO: Figure out how to get StartBuffer to work here so we can delete this and use `DocumentMessage::ZoomCanvasToFitAll` instead
3535
// Currently, it is necessary to use `FrontendMessage::TriggerDelayedZoomCanvasToFitAll` rather than `DocumentMessage::ZoomCanvasToFitAll` because the size of the viewport is not yet populated
36-
responses.add(Message::StartBuffer);
36+
responses.add(Message::StartQueue);
3737
responses.add(FrontendMessage::TriggerDelayedZoomCanvasToFitAll);
3838
responses.add(DocumentMessage::DeselectAllLayers);
3939
}

editor/src/messages/dialog/preferences_dialog/preferences_dialog_message_handler.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ impl PreferencesDialogMessageHandler {
174174
let use_vello = vec![
175175
Separator::new(SeparatorType::Unrelated).widget_holder(),
176176
Separator::new(SeparatorType::Unrelated).widget_holder(),
177-
CheckboxInput::new(preferences.use_vello && preferences.supports_wgpu())
177+
CheckboxInput::new(preferences.use_vello())
178178
.tooltip(vello_tooltip)
179179
.disabled(!preferences.supports_wgpu())
180180
.on_update(|checkbox_input: &CheckboxInput| PreferencesMessage::UseVello { use_vello: checkbox_input.checked }.into())

editor/src/messages/frontend/frontend_message.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ use graphene_std::text::Font;
1414
#[impl_message(Message, Frontend)]
1515
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)]
1616
pub enum FrontendMessage {
17+
ClearNodeThumbnail {
18+
sni: NodeId,
19+
},
1720
// Display prefix: make the frontend show something, like a dialog
1821
DisplayDialog {
1922
title: String,
@@ -272,10 +275,6 @@ pub enum FrontendMessage {
272275
UpdateNodeGraphTransform {
273276
transform: Transform,
274277
},
275-
UpdateNodeThumbnail {
276-
id: NodeId,
277-
value: String,
278-
},
279278
UpdateOpenDocumentsList {
280279
#[serde(rename = "openDocuments")]
281280
open_documents: Vec<FrontendDocumentDetails>,
@@ -285,6 +284,11 @@ pub enum FrontendMessage {
285284
layout_target: LayoutTarget,
286285
diff: Vec<WidgetDiff>,
287286
},
287+
UpdateThumbnails {
288+
add: Vec<(NodeId, String)>,
289+
clear: Vec<NodeId>,
290+
// remove: Vec<NodeId>,
291+
},
288292
UpdateToolOptionsLayout {
289293
#[serde(rename = "layoutTarget")]
290294
layout_target: LayoutTarget,

editor/src/messages/input_preprocessor/input_preprocessor_message_handler.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct InputPreprocessorMessageData {
1414
#[derive(Debug, Default, ExtractField)]
1515
pub struct InputPreprocessorMessageHandler {
1616
pub frame_time: FrameTimeInfo,
17-
pub time: u64,
17+
pub time: f64,
1818
pub keyboard: KeyStates,
1919
pub mouse: MouseState,
2020
pub viewport_bounds: ViewportBounds,
@@ -98,9 +98,7 @@ impl MessageHandler<InputPreprocessorMessage, InputPreprocessorMessageData> for
9898
self.translate_mouse_event(mouse_state, false, responses);
9999
}
100100
InputPreprocessorMessage::CurrentTime { timestamp } => {
101-
responses.add(AnimationMessage::SetTime(timestamp as f64));
102-
self.time = timestamp;
103-
self.frame_time.advance_timestamp(Duration::from_millis(timestamp));
101+
self.time = timestamp as f64;
104102
}
105103
InputPreprocessorMessage::WheelScroll { editor_mouse_state, modifier_keys } => {
106104
self.update_states_of_modifier_keys(modifier_keys, keyboard_platform, responses);
@@ -187,10 +185,19 @@ impl InputPreprocessorMessageHandler {
187185
}
188186
}
189187

190-
pub fn document_bounds(&self) -> [DVec2; 2] {
188+
pub fn viewport_bounds(&self) -> [DVec2; 2] {
191189
// IPP bounds are relative to the entire application
192190
[(0., 0.).into(), self.viewport_bounds.bottom_right - self.viewport_bounds.top_left]
193191
}
192+
193+
pub fn document_bounds(&self, document_to_viewport: DAffine2) -> [DVec2; 2] {
194+
// IPP bounds are relative to the entire application
195+
let mut bounds = self.viewport_bounds();
196+
for point in &mut bounds {
197+
*point = document_to_viewport.transform_point2(*point);
198+
}
199+
bounds
200+
}
194201
}
195202

196203
#[cfg(test)]

editor/src/messages/message.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1+
use std::sync::Arc;
2+
13
use crate::messages::prelude::*;
4+
use graphene_std::{IntrospectMode, uuid::CompiledProtonodeInput};
25
use graphite_proc_macros::*;
36

47
#[impl_message]
5-
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
8+
#[derive(Clone, Debug, PartialEq)]
69
pub enum Message {
710
NoOp,
811
Init,
912
Batched(Box<[Message]>),
10-
StartBuffer,
11-
EndBuffer(graphene_std::renderer::RenderMetadata),
13+
// Adds any subsequent messages to the queue
14+
StartQueue,
15+
// Stop adding messages to the queue.
16+
EndQueue,
17+
// Processes all messages that are queued, which occurs on the evaluation response. This allows a message to be run with data from after the evaluation is complete
18+
ProcessQueue(
19+
(
20+
graphene_std::renderer::RenderMetadata,
21+
Vec<(CompiledProtonodeInput, IntrospectMode, Box<dyn std::any::Any + Send + Sync>)>,
22+
),
23+
),
1224

1325
#[child]
1426
Animation(AnimationMessage),

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ use crate::messages::portfolio::document::utility_types::misc::{AlignAggregate,
77
use crate::messages::portfolio::utility_types::PanelType;
88
use crate::messages::prelude::*;
99
use glam::DAffine2;
10-
use graph_craft::document::NodeId;
10+
use graphene_std::uuid::CompiledProtonodeInput;
1111
use graphene_std::Color;
1212
use graphene_std::raster::BlendMode;
1313
use graphene_std::raster::Image;
14+
use graphene_std::renderer::ClickTarget;
1415
use graphene_std::transform::Footprint;
15-
use graphene_std::vector::click_target::ClickTarget;
16+
use graphene_std::uuid::NodeId;
1617
use graphene_std::vector::style::ViewMode;
1718

1819
#[impl_message(Message, PortfolioMessage, Document)]

0 commit comments

Comments
 (0)