Skip to content

Commit ab0590c

Browse files
authored
Merge branch 'master' into gradient
2 parents 392e43c + 56fafa9 commit ab0590c

Some content is hidden

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

47 files changed

+2079
-182
lines changed

.github/workflows/build-dev-and-ci.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,6 @@ jobs:
108108
- name: 📥 Clone and checkout repository
109109
uses: actions/checkout@v3
110110

111-
- name: 🔒 Check crate security advisories for root workspace
112-
uses: EmbarkStudios/cargo-deny-action@v2
113-
with:
114-
command: check advisories
115-
116-
- name: 🔒 Check crate security advisories for /libraries/rawkit
117-
uses: EmbarkStudios/cargo-deny-action@v2
118-
with:
119-
command: check advisories
120-
manifest-path: libraries/rawkit/Cargo.toml
121-
122111
- name: 📜 Check crate license compatibility for root workspace
123112
uses: EmbarkStudios/cargo-deny-action@v2
124113
with:

.github/workflows/cargo-deny.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "Audit Security Advisories"
2+
3+
on:
4+
# Run once each day
5+
schedule:
6+
- cron: "0 0 * * *"
7+
8+
jobs:
9+
cargo-deny:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: 📥 Clone and checkout repository
14+
uses: actions/checkout@v3
15+
16+
- name: 🔒 Check crate security advisories for root workspace
17+
uses: EmbarkStudios/cargo-deny-action@v2
18+
with:
19+
command: check advisories
20+
21+
- name: 🔒 Check crate security advisories for /libraries/rawkit
22+
uses: EmbarkStudios/cargo-deny-action@v2
23+
with:
24+
command: check advisories
25+
manifest-path: libraries/rawkit/Cargo.toml

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/parametric-dunescape.graphite

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

