Skip to content

Commit 1f700ad

Browse files
committed
Code review
1 parent 90d8447 commit 1f700ad

Some content is hidden

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

42 files changed

+86794
-275
lines changed

demo-artwork/isometric-fountain.graphite

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

demo-artwork/just-a-potted-cactus.graphite

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

demo-artwork/procedural-string-lights.graphite

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

demo-artwork/red-dress.graphite

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

demo-artwork/valley-of-spires.graphite

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

editor/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,7 @@ futures = { workspace = true }
6767
tokio = { workspace = true, features = ["rt", "macros"] }
6868

6969
[lints.rust]
70-
# ToDo: figure out why we check these features when they do not exist
71-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(feature, values("resvg", "vello"))'] }
70+
# TODO: figure out why we check these features when they do not exist
71+
unexpected_cfgs = { level = "warn", check-cfg = [
72+
'cfg(feature, values("resvg", "vello"))',
73+
] }

editor/src/dispatcher.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -433,19 +433,18 @@ mod test {
433433

434434
for (document_name, _, file_name) in crate::messages::dialog::simple_dialogs::ARTWORK {
435435
let document_serialized_content = std::fs::read_to_string(format!("../demo-artwork/{file_name}")).unwrap();
436-
let document_serialized_content = document_serialized_content.replace("\"ManipulatorGroupIds\"", "\"PointIds\"");
437436

438-
// assert_eq!(
439-
// document_serialized_content.lines().count(),
440-
// 1,
441-
// "Demo artwork '{document_name}' has more than 1 line (remember to open and re-save it in Graphite)",
442-
// );
437+
assert_eq!(
438+
document_serialized_content.lines().count(),
439+
1,
440+
"Demo artwork '{document_name}' has more than 1 line (remember to open and re-save it in Graphite)",
441+
);
443442

444443
let responses = editor.handle_message(PortfolioMessage::OpenDocumentFile {
445444
document_name: document_name.into(),
446445
document_serialized_content,
447446
});
448-
println!("Res {responses:#?}");
447+
println!("Responses:\n{responses:#?}");
449448

450449
// Check if the graph renders
451450
let portfolio = &mut editor.dispatcher.message_handlers.portfolio_message_handler;
@@ -454,7 +453,7 @@ mod test {
454453
.submit_node_graph_evaluation(portfolio.documents.get_mut(&portfolio.active_document_id.unwrap()).unwrap(), glam::UVec2::ONE);
455454
crate::node_graph_executor::run_node_graph().await;
456455
let mut messages = VecDeque::new();
457-
editor.poll_node_graph_evaluation(&mut messages).expect("graph should render");
456+
editor.poll_node_graph_evaluation(&mut messages).expect("Graph should render");
458457

459458
for response in responses {
460459
// Check for the existence of the file format incompatibility warning dialog after opening the test file
@@ -476,9 +475,11 @@ mod test {
476475
async fn migrate() {
477476
use crate::messages::portfolio::document::graph_operation::transform_utils::*;
478477
use crate::messages::portfolio::document::graph_operation::utility_types::*;
478+
479479
use graph_craft::document::NodeInput;
480480
use graph_craft::document::{value::TaggedValue, DocumentNodeImplementation};
481481
use graphene_core::vector::*;
482+
482483
init_logger();
483484
let mut editor = Editor::create();
484485

@@ -508,8 +509,9 @@ mod test {
508509
.executor
509510
.submit_node_graph_evaluation(portfolio.documents.get_mut(&portfolio.active_document_id.unwrap()).unwrap(), glam::UVec2::ONE);
510511
crate::node_graph_executor::run_node_graph().await;
512+
511513
let mut messages = VecDeque::new();
512-
editor.poll_node_graph_evaluation(&mut messages).expect("graph should render");
514+
editor.poll_node_graph_evaluation(&mut messages).expect("Graph should render");
513515

514516
let document = editor.dispatcher.message_handlers.portfolio_message_handler.active_document_mut().unwrap();
515517
let mut updated_nodes = HashSet::new();
@@ -519,25 +521,28 @@ mod test {
519521
if document.metadata.is_folder(layer) {
520522
continue;
521523
}
522-
println!("Layer {layer:?}");
523524
let bounds = LayerBounds::new(&document.metadata, layer);
525+
524526
let mut responses = VecDeque::new();
525527
let mut shape = None;
528+
526529
if let Some(mut modify_inputs) = ModifyInputsContext::new_with_layer(layer.to_node(), &mut document.network, &mut document.metadata, &mut document.node_graph_handler, &mut responses) {
527530
modify_inputs.modify_existing_inputs("Transform", |inputs, node_id, metadata| {
528531
if !updated_nodes.insert(node_id) {
529532
return;
530533
}
534+
531535
let transform = get_current_transform(&inputs);
532536
let upstream_transform = metadata.upstream_transform(node_id);
533537
let pivot_transform = glam::DAffine2::from_translation(upstream_transform.transform_point2(bounds.local_pivot(get_current_normalized_pivot(&inputs))));
534-
println!("pivot {pivot_transform}");
538+
535539
update_transform(inputs, pivot_transform * transform * pivot_transform.inverse());
536540
});
537541
modify_inputs.modify_existing_inputs("Shape", |inputs, node_id, metadata| {
538542
if !updated_nodes.insert(node_id) {
539543
return;
540544
}
545+
541546
let path_data = if let NodeInput::Value {
542547
tagged_value: TaggedValue::Subpaths(translation),
543548
..
@@ -547,6 +552,7 @@ mod test {
547552
} else {
548553
&Vec::new()
549554
};
555+
550556
let colinear_manipulators = if let NodeInput::Value {
551557
tagged_value: TaggedValue::PointIds(translation),
552558
..
@@ -556,11 +562,13 @@ mod test {
556562
} else {
557563
&Vec::new()
558564
};
565+
559566
let mut vector_data = VectorData::from_subpaths(path_data, false);
560567
vector_data.colinear_manipulators = colinear_manipulators
561568
.iter()
562569
.filter_map(|&point| ManipulatorPointId::Anchor(point).get_handle_pair(&vector_data))
563570
.collect();
571+
564572
shape = Some((node_id, VectorModification::create_from_vector(&vector_data)));
565573
});
566574
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use super::utility_types::TransformIn;
22
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
33
use crate::messages::prelude::*;
4-
use graphene_core::vector::VectorModificationType;
54

65
use bezier_rs::Subpath;
76
use graph_craft::document::{DocumentNode, NodeId, NodeInput};
@@ -10,6 +9,7 @@ use graphene_core::text::Font;
109
use graphene_core::vector::brush_stroke::BrushStroke;
1110
use graphene_core::vector::style::{Fill, Stroke};
1211
use graphene_core::vector::PointId;
12+
use graphene_core::vector::VectorModificationType;
1313
use graphene_core::{Artboard, Color};
1414
use graphene_std::vector::misc::BooleanOperation;
1515

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use super::transform_utils::{self};
1+
use super::transform_utils;
22
use super::utility_types::ModifyInputsContext;
33
use crate::messages::portfolio::document::node_graph::document_node_types::resolve_document_node_type;
44
use crate::messages::portfolio::document::utility_types::document_metadata::{DocumentMetadata, LayerNodeIdentifier};

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use bezier_rs::Subpath;
2-
use glam::{DAffine2, DVec2};
32
use graph_craft::document::{value::TaggedValue, NodeInput};
43
use graphene_core::vector::PointId;
54

5+
use glam::{DAffine2, DVec2};
6+
67
/// Convert an affine transform into the tuple `(scale, angle, translation, shear)` assuming `shear.y = 0`.
78
pub fn compute_scale_angle_translation_shear(transform: DAffine2) -> (DVec2, f64, DVec2, DVec2) {
89
let x_axis = transform.matrix2.x_axis;
@@ -46,13 +47,13 @@ pub struct LayerBounds {
4647
pub layer_transform: DAffine2,
4748
}
4849

49-
#[cfg(test)]
50-
use crate::messages::portfolio::document::utility_types::document_metadata::{DocumentMetadata, LayerNodeIdentifier};
51-
5250
#[cfg(test)]
5351
impl LayerBounds {
5452
/// Extract the layer bounds and their transform for a layer.
55-
pub fn new(metadata: &DocumentMetadata, layer: LayerNodeIdentifier) -> Self {
53+
pub fn new(
54+
metadata: &crate::messages::portfolio::document::utility_types::document_metadata::DocumentMetadata,
55+
layer: crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier,
56+
) -> Self {
5657
Self {
5758
bounds: metadata.nonzero_bounding_box(layer),
5859
bounds_transform: DAffine2::IDENTITY,

0 commit comments

Comments
 (0)