Skip to content

Commit c6ff7e6

Browse files
authored
Merge branch 'master' into fix-stroke-alignment-outside
2 parents ed901ac + 36a1453 commit c6ff7e6

File tree

60 files changed

+995
-508
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

+995
-508
lines changed

desktop/src/app.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ impl WinitApp {
6161
}
6262

6363
fn send_messages_to_editor(&mut self, mut responses: Vec<FrontendMessage>) {
64-
for message in responses.extract_if(.., |m| matches!(m, FrontendMessage::RenderOverlays(_))) {
65-
let FrontendMessage::RenderOverlays(overlay_context) = message else { unreachable!() };
64+
for message in responses.extract_if(.., |m| matches!(m, FrontendMessage::RenderOverlays { .. })) {
65+
let FrontendMessage::RenderOverlays { context: overlay_context } = message else { unreachable!() };
6666
if let Some(graphics_state) = &mut self.graphics_state {
6767
let scene = overlay_context.take_scene();
6868
graphics_state.set_overlays_scene(scene);

editor/src/dispatcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const SIDE_EFFECT_FREE_MESSAGES: &[MessageDiscriminant] = &[
5252
MessageDiscriminant::Frontend(FrontendMessageDiscriminant::TriggerFontLoad),
5353
];
5454
const DEBUG_MESSAGE_BLOCK_LIST: &[MessageDiscriminant] = &[
55-
MessageDiscriminant::Broadcast(BroadcastMessageDiscriminant::TriggerEvent(BroadcastEventDiscriminant::AnimationFrame)),
55+
MessageDiscriminant::Broadcast(BroadcastMessageDiscriminant::TriggerEvent(EventMessageDiscriminant::AnimationFrame)),
5656
MessageDiscriminant::Animation(AnimationMessageDiscriminant::IncrementFrameCounter),
5757
];
5858
// TODO: Find a way to combine these with the list above. We use strings for now since these are the standard variant names used by multiple messages. But having these also type-checked would be best.

editor/src/messages/animation/animation_message.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use crate::messages::prelude::*;
2-
31
use super::animation_message_handler::AnimationTimeMode;
2+
use crate::messages::prelude::*;
43

54
#[impl_message(Message, Animation)]
65
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]

editor/src/messages/broadcast/broadcast_message.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ use crate::messages::prelude::*;
55
pub enum BroadcastMessage {
66
// Sub-messages
77
#[child]
8-
TriggerEvent(BroadcastEvent),
8+
TriggerEvent(EventMessage),
99

1010
// Messages
1111
SubscribeEvent {
12-
on: BroadcastEvent,
12+
on: EventMessage,
1313
send: Box<Message>,
1414
},
1515
UnsubscribeEvent {
16-
on: BroadcastEvent,
17-
message: Box<Message>,
16+
on: EventMessage,
17+
send: Box<Message>,
1818
},
1919
}

editor/src/messages/broadcast/broadcast_message_handler.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,24 @@ use crate::messages::prelude::*;
22

33
#[derive(Debug, Clone, Default, ExtractField)]
44
pub struct BroadcastMessageHandler {
5-
listeners: HashMap<BroadcastEvent, Vec<Message>>,
5+
event: EventMessageHandler,
6+
listeners: HashMap<EventMessage, Vec<Message>>,
67
}
78

89
#[message_handler_data]
910
impl MessageHandler<BroadcastMessage, ()> for BroadcastMessageHandler {
1011
fn process_message(&mut self, message: BroadcastMessage, responses: &mut VecDeque<Message>, _: ()) {
1112
match message {
1213
// Sub-messages
13-
BroadcastMessage::TriggerEvent(event) => {
14-
for message in self.listeners.entry(event).or_default() {
15-
responses.add_front(message.clone())
16-
}
17-
}
14+
BroadcastMessage::TriggerEvent(message) => self.event.process_message(message, responses, EventMessageContext { listeners: &mut self.listeners }),
1815

1916
// Messages
2017
BroadcastMessage::SubscribeEvent { on, send } => self.listeners.entry(on).or_default().push(*send),
21-
BroadcastMessage::UnsubscribeEvent { on, message } => self.listeners.entry(on).or_default().retain(|msg| *msg != *message),
18+
BroadcastMessage::UnsubscribeEvent { on, send } => self.listeners.entry(on).or_default().retain(|msg| *msg != *send),
2219
}
2320
}
2421

2522
fn actions(&self) -> ActionList {
26-
actions!(BroadcastEventDiscriminant;)
23+
actions!(EventMessageDiscriminant;)
2724
}
2825
}

editor/src/messages/broadcast/broadcast_event.rs renamed to editor/src/messages/broadcast/event/event_message.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::messages::prelude::*;
22

3-
#[derive(PartialEq, Eq, Clone, Debug, serde::Serialize, serde::Deserialize, Hash)]
43
#[impl_message(Message, BroadcastMessage, TriggerEvent)]
5-
pub enum BroadcastEvent {
4+
#[derive(PartialEq, Eq, Clone, Debug, serde::Serialize, serde::Deserialize, Hash)]
5+
pub enum EventMessage {
66
/// Triggered by requestAnimationFrame in JS
77
AnimationFrame,
88
CanvasTransformed,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use crate::messages::prelude::*;
2+
3+
#[derive(ExtractField)]
4+
pub struct EventMessageContext<'a> {
5+
pub listeners: &'a mut HashMap<EventMessage, Vec<Message>>,
6+
}
7+
8+
#[derive(Debug, Clone, Default, ExtractField)]
9+
pub struct EventMessageHandler {}
10+
11+
#[message_handler_data]
12+
impl MessageHandler<EventMessage, EventMessageContext<'_>> for EventMessageHandler {
13+
fn process_message(&mut self, message: EventMessage, responses: &mut VecDeque<Message>, context: EventMessageContext) {
14+
for message in context.listeners.entry(message).or_default() {
15+
responses.add_front(message.clone())
16+
}
17+
}
18+
19+
fn actions(&self) -> ActionList {
20+
actions!(EventMessageDiscriminant;)
21+
}
22+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
mod event_message;
2+
mod event_message_handler;
3+
4+
#[doc(inline)]
5+
pub use event_message::{EventMessage, EventMessageDiscriminant};
6+
#[doc(inline)]
7+
pub use event_message_handler::{EventMessageContext, EventMessageHandler};

editor/src/messages/broadcast/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
mod broadcast_message;
22
mod broadcast_message_handler;
33

4-
pub mod broadcast_event;
4+
pub mod event;
55

66
#[doc(inline)]
77
pub use broadcast_message::{BroadcastMessage, BroadcastMessageDiscriminant};

editor/src/messages/defer/defer_message.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use crate::messages::prelude::*;
33
#[impl_message(Message, Defer)]
44
#[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize)]
55
pub enum DeferMessage {
6-
SetGraphSubmissionIndex(u64),
7-
TriggerGraphRun(u64, DocumentId),
6+
SetGraphSubmissionIndex { execution_id: u64 },
7+
TriggerGraphRun { execution_id: u64, document_id: DocumentId },
88
AfterGraphRun { messages: Vec<Message> },
99
TriggerNavigationReady,
1010
AfterNavigationReady { messages: Vec<Message> },

0 commit comments

Comments
 (0)