editor/src/dispatcher.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ mod test {
515515
// include_str!("../../demo-artwork/isometric-fountain.graphite"),
516516
// include_str!("../../demo-artwork/painted-dreams.graphite"),
517517
// include_str!("../../demo-artwork/procedural-string-lights.graphite"),
518+
// include_str!("../../demo-artwork/parametric-dunescape.graphite"),
518519
// include_str!("../../demo-artwork/red-dress.graphite"),
519520
// include_str!("../../demo-artwork/valley-of-spires.graphite"),
520521
// ];

editor/src/messages/animation/animation_message_handler.rs

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,55 +11,72 @@ pub enum AnimationTimeMode {
1111
FrameBased,
1212
}
1313

14-
#[derive(Debug, Default)]
14+
#[derive(Default, Debug, Clone, PartialEq)]
15+
enum AnimationState {
16+
#[default]
17+
Stopped,
18+
Playing {
19+
start: f64,
20+
},
21+
Paused {
22+
start: f64,
23+
pause_time: f64,
24+
},
25+
}
26+
27+
#[derive(Default, Debug, Clone, PartialEq)]
1528
pub struct AnimationMessageHandler {
16-
live_preview: bool,
1729
/// Used to re-send the UI on the next frame after playback starts
1830
live_preview_recently_zero: bool,
1931
timestamp: f64,
2032
frame_index: f64,
21-
animation_start: Option<f64>,
33+
animation_state: AnimationState,
2234
fps: f64,
2335
animation_time_mode: AnimationTimeMode,
2436
}
2537
impl AnimationMessageHandler {
2638
pub(crate) fn timing_information(&self) -> TimingInformation {
27-
let animation_time = self.timestamp - self.animation_start.unwrap_or(self.timestamp);
39+
let animation_time = self.timestamp - self.animation_start();
2840
let animation_time = match self.animation_time_mode {
2941
AnimationTimeMode::TimeBased => Duration::from_millis(animation_time as u64),
3042
AnimationTimeMode::FrameBased => Duration::from_secs((self.frame_index / self.fps) as u64),
3143
};
3244
TimingInformation { time: self.timestamp, animation_time }
3345
}
3446

47+
pub(crate) fn animation_start(&self) -> f64 {
48+
match self.animation_state {
49+
AnimationState::Stopped => self.timestamp,
50+
AnimationState::Playing { start } => start,
51+
AnimationState::Paused { start, pause_time } => start + self.timestamp - pause_time,
52+
}
53+
}
54+
3555
pub fn is_playing(&self) -> bool {
36-
self.live_preview
56+
matches!(self.animation_state, AnimationState::Playing { .. })
3757
}
3858
}
3959

4060
impl MessageHandler<AnimationMessage, ()> for AnimationMessageHandler {
4161
fn process_message(&mut self, message: AnimationMessage, responses: &mut VecDeque<Message>, _data: ()) {
4262
match message {
43-
AnimationMessage::ToggleLivePreview => {
44-
if self.animation_start.is_none() {
45-
self.animation_start = Some(self.timestamp);
46-
}
47-
self.live_preview = !self.live_preview;
48-
49-
// Update the restart and pause/play buttons
50-
responses.add(PortfolioMessage::UpdateDocumentWidgets);
51-
}
63+
AnimationMessage::ToggleLivePreview => match self.animation_state {
64+
AnimationState::Stopped => responses.add(AnimationMessage::EnableLivePreview),
65+
AnimationState::Playing { .. } => responses.add(AnimationMessage::DisableLivePreview),
66+
AnimationState::Paused { .. } => responses.add(AnimationMessage::EnableLivePreview),
67+
},
5268
AnimationMessage::EnableLivePreview => {
53-
if self.animation_start.is_none() {
54-
self.animation_start = Some(self.timestamp);
55-
}
56-
self.live_preview = true;
69+
self.animation_state = AnimationState::Playing { start: self.animation_start() };
5770

5871
// Update the restart and pause/play buttons
5972
responses.add(PortfolioMessage::UpdateDocumentWidgets);
6073
}
6174
AnimationMessage::DisableLivePreview => {
62-
self.live_preview = false;
75+
match self.animation_state {
76+
AnimationState::Stopped => (),
77+
AnimationState::Playing { start } => self.animation_state = AnimationState::Paused { start, pause_time: self.timestamp },
78+
AnimationState::Paused { .. } => (),
79+
}
6380

6481
// Update the restart and pause/play buttons
6582
responses.add(PortfolioMessage::UpdateDocumentWidgets);
@@ -72,18 +89,16 @@ impl MessageHandler<AnimationMessage, ()> for AnimationMessageHandler {
7289
}
7390
AnimationMessage::SetTime(time) => {
7491
self.timestamp = time;
75-
if self.live_preview {
76-
responses.add(AnimationMessage::UpdateTime);
77-
}
92+
responses.add(AnimationMessage::UpdateTime);
7893
}
7994
AnimationMessage::IncrementFrameCounter => {
80-
if self.live_preview {
95+
if self.is_playing() {
8196
self.frame_index += 1.;
8297
responses.add(AnimationMessage::UpdateTime);
8398
}
8499
}
85100
AnimationMessage::UpdateTime => {
86-
if self.live_preview {
101+
if self.is_playing() {
87102
responses.add(PortfolioMessage::SubmitActiveGraphRender);
88103

89104
if self.live_preview_recently_zero {
@@ -95,7 +110,10 @@ impl MessageHandler<AnimationMessage, ()> for AnimationMessageHandler {
95110
}
96111
AnimationMessage::RestartAnimation => {
97112
self.frame_index = 0.;
98-
self.animation_start = None;
113+
self.animation_state = match self.animation_state {
114+
AnimationState::Playing { .. } => AnimationState::Playing { start: self.timestamp },
115+
_ => AnimationState::Stopped,
116+
};
99117
self.live_preview_recently_zero = true;
100118
responses.add(PortfolioMessage::SubmitActiveGraphRender);
101119
// Update the restart and pause/play buttons

editor/src/messages/dialog/simple_dialogs/demo_artwork_dialog.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ use crate::messages::prelude::*;
55
pub struct DemoArtworkDialog;
66

77
/// `(name, thumbnail, filename)`
8-
pub const ARTWORK: [(&str, &str, &str); 6] = [
8+
pub const ARTWORK: [(&str, &str, &str); 7] = [
99
("Isometric Fountain", "ThumbnailIsometricFountain", "isometric-fountain.graphite"),
1010
("Changing Seasons", "ThumbnailChangingSeasons", "changing-seasons.graphite"),
1111
("Painted Dreams", "ThumbnailPaintedDreams", "painted-dreams.graphite"),
12+
("Parametric Dunescape", "ThumbnailParametricDunescape", "parametric-dunescape.graphite"),
1213
("Red Dress", "ThumbnailRedDress", "red-dress.graphite"),
1314
("Procedural String Lights", "ThumbnailProceduralStringLights", "procedural-string-lights.graphite"),
1415
("Valley of Spires", "ThumbnailValleyOfSpires", "valley-of-spires.graphite"),
@@ -28,7 +29,7 @@ impl DialogLayoutHolder for DemoArtworkDialog {
2829
impl LayoutHolder for DemoArtworkDialog {
2930
fn layout(&self) -> Layout {
3031
let mut rows_of_images_with_buttons: Vec<_> = ARTWORK
31-
.chunks(3)
32+
.chunks(4)
3233
.flat_map(|chunk| {
3334
fn make_dialog(name: &str, filename: &str) -> Message {
3435
DialogMessage::CloseDialogAndThen {

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pub struct DocumentMessageData<'a> {
4242
pub executor: &'a mut NodeGraphExecutor,
4343
pub current_tool: &'a ToolType,
4444
pub preferences: &'a PreferencesMessageHandler,
45+
pub device_pixel_ratio: f64,
4546
}
4647

4748
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
@@ -173,6 +174,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
173174
executor,
174175
current_tool,
175176
preferences,
177+
device_pixel_ratio,
176178
} = data;
177179

178180
let selected_nodes_bounding_box_viewport = self.network_interface.selected_nodes_bounding_box_viewport(&self.breadcrumb_network_path);
@@ -197,7 +199,15 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
197199
}
198200
DocumentMessage::Overlays(message) => {
199201
let overlays_visible = self.overlays_visible;
200-
self.overlays_message_handler.process_message(message, responses, OverlaysMessageData { overlays_visible, ipp });
202+
self.overlays_message_handler.process_message(
203+
message,
204+
responses,
205+
OverlaysMessageData {
206+
overlays_visible,
207+
ipp,
208+
device_pixel_ratio,
209+
},
210+
);
201211
}
202212
DocumentMessage::PropertiesPanel(message) => {
203213
let properties_panel_message_handler_data = PropertiesPanelMessageHandlerData {
@@ -1199,14 +1209,14 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
11991209

12001210
if is_collapsed {
12011211
if recursive {
1202-
let children: HashSet<_> = layer.children(metadata).collect();
1212+
let children: HashSet<_> = layer.descendants(metadata).collect();
12031213
self.collapsed.0.retain(|collapsed_layer| !children.contains(collapsed_layer) && collapsed_layer != &layer);
12041214
} else {
12051215
self.collapsed.0.retain(|collapsed_layer| collapsed_layer != &layer);
12061216
}
12071217
} else {
12081218
if recursive {
1209-
let children_to_add: Vec<_> = layer.children(metadata).filter(|child| !self.collapsed.0.contains(child)).collect();
1219+
let children_to_add: Vec<_> = layer.descendants(metadata).filter(|child| !self.collapsed.0.contains(child)).collect();
12101220
self.collapsed.0.extend(children_to_add);
12111221
}
12121222
self.collapsed.0.push(layer);

editor/src/messages/portfolio/document/graph_operation/utility_types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ impl<'a> ModifyInputsContext<'a> {
292292
// If inserting a path node, insert a flatten vector elements if the type is a graphic group.
293293
// TODO: Allow the path node to operate on Graphic Group data by utilizing the reference for each vector data in a group.
294294
if node_definition.identifier == "Path" {
295-
let layer_input_type = self.network_interface.input_type(&InputConnector::node(output_layer.to_node(), 1), &[]).0.nested_type();
295+
let layer_input_type = self.network_interface.input_type(&InputConnector::node(output_layer.to_node(), 1), &[]).0.nested_type().clone();
296296
if layer_input_type == concrete!(GraphicGroupTable) {
297297
let Some(flatten_vector_elements_definition) = resolve_document_node_type("Flatten Vector Elements") else {
298298
log::error!("Flatten Vector Elements does not exist in ModifyInputsContext::existing_node_id");

editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,6 +809,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
809809
NodeInput::value(TaggedValue::ImageFrame(ImageFrameTable::one_empty_image()), true),
810810
NodeInput::value(TaggedValue::ImageFrame(ImageFrameTable::one_empty_image()), true),
811811
],
812+
manual_composition: Some(generic!(T)),
812813
..Default::default()
813814
},
814815
persistent_node_metadata: DocumentNodePersistentMetadata {
@@ -2663,6 +2664,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
26632664
let node_registry = graphene_core::registry::NODE_REGISTRY.lock().unwrap();
26642665
'outer: for (id, metadata) in graphene_core::registry::NODE_METADATA.lock().unwrap().iter() {
26652666
use graphene_core::registry::*;
2667+
let id = id.clone();
26662668

26672669
for node in custom.iter() {
26682670
let DocumentNodeDefinition {
@@ -2673,7 +2675,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
26732675
..
26742676
} = node;
26752677
match implementation {
2676-
DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier { name }) if name == id => continue 'outer,
2678+
DocumentNodeImplementation::ProtoNode(ProtoNodeIdentifier { name }) if name == &id => continue 'outer,
26772679
_ => (),
26782680
}
26792681
}
@@ -2685,12 +2687,12 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
26852687
description,
26862688
properties,
26872689
} = metadata;
2688-
let Some(implementations) = &node_registry.get(id) else { continue };
2690+
let Some(implementations) = &node_registry.get(&id) else { continue };
26892691
let valid_inputs: HashSet<_> = implementations.iter().map(|(_, node_io)| node_io.call_argument.clone()).collect();
26902692
let first_node_io = implementations.first().map(|(_, node_io)| node_io).unwrap_or(const { &NodeIOTypes::empty() });
26912693
let mut input_type = &first_node_io.call_argument;
26922694
if valid_inputs.len() > 1 {
2693-
input_type = &const { generic!(T) };
2695+
input_type = &const { generic!(D) };
26942696
}
26952697
let output_type = &first_node_io.return_value;
26962698

@@ -2740,6 +2742,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
27402742
output_names: vec![output_type.to_string()],
27412743
has_primary_output: true,
27422744
locked: false,
2745+
27432746
..Default::default()
27442747
},
27452748
},

0 commit comments

Comments
 (0)