Skip to content

Commit d2edc38

Browse files
committed
merge onto master
1 parent ce605ac commit d2edc38

File tree

60 files changed

+2853
-3224
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

+2853
-3224
lines changed

editor/src/dispatcher.rs

Lines changed: 19 additions & 31 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,34 +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-
click_targets,
144-
clip_targets,
145-
} = render_metadata;
146-
147-
// Run these update state messages immediately
148-
let messages = [
149-
DocumentMessage::UpdateUpstreamTransforms {
150-
upstream_footprints: footprints,
151-
local_transforms,
152-
},
153-
DocumentMessage::UpdateClickTargets { click_targets },
154-
DocumentMessage::UpdateClipTargets { clip_targets },
155-
];
156-
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));
157145
}
158146
Message::NoOp => {}
159147
Message::Init => {

editor/src/messages/animation/animation_message_handler.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl MessageHandler<AnimationMessage, ()> for AnimationMessageHandler {
8383
}
8484
AnimationMessage::SetFrameIndex(frame) => {
8585
self.frame_index = frame;
86-
responses.add(PortfolioMessage::SubmitActiveGraphRender);
86+
responses.add(PortfolioMessage::EvaluateActiveDocument);
8787
// Update the restart and pause/play buttons
8888
responses.add(PortfolioMessage::UpdateDocumentWidgets);
8989
}
@@ -99,7 +99,7 @@ impl MessageHandler<AnimationMessage, ()> for AnimationMessageHandler {
9999
}
100100
AnimationMessage::UpdateTime => {
101101
if self.is_playing() {
102-
responses.add(PortfolioMessage::SubmitActiveGraphRender);
102+
responses.add(PortfolioMessage::EvaluateActiveDocument);
103103

104104
if self.live_preview_recently_zero {
105105
// Update the restart and pause/play buttons
@@ -115,7 +115,7 @@ impl MessageHandler<AnimationMessage, ()> for AnimationMessageHandler {
115115
_ => AnimationState::Stopped,
116116
};
117117
self.live_preview_recently_zero = true;
118-
responses.add(PortfolioMessage::SubmitActiveGraphRender);
118+
responses.add(PortfolioMessage::EvaluateActiveDocument);
119119
// Update the restart and pause/play buttons
120120
responses.add(PortfolioMessage::UpdateDocumentWidgets);
121121
}

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
@@ -41,7 +41,7 @@ impl MessageHandler<ExportDialogMessage, ExportDialogMessageData<'_>> for Export
4141
ExportDialogMessage::TransparentBackground(transparent_background) => self.transparent_background = transparent_background,
4242
ExportDialogMessage::ExportBounds(export_area) => self.bounds = export_area,
4343

44-
ExportDialogMessage::Submit => responses.add_front(PortfolioMessage::SubmitDocumentExport {
44+
ExportDialogMessage::Submit => responses.add_front(PortfolioMessage::ActiveDocumentExport {
4545
file_name: portfolio.active_document().map(|document| document.name.clone()).unwrap_or_default(),
4646
file_type: self.file_type,
4747
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
@@ -23,7 +23,7 @@ impl MessageHandler<NewDocumentDialogMessage, ()> for NewDocumentDialogMessageHa
2323

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

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

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
@@ -172,7 +172,7 @@ impl PreferencesDialogMessageHandler {
172172
let use_vello = vec![
173173
Separator::new(SeparatorType::Unrelated).widget_holder(),
174174
Separator::new(SeparatorType::Unrelated).widget_holder(),
175-
CheckboxInput::new(preferences.use_vello && preferences.supports_wgpu())
175+
CheckboxInput::new(preferences.use_vello())
176176
.tooltip(vello_tooltip)
177177
.disabled(!preferences.supports_wgpu())
178178
.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
@@ -13,7 +13,7 @@ pub struct InputPreprocessorMessageData {
1313
#[derive(Debug, Default)]
1414
pub struct InputPreprocessorMessageHandler {
1515
pub frame_time: FrameTimeInfo,
16-
pub time: u64,
16+
pub time: f64,
1717
pub keyboard: KeyStates,
1818
pub mouse: MouseState,
1919
pub viewport_bounds: ViewportBounds,
@@ -96,9 +96,7 @@ impl MessageHandler<InputPreprocessorMessage, InputPreprocessorMessageData> for
9696
self.translate_mouse_event(mouse_state, false, responses);
9797
}
9898
InputPreprocessorMessage::CurrentTime { timestamp } => {
99-
responses.add(AnimationMessage::SetTime(timestamp as f64));
100-
self.time = timestamp;
101-
self.frame_time.advance_timestamp(Duration::from_millis(timestamp));
99+
self.time = timestamp as f64;
102100
}
103101
InputPreprocessorMessage::WheelScroll { editor_mouse_state, modifier_keys } => {
104102
self.update_states_of_modifier_keys(modifier_keys, keyboard_platform, responses);
@@ -185,10 +183,19 @@ impl InputPreprocessorMessageHandler {
185183
}
186184
}
187185

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

194201
#[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)