before_code stringlengths 30 149k | reviewer_comment stringlengths 16 20.6k | after_code stringlengths 30 163k | diff_context stringlengths 0 22.4k | file_path stringlengths 6 155 | comment_line int64 0 26 | language stringclasses 19
values | quality_score float64 0.07 1 | comment_type stringclasses 9
values | comment_length int64 16 20.6k | before_lines int64 2 4.61k | after_lines int64 2 4.4k | is_negative bool 2
classes | pr_title stringlengths 7 140 | pr_number int64 18 61.2k | repo_name stringclasses 29
values | repo_stars int64 321 56k | repo_language stringclasses 14
values | reviewer_username stringclasses 378
values | author_username stringclasses 739
values | user stringlengths 361 200k | assistant stringlengths 16 20.6k | system stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
#[derive(Debug, Clone)]
pub struct ImageTexture {
#[cfg(feature = "wgpu")]
pub texture: Arc<wgpu::Texture>,
#[cfg(not(feature = "wgpu"))]
pub texture: (),
}
impl Hash for ImageTexture {
#[cfg(feature = "wgpu")]
fn hash<H: Hasher>(&self, state: &mut H) {
self.texture.hash(state);
}
#[cfg(not(feature = "wgpu")... | Why did you make this change? Seems nonsensical | #[derive(Debug, Clone)]
pub struct ImageTexture {
#[cfg(feature = "wgpu")]
pub texture: Arc<wgpu::Texture>,
#[cfg(not(feature = "wgpu"))]
pub texture: (),
}
impl Hash for ImageTexture {
#[cfg(feature = "wgpu")]
fn hash<H: Hasher>(&self, state: &mut H) {
self.texture.hash(state);
}
#[cfg(not(feature = "wgpu")... | @@ -91,7 +91,7 @@ impl PartialEq for ImageTexture {
}
#[cfg(not(feature = "wgpu"))]
{
- true // Unit values are always equal | node-graph/gcore/src/application_io.rs | 26 | Rust | 0.143 | question | 47 | 51 | 51 | false | Refactor many usages of Color to natively store linear not gamma | 2,457 | GraphiteEditor/Graphite | 17,935 | Rust | TrueDoctor | Keavon | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/application_io.rs
PR Title: Refactor many usages of Color to natively store linear not gamma
BEFORE CODE: #[derive(Debug, Clone)]
pub struct ImageTexture {
#[cfg(feature = "wgpu")]
pub texture: Arc<wgpu::Texture>,
#[cfg(not(feature = "wgp... | Why did you make this change? Seems nonsensical | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
let len = ellipse.segment_domain.ids().len();
for i in 0..len {
ellipse
.colinear_manipulators
.push([HandleId::end(ellipse.segment_domain.ids()[i]), HandleId::primary(ellipse.segment_domain.ids()[(i + 1) % len])]);
}
VectorDataTable::new(ellipse)
}
#[node_macro::node(category("Vector: Shape"), propertie... | @TrueDoctor can we avoid needing to include these trait bounds for `T` here? | #[default(270.)]
#[range((0., 360.))]
sweep_angle: Angle,
arc_type: ArcType,
) -> VectorDataTable {
VectorDataTable::new(VectorData::from_subpath(Subpath::new_arc(
radius,
start_angle / 360. * std::f64::consts::TAU,
sweep_angle / 360. * std::f64::consts::TAU,
match arc_type {
ArcType::Open => bezier_rs:... | @@ -72,11 +73,11 @@ fn rectangle<T: CornerRadius>(
}
#[node_macro::node(category("Vector: Shape"))]
-fn regular_polygon<T: AsU64>(
+fn regular_polygon<T: AsU64 + std::cmp::PartialOrd + FromPrimitive>( | node-graph/gcore/src/vector/generator_nodes.rs | 26 | Rust | 0.429 | question | 76 | 51 | 51 | false | Update #[min/max] node macro attributes to #[soft/hard]_[min/max] and make them clamp their input data | 2,464 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | mTvare6 | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/vector/generator_nodes.rs
PR Title: Update #[min/max] node macro attributes to #[soft/hard]_[min/max] and make them clamp their input data
BEFORE CODE:
let len = ellipse.segment_domain.ids().len();
for i in 0..len {
ellipse
.colinear... | @TrueDoctor can we avoid needing to include these trait bounds for `T` here? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Some(ty) => quote!(Some(concrete!(#ty))),
_ => quote!(None),
},
_ => quote!(None),
})
.collect();
let number_min_values: Vec<_> = fields
.iter()
.map(|field| match field {
ParsedField::Regular { number_min: Some(number_min), .. } => quote!(Some(#number_min)),
_ => quote!(None),
})
.col... | We have the hard and soft cases of these match arms both producing the same result. Is that intentional and sensible here? Assuming so, they should also perhaps be combined, replacing `None` with `_` and using ` | ` to put them on the same line. | Some(ty) => quote!(Some(concrete!(#ty))),
_ => quote!(None),
},
_ => quote!(None),
})
.collect();
let number_min_values: Vec<_> = fields
.iter()
.map(|field| match field {
ParsedField::Regular { number_soft_min, number_hard_min, .. } => match (number_soft_min, number_hard_min) {
(Some(sof... | @@ -134,14 +134,22 @@ pub(crate) fn generate_node_code(parsed: &ParsedNodeFn) -> syn::Result<TokenStre
let number_min_values: Vec<_> = fields
.iter()
.map(|field| match field {
- ParsedField::Regular { number_min: Some(number_min), .. } => quote!(Some(#number_min)),
+ ParsedField::Regular { number_soft_min,... | node-graph/node-macro/src/codegen.rs | 26 | Rust | 0.643 | suggestion | 245 | 51 | 51 | false | Update #[min/max] node macro attributes to #[soft/hard]_[min/max] and make them clamp their input data | 2,464 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | mTvare6 | Review this pull request change.
Language: Rust
File: node-graph/node-macro/src/codegen.rs
PR Title: Update #[min/max] node macro attributes to #[soft/hard]_[min/max] and make them clamp their input data
BEFORE CODE: Some(ty) => quote!(Some(concrete!(#ty))),
_ => quote!(None),
},
_ => quote!(None),
... | We have the hard and soft cases of these match arms both producing the same result. Is that intentional and sensible here? Assuming so, they should also perhaps be combined, replacing `None` with `_` and using ` | ` to put them on the same line. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
slow_key: SLOW_KEY,
increments_key: INCREMENTS_KEY,
});
}
TransformLayerMessage::BeginGRS { transform_type } => {
let selected_points: Vec<&ManipulatorPointId> = shape_editor.selected_points().collect();
if (using_path_tool && selected_points.is_empty())
|| (!using_path_tool && !using_s... | ```suggestion
if (handle1_length == 0. && handle2_length == 0.) || (handle1_length == f64::MAX && handle2_length == f64::MAX) {
``` | slow_key: SLOW_KEY,
increments_key: INCREMENTS_KEY,
});
}
TransformLayerMessage::BeginGRS { transform_type } => {
let selected_points: Vec<&ManipulatorPointId> = shape_editor.selected_points().collect();
if (using_path_tool && selected_points.is_empty())
|| (!using_path_tool && !using_s... | @@ -395,7 +403,7 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
let handle1_length = handle1.length(&vector_data);
let handle2_length = handle2.length(&vector_data);
- if (handle1_length == 0. && handle2_length == 0.) || (handle1_length == f64::MAX && handle2... | editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs | 26 | Rust | 0.857 | suggestion | 140 | 51 | 51 | false | Make GRS rotation (R) angle overlay label show values between -360° and 360° | 2,473 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs
PR Title: Make GRS rotation (R) angle overlay label show values between -360° and 360°
BEFORE CODE: slow_key: SLOW_KEY,
increments_key: INCREMENTS_KEY,
});
}
Transfor... | ```suggestion
if (handle1_length == 0. && handle2_length == 0.) || (handle1_length == f64::MAX && handle2_length == f64::MAX) {
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
editor
.handle_message(TransformLayerMessage::PointerMove {
slow_key: Key::Shift,
increments_key: Key::Control,
})
.await;
let after_scale_transform = get_layer_transform(&mut editor, layer).await.unwrap();
// Verifying translation is preserved
let translation_diff = (after_scale_transform.tr... | Why are you comparing the `get_layer_transform` to the `get_layer_transform` from before a few matrix multiplications and asserts (which won't change the transform at all)? | // Checking for off-diagonal elements close to 0.707, which corresponds to cos(45°) and sin(45°)
assert!(
!after_rotate_transform.matrix2.abs_diff_eq(after_grab_transform.matrix2, 1e-5) &&
(after_rotate_transform.matrix2.x_axis.y.abs() - 0.707).abs() < 0.1 && // Check for off-diagonal elements close to 0.707... | @@ -908,4 +908,71 @@ mod test_transform_layer {
let translation_diff = (after_cancel.translation - original_transform.translation).length();
assert!(translation_diff < 1.0, "Translation component changed too much: {}", translation_diff);
}
+
+ #[tokio::test]
+ async fn test_grab_rotate_scale_chained() {
+ let ... | editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs | 26 | Rust | 0.571 | question | 172 | 29 | 36 | false | Add test for chained GRS transformations | 2,475 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs
PR Title: Add test for chained GRS transformations
BEFORE CODE: editor
.handle_message(TransformLayerMessage::PointerMove {
slow_key: Key::Shift,
increments_key: Key::Contro... | Why are you comparing the `get_layer_transform` to the `get_layer_transform` from before a few matrix multiplications and asserts (which won't change the transform at all)? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
editor.move_mouse(150.0, 100.0, ModifierKeys::empty(), MouseKeys::NONE).await;
editor
.handle_message(TransformLayerMessage::PointerMove {
slow_key: Key::Shift,
increments_key: Key::Control,
})
.await;
let after_rotate_transform = get_layer_transform(&mut editor, layer).await.unwrap();
edito... | A tolerance of 1 is really quite high considering that you are working with doubles. Perhaps use `1e-5` or something? | expected_translation,
actual_translation
);
// 2. Chain to rotation - from current position to create ~45 degree rotation
editor.handle_message(TransformLayerMessage::BeginRotate).await;
editor.move_mouse(190.0, 90.0, ModifierKeys::empty(), MouseKeys::NONE).await;
editor
.handle_message(TransformLay... | @@ -908,4 +908,71 @@ mod test_transform_layer {
let translation_diff = (after_cancel.translation - original_transform.translation).length();
assert!(translation_diff < 1.0, "Translation component changed too much: {}", translation_diff);
}
+
+ #[tokio::test]
+ async fn test_grab_rotate_scale_chained() {
+ let ... | editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs | 26 | Rust | 0.571 | question | 117 | 43 | 50 | false | Add test for chained GRS transformations | 2,475 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs
PR Title: Add test for chained GRS transformations
BEFORE CODE:
editor.move_mouse(150.0, 100.0, ModifierKeys::empty(), MouseKeys::NONE).await;
editor
.handle_message(TransformLay... | A tolerance of 1 is really quite high considering that you are working with doubles. Perhaps use `1e-5` or something? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
let after_rotate_transform = get_layer_transform(&mut editor, layer).await.unwrap();
editor.handle_message(TransformLayerMessage::BeginScale).await;
editor.move_mouse(150.0, 150.0, ModifierKeys::empty(), MouseKeys::NONE).await;
editor
.handle_message(TransformLayerMessage::PointerMove {
slow_key: Key::... | I don't really understand why you are doing this. I'd suggest that you utilise the [`DAffine2::abs_diff_eq`](https://docs.rs/glam/latest/glam/f64/struct.DAffine2.html#method.abs_diff_eq) to compare the transformation to an expected matrix (which you can build using [`DAffine2::from_scale_angle_translation`](https://doc... | slow_key: Key::Shift,
increments_key: Key::Control,
})
.await;
let after_rotate_transform = get_layer_transform(&mut editor, layer).await.unwrap();
// Checking for off-diagonal elements close to 0.707, which corresponds to cos(45°) and sin(45°)
assert!(
!after_rotate_transform.matrix2.abs_diff_eq... | @@ -908,4 +908,71 @@ mod test_transform_layer {
let translation_diff = (after_cancel.translation - original_transform.translation).length();
assert!(translation_diff < 1.0, "Translation component changed too much: {}", translation_diff);
}
+
+ #[tokio::test]
+ async fn test_grab_rotate_scale_chained() {
+ let ... | editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs | 26 | Rust | 0.571 | suggestion | 405 | 34 | 41 | false | Add test for chained GRS transformations | 2,475 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs
PR Title: Add test for chained GRS transformations
BEFORE CODE: let after_rotate_transform = get_layer_transform(&mut editor, layer).await.unwrap();
editor.handle_message(TransformL... | I don't really understand why you are doing this. I'd suggest that you utilise the [`DAffine2::abs_diff_eq`](https://docs.rs/glam/latest/glam/f64/struct.DAffine2.html#method.abs_diff_eq) to compare the transformation to an expected matrix (which you can build using [`DAffine2::from_scale_angle_translation`](https://doc... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
use crate::consts::{ANGLE_MEASURE_RADIUS_FACTOR, ARC_MEASURE_RADIUS_FACTOR_RANGE, COLOR_OVERLAY_BLUE, SLOWING_DIVISOR};
use crate::messages::input_mapper::utility_types::input_mouse::{DocumentPosition, ViewportPosition};
use crate::messages::portfolio::document::overlays::utility_types::{OverlayProvider, Pivot};
use cr... | Verifying that the transform is different is not really good enough. We are trying to test that the pivots and transformations all work correctly, which was fixed in #2450.
I would expect you to build a transform based on the expected scaling and translation and then to assert that it is equal to the actual transfor... |
// 3. Chain to scaling - scale(area) up by 2x
editor.handle_message(TransformLayerMessage::BeginScale).await;
editor.move_mouse(250.0, 200.0, ModifierKeys::empty(), MouseKeys::NONE).await;
editor
.handle_message(TransformLayerMessage::PointerMove {
slow_key: Key::Shift,
increments_key: Key::Control,... | @@ -908,4 +908,69 @@ mod test_transform_layer {
let translation_diff = (after_cancel.translation - original_transform.translation).length();
assert!(translation_diff < 1.0, "Translation component changed too much: {}", translation_diff);
}
+
+ #[tokio::test]
+ async fn test_grab_rotate_scale_chained() {
+ let ... | editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs | 26 | Rust | 0.429 | style | 343 | 977 | 29 | false | Add test for chained GRS transformations | 2,475 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs
PR Title: Add test for chained GRS transformations
BEFORE CODE: use crate::consts::{ANGLE_MEASURE_RADIUS_FACTOR, ARC_MEASURE_RADIUS_FACTOR_RANGE, COLOR_OVERLAY_BLUE, SLOWING_DIVISOR};
us... | Verifying that the transform is different is not really good enough. We are trying to test that the pivots and transformations all work correctly, which was fixed in #2450.
I would expect you to build a transform based on the expected scaling and translation and then to assert that it is equal to the actual transfor... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
let size = ipp.viewport_bounds.size().as_uvec2();
let [a, b, c, d, e, f] = DAffine2::from_scale(DVec2::splat(device_pixel_ratio)).to_cols_array();
let _ = context.set_transform(a, b, c, d, e, f);
context.clear_rect(0., 0., ipp.viewport_bounds.size().x, ipp.viewport_bounds.size().y);
let _ = context... | ```suggestion
"Cannot render overlays on non-Wasm targets.\n{responses:?} {overlays_visible} {ipp:?} {:?} {:?}",
``` | let size = ipp.viewport_bounds.size().as_uvec2();
let [a, b, c, d, e, f] = DAffine2::from_scale(DVec2::splat(device_pixel_ratio)).to_cols_array();
let _ = context.set_transform(a, b, c, d, e, f);
context.clear_rect(0., 0., ipp.viewport_bounds.size().x, ipp.viewport_bounds.size().y);
let _ = context... | @@ -66,7 +66,7 @@ impl MessageHandler<OverlaysMessage, OverlaysMessageData<'_>> for OverlaysMessag
#[cfg(not(target_arch = "wasm32"))]
OverlaysMessage::Draw => {
warn!(
- "Cannot render overlays on non-Wasm targets.\n{responses:?} {overlays_visible} {ipp:?} {:?} {:?}",
+ "Cannot render overlays on ... | editor/src/messages/portfolio/document/overlays/overlays_message_handler.rs | 26 | Rust | 0.714 | suggestion | 123 | 41 | 41 | false | Add tests for gradient drawing with transformations | 2,481 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 0HyperCube | Review this pull request change.
Language: Rust
File: editor/src/messages/portfolio/document/overlays/overlays_message_handler.rs
PR Title: Add tests for gradient drawing with transformations
BEFORE CODE: let size = ipp.viewport_bounds.size().as_uvec2();
let [a, b, c, d, e, f] = DAffine2::from_scale(DVec2:... | ```suggestion
"Cannot render overlays on non-Wasm targets.\n{responses:?} {overlays_visible} {ipp:?} {:?} {:?}",
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
let document = editor.active_document();
let layer = document.metadata().all_layers().next().unwrap();
editor.handle_message(TransformLayerMessage::BeginScale).await;
// Move mouse exactly to the pivot point to achieve zero scale
let center_x = 50.0;
let center_y = 50.0;
editor.move_mouse(center_x, cent... | You can simply do:
```rs
assert!(final_transform.is_finite(), "Matrix should be finite");
``` | #[tokio::test]
async fn test_grab_rotate_scale_chained() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
editor.drag_tool(ToolType::Rectangle, 0., 0., 100., 100., ModifierKeys::empty()).await;
let document = editor.active_document();
let layer = document.metadata().all_layers().ne... | @@ -908,4 +908,47 @@ mod test_transform_layer {
let translation_diff = (after_cancel.translation - original_transform.translation).length();
assert!(translation_diff < 1.0, "Translation component changed too much: {}", translation_diff);
}
+
+ #[tokio::test]
+ async fn test_scale_to_zero_apply() {
+ let mut ed... | editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs | 26 | Rust | 0.643 | suggestion | 96 | 39 | 51 | false | Add test for scaling objects to zero without any crash | 2,491 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs
PR Title: Add test for scaling objects to zero without any crash
BEFORE CODE: let document = editor.active_document();
let layer = document.metadata().all_layers().next().unwrap();
... | You can simply do:
```rs
assert!(final_transform.is_finite(), "Matrix should be finite");
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
editor
.handle_message(GraphOperationMessage::TransformSet {
layer,
transform: near_zero_scale,
transform_in: TransformIn::Local,
skip_rerender: false,
})
.await;
let zero_transform = get_layer_transform(&mut editor, layer).await.unwrap();
assert!(zero_transform.is_finite(), "First trans... | This isn't testing the GRS system though? | editor.new_document().await;
editor.drag_tool(ToolType::Rectangle, 0., 0., 100., 100., ModifierKeys::empty()).await;
let document = editor.active_document();
let layer = document.metadata().all_layers().next().unwrap();
let original_transform = get_layer_transform(&mut editor, layer).await.unwrap();
let p... | @@ -982,4 +982,51 @@ mod test_transform_layer {
assert!(final_transform.abs_diff_eq(after_scale_transform, 1e-5), "Final transform should match the transform before committing");
assert!(!final_transform.abs_diff_eq(original_transform, 1e-5), "Final transform should be different from original transform");
}
+ #... | editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs | 26 | Rust | 0.071 | question | 41 | 40 | 51 | false | Add test for scaling objects to zero without any crash | 2,491 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs
PR Title: Add test for scaling objects to zero without any crash
BEFORE CODE: editor
.handle_message(GraphOperationMessage::TransformSet {
layer,
transform: near_zero_scale,... | This isn't testing the GRS system though? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// Also check translation component is similar
let translation_diff = (after_cancel.translation - original_transform.translation).length();
assert!(translation_diff < 1.0, "Translation component changed too much: {}", translation_diff);
}
#[tokio::test]
async fn test_transform_with_panned_view() {
let mut e... | I though this was meant to test the GRS system? | // Also check translation component is similar
let translation_diff = (after_cancel.translation - original_transform.translation).length();
assert!(translation_diff < 1.0, "Translation component changed too much: {}", translation_diff);
}
#[tokio::test]
async fn test_grab_rotate_scale_chained() {
let mut ed... | @@ -908,4 +908,99 @@ mod test_transform_layer {
let translation_diff = (after_cancel.translation - original_transform.translation).length();
assert!(translation_diff < 1.0, "Translation component changed too much: {}", translation_diff);
}
+
+ #[tokio::test]
+ async fn test_transform_with_panned_view() {
+ let... | editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs | 26 | Rust | 0.071 | question | 47 | 51 | 51 | false | Add tests for document panning, zooming, and rotating | 2,492 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs
PR Title: Add tests for document panning, zooming, and rotating
BEFORE CODE: // Also check translation component is similar
let translation_diff = (after_cancel.translation - origina... | I though this was meant to test the GRS system? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
#[tokio::test]
async fn test_transform_with_panned_view() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
editor.drag_tool(ToolType::Rectangle, 0., 0., 100., 100., ModifierKeys::empty()).await;
let document = editor.active_document();
let layer = document.metadata().all_layers... | Panning the canvas doesn't impact a translation. I'd suggest you do a scale transformation. | }
#[tokio::test]
async fn test_grab_rotate_scale_chained() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
editor.drag_tool(ToolType::Rectangle, 0., 0., 100., 100., ModifierKeys::empty()).await;
let document = editor.active_document();
let layer = document.metadata().all_layers(... | @@ -908,4 +908,99 @@ mod test_transform_layer {
let translation_diff = (after_cancel.translation - original_transform.translation).length();
assert!(translation_diff < 1.0, "Translation component changed too much: {}", translation_diff);
}
+
+ #[tokio::test]
+ async fn test_transform_with_panned_view() {
+ let... | editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs | 26 | Rust | 0.214 | suggestion | 91 | 51 | 51 | false | Add tests for document panning, zooming, and rotating | 2,492 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs
PR Title: Add tests for document panning, zooming, and rotating
BEFORE CODE: }
#[tokio::test]
async fn test_transform_with_panned_view() {
let mut editor = EditorTestUtils::create(... | Panning the canvas doesn't impact a translation. I'd suggest you do a scale transformation. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
let nearest_point = shape_editor.find_nearest_point_indices(&document.network_interface, input.mouse.position, SELECTION_THRESHOLD);
if nearest_point.is_some() {
// Flip the selected point between smooth and sharp
if !tool_data.double_click_handled && tool_data.drag_start_pos.distance(input.mouse.posi... | Please delete rather than commenting. | if tool_data.snapping_axis.is_some() {
tool_data.snapping_axis = None;
}
responses.add(DocumentMessage::EndTransaction);
responses.add(PathToolMessage::SelectedPointUpdated);
tool_data.snap_manager.cleanup(responses);
tool_data.opposite_handle_position = None;
PathToolFsmState::Ready
... | @@ -1501,7 +1478,7 @@ impl Fsm for PathToolFsmState {
responses.add(OverlaysMessage::Draw);
PathToolFsmState::Ready
}
- (_, PathToolMessage::PointerMove { .. }) => self,
+ // (_, PathToolMessage::PointerMove { .. }) => self, | editor/src/messages/tool/tool_messages/path_tool.rs | 26 | Rust | 0.071 | suggestion | 37 | 51 | 51 | false | Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment | 2,495 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/path_tool.rs
PR Title: Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment
BEFORE CODE: let nearest_point = shape_editor.find_nearest_point_indices(&document.network_interface, i... | Please delete rather than commenting. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
let messages = [
PathToolMessage::PointerOutsideViewport {
toggle_colinear,
equidistant,
move_anchor_with_handles,
snap_angle,
lock_angle,
}
.into(),
PathToolMessage::PointerMove {
toggle_colinear,
equidistant,
move_anchor_with_handles,
snap_... | Why is `delete_segment_pressed` determined by `lock_angle_state`? | shape_editor.select_points_by_manipulator_id(&tool_data.saved_points_before_anchor_select_toggle);
tool_data.remove_saved_points();
}
let toggle_colinear_state = input.keyboard.get(toggle_colinear as usize);
let equidistant_state = input.keyboard.get(equidistant as usize);
let lock_angle_stat... | @@ -1273,6 +1219,37 @@ impl Fsm for PathToolFsmState {
PathToolFsmState::Dragging(tool_data.dragging_state)
}
+ (PathToolFsmState::Ready, PathToolMessage::PointerMove { lock_angle, .. }) => {
+ let lock_angle_state = input.keyboard.get(lock_angle as usize);
+ if lock_angle_state {
+ tool_data.del... | editor/src/messages/tool/tool_messages/path_tool.rs | 26 | Rust | 0.357 | question | 65 | 51 | 51 | false | Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment | 2,495 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/path_tool.rs
PR Title: Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment
BEFORE CODE: let messages = [
PathToolMessage::PointerOutsideViewport {
toggle_colinear,
... | Why is `delete_segment_pressed` determined by `lock_angle_state`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
equidistant,
move_anchor_with_handles,
snap_angle,
lock_angle,
}
.into(),
PathToolMessage::PointerMove {
toggle_colinear,
equidistant,
move_anchor_with_handles,
snap_angle,
lock_angle,
}
.into(),
];
tool_data.auto_panning.setup_by_mo... | It would be much simpler to simply assign: `tool_data.delete_segment_pressed = lock_angle_state`. |
let toggle_colinear_state = input.keyboard.get(toggle_colinear as usize);
let equidistant_state = input.keyboard.get(equidistant as usize);
let lock_angle_state = input.keyboard.get(lock_angle as usize);
let snap_angle_state = input.keyboard.get(snap_angle as usize);
if !lock_angle_state {
to... | @@ -1273,6 +1219,37 @@ impl Fsm for PathToolFsmState {
PathToolFsmState::Dragging(tool_data.dragging_state)
}
+ (PathToolFsmState::Ready, PathToolMessage::PointerMove { lock_angle, .. }) => {
+ let lock_angle_state = input.keyboard.get(lock_angle as usize);
+ if lock_angle_state {
+ tool_data.del... | editor/src/messages/tool/tool_messages/path_tool.rs | 26 | Rust | 0.357 | suggestion | 97 | 51 | 51 | false | Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment | 2,495 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/path_tool.rs
PR Title: Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment
BEFORE CODE: equidistant,
move_anchor_with_handles,
snap_angle,
lock_angle,
}
... | It would be much simpler to simply assign: `tool_data.delete_segment_pressed = lock_angle_state`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
for (segment_id, _bezier, start, end) in vector_data.segment_bezier_iter() {
if selected_segments.contains(&segment_id) {
selected_segments_by_point.entry(start).or_default().push(segment_id);
selected_segments_by_point.entry(end).or_default().push(segment_id);
}
}
... | Please keep all comments in english and with one space beforehand. | responses.add(OverlaysMessage::Draw);
responses.add(PathToolMessage::SelectedPointUpdated);
self
}
(_, PathToolMessage::Overlays(mut overlay_context)) => {
// TODO: find the segment ids of which the selected points are a part of
match tool_options.path_overlay_mode {
PathOverlayMode::Al... | @@ -1029,6 +978,44 @@ impl Fsm for PathToolFsmState {
}
match self {
+ Self::Ready => {
+ //closest segment should be set when pointermoved and tabhi update segment bhi hona chahiye | editor/src/messages/tool/tool_messages/path_tool.rs | 26 | Rust | 0.214 | suggestion | 66 | 51 | 51 | false | Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment | 2,495 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/path_tool.rs
PR Title: Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment
BEFORE CODE: for (segment_id, _bezier, start, end) in vector_data.segment_bezier_iter() {
... | Please keep all comments in english and with one space beforehand. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if let Some(vector_data) = document.network_interface.compute_modified_vector(layer) {
if let (Some(pos1), Some(pos2)) = (
ManipulatorPointId::Anchor(points[0]).get_position(&vector_data),
ManipulatorPointId::Anchor(points[1]).get_position(&vector_data),
) {
(pos1... | Prefer using `if self == Self::Ready` instead of a match since there is only one match arm. |
for (segment_id, _bezier, start, end) in vector_data.segment_bezier_iter() {
if selected_segments.contains(&segment_id) {
selected_segments_by_point.entry(start).or_default().push(segment_id);
selected_segments_by_point.entry(end).or_default().push(segment_id);
}
}... | @@ -1029,6 +978,44 @@ impl Fsm for PathToolFsmState {
}
match self {
+ Self::Ready => { | editor/src/messages/tool/tool_messages/path_tool.rs | 26 | Rust | 0.429 | suggestion | 91 | 51 | 51 | false | Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment | 2,495 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/path_tool.rs
PR Title: Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment
BEFORE CODE: if let Some(vector_data) = document.network_interface.compute_modified_vector(layer) {... | Prefer using `if self == Self::Ready` instead of a match since there is only one match arm. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
selected_segments_by_point.entry(start).or_default().push(segment_id);
selected_segments_by_point.entry(end).or_default().push(segment_id);
}
}
for (point, attached_segments) in selected_segments_by_point {
if attached_segments.len() == 1 {
segment_endpoi... | Please put this functionality in a function to keep the tool code at least slightly readable. | responses.add(PathToolMessage::SelectedPointUpdated);
self
}
(_, PathToolMessage::Overlays(mut overlay_context)) => {
// TODO: find the segment ids of which the selected points are a part of
match tool_options.path_overlay_mode {
PathOverlayMode::AllHandles => {
path_overlays(document,... | @@ -1029,6 +978,44 @@ impl Fsm for PathToolFsmState {
}
match self {
+ Self::Ready => {
+ //closest segment should be set when pointermoved and tabhi update segment bhi hona chahiye
+
+ //check for a close segment if it is there | editor/src/messages/tool/tool_messages/path_tool.rs | 26 | Rust | 0.214 | suggestion | 93 | 51 | 51 | false | Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment | 2,495 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/path_tool.rs
PR Title: Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment
BEFORE CODE: selected_segments_by_point.entry(start).or_default().push(segment_id);
sel... | Please put this functionality in a function to keep the tool code at least slightly readable. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
snap_angle,
lock_angle,
}
.into(),
];
tool_data.auto_panning.setup_by_mouse_position(input, &messages, responses);
PathToolFsmState::Dragging(tool_data.dragging_state)
}
(PathToolFsmState::Ready, PathToolMessage::PointerMove { lock_angle, .. }) => {
let lock_angle_state = in... | Why did you choose to calculate the state here and cache it instead of computing it when it is actually needed? | if !tool_data.update_colinear(equidistant_state, toggle_colinear_state, tool_action_data.shape_editor, tool_action_data.document, responses) {
tool_data.drag(
equidistant_state,
lock_angle_state,
snap_angle_state,
tool_action_data.shape_editor,
tool_action_data.document,
inp... | @@ -1273,6 +1219,37 @@ impl Fsm for PathToolFsmState {
PathToolFsmState::Dragging(tool_data.dragging_state)
}
+ (PathToolFsmState::Ready, PathToolMessage::PointerMove { lock_angle, .. }) => {
+ let lock_angle_state = input.keyboard.get(lock_angle as usize);
+ if lock_angle_state {
+ tool_data.del... | editor/src/messages/tool/tool_messages/path_tool.rs | 26 | Rust | 0.429 | performance | 111 | 51 | 51 | false | Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment | 2,495 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/path_tool.rs
PR Title: Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment
BEFORE CODE: snap_angle,
lock_angle,
}
.into(),
];
tool_data.auto_panning.set... | Why did you choose to calculate the state here and cache it instead of computing it when it is actually needed? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
responses.add(FrontendMessage::UpdateMouseCursor { cursor: MouseCursorIcon::Default });
}
}
#[derive(Debug, PartialEq, Default)]
enum SelectionStatus {
#[default]
None,
One(SingleSelectedPoint),
Multiple(MultipleSelectedPoints),
}
impl SelectionStatus {
fn is_none(&self) -> bool {
self == &SelectionStatus::... | You are missing a hint for the new <kbd>Ctrl</kbd> to delete segment behaviour I think? | hints.push(HintInfo::keys([Key::Shift], "15° Increments"));
hints.push(HintInfo::keys([Key::Control], "Lock Angle"));
hints.push(drag_anchor);
hints
}
PointSelectState::Anchor => Vec::new(),
};
if !toggle_group.is_empty() {
dragging_hint_data.0.push(HintGroup(toggle_group... | @@ -1652,10 +1629,6 @@ impl Fsm for PathToolFsmState {
HintInfo::keys([Key::Alt], "Subtract").prepend_plus(),
]),
]), | editor/src/messages/tool/tool_messages/path_tool.rs | 26 | Rust | 0.214 | question | 87 | 51 | 51 | false | Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment | 2,495 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/path_tool.rs
PR Title: Insert point on segment by clicking once (no more sliding) and Alt+click to delete a segment
BEFORE CODE: responses.add(FrontendMessage::UpdateMouseCursor { cursor: MouseCursorIcon::Default });
}
}... | You are missing a hint for the new <kbd>Ctrl</kbd> to delete segment behaviour I think? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
entry!(KeyUp(MouseLeft); action_dispatch=EllipseToolMessage::DragStop),
entry!(KeyDown(MouseRight); action_dispatch=EllipseToolMessage::Abort),
entry!(KeyDown(Escape); action_dispatch=EllipseToolMessage::Abort),
entry!(PointerMove; refresh_keys=[Alt, Shift], action_dispatch=EllipseToolMessage::PointerMove { cen... | ```suggestion
entry!(KeyDown(MouseLeft); action_dispatch=PathToolMessage::MouseDown { direct_insert_without_sliding: Control, extend_selection: Shift, lasso_select: Control, handle_drag_from_anchor: Alt }),
``` | entry!(KeyUp(MouseLeft); action_dispatch=EllipseToolMessage::DragStop),
entry!(KeyDown(MouseRight); action_dispatch=EllipseToolMessage::Abort),
entry!(KeyDown(Escape); action_dispatch=EllipseToolMessage::Abort),
entry!(PointerMove; refresh_keys=[Alt, Shift], action_dispatch=EllipseToolMessage::PointerMove { cen... | @@ -212,7 +212,7 @@ pub fn input_mappings() -> Mapping {
entry!(KeyDown(Delete); modifiers=[Shift], action_dispatch=PathToolMessage::BreakPath),
entry!(KeyDown(Backspace); modifiers=[Shift], action_dispatch=PathToolMessage::BreakPath),
entry!(KeyDownNoRepeat(Tab); action_dispatch=PathToolMessage::SwapSelectedH... | editor/src/messages/input_mapper/input_mappings.rs | 26 | Rust | 1 | suggestion | 214 | 51 | 51 | false | Add Path tool support for Alt-dragging an anchor to pull out a fresh equidistant handle pair | 2,496 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/input_mapper/input_mappings.rs
PR Title: Add Path tool support for Alt-dragging an anchor to pull out a fresh equidistant handle pair
BEFORE CODE: entry!(KeyUp(MouseLeft); action_dispatch=EllipseToolMessage::DragStop),
entry!(KeyDown(Mous... | ```suggestion
entry!(KeyDown(MouseLeft); action_dispatch=PathToolMessage::MouseDown { direct_insert_without_sliding: Control, extend_selection: Shift, lasso_select: Control, handle_drag_from_anchor: Alt }),
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
let current_mouse = input.mouse.position;
let raw_delta = document_to_viewport.inverse().transform_vector2(current_mouse - previous_mouse);
let snapped_delta = if let Some((handle_pos, anchor_pos, handle_id)) = self.try_get_selected_handle_and_anchor(shape_editor, document) {
let cursor_pos = handle_pos + raw... | ```suggestion
// Checking which direction the dragging begins
``` | let current_mouse = input.mouse.position;
let raw_delta = document_to_viewport.inverse().transform_vector2(current_mouse - previous_mouse);
let snapped_delta = if let Some((handle_pos, anchor_pos, handle_id)) = self.try_get_selected_handle_and_anchor(shape_editor, document) {
let cursor_pos = handle_pos + raw... | @@ -829,9 +875,51 @@ impl PathToolData {
let handle_lengths = if equidistant { None } else { self.opposing_handle_lengths.take() };
let opposite = if lock_angle { None } else { self.opposite_handle_position };
let unsnapped_delta = current_mouse - previous_mouse;
+ let mut was_alt_dragging = false;
if se... | editor/src/messages/tool/tool_messages/path_tool.rs | 26 | Rust | 0.571 | suggestion | 71 | 51 | 51 | false | Add Path tool support for Alt-dragging an anchor to pull out a fresh equidistant handle pair | 2,496 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/path_tool.rs
PR Title: Add Path tool support for Alt-dragging an anchor to pull out a fresh equidistant handle pair
BEFORE CODE: let current_mouse = input.mouse.position;
let raw_delta = document_to_viewport.inverse().t... | ```suggestion
// Checking which direction the dragging begins
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return;
};
let Some(vector_data) = document.network_interface.compute_modified_vector(layer) else { return };
let Some(point_id) = shape_editor.selected_points().next().unwrap().get_anchor(&vector_data) else {
return;
};
if vector_data.connected_count(point_id) == 2 {
let connected_s... | ```suggestion
// Now change the selection to this handle
``` | return;
};
let Some(vector_data) = document.network_interface.compute_modified_vector(layer) else { return };
let Some(point_id) = shape_editor.selected_points().next().unwrap().get_anchor(&vector_data) else {
return;
};
if vector_data.connected_count(point_id) == 2 {
let connected_s... | @@ -829,9 +875,51 @@ impl PathToolData {
let handle_lengths = if equidistant { None } else { self.opposing_handle_lengths.take() };
let opposite = if lock_angle { None } else { self.opposite_handle_position };
let unsnapped_delta = current_mouse - previous_mouse;
+ let mut was_alt_dragging = false;
if se... | editor/src/messages/tool/tool_messages/path_tool.rs | 26 | Rust | 0.786 | suggestion | 67 | 51 | 51 | false | Add Path tool support for Alt-dragging an anchor to pull out a fresh equidistant handle pair | 2,496 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/path_tool.rs
PR Title: Add Path tool support for Alt-dragging an anchor to pull out a fresh equidistant handle pair
BEFORE CODE: return;
};
let Some(vector_data) = document.network_interface.compute_modified_ve... | ```suggestion
// Now change the selection to this handle
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
increments_key: Key::Control,
})
.await;
let after_scale_transform = get_layer_transform(&mut editor, layer).await.unwrap();
let before_scale_det = after_rotate_transform.matrix2.determinant();
let after_scale_det = after_scale_transform.matrix2.determinant();
assert!(
after_scale_det >= 2.0 * bef... | Whilst this does create a path with one point at the moment, this is a bug (I've now created an issue #2503).
If you create a layer, you can then add a path node with a single point with:
```rs
let modification_type = VectorModificationType::InsertPoint {
id: PointId::generate(),
position: DVec2::ZERO,
};
re... | .handle_message(TransformLayerMessage::PointerMove {
slow_key: Key::Shift,
increments_key: Key::Control,
})
.await;
let after_scale_transform = get_layer_transform(&mut editor, layer).await.unwrap();
let before_scale_det = after_rotate_transform.matrix2.determinant();
let after_scale_det = after... | @@ -982,4 +982,28 @@ mod test_transform_layer {
assert!(final_transform.abs_diff_eq(after_scale_transform, 1e-5), "Final transform should match the transform before committing");
assert!(!final_transform.abs_diff_eq(original_transform, 1e-5), "Final transform should be different from original transform");
}
+ #... | editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs | 26 | Rust | 0.929 | bug | 397 | 46 | 51 | false | Test that select tool GRS works with only one anchor | 2,502 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs
PR Title: Test that select tool GRS works with only one anchor
BEFORE CODE: increments_key: Key::Control,
})
.await;
let after_scale_transform = get_layer_transform(&mut edi... | Whilst this does create a path with one point at the moment, this is a bug (I've now created an issue #2503).
If you create a layer, you can then add a path node with a single point with:
```rs
let modification_type = VectorModificationType::InsertPoint {
id: PointId::generate(),
position: DVec2::ZERO,
};
re... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// Rotate the document view (45 degrees)
editor.handle_message(NavigationMessage::BeginCanvasTilt { was_dispatched_from_menu: false }).await;
editor.handle_message(NavigationMessage::CanvasTiltSet { angle_radians: 45.0_f64.to_radians() }).await;
editor.handle_message(TransformLayerMessage::BeginRotate).await;
... | Since you've created a rectangle, this will have 4 points already.
You can create an empty layer with no points using `DocumentMessage::CreateEmptyFolder` (a folder is the same as a layer). | editor.handle_message(NavigationMessage::CanvasTiltSet { angle_radians: 45.0_f64.to_radians() }).await;
editor.handle_message(TransformLayerMessage::BeginRotate).await;
editor.handle_message(TransformLayerMessage::TypeDigit { digit: 9 }).await;
editor.handle_message(TransformLayerMessage::TypeDigit { digit: 0 ... | @@ -1064,4 +1069,35 @@ mod test_transform_layer {
let angle_change = ((angle_change % 360.0) + 360.0) % 360.0;
assert!((angle_change - 90.0).abs() < 0.1, "Expected rotation of 90 degrees, got: {}", angle_change);
}
+
+ #[tokio::test]
+ async fn test_grs_single_anchor() {
+ let mut editor = EditorTestUtils::cre... | editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs | 26 | Rust | 0.5 | suggestion | 192 | 51 | 50 | false | Test that select tool GRS works with only one anchor | 2,502 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs
PR Title: Test that select tool GRS works with only one anchor
BEFORE CODE:
// Rotate the document view (45 degrees)
editor.handle_message(NavigationMessage::BeginCanvasTilt { was_d... | Since you've created a rectangle, this will have 4 points already.
You can create an empty layer with no points using `DocumentMessage::CreateEmptyFolder` (a folder is the same as a layer). | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Ok(inner.len())
}
}
impl CloneVarArgs for Arc<OwnedContextImpl> {
fn arc_clone(&self) -> Option<Arc<dyn ExtractVarArgs + Send + Sync>> {
Some(self.clone())
}
}
pub type Context<'a> = Option<Arc<OwnedContextImpl>>;
type DynRef<'a> = &'a (dyn Any + Send + Sync);
type DynBox = Box<dyn Any + Send + Sync>;
#[deriv... | Course of action for this todo comment? | Ok(inner.len())
}
}
impl CloneVarArgs for Arc<OwnedContextImpl> {
fn arc_clone(&self) -> Option<Arc<dyn ExtractVarArgs + Send + Sync>> {
Some(self.clone())
}
}
pub type Context<'a> = Option<Arc<OwnedContextImpl>>;
type DynRef<'a> = &'a (dyn Any + Send + Sync);
type DynBox = Box<dyn Any + Send + Sync>;
#[deriv... | @@ -245,10 +245,24 @@ pub struct OwnedContextImpl {
parent: Option<Arc<dyn ExtractVarArgs + Sync + Send>>,
// This could be converted into a single enum to save extra bytes
index: Option<usize>,
- time: Option<f64>,
+ real_time: Option<f64>,
animation_time: Option<f64>,
}
+// TODO: Probably delete this befor... | node-graph/gcore/src/context.rs | 26 | Rust | 0.071 | question | 39 | 51 | 51 | false | Add 'Freeze Real Time' and 'Boundless Footprint' nodes as alternatives to using 'Memoize Impure' | 2,509 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | TrueDoctor | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/context.rs
PR Title: Add 'Freeze Real Time' and 'Boundless Footprint' nodes as alternatives to using 'Memoize Impure'
BEFORE CODE: Ok(inner.len())
}
}
impl CloneVarArgs for Arc<OwnedContextImpl> {
fn arc_clone(&self) -> Option<Arc<dyn E... | Course of action for this todo comment? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Some(self.clone())
}
}
pub type Context<'a> = Option<Arc<OwnedContextImpl>>;
type DynRef<'a> = &'a (dyn Any + Send + Sync);
type DynBox = Box<dyn Any + Send + Sync>;
#[derive(dyn_any::DynAny)]
pub struct OwnedContextImpl {
footprint: Option<crate::transform::Footprint>,
varargs: Option<Arc<[DynBox]>>,
parent: O... | Course of action for this commented out line? | Some(self.clone())
}
}
pub type Context<'a> = Option<Arc<OwnedContextImpl>>;
type DynRef<'a> = &'a (dyn Any + Send + Sync);
type DynBox = Box<dyn Any + Send + Sync>;
#[derive(dyn_any::DynAny)]
pub struct OwnedContextImpl {
footprint: Option<crate::transform::Footprint>,
varargs: Option<Arc<[DynBox]>>,
parent: O... | @@ -245,10 +245,24 @@ pub struct OwnedContextImpl {
parent: Option<Arc<dyn ExtractVarArgs + Sync + Send>>,
// This could be converted into a single enum to save extra bytes
index: Option<usize>,
- time: Option<f64>,
+ real_time: Option<f64>,
animation_time: Option<f64>,
}
+// TODO: Probably delete this befor... | node-graph/gcore/src/context.rs | 26 | Rust | 0.071 | question | 45 | 51 | 51 | false | Add 'Freeze Real Time' and 'Boundless Footprint' nodes as alternatives to using 'Memoize Impure' | 2,509 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | TrueDoctor | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/context.rs
PR Title: Add 'Freeze Real Time' and 'Boundless Footprint' nodes as alternatives to using 'Memoize Impure'
BEFORE CODE: Some(self.clone())
}
}
pub type Context<'a> = Option<Arc<OwnedContextImpl>>;
type DynRef<'a> = &'a (dyn An... | Course of action for this commented out line? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
editor.handle_message(TransformLayerMessage::BeginScale).await;
editor.handle_message(TransformLayerMessage::TypeDigit { digit: 2 }).await;
editor.handle_message(TransformLayerMessage::ApplyTransformOperation { final_transform: true }).await;
let final_transform = get_layer_transform(&mut editor, layer).await... | Why is this `>=`? Surely you can specify exactly? | editor.handle_message(TransformLayerMessage::TypeDigit { digit: 1 }).await;
editor.handle_message(TransformLayerMessage::ApplyTransformOperation { final_transform: true }).await;
let near_zero_transform = get_layer_transform(&mut editor, layer).await.unwrap();
// Verify scale is near zero.
let scale_x = near... | @@ -1139,4 +1140,80 @@ mod test_transform_layer {
assert!(new_scale_x > 0.0, "After rescaling, scale factor X should be non-zero");
assert!(new_scale_y > 0.0, "After rescaling, scale factor Y should be non-zero");
}
+
+ #[tokio::test]
+ async fn test_transform_with_different_selections() {
+ let mut editor = E... | editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs | 26 | Rust | 0.214 | question | 49 | 51 | 51 | false | Add GRS tests for different types of nested layer multi-selections | 2,518 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs
PR Title: Add GRS tests for different types of nested layer multi-selections
BEFORE CODE:
editor.handle_message(TransformLayerMessage::BeginScale).await;
editor.handle_message(Trans... | Why is this `>=`? Surely you can specify exactly? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
})
.await;
editor
.handle_message(DocumentMessage::GroupSelectedLayers {
group_folder_type: GroupFolderType::Layer,
})
.await;
// Get the group layer (should be the newest layer)
let document = editor.active_document();
let group_layer = document.metadata().all_layers().next().unwrap();
/... | The fact that the transform changes is not that useful. Please test the actual transform with `DAffine2::abs_diff_eq`. | editor.draw_rect(0., 150., 100., 250.).await;
editor.draw_rect(150., 150., 250., 250.).await;
let document = editor.active_document();
let layers: Vec<LayerNodeIdentifier> = document.metadata().all_layers().collect();
assert!(layers.len() == 4);
// Creating a group with two rectangles
editor
.handle_... | @@ -1139,4 +1140,80 @@ mod test_transform_layer {
assert!(new_scale_x > 0.0, "After rescaling, scale factor X should be non-zero");
assert!(new_scale_y > 0.0, "After rescaling, scale factor Y should be non-zero");
}
+
+ #[tokio::test]
+ async fn test_transform_with_different_selections() {
+ let mut editor = E... | editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs | 26 | Rust | 0.571 | suggestion | 118 | 51 | 51 | false | Add GRS tests for different types of nested layer multi-selections | 2,518 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs
PR Title: Add GRS tests for different types of nested layer multi-selections
BEFORE CODE: })
.await;
editor
.handle_message(DocumentMessage::GroupSelectedLayers {
group_fo... | The fact that the transform changes is not that useful. Please test the actual transform with `DAffine2::abs_diff_eq`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
use crate::consts::{ANGLE_MEASURE_RADIUS_FACTOR, ARC_MEASURE_RADIUS_FACTOR_RANGE, COLOR_OVERLAY_BLUE, SLOWING_DIVISOR};
use crate::messages::input_mapper::utility_types::input_mouse::{DocumentPosition, ViewportPosition};
use crate::messages::portfolio::document::overlays::utility_types::{OverlayProvider, Pivot};
use cr... | I also think it would be useful if you could scale the group and then translate layers in the group. This would then test that the transforms work correctly when the parent is transformed (which tends to be rather fragile). | // Test 2: Transform multiple layers
editor
.handle_message(NodeGraphMessage::SelectedNodesSet {
nodes: vec![layers[0].to_node(), layers[1].to_node()],
})
.await;
let original_transform_1 = get_layer_transform(&mut editor, layers[0]).await.unwrap();
let original_transform_2 = get_layer_transform(&m... | @@ -1139,4 +1140,80 @@ mod test_transform_layer {
assert!(new_scale_x > 0.0, "After rescaling, scale factor X should be non-zero");
assert!(new_scale_y > 0.0, "After rescaling, scale factor Y should be non-zero");
}
+
+ #[tokio::test]
+ async fn test_transform_with_different_selections() {
+ let mut editor = E... | editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs | 26 | Rust | 0.5 | suggestion | 223 | 1,220 | 51 | false | Add GRS tests for different types of nested layer multi-selections | 2,518 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs
PR Title: Add GRS tests for different types of nested layer multi-selections
BEFORE CODE: use crate::consts::{ANGLE_MEASURE_RADIUS_FACTOR, ARC_MEASURE_RADIUS_FACTOR_RANGE, COLOR_OVERLAY_... | I also think it would be useful if you could scale the group and then translate layers in the group. This would then test that the transforms work correctly when the parent is transformed (which tends to be rather fragile). | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return;
}
let polygon: Subpath<PointId> = Subpath::from_anchors_linear(polygon.to_vec(), true);
Some(polygon)
} else {
None
};
for (id, bezier, _, _) in vector_data.segment_bezier_iter() {
for (position, id) in [(bezier.handle_start(), ManipulatorPointId::PrimaryHandle(id)), (bezier.h... | ```suggestion
// Select only the handles which are of nonzero length
``` | return;
}
let polygon: Subpath<PointId> = Subpath::from_anchors_linear(polygon.to_vec(), true);
Some(polygon)
} else {
None
};
for (id, bezier, _, _) in vector_data.segment_bezier_iter() {
for (position, id) in [(bezier.handle_start(), ManipulatorPointId::PrimaryHandle(id)), (bezier.h... | @@ -1444,7 +1444,14 @@ impl ShapeState {
if select {
match selection_change {
SelectionChange::Shrink => state.deselect_point(id),
- _ => state.select_point(id),
+ _ => {
+ // select only those handles which are of non zero length | editor/src/messages/tool/common_functionality/shape_editor.rs | 26 | Rust | 0.714 | suggestion | 82 | 51 | 51 | false | Fix box selection erroneously including zero-length handles; fix GRS failing on sharp points | 2,550 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/common_functionality/shape_editor.rs
PR Title: Fix box selection erroneously including zero-length handles; fix GRS failing on sharp points
BEFORE CODE: return;
}
let polygon: Subpath<PointId> = Subpath::from_anchors_linear(... | ```suggestion
// Select only the handles which are of nonzero length
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
increments_key: INCREMENTS_KEY,
});
}
TransformLayerMessage::BeginGRS { transform_type } => {
let selected_points: Vec<&ManipulatorPointId> = shape_editor.selected_points().collect();
if (using_path_tool && selected_points.is_empty())
|| (!using_path_tool && !using_select_tool && !using_pen_... | ```suggestion
// G should work for this point but not R and S
``` | increments_key: INCREMENTS_KEY,
});
}
TransformLayerMessage::BeginGRS { transform_type } => {
let selected_points: Vec<&ManipulatorPointId> = shape_editor.selected_points().collect();
if (using_path_tool && selected_points.is_empty())
|| (!using_path_tool && !using_select_tool && !using_pen_... | @@ -403,9 +403,12 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
let handle1_length = handle1.length(&vector_data);
let handle2_length = handle2.length(&vector_data);
- if (handle1_length == 0. && handle2_length == 0.) || (handle1_length == f64::MAX && handle... | editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs | 26 | Rust | 0.643 | suggestion | 75 | 51 | 51 | false | Fix box selection erroneously including zero-length handles; fix GRS failing on sharp points | 2,550 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs
PR Title: Fix box selection erroneously including zero-length handles; fix GRS failing on sharp points
BEFORE CODE: increments_key: INCREMENTS_KEY,
});
}
TransformLayerMes... | ```suggestion
// G should work for this point but not R and S
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
editor_position: click_position,
mouse_keys: MouseKeys::LEFT,
scroll_delta: ScrollDelta::default(),
},
modifier_keys,
})
.await;
// Check that a new stop has been added
let updated_fills = get_fills(&mut editor).await;
assert_eq!(updated_fills.len(), 1);
let (updated_fill, _) = upd... | It might be useful to change the transform of the layer as well as to zoom the document. This actually confirms that it works in viewport space. You can do this with something like:
```rs
editor.handle_message(NavigationMessage::CanvasZoomSet { zoom_factor: 2.0 }).await;
editor.handle_message(GraphOperationMessage::... | editor_position: click_position,
mouse_keys: MouseKeys::LEFT,
scroll_delta: ScrollDelta::default(),
},
modifier_keys,
})
.await;
// Check that a new stop has been added
let updated_fills = get_fills(&mut editor).await;
assert_eq!(updated_fills.len(), 1);
let (updated_fill, _) = upd... | @@ -709,4 +709,65 @@ mod test_gradient {
positions
);
}
+
+ #[tokio::test]
+ async fn dragging_endpoint_sets_correct_point() { | editor/src/messages/tool/tool_messages/gradient_tool.rs | 26 | Rust | 1 | suggestion | 353 | 51 | 51 | false | Add Gradient tool test for dragging an endpoint setting the correct point in the viewport | 2,564 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | Sidharth-Singh10 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/gradient_tool.rs
PR Title: Add Gradient tool test for dragging an endpoint setting the correct point in the viewport
BEFORE CODE: editor_position: click_position,
mouse_keys: MouseKeys::LEFT,
scroll_delta: Sc... | It might be useful to change the transform of the layer as well as to zoom the document. This actually confirms that it works in viewport space. You can do this with something like:
```rs
editor.handle_message(NavigationMessage::CanvasZoomSet { zoom_factor: 2.0 }).await;
editor.handle_message(GraphOperationMessage::... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// Verify the start point hasn't changed
let updated_start = transform.transform_point2(updated_gradient.start);
assert!(updated_start.abs_diff_eq(DVec2::new(0., 0.), 1e-10));
// Verify the end point has been updated to the new position
let updated_end = transform.transform_point2(updated_gradient.end);
as... | You can probably make this a function to reduce duplication. |
#[tokio::test]
async fn dragging_stop_reorders_gradient() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
editor.drag_tool(ToolType::Rectangle, -5., -3., 100., 100., ModifierKeys::empty()).await;
editor.select_primary_color(Color::GREEN).await;
editor.select_secondary_color(Colo... | @@ -783,4 +783,93 @@ mod test_gradient {
let updated_end = transform.transform_point2(updated_gradient.end);
assert!(updated_end.abs_diff_eq(DVec2::new(100., 50.), 1e-10), "Expected end point at (100, 50), got {:?}", updated_end);
}
+
+ #[tokio::test]
+ async fn select_and_delete_removes_stop() {
+ let mut edi... | editor/src/messages/tool/tool_messages/gradient_tool.rs | 26 | Rust | 0.214 | suggestion | 60 | 51 | 51 | false | Add Gradient tool test for select and delete removes a stop | 2,571 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | Sidharth-Singh10 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/gradient_tool.rs
PR Title: Add Gradient tool test for select and delete removes a stop
BEFORE CODE: // Verify the start point hasn't changed
let updated_start = transform.transform_point2(updated_gradient.start);
asse... | You can probably make this a function to reduce duplication. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
editor.select_tool(ToolType::Gradient).await;
let position1 = DVec2::new(25., 0.);
editor
.handle_message(InputPreprocessorMessage::DoubleClick {
editor_mouse_state: EditorMouseState {
editor_position: position1,
mouse_keys: MouseKeys::LEFT,
scroll_delta: ScrollDelta::default(),
},
... | Also double clicking can be made a function. | // Simulate dragging the middle stop to position 0.8
let click_position = DVec2::new(50., 0.);
editor
.mousedown(
EditorMouseState {
editor_position: click_position,
mouse_keys: MouseKeys::LEFT,
scroll_delta: ScrollDelta::default(),
},
ModifierKeys::empty(),
)
.await;
let dr... | @@ -783,4 +783,93 @@ mod test_gradient {
let updated_end = transform.transform_point2(updated_gradient.end);
assert!(updated_end.abs_diff_eq(DVec2::new(100., 50.), 1e-10), "Expected end point at (100, 50), got {:?}", updated_end);
}
+
+ #[tokio::test]
+ async fn select_and_delete_removes_stop() {
+ let mut edi... | editor/src/messages/tool/tool_messages/gradient_tool.rs | 26 | Rust | 0.071 | suggestion | 44 | 51 | 51 | false | Add Gradient tool test for select and delete removes a stop | 2,571 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | Sidharth-Singh10 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/gradient_tool.rs
PR Title: Add Gradient tool test for select and delete removes a stop
BEFORE CODE: editor.select_tool(ToolType::Gradient).await;
let position1 = DVec2::new(25., 0.);
editor
.handle_message(InputPr... | Also double clicking can be made a function. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
.collect()
}
async fn get_gradient(editor: &mut EditorTestUtils) -> (Gradient, DAffine2) {
let fills = get_fills(editor).await;
assert_eq!(fills.len(), 1, "Expected 1 gradient fill, found {}", fills.len());
let (fill, transform) = fills.first().unwrap();
let gradient = fill.as_gradient().expect("Expected... | This looks good, however why is this not part of the `EditorTestUtils` like all the other testing utilities? It doesn't seem to be specific to the gradient tool. | .collect()
}
async fn get_gradient(editor: &mut EditorTestUtils) -> (Gradient, DAffine2) {
let fills = get_fills(editor).await;
assert_eq!(fills.len(), 1, "Expected 1 gradient fill, found {}", fills.len());
let (fill, transform) = fills.first().unwrap();
let gradient = fill.as_gradient().expect("Expected... | @@ -557,6 +558,29 @@ mod test_gradient {
.collect()
}
+ async fn get_gradient(editor: &mut EditorTestUtils) -> (Gradient, DAffine2) {
+ let fills = get_fills(editor).await;
+ assert_eq!(fills.len(), 1, "Expected 1 gradient fill, found {}", fills.len());
+
+ let (fill, transform) = fills.first().unwrap();
+ ... | editor/src/messages/tool/tool_messages/gradient_tool.rs | 26 | Rust | 0.5 | suggestion | 161 | 51 | 51 | false | Add Gradient tool test for select and delete removes a stop | 2,571 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | Sidharth-Singh10 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/gradient_tool.rs
PR Title: Add Gradient tool test for select and delete removes a stop
BEFORE CODE: .collect()
}
async fn get_gradient(editor: &mut EditorTestUtils) -> (Gradient, DAffine2) {
let fills = get_fills(ed... | This looks good, however why is this not part of the `EditorTestUtils` like all the other testing utilities? It doesn't seem to be specific to the gradient tool. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
editor.drag_tool(ToolType::Rectangle, -5., -3., 100., 100., ModifierKeys::empty()).await;
editor.select_primary_color(Color::GREEN).await;
editor.select_secondary_color(Color::BLUE).await;
editor.drag_tool(ToolType::Gradient, 0., 0., 100., 0., ModifierKeys::empty()).await;
// Get initial gradient state (sho... | Probably a function to verify that the gradient positions match a slice would reduce duplication here. | editor.drag_tool(ToolType::Rectangle, -5., -3., 100., 100., ModifierKeys::empty()).await;
editor.select_primary_color(Color::GREEN).await;
editor.select_secondary_color(Color::BLUE).await;
editor.drag_tool(ToolType::Gradient, 0., 0., 100., 0., ModifierKeys::empty()).await;
// Get initial gradient state (shou... | @@ -875,4 +847,66 @@ mod test_gradient {
assert_eq!(updated_stops[1].1.to_rgba8_srgb(), middle_color);
assert_eq!(updated_stops[2].1.to_rgba8_srgb(), Color::GREEN.to_rgba8_srgb());
}
+
+ #[tokio::test]
+ async fn select_and_delete_removes_stop() {
+ let mut editor = EditorTestUtils::create();
+ editor.new_doc... | editor/src/messages/tool/tool_messages/gradient_tool.rs | 26 | Rust | 0.357 | suggestion | 102 | 51 | 51 | false | Add Gradient tool test for select and delete removes a stop | 2,571 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | Sidharth-Singh10 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/gradient_tool.rs
PR Title: Add Gradient tool test for select and delete removes a stop
BEFORE CODE:
editor.drag_tool(ToolType::Rectangle, -5., -3., 100., 100., ModifierKeys::empty()).await;
editor.select_primary_color(... | Probably a function to verify that the gradient positions match a slice would reduce duplication here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
(start_input, end_input) => {
let line_vec = end_input - start_input;
let angle_radians = line_vec.angle_to(DVec2::X);
let angle_degrees = angle_radians.to_degrees();
let nearest_angle = (angle_degrees / 15.0).round() * 15.0;
assert!((angle_degrees - nearest_angle).abs() < 1.0, "Angle shou... | This is very verbose. Consider adding a function to get the selected layers directly on `EditorTestUtils`. | (start_input, end_input) => {
let line_vec = end_input - start_input;
let angle_radians = line_vec.angle_to(DVec2::X);
let angle_degrees = angle_radians.to_degrees();
let nearest_angle = (angle_degrees / 15.0).round() * 15.0;
assert!((angle_degrees - nearest_angle).abs() < 1.0, "Angle shou... | @@ -561,4 +563,47 @@ mod test_line_tool {
}
}
}
+
+ #[tokio::test]
+ async fn test_line_tool_with_transformed_artboard() {
+ let mut editor = EditorTestUtils::create();
+ editor.new_document().await;
+ editor.select_tool(ToolType::Artboard).await;
+ editor.drag_tool(ToolType::Artboard, 0., 0., 200., 200., ... | editor/src/messages/tool/tool_messages/line_tool.rs | 26 | Rust | 0.571 | suggestion | 106 | 51 | 51 | false | Add Line tool tests for drawing within a transformed artboard | 2,572 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/line_tool.rs
PR Title: Add Line tool tests for drawing within a transformed artboard
BEFORE CODE: (start_input, end_input) => {
let line_vec = end_input - start_input;
let angle_radians = line_vec.angle_to(DVe... | This is very verbose. Consider adding a function to get the selected layers directly on `EditorTestUtils`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
editor
.handle_message(GraphOperationMessage::TransformChange {
layer: artboard_id,
transform: DAffine2::from_angle(45.0_f64.to_radians()),
transform_in: TransformIn::Local,
skip_rerender: false,
})
.await;
editor.drag_tool(ToolType::Line, 50., 50., 150., 150., ModifierKeys::empty()).await... | It is probably cleaner to add a guard here. | use super::tool_prelude::*;
use crate::consts::{BOUNDS_SELECT_THRESHOLD, DEFAULT_STROKE_WIDTH, LINE_ROTATE_SNAP_ANGLE};
use crate::messages::portfolio::document::node_graph::document_node_definitions::resolve_document_node_type;
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
use crat... | @@ -561,4 +563,47 @@ mod test_line_tool {
}
}
}
+
+ #[tokio::test]
+ async fn test_line_tool_with_transformed_artboard() {
+ let mut editor = EditorTestUtils::create();
+ editor.new_document().await;
+ editor.select_tool(ToolType::Artboard).await;
+ editor.drag_tool(ToolType::Artboard, 0., 0., 200., 200., ... | editor/src/messages/tool/tool_messages/line_tool.rs | 26 | Rust | 0.071 | suggestion | 43 | 29 | 605 | false | Add Line tool tests for drawing within a transformed artboard | 2,572 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/line_tool.rs
PR Title: Add Line tool tests for drawing within a transformed artboard
BEFORE CODE: editor
.handle_message(GraphOperationMessage::TransformChange {
layer: artboard_id,
transform: DAffine2::from_an... | It is probably cleaner to add a guard here. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// Initiate drawing a spline
editor.left_mousedown(50.0, 50.0, ModifierKeys::empty()).await;
editor
.mouseup(
EditorMouseState {
editor_position: DVec2::new(50.0, 50.0),
mouse_keys: MouseKeys::empty(),
scroll_delta: ScrollDelta::default(),
},
ModifierKeys::empty(),
)
.await;
... | Consider using `editor.click_tool(…)` to simplify the logic. You are also free to write your own helper functions e.g. on `EditorTestUtils`. | i,
expected_point,
actual_point,
distance
);
}
}
#[tokio::test]
async fn test_continue_drawing_from_existing_spline() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
let initial_points = [DVec2::new(100., 100.), DVec2::new(200., 150.), DVec2::new(300., 100.)];
... | @@ -534,3 +534,308 @@ fn delete_preview(tool_data: &mut SplineToolData, responses: &mut VecDeque<Messa
tool_data.preview_point = None;
tool_data.preview_segment = None;
}
+
+#[cfg(test)]
+mod test_spline_tool {
+ use crate::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, ScrollDelta};
+ use ... | editor/src/messages/tool/tool_messages/spline_tool.rs | 26 | Rust | 0.571 | refactor | 140 | 51 | 51 | false | Add Spline tool test for drawing with PTZ applied to the canvas view | 2,573 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/spline_tool.rs
PR Title: Add Spline tool test for drawing with PTZ applied to the canvas view
BEFORE CODE:
// Initiate drawing a spline
editor.left_mousedown(50.0, 50.0, ModifierKeys::empty()).await;
editor
.mouse... | Consider using `editor.click_tool(…)` to simplify the logic. You are also free to write your own helper functions e.g. on `EditorTestUtils`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
},
ModifierKeys::empty(),
)
.await;
// Adding the third point
editor.left_mousedown(150.0, 100.0, ModifierKeys::empty()).await;
editor
.mouseup(
EditorMouseState {
editor_position: DVec2::new(150.0, 100.0),
mouse_keys: MouseKeys::empty(),
scroll_delta: ScrollDelta::default(),
... | Please assert exact equals. There is no reason why there would be more than three points? |
let document = editor.active_document();
let spline_layer = document
.metadata()
.all_layers()
.find(|layer| find_spline(document, *layer).is_some())
.expect("Failed to find a layer with a spline node");
let first_spline_node = find_spline(document, spline_layer).expect("Spline node not found in the... | @@ -534,3 +534,308 @@ fn delete_preview(tool_data: &mut SplineToolData, responses: &mut VecDeque<Messa
tool_data.preview_point = None;
tool_data.preview_segment = None;
}
+
+#[cfg(test)]
+mod test_spline_tool {
+ use crate::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, ScrollDelta};
+ use ... | editor/src/messages/tool/tool_messages/spline_tool.rs | 26 | Rust | 0.214 | question | 89 | 51 | 51 | false | Add Spline tool test for drawing with PTZ applied to the canvas view | 2,573 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/spline_tool.rs
PR Title: Add Spline tool test for drawing with PTZ applied to the canvas view
BEFORE CODE: },
ModifierKeys::empty(),
)
.await;
// Adding the third point
editor.left_mousedown(150.0, 100.0,... | Please assert exact equals. There is no reason why there would be more than three points? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
)
.await;
// Finish the spline
editor.handle_message(SplineToolMessage::Confirm).await;
// Evaluate the graph to ensure everything is processed
editor.eval_graph().await;
if let Some(points) = get_spline_points(&mut editor).await {
assert!(points.len() >= 3, "Spline should have at least 3 points")... | 1.0 is quite a high tolerance. Consider something smaller e.g. 1e-10. | assert_eq!(initial_point_count, 3, "Expected 3 points in initial spline, found {}", initial_point_count);
assert_eq!(initial_segment_count, 2, "Expected 2 segments in initial spline, found {}", initial_segment_count);
let layer_to_viewport = document.metadata().transform_to_viewport(spline_layer);
let endpoin... | @@ -534,3 +534,308 @@ fn delete_preview(tool_data: &mut SplineToolData, responses: &mut VecDeque<Messa
tool_data.preview_point = None;
tool_data.preview_segment = None;
}
+
+#[cfg(test)]
+mod test_spline_tool {
+ use crate::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, ScrollDelta};
+ use ... | editor/src/messages/tool/tool_messages/spline_tool.rs | 26 | Rust | 0.286 | suggestion | 69 | 51 | 51 | false | Add Spline tool test for drawing with PTZ applied to the canvas view | 2,573 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/spline_tool.rs
PR Title: Add Spline tool test for drawing with PTZ applied to the canvas view
BEFORE CODE: )
.await;
// Finish the spline
editor.handle_message(SplineToolMessage::Confirm).await;
// Evaluate th... | 1.0 is quite a high tolerance. Consider something smaller e.g. 1e-10. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
editor_position: DVec2::new(150.0, 100.0),
mouse_keys: MouseKeys::empty(),
scroll_delta: ScrollDelta::default(),
},
ModifierKeys::empty(),
)
.await;
editor.handle_message(SplineToolMessage::Confirm).await;
editor.eval_graph().await;
if let Some(points) = get_spline_points(&mut edito... | Since this is repeaded several times, consider making this a function. |
// Get the layer and vector data
let document = editor.active_document();
let network_interface = &document.network_interface;
let layer = network_interface
.selected_nodes()
.selected_visible_and_unlocked_layers(network_interface)
.next()
.expect("Should have a selected layer");
let vector_data ... | @@ -534,3 +534,308 @@ fn delete_preview(tool_data: &mut SplineToolData, responses: &mut VecDeque<Messa
tool_data.preview_point = None;
tool_data.preview_segment = None;
}
+
+#[cfg(test)]
+mod test_spline_tool {
+ use crate::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, ScrollDelta};
+ use ... | editor/src/messages/tool/tool_messages/spline_tool.rs | 26 | Rust | 0.286 | suggestion | 70 | 51 | 51 | false | Add Spline tool test for drawing with PTZ applied to the canvas view | 2,573 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/spline_tool.rs
PR Title: Add Spline tool test for drawing with PTZ applied to the canvas view
BEFORE CODE: editor_position: DVec2::new(150.0, 100.0),
mouse_keys: MouseKeys::empty(),
scroll_delta: ScrollDelta:... | Since this is repeaded several times, consider making this a function. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
editor.left_mousedown(150.0, 100.0, ModifierKeys::empty()).await;
editor
.mouseup(
EditorMouseState {
editor_position: DVec2::new(150.0, 100.0),
mouse_keys: MouseKeys::empty(),
scroll_delta: ScrollDelta::default(),
},
ModifierKeys::empty(),
)
.await;
editor.handle_message(Spl... | There is no need to use `.take()` since zip will end when either of the iterators ends. See: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.zip | // Finish the spline
editor.handle_message(SplineToolMessage::Confirm).await;
// Evaluate the graph to ensure everything is processed
editor.eval_graph().await;
// Get the layer and vector data
let document = editor.active_document();
let network_interface = &document.network_interface;
let layer = ne... | @@ -534,3 +534,308 @@ fn delete_preview(tool_data: &mut SplineToolData, responses: &mut VecDeque<Messa
tool_data.preview_point = None;
tool_data.preview_segment = None;
}
+
+#[cfg(test)]
+mod test_spline_tool {
+ use crate::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, ScrollDelta};
+ use ... | editor/src/messages/tool/tool_messages/spline_tool.rs | 26 | Rust | 0.571 | suggestion | 158 | 51 | 51 | false | Add Spline tool test for drawing with PTZ applied to the canvas view | 2,573 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/spline_tool.rs
PR Title: Add Spline tool test for drawing with PTZ applied to the canvas view
BEFORE CODE:
editor.left_mousedown(150.0, 100.0, ModifierKeys::empty()).await;
editor
.mouseup(
EditorMouseState {
... | There is no need to use `.take()` since zip will end when either of the iterators ends. See: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.zip | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
#[tokio::test]
async fn test_line_tool_basicdraw() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
editor.drag_tool(ToolType::Line, 0., 0., 100., 100., ModifierKeys::empty()).await;
if let Some((start_input, end_input)) = get_line_node_inputs(&mut editor).await {
match (start... | You can just write `30_f64.to_radians()`. However it doesn't really matter. | }
#[tokio::test]
async fn test_line_tool_basicdraw() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
editor.drag_tool(ToolType::Line, 0., 0., 100., 100., ModifierKeys::empty()).await;
if let Some((start_input, end_input)) = get_line_node_inputs(&mut editor).await {
match (start... | @@ -473,26 +473,30 @@ mod test_line_tool {
async fn test_line_tool_with_transformed_viewport() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
- editor.handle_message(NavigationMessage::CanvasZoomSet { zoom_factor: 2.0 }).await;
- editor.handle_message(NavigationMessage::CanvasPan {... | editor/src/messages/tool/tool_messages/line_tool.rs | 26 | Rust | 0.357 | suggestion | 75 | 51 | 51 | false | Add Spline tool test for drawing with PTZ applied to the canvas view | 2,573 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | rahat2134 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/line_tool.rs
PR Title: Add Spline tool test for drawing with PTZ applied to the canvas view
BEFORE CODE: }
#[tokio::test]
async fn test_line_tool_basicdraw() {
let mut editor = EditorTestUtils::create();
editor.new_... | You can just write `30_f64.to_radians()`. However it doesn't really matter. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
editor
.handle_message(GraphOperationMessage::TransformSet {
layer: artboard_layer,
transform: DAffine2::from_scale_angle_translation(DVec2::new(1.5, 1.2), 30.0_f64.to_radians(), DVec2::new(50.0, 25.0)),
transform_in: TransformIn::Local,
skip_rerender: false,
})
.await;
let spline_start = ... | Consider using `editor.click_tool(…)` to simplify the logic. You are also free to write your own helper functions e.g. on `EditorTestUtils`. | })
.collect();
// Verify each point position is close to the expected position
for (i, expected_point) in expected_points.iter().enumerate() {
let actual_point = points_in_viewport[i];
let distance = (actual_point - *expected_point).length();
assert!(
distance < epsilon,
"Point {} position ... | @@ -534,3 +534,102 @@ fn delete_preview(tool_data: &mut SplineToolData, responses: &mut VecDeque<Messa
tool_data.preview_point = None;
tool_data.preview_segment = None;
}
+#[cfg(test)]
+mod test_spline_tool {
+ use crate::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, ScrollDelta};
+ use cr... | editor/src/messages/tool/tool_messages/spline_tool.rs | 26 | Rust | 0.571 | refactor | 140 | 51 | 51 | false | Add Spline tool tests for drawing within a transformed artboard | 2,575 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | Sidharth-Singh10 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/spline_tool.rs
PR Title: Add Spline tool tests for drawing within a transformed artboard
BEFORE CODE: editor
.handle_message(GraphOperationMessage::TransformSet {
layer: artboard_layer,
transform: DAffine2::fro... | Consider using `editor.click_tool(…)` to simplify the logic. You are also free to write your own helper functions e.g. on `EditorTestUtils`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
EditorMouseState {
editor_position: spline_mid,
mouse_keys: MouseKeys::empty(),
scroll_delta: ScrollDelta::default(),
},
ModifierKeys::empty(),
)
.await;
editor.move_mouse(spline_end.x, spline_end.y, ModifierKeys::empty(), MouseKeys::empty()).await;
editor.left_mousedown(spline_end... | This is redundant as the testing code calls this after every message dispatch. |
editor.press(Key::Enter, ModifierKeys::empty()).await;
let document = editor.active_document();
let spline_layer = document
.metadata()
.all_layers()
.find(|layer| find_spline(document, *layer).is_some())
.expect("Failed to find a layer with a spline node");
let first_spline_node = find_spline(do... | @@ -534,3 +534,102 @@ fn delete_preview(tool_data: &mut SplineToolData, responses: &mut VecDeque<Messa
tool_data.preview_point = None;
tool_data.preview_segment = None;
}
+#[cfg(test)]
+mod test_spline_tool {
+ use crate::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, ScrollDelta};
+ use cr... | editor/src/messages/tool/tool_messages/spline_tool.rs | 26 | Rust | 0.214 | suggestion | 78 | 51 | 51 | false | Add Spline tool tests for drawing within a transformed artboard | 2,575 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | Sidharth-Singh10 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/spline_tool.rs
PR Title: Add Spline tool tests for drawing within a transformed artboard
BEFORE CODE: EditorMouseState {
editor_position: spline_mid,
mouse_keys: MouseKeys::empty(),
scroll_delta: ScrollDe... | This is redundant as the testing code calls this after every message dispatch. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
use super::tool_prelude::*;
use crate::consts::{DEFAULT_STROKE_WIDTH, DRAG_THRESHOLD, PATH_JOIN_THRESHOLD, SNAP_POINT_TOLERANCE};
use crate::messages::input_mapper::utility_types::input_mouse::MouseKeys;
use crate::messages::portfolio::document::node_graph::document_node_definitions::resolve_document_node_type;
use cra... | Since you just count the points and don't check if their positions are correct, the point of the test is missed. Please assert that the positions of the points are correct in viewport space. | layer: artboard_layer,
transform: DAffine2::from_scale_angle_translation(DVec2::new(1.5, 1.2), 30_f64.to_radians(), DVec2::new(50., 25.)),
transform_in: TransformIn::Local,
skip_rerender: false,
})
.await;
let spline_points = [DVec2::new(100., 100.), DVec2::new(200., 150.), DVec2::new(300., 100... | @@ -534,3 +534,102 @@ fn delete_preview(tool_data: &mut SplineToolData, responses: &mut VecDeque<Messa
tool_data.preview_point = None;
tool_data.preview_segment = None;
}
+#[cfg(test)]
+mod test_spline_tool {
+ use crate::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, ScrollDelta};
+ use cr... | editor/src/messages/tool/tool_messages/spline_tool.rs | 26 | Rust | 0.357 | suggestion | 190 | 636 | 34 | false | Add Spline tool tests for drawing within a transformed artboard | 2,575 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | Sidharth-Singh10 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/spline_tool.rs
PR Title: Add Spline tool tests for drawing within a transformed artboard
BEFORE CODE: use super::tool_prelude::*;
use crate::consts::{DEFAULT_STROKE_WIDTH, DRAG_THRESHOLD, PATH_JOIN_THRESHOLD, SNAP_POINT_TOL... | Since you just count the points and don't check if their positions are correct, the point of the test is missed. Please assert that the positions of the points are correct in viewport space. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
let points_in_viewport: Vec<DVec2> = vector_data
.point_domain
.ids()
.iter()
.filter_map(|&point_id| {
let position = vector_data.point_domain.position_from_id(point_id)?;
Some(layer_to_viewport.transform_point2(position))
})
.collect();
// Verify each point position is close to the exp... | Perhaps you could make a function to check that the points match a list passed in (in viewport space)? | editor.click_tool(ToolType::Spline, MouseKeys::LEFT, point, ModifierKeys::empty()).await;
}
editor.press(Key::Enter, ModifierKeys::empty()).await;
let document = editor.active_document();
let spline_layer = document
.metadata()
.all_layers()
.find(|layer| find_spline(document, *layer).is_some())
... | @@ -534,3 +534,78 @@ fn delete_preview(tool_data: &mut SplineToolData, responses: &mut VecDeque<Messa
tool_data.preview_point = None;
tool_data.preview_segment = None;
}
+#[cfg(test)]
+mod test_spline_tool {
+ use crate::messages::portfolio::document::graph_operation::utility_types::TransformIn;
+ use crate::messa... | editor/src/messages/tool/tool_messages/spline_tool.rs | 26 | Rust | 0.429 | question | 102 | 29 | 51 | false | Add Spline tool tests for drawing within a transformed artboard | 2,575 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | Sidharth-Singh10 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/spline_tool.rs
PR Title: Add Spline tool tests for drawing within a transformed artboard
BEFORE CODE:
let points_in_viewport: Vec<DVec2> = vector_data
.point_domain
.ids()
.iter()
.filter_map(|&point_id| {
... | Perhaps you could make a function to check that the points match a list passed in (in viewport space)? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
.selected_visible_and_unlocked_layers(network_interface)
.next()
.expect("Should have a selected layer");
let vector_data = network_interface.compute_modified_vector(layer).expect("Should have vector data");
let layer_to_viewport = document.metadata().transform_to_viewport(layer);
// Expected points in ... | ```suggestion
transform: DAffine2::from_scale_angle_translation(DVec2::new(1.5, 1.2), 30_f64.to_radians(), DVec2::new(50., 25.)),
``` | .selected_visible_and_unlocked_layers(network_interface)
.next()
.expect("Should have a selected layer");
let vector_data = network_interface.compute_modified_vector(layer).expect("Should have vector data");
let layer_to_viewport = document.metadata().transform_to_viewport(layer);
// Expected points in ... | @@ -799,4 +800,48 @@ mod test_spline_tool {
// Assert all points are correctly positioned
assert_point_positions(&vector_data, layer_to_viewport, &expected_points, 1e-10);
}
+
+ #[tokio::test]
+ async fn test_spline_tool_with_transformed_artboard() {
+ let mut editor = EditorTestUtils::create();
+ editor.new_... | editor/src/messages/tool/tool_messages/spline_tool.rs | 26 | Rust | 0.714 | suggestion | 139 | 51 | 51 | false | Add Spline tool tests for drawing within a transformed artboard | 2,575 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | Sidharth-Singh10 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/spline_tool.rs
PR Title: Add Spline tool tests for drawing within a transformed artboard
BEFORE CODE: .selected_visible_and_unlocked_layers(network_interface)
.next()
.expect("Should have a selected layer");
let ... | ```suggestion
transform: DAffine2::from_scale_angle_translation(DVec2::new(1.5, 1.2), 30_f64.to_radians(), DVec2::new(50., 25.)),
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
let position = extended_vector_data.point_domain.position_from_id(point_id)?;
Some(layer_to_viewport.transform_point2(position))
})
.collect();
let all_expected_points = [initial_points[0], initial_points[1], initial_points[2], continuation_points[0], continuation_points[1]];
assert_eq!(
points_i... | Perhaps a function that extracts the viewport positions of the points and asserts that they are equal to a target slice? | }
editor.press(Key::Enter, ModifierKeys::empty()).await;
let document = editor.active_document();
let extended_vector_data = document
.network_interface
.compute_modified_vector(spline_layer)
.expect("Vector data not found for the extended spline layer");
// Verify extended spline has correct numb... | @@ -534,3 +534,117 @@ fn delete_preview(tool_data: &mut SplineToolData, responses: &mut VecDeque<Messa
tool_data.preview_point = None;
tool_data.preview_segment = None;
}
+
+#[cfg(test)]
+mod test_spline_tool {
+ use crate::messages::tool::tool_messages::spline_tool::find_spline;
+ use crate::test_utils::test_prel... | editor/src/messages/tool/tool_messages/spline_tool.rs | 26 | Rust | 0.429 | refactor | 120 | 29 | 30 | false | Add tests for Spline tool to support continuing a previously drawn spline | 2,591 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | Sidharth-Singh10 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/spline_tool.rs
PR Title: Add tests for Spline tool to support continuing a previously drawn spline
BEFORE CODE: let position = extended_vector_data.point_domain.position_from_id(point_id)?;
Some(layer_to_viewport.tr... | Perhaps a function that extracts the viewport positions of the points and asserts that they are equal to a target slice? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
#[tokio::test]
async fn test_freehand_transformed_artboard() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
editor.drag_tool(ToolType::Artboard, 0., 0., 500., 500., ModifierKeys::empty()).await;
let metadata = editor.active_document().metadata();
let artboard = metadata.all_la... | It would probably be clearer if you generated this by mapping the `mouse_points` |
fn verify_path_points(vector_data_list: &[(VectorData, DAffine2)], expected_captured_points: &[DVec2], tolerance: f64) -> Result<(), String> {
if vector_data_list.len() == 0 {
return Err("No vector data found after drawing".to_string());
}
let path_data = vector_data_list.iter().find(|(data, _)| data.point_... | @@ -340,3 +340,397 @@ fn extend_path_with_next_segment(tool_data: &mut FreehandToolData, position: DVe
tool_data.dragged = true;
tool_data.end_point = Some((position, id));
}
+
+#[cfg(test)]
+mod test_freehand {
+ use crate::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, MouseKeys, ScrollDe... | editor/src/messages/tool/tool_messages/freehand_tool.rs | 26 | Rust | 0.429 | suggestion | 80 | 51 | 51 | false | Add tests for the Freehand tool | 2,599 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | Sidharth-Singh10 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/freehand_tool.rs
PR Title: Add tests for the Freehand tool
BEFORE CODE:
#[tokio::test]
async fn test_freehand_transformed_artboard() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
edito... | It would probably be clearer if you generated this by mapping the `mouse_points` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
editor.select_tool(ToolType::Freehand).await;
let mouse_points = [DVec2::new(150.0, 100.0), DVec2::new(200.0, 150.0), DVec2::new(250.0, 130.0), DVec2::new(300.0, 170.0)];
// Expected points that will actually be captured by the tool
let expected_captured_points = [DVec2::new(200.0, 150.0), DVec2::new(250.0, ... | Possibly a function for dragging through points could be added to the `EditorTestUtils`. | })
.collect();
if segment_count != point_count - 1 {
return Err(format!("Expected segments to be one less than points, got {} segments for {} points", segment_count, point_count));
}
if point_count != expected_captured_points.len() {
return Err(format!("Expected {} points, got {}", expected_captured... | @@ -340,3 +340,397 @@ fn extend_path_with_next_segment(tool_data: &mut FreehandToolData, position: DVe
tool_data.dragged = true;
tool_data.end_point = Some((position, id));
}
+
+#[cfg(test)]
+mod test_freehand {
+ use crate::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, MouseKeys, ScrollDe... | editor/src/messages/tool/tool_messages/freehand_tool.rs | 26 | Rust | 0.429 | suggestion | 88 | 51 | 51 | false | Add tests for the Freehand tool | 2,599 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | Sidharth-Singh10 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/freehand_tool.rs
PR Title: Add tests for the Freehand tool
BEFORE CODE:
editor.select_tool(ToolType::Freehand).await;
let mouse_points = [DVec2::new(150.0, 100.0), DVec2::new(200.0, 150.0), DVec2::new(250.0, 130.0), D... | Possibly a function for dragging through points could be added to the `EditorTestUtils`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
let actual_positions: Vec<DVec2> = vector_data
.point_domain
.ids()
.iter()
.filter_map(|&point_id| {
let position = vector_data.point_domain.position_from_id(point_id)?;
Some(transform.transform_point2(position))
})
.collect();
assert_eq!(segment_count, point_count - 1, "Expected segment... | Collecting and asserting that the positions equal a desired list could also be a function. | .await;
editor.select_tool(ToolType::Freehand).await;
let mouse_points = [DVec2::new(150.0, 100.0), DVec2::new(200.0, 150.0), DVec2::new(250.0, 130.0), DVec2::new(300.0, 170.0)];
// Expected points that will actually be captured by the tool
let expected_captured_points = &mouse_points[1..];
editor.drag_... | @@ -340,3 +340,397 @@ fn extend_path_with_next_segment(tool_data: &mut FreehandToolData, position: DVe
tool_data.dragged = true;
tool_data.end_point = Some((position, id));
}
+
+#[cfg(test)]
+mod test_freehand {
+ use crate::messages::input_mapper::utility_types::input_mouse::{EditorMouseState, MouseKeys, ScrollDe... | editor/src/messages/tool/tool_messages/freehand_tool.rs | 26 | Rust | 0.286 | suggestion | 90 | 51 | 51 | false | Add tests for the Freehand tool | 2,599 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | Sidharth-Singh10 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/freehand_tool.rs
PR Title: Add tests for the Freehand tool
BEFORE CODE: let actual_positions: Vec<DVec2> = vector_data
.point_domain
.ids()
.iter()
.filter_map(|&point_id| {
let position = vector_data.poin... | Collecting and asserting that the positions equal a desired list could also be a function. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
let clicked_layer = document.find_deepest(&selected).unwrap_or_else(|| {
LayerNodeIdentifier::ROOT_PARENT
.children(document.metadata())
.next()
.expect("ROOT_PARENT should have at least one layer when clicking")
});
let metadata = document.metadata();
let selected_layers = document.network_interface.... | What does `lca` stand for? Expand this please. | let clicked_layer = document.find_deepest(&selected).unwrap_or_else(|| {
LayerNodeIdentifier::ROOT_PARENT
.children(document.metadata())
.next()
.expect("ROOT_PARENT should have at least one layer when clicking")
});
let metadata = document.metadata();
let selected_layers = document.network_interface.s... | @@ -1590,16 +1645,47 @@ fn not_artboard(document: &DocumentMessageHandler) -> impl Fn(&LayerNodeIdentifi
|&layer| layer != LayerNodeIdentifier::ROOT_PARENT && !document.network_interface.is_artboard(&layer.to_node(), &[])
}
-fn drag_shallowest_manipulation(responses: &mut VecDeque<Message>, selected: Vec<LayerNode... | editor/src/messages/tool/tool_messages/select_tool.rs | 26 | Rust | 0.214 | question | 46 | 51 | 51 | false | Fix 'Shallow Select' mode behavior for selection context transference | 2,604 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | mTvare6 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/select_tool.rs
PR Title: Fix 'Shallow Select' mode behavior for selection context transference
BEFORE CODE:
let clicked_layer = document.find_deepest(&selected).unwrap_or_else(|| {
LayerNodeIdentifier::ROOT_PARENT
.c... | What does `lca` stand for? Expand this please. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, Hash, DynAny, specta::Type)]
pub enum GridType {
#[default]
Rectangular,
Isometric,
}
#[repr(C)]
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize, Hash, DynAny, specta::Type)]
pub enum... | This only gets used once, it's better to just do it inline. | use dyn_any::DynAny;
use glam::DVec2;
use kurbo::Point;
/// Represents different ways of calculating the centroid.
#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, Hash, DynAny, specta::Type)]
pub enum CentroidType {
/// The center of mass for the area of a solid shape's inte... | @@ -111,3 +111,7 @@ pub fn point_to_dvec2(point: Point) -> DVec2 {
pub fn dvec2_to_point(value: DVec2) -> Point {
Point { x: value.x, y: value.y }
}
+
+pub fn daffine2_to_affine(value: DAffine2) -> Affine {
+ Affine::new(value.to_cols_array()) | node-graph/gcore/src/vector/misc.rs | 26 | Rust | 0.286 | suggestion | 59 | 28 | 114 | false | Refactor the 'Position on Path' and 'Tangent on Path' nodes to use the Kurbo API | 2,611 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | indierusty | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/vector/misc.rs
PR Title: Refactor the 'Position on Path' and 'Tangent on Path' nodes to use the Kurbo API
BEFORE CODE: #[derive(Default, Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize, Hash, DynAny, specta::Type)]
pu... | This only gets used once, it's better to just do it inline. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
.selected_shape_state
.iter()
.map(|(&layer, selection_state)| (network_interface.compute_modified_vector(layer), selection_state))
.flat_map(|(data, selection_state)| {
selection_state.selected_points.iter().filter_map(move |&point| {
let Some(data) = &data else { return None };
let _ = point... | Careful not to have a habit of "sticking code in holes", thereby filling up the holes. Blank lines exist for a reason, so if you're filling them up with code, they aren't blank lines anymore. | // This iterator contains a bool indicating whether or not selected points' manipulator groups have colinear handles.
let mut points_colinear_status = self
.selected_shape_state
.iter()
.map(|(&layer, selection_state)| (network_interface.compute_modified_vector(layer), selection_state))
.flat_map(|(data... | @@ -728,7 +728,7 @@ impl ShapeState {
return;
};
let handles = vector_data.all_connected(point_id).take(2).collect::<Vec<_>>();
-
+ let non_zero_handles = handles.iter().filter(|handle| handle.length(vector_data) > 1e-6).count(); | editor/src/messages/tool/common_functionality/shape_editor.rs | 26 | Rust | 0.357 | style | 191 | 51 | 51 | false | Add Path tool support for Ctrl-dragging to pull out zero-length handles with angle locking | 2,620 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 0SlowPoke0 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/common_functionality/shape_editor.rs
PR Title: Add Path tool support for Ctrl-dragging to pull out zero-length handles with angle locking
BEFORE CODE: .selected_shape_state
.iter()
.map(|(&layer, selection_state)| (network_inter... | Careful not to have a habit of "sticking code in holes", thereby filling up the holes. Blank lines exist for a reason, so if you're filling them up with code, they aren't blank lines anymore. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// Set the manipulator to have colinear handles
if let (Some(a), Some(b)) = (handles.first(), handles.get(1)) {
let handles = [*a, *b];
let modification_type = VectorModificationType::SetG1Continuous { handles, enabled: true };
responses.add(GraphOperationMessage::Vector { layer, modification_type });
}
... | `-direction` is probably cleaner than `direction * -1`. Maybe also put it on the left hand side of the multiplication for further cleanliness/readability. | segment_count += 1.;
}
// For a non-endpoint anchor, handles are perpendicular to the average tangent of adjacent segments.(Refer:https://github.com/GraphiteEditor/Graphite/pull/2620#issuecomment-2881501494)
let mut handle_direction = if segment_count > 1. {
segment_angle = segment_angle / segment_count;
... | @@ -762,20 +762,35 @@ impl ShapeState {
handle_direction *= -1.;
}
- // Push both in and out handles into the correct position
- for ((handle, sign), other_anchor) in handles.iter().zip([1., -1.]).zip(&anchor_positions) {
- // To find the length of the new tangent we just take the distance to the anchor an... | editor/src/messages/tool/common_functionality/shape_editor.rs | 26 | Rust | 0.5 | suggestion | 154 | 51 | 51 | false | Add Path tool support for Ctrl-dragging to pull out zero-length handles with angle locking | 2,620 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 0SlowPoke0 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/common_functionality/shape_editor.rs
PR Title: Add Path tool support for Ctrl-dragging to pull out zero-length handles with angle locking
BEFORE CODE: // Set the manipulator to have colinear handles
if let (Some(a), Some(b)) = (handl... | `-direction` is probably cleaner than `direction * -1`. Maybe also put it on the left hand side of the multiplication for further cleanliness/readability. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
// Flip the vector if it is not facing towards the same direction as the anchor
let [first, second] = [anchor_positions.first().copied().flatten(), anchor_positions.get(1).copied().flatten()];
if first.is_some_and(|group| (group - anchor_position).normalize_or_zero().dot(handle_direction) < 0.)
|| second.is_s... | What changes with different values than `3`? I don't see what part of this feature relies on an arbitrary constant. | segment_angle += std::f64::consts::FRAC_PI_2;
DVec2::new(segment_angle.cos(), segment_angle.sin())
} else {
DVec2::new(segment_angle.cos(), segment_angle.sin())
};
// Set the manipulator to have colinear handles
if let (Some(a), Some(b)) = (handles.first(), handles.get(1)) {
let handles = [*a, *b];... | @@ -762,20 +762,35 @@ impl ShapeState {
handle_direction *= -1.;
}
- // Push both in and out handles into the correct position
- for ((handle, sign), other_anchor) in handles.iter().zip([1., -1.]).zip(&anchor_positions) {
- // To find the length of the new tangent we just take the distance to the anchor an... | editor/src/messages/tool/common_functionality/shape_editor.rs | 26 | Rust | 0.571 | question | 115 | 51 | 51 | false | Add Path tool support for Ctrl-dragging to pull out zero-length handles with angle locking | 2,620 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 0SlowPoke0 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/common_functionality/shape_editor.rs
PR Title: Add Path tool support for Ctrl-dragging to pull out zero-length handles with angle locking
BEFORE CODE:
// Flip the vector if it is not facing towards the same direction as the anchor
l... | What changes with different values than `3`? I don't see what part of this feature relies on an arbitrary constant. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
return;
};
let new_position = non_zero_handle.length(vector_data) * direction * -1.;
let modification_type = zero_handle.set_relative_position(new_position);
responses.add(GraphOperationMessage::Vector { layer, modification_type });
} else {
// Push both in and out handles into the correct position... | Does the formatter let you remove this `continue`'s semicolon to put it all on one line, or is it too long? | {
handle_direction *= -1.;
}
if non_zero_handles != 0 {
let [a, b] = handles.as_slice() else { return };
let (non_zero_handle, zero_handle) = if a.length(vector_data) > 1e-6 { (a, b) } else { (b, a) };
let Some(direction) = non_zero_handle
.to_manipulator_point()
.get_position(&vector_data)
... | @@ -762,20 +762,35 @@ impl ShapeState {
handle_direction *= -1.;
}
- // Push both in and out handles into the correct position
- for ((handle, sign), other_anchor) in handles.iter().zip([1., -1.]).zip(&anchor_positions) {
- // To find the length of the new tangent we just take the distance to the anchor an... | editor/src/messages/tool/common_functionality/shape_editor.rs | 26 | Rust | 0.571 | refactor | 107 | 51 | 51 | false | Add Path tool support for Ctrl-dragging to pull out zero-length handles with angle locking | 2,620 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 0SlowPoke0 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/common_functionality/shape_editor.rs
PR Title: Add Path tool support for Ctrl-dragging to pull out zero-length handles with angle locking
BEFORE CODE: return;
};
let new_position = non_zero_handle.length(vector_data) * directio... | Does the formatter let you remove this `continue`'s semicolon to put it all on one line, or is it too long? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
pub const BOUNDS_ROTATE_THRESHOLD: f64 = 20.;
pub const MIN_LENGTH_FOR_MIDPOINT_VISIBILITY: f64 = 20.;
pub const MIN_LENGTH_FOR_CORNERS_VISIBILITY: f64 = 12.;
/// The width or height that the transform cage needs to be (at least) before the corner resize handle click targets take up their full surroundings. Otherwise, ... | ```suggestion
pub const HANDLE_LENGTH_FACTOR: f64 = 0.5;
``` | pub const BOUNDS_ROTATE_THRESHOLD: f64 = 20.;
pub const MIN_LENGTH_FOR_MIDPOINT_VISIBILITY: f64 = 20.;
pub const MIN_LENGTH_FOR_CORNERS_VISIBILITY: f64 = 12.;
/// The width or height that the transform cage needs to be (at least) before the corner resize handle click targets take up their full surroundings. Otherwise, ... | @@ -102,6 +102,7 @@ pub const HIDE_HANDLE_DISTANCE: f64 = 3.;
pub const HANDLE_ROTATE_SNAP_ANGLE: f64 = 15.;
pub const SEGMENT_INSERTION_DISTANCE: f64 = 7.5;
pub const SEGMENT_OVERLAY_SIZE: f64 = 10.;
+pub const HANDLE_LENGTH_FACTOR: f64 = 0.80; | editor/src/consts.rs | 26 | Rust | 0.714 | suggestion | 62 | 51 | 51 | false | Add Path tool support for Ctrl-dragging to pull out zero-length handles with angle locking | 2,620 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 0SlowPoke0 | Review this pull request change.
Language: Rust
File: editor/src/consts.rs
PR Title: Add Path tool support for Ctrl-dragging to pull out zero-length handles with angle locking
BEFORE CODE: pub const BOUNDS_ROTATE_THRESHOLD: f64 = 20.;
pub const MIN_LENGTH_FOR_MIDPOINT_VISIBILITY: f64 = 20.;
pub const MIN_LENGTH_FOR... | ```suggestion
pub const HANDLE_LENGTH_FACTOR: f64 = 0.5;
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
use_children: bool,
}
/// An iterator for finding layers within an [`XRayTarget`]. Constructed by [`DocumentMessageHandler::intersect_quad`] and [`DocumentMessageHandler::click_xray`].
#[derive(Clone)]
pub struct ClickXRayIter<'a> {
next_layer: Option<LayerNodeIdentifier>,
network_interface: &'a NodeNetworkInterfac... | You can use `.filter(|target| matches!(target.target_group(), ClickTargetGroup::Subpath(_)))` | // Ignore those with selected ancestors
let mut top_level_layers = Vec::new();
for &layer in &selected_layer_set {
let mut is_top_level = true;
let mut current_layer = layer;
while let Some(parent) = current_layer.parent(metadata) {
if selected_layer_set.contains(&parent) {
is_top_level = false... | @@ -2733,7 +2740,18 @@ fn click_targets_to_path_lib_segments<'a>(click_targets: impl Iterator<Item = &'
bezier_rs::BezierHandles::Cubic { handle_start, handle_end } => path_bool_lib::PathSegment::Cubic(bezier.start, handle_start, handle_end, bezier.end),
};
click_targets
- .flat_map(|target| target.subpath().it... | editor/src/messages/portfolio/document/document_message_handler.rs | 26 | Rust | 0.429 | suggestion | 93 | 51 | 51 | false | Add overlays for free-floating anchors on hovered/selected vector layers | 2,630 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | seam0s-dev | Review this pull request change.
Language: Rust
File: editor/src/messages/portfolio/document/document_message_handler.rs
PR Title: Add overlays for free-floating anchors on hovered/selected vector layers
BEFORE CODE: use_children: bool,
}
/// An iterator for finding layers within an [`XRayTarget`]. Constructed by... | You can use `.filter(|target| matches!(target.target_group(), ClickTargetGroup::Subpath(_)))` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
mod quad;
mod rect;
use crate::raster::image::ImageFrameTable;
use crate::raster::{BlendMode, Image};
use crate::transform::{Footprint, Transform};
use crate::uuid::{NodeId, generate_uuid};
use crate::vector::style::{Fill, Stroke, ViewMode};
use crate::vector::{PointId, VectorDataTable};
use crate::{Artboard, Artboard... | Why is manipulator group now a point group? Please avoid introducing redundant terminology. | mod quad;
mod rect;
use crate::raster::image::RasterDataTable;
use crate::raster::{BlendMode, Image};
use crate::transform::{Footprint, Transform};
use crate::uuid::{NodeId, generate_uuid};
use crate::vector::style::{Fill, Stroke, ViewMode};
use crate::vector::{PointId, VectorDataTable};
use crate::{Artboard, Artboard... | @@ -20,22 +20,43 @@ use std::fmt::Write;
#[cfg(feature = "vello")]
use vello::*;
+#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
+pub enum ClickTargetGroup {
+ Subpath(bezier_rs::Subpath<PointId>),
+ PointGroup(ManipulatorGroup<PointId>), | node-graph/gcore/src/graphic_element/renderer.rs | 26 | Rust | 0.286 | question | 91 | 51 | 51 | false | Add overlays for free-floating anchors on hovered/selected vector layers | 2,630 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | seam0s-dev | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/graphic_element/renderer.rs
PR Title: Add overlays for free-floating anchors on hovered/selected vector layers
BEFORE CODE: mod quad;
mod rect;
use crate::raster::image::ImageFrameTable;
use crate::raster::{BlendMode, Image};
use crate::tra... | Why is manipulator group now a point group? Please avoid introducing redundant terminology. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
parent_targets: Vec<(LayerNodeIdentifier, XRayTarget)>,
}
fn quad_to_path_lib_segments(quad: Quad) -> Vec<path_bool_lib::PathSegment> {
quad.all_edges().into_iter().map(|[start, end]| path_bool_lib::PathSegment::Line(start, end)).collect()
}
fn click_targets_to_path_lib_segments<'a>(click_targets: impl Iterator<Ite... | It is probably neater to use the filter_map and then .flatten() to avoid panic. | is_top_level = false;
break;
}
current_layer = parent;
}
if is_top_level {
top_level_layers.push(layer);
}
}
// Group selected layers by their parent
let mut grouped_layers: HashMap<LayerNodeIdentifier, Vec<(usize, LayerNodeIdentifier)>> = HashMap::new();
for &layer in &top_leve... | @@ -2733,7 +2740,18 @@ fn click_targets_to_path_lib_segments<'a>(click_targets: impl Iterator<Item = &'
bezier_rs::BezierHandles::Cubic { handle_start, handle_end } => path_bool_lib::PathSegment::Cubic(bezier.start, handle_start, handle_end, bezier.end),
};
click_targets
- .flat_map(|target| target.subpath().it... | editor/src/messages/portfolio/document/document_message_handler.rs | 26 | Rust | 0.286 | suggestion | 79 | 51 | 51 | false | Add overlays for free-floating anchors on hovered/selected vector layers | 2,630 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | seam0s-dev | Review this pull request change.
Language: Rust
File: editor/src/messages/portfolio/document/document_message_handler.rs
PR Title: Add overlays for free-floating anchors on hovered/selected vector layers
BEFORE CODE: parent_targets: Vec<(LayerNodeIdentifier, XRayTarget)>,
}
fn quad_to_path_lib_segments(quad: Quad... | It is probably neater to use the filter_map and then .flatten() to avoid panic. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
mod quad;
mod rect;
use crate::raster::image::ImageFrameTable;
use crate::raster::{BlendMode, Image};
use crate::transform::{Footprint, Transform};
use crate::uuid::{NodeId, generate_uuid};
use crate::vector::style::{Fill, Stroke, ViewMode};
use crate::vector::{PointId, VectorDataTable};
use crate::{Artboard, Artboard... | I don't really understand why this data structure is used anyway? An unconnected point won't have any handles. It would be far more ergonomic just to use a DVec2 and a PointId. | mod quad;
mod rect;
use crate::raster::image::RasterDataTable;
use crate::raster::{BlendMode, Image};
use crate::transform::{Footprint, Transform};
use crate::uuid::{NodeId, generate_uuid};
use crate::vector::style::{Fill, Stroke, ViewMode};
use crate::vector::{PointId, VectorDataTable};
use crate::{Artboard, Artboard... | @@ -20,22 +20,43 @@ use std::fmt::Write;
#[cfg(feature = "vello")]
use vello::*;
+#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
+pub enum ClickTargetGroup {
+ Subpath(bezier_rs::Subpath<PointId>),
+ PointGroup(ManipulatorGroup<PointId>), | node-graph/gcore/src/graphic_element/renderer.rs | 26 | Rust | 0.571 | suggestion | 176 | 51 | 51 | false | Add overlays for free-floating anchors on hovered/selected vector layers | 2,630 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | seam0s-dev | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/graphic_element/renderer.rs
PR Title: Add overlays for free-floating anchors on hovered/selected vector layers
BEFORE CODE: mod quad;
mod rect;
use crate::raster::image::ImageFrameTable;
use crate::raster::{BlendMode, Image};
use crate::tra... | I don't really understand why this data structure is used anyway? An unconnected point won't have any handles. It would be far more ergonomic just to use a DVec2 and a PointId. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
fn collect_metadata(&self, metadata: &mut RenderMetadata, mut footprint: Footprint, element_id: Option<NodeId>) {
let instance_transform = self.transform();
for instance in self.instance_ref_iter().map(|instance| instance.instance) {
if let Some(element_id) = element_id {
let stroke_width = instance.st... | It is not ergonomic or performant to collect and then iterate. There is no need for this heap allocation. | .flat_map(|instance| {
if !include_stroke {
return instance.instance.bounding_box_with_transform(transform * *instance.transform);
}
let stroke_width = instance.instance.style.stroke().map(|s| s.weight()).unwrap_or_default();
let miter_limit = instance.instance.style.stroke().map(|s| s.line_jo... | @@ -652,10 +698,22 @@ impl GraphicElementRendered for VectorDataTable {
subpath
};
+ // For free-floating anchors, we need to add a click target for each
+ let single_anchors = instance.point_domain.ids().iter().filter(|&&point_id| instance.connected_count(point_id) == 0);
+ let single_anchors_tar... | node-graph/gcore/src/graphic_element/renderer.rs | 26 | Rust | 0.357 | suggestion | 105 | 51 | 51 | false | Add overlays for free-floating anchors on hovered/selected vector layers | 2,630 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | seam0s-dev | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/graphic_element/renderer.rs
PR Title: Add overlays for free-floating anchors on hovered/selected vector layers
BEFORE CODE: }
fn collect_metadata(&self, metadata: &mut RenderMetadata, mut footprint: Footprint, element_id: Option<NodeId>) ... | It is not ergonomic or performant to collect and then iterate. There is no need for this heap allocation. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
.chain(single_anchors_targets.into_iter())
.collect::<Vec<ClickTarget>>();
metadata.click_targets.insert(element_id, click_targets);
}
if let Some(upstream_graphic_group) = &instance.upstream_graphic_group {
footprint.transform *= instance_transform;
upstream_graphic_group.collect_metadata... | There is no need to allocate if you are just going to collect. Also why is this created at the top and used at the bottom of the function? | subpath
};
// For free-floating anchors, we need to add a click target for each
let single_anchors_targets = instance.point_domain.ids().iter().filter_map(|&point_id| {
if instance.connected_count(point_id) == 0 {
let anchor = instance.point_domain.position_from_id(point_id).unwrap_or_defau... | @@ -670,6 +728,18 @@ impl GraphicElementRendered for VectorDataTable {
fn add_upstream_click_targets(&self, click_targets: &mut Vec<ClickTarget>) {
for instance in self.instance_ref_iter() {
+ // For free-floating anchors, we need to add a click target for each
+ let single_anchors = instance.instance.point_... | node-graph/gcore/src/graphic_element/renderer.rs | 26 | Rust | 0.429 | question | 138 | 51 | 51 | false | Add overlays for free-floating anchors on hovered/selected vector layers | 2,630 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | seam0s-dev | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/graphic_element/renderer.rs
PR Title: Add overlays for free-floating anchors on hovered/selected vector layers
BEFORE CODE: .chain(single_anchors_targets.into_iter())
.collect::<Vec<ClickTarget>>();
metadata.click_targets.inse... | There is no need to allocate if you are just going to collect. Also why is this created at the top and used at the bottom of the function? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
let point_in_shape = point_in_shape_checker(corner);
let square_edges_intersect_shape = square_edges_intersect_shape_checker(corner, square_size);
let square_not_outside_shape = point_in_shape || square_edges_intersect_shape;
let square_in_shape = !square_edges_intersect_shape && point_in_shape_checker... | I think there is no need for this option value in the actual logic. Is this for any specific reason? | }
}
pub fn new_filled(
square_size: f64,
offset: DVec2,
width: f64,
height: f64,
point_in_shape_checker: impl Fn(DVec2) -> bool,
line_intersect_shape_checker: impl Fn((f64, f64), (f64, f64)) -> bool,
) -> Self {
// These should divide evenly but rounding is to protect against small numerical impreci... | @@ -209,23 +222,64 @@ impl ActiveListLevel {
}
}
- #[inline(always)]
- pub fn new_filled(square_size: f64, width: f64, height: f64, point_in_shape_checker: impl Fn(DVec2) -> bool, square_edges_intersect_shape_checker: impl Fn(DVec2, f64) -> bool) -> Self {
+ pub fn new_filled(
+ square_size: f64,
+ offset: DVe... | node-graph/gcore/src/vector/algorithms/poisson_disk.rs | 26 | Rust | 0.357 | question | 100 | 51 | 51 | false | Optimize Poisson-disk point sampling by halving the number of line intersection checks with caching | 2,661 | GraphiteEditor/Graphite | 17,935 | Rust | indierusty | Keavon | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/vector/algorithms/poisson_disk.rs
PR Title: Optimize Poisson-disk point sampling by halving the number of line intersection checks with caching
BEFORE CODE:
let point_in_shape = point_in_shape_checker(corner);
let square_edges_inter... | I think there is no need for this option value in the actual logic. Is this for any specific reason? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
#[allow(clippy::too_many_arguments)]
fn calculate_handle_angle(
&mut self,
shape_editor: &mut ShapeState,
document: &DocumentMessageHandler,
responses: &mut VecDeque<Message>,
relative_vector: DVec2,
handle_vector: DVec2,
handle_id: ManipulatorPointId,
lock_angle: bool,
snap_angle: bool,
tangent_... | ```suggestion
// If the handle is dragged over one of its adjacent anchors while holding down the Ctrl key, compute the angle based on the tangent formed with the neighboring anchor points.
``` |
#[allow(clippy::too_many_arguments)]
fn calculate_handle_angle(
&mut self,
shape_editor: &mut ShapeState,
document: &DocumentMessageHandler,
responses: &mut VecDeque<Message>,
relative_vector: DVec2,
handle_vector: DVec2,
handle_id: ManipulatorPointId,
lock_angle: bool,
snap_angle: bool,
tangent_... | @@ -726,18 +727,39 @@ impl PathToolData {
) -> f64 {
let current_angle = -handle_vector.angle_to(DVec2::X);
- if let Some(vector_data) = shape_editor
+ if let Some((vector_data, layer)) = shape_editor
.selected_shape_state
.iter()
.next()
- .and_then(|(layer, _)| document.network_interface.comput... | editor/src/messages/tool/tool_messages/path_tool.rs | 26 | Rust | 0.857 | suggestion | 198 | 51 | 51 | false | Implement angle locking when Ctrl is pressed over an adjacent anchor | 2,663 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 0SlowPoke0 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/path_tool.rs
PR Title: Implement angle locking when Ctrl is pressed over an adjacent anchor
BEFORE CODE:
#[allow(clippy::too_many_arguments)]
fn calculate_handle_angle(
&mut self,
shape_editor: &mut ShapeState,
doc... | ```suggestion
// If the handle is dragged over one of its adjacent anchors while holding down the Ctrl key, compute the angle based on the tangent formed with the neighboring anchor points.
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
.collect::<Vec<_>>();
// Match the behavior of `PathOverlayMode::SelectedPointHandles` when only one point is selected
if shape_editor.selected_points().count() == 1 {
path_overlays(document, DrawHandles::SelectedAnchors(selected_segments), shape_editor, &mut overlay_context);
} else {
... | Please fix the grammar of this sentence, I can't make sense of it currently. | .collect::<Vec<_>>();
// Match the behavior of `PathOverlayMode::SelectedPointHandles` when only one point is selected
if shape_editor.selected_points().count() == 1 {
path_overlays(document, DrawHandles::SelectedAnchors(selected_segments), shape_editor, &mut overlay_context);
} else {
... | @@ -1090,13 +1107,18 @@ impl Fsm for PathToolFsmState {
for (point, attached_segments) in selected_segments_by_point {
if attached_segments.len() == 1 {
segment_endpoints.entry(attached_segments[0]).or_default().push(point);
- } else if !selected_anchors.contains(&point) {
+ ... | editor/src/messages/tool/tool_messages/path_tool.rs | 26 | Rust | 0.214 | nitpick | 76 | 51 | 51 | false | Make the Path tool only allow selecting points that are visible | 2,668 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/path_tool.rs
PR Title: Make the Path tool only allow selecting points that are visible
BEFORE CODE: .collect::<Vec<_>>();
// Match the behavior of `PathOverlayMode::SelectedPointHandles` when only one point is... | Please fix the grammar of this sentence, I can't make sense of it currently. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
fn insert_new_segments(vector_data: &mut VectorData, new_segments: &[[usize; 2]]) {
let mut next_id = vector_data.segment_domain.next_id();
for &[start, end] in new_segments {
vector_data.segment_domain.push(next_id.next_id(), start, end, bezier_rs::BezierHandles::Linear, StrokeId::ZERO);
}
}
let mut segm... | Remove the name, since it gets auto-generated. |
fn insert_new_segments(vector_data: &mut VectorData, new_segments: &[[usize; 2]]) {
let mut next_id = vector_data.segment_domain.next_id();
for &[start, end] in new_segments {
vector_data.segment_domain.push(next_id.next_id(), start, end, bezier_rs::BezierHandles::Linear, StrokeId::ZERO);
}
}
let mut segm... | @@ -1715,6 +1715,29 @@ fn bevel(_: impl Ctx, source: VectorDataTable, #[default(10.)] distance: Length)
result
}
+#[node_macro::node(name("Close Path"), category("Vector"), path(graphene_core::vector))] | node-graph/gcore/src/vector/vector_nodes.rs | 26 | Rust | 0.143 | suggestion | 46 | 51 | 51 | false | New nodes: 'Point Inside Shape' and 'Close Path' | 2,673 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 0SlowPoke0 | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/vector/vector_nodes.rs
PR Title: New nodes: 'Point Inside Shape' and 'Close Path'
BEFORE CODE:
fn insert_new_segments(vector_data: &mut VectorData, new_segments: &[[usize; 2]]) {
let mut next_id = vector_data.segment_domain.next_id();
... | Remove the name, since it gets auto-generated. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
#[node_macro::node(category("Vector"), path(graphene_core::vector))]
fn bevel(_: impl Ctx, source: VectorDataTable, #[default(10.)] distance: Length) -> VectorDataTable {
let source_transform = source.transform();
let source = source.one_instance_ref().instance;
let mut result = VectorDataTable::new(bevel_algorithm... | Remove the name, since it must match its function name and we prefer to just call it "Point Inside". The name should be used only for changing the capitalization and whitespace styling if the autogeneration doesn't work. | #[node_macro::node(category("Vector"), path(graphene_core::vector))]
fn bevel(_: impl Ctx, source: VectorDataTable, #[default(10.)] distance: Length) -> VectorDataTable {
let source_transform = source.transform();
let source = source.one_instance_ref().instance;
let mut result = VectorDataTable::new(bevel_algorithm... | @@ -1715,6 +1715,29 @@ fn bevel(_: impl Ctx, source: VectorDataTable, #[default(10.)] distance: Length)
result
}
+#[node_macro::node(name("Close Path"), category("Vector"), path(graphene_core::vector))]
+fn close_path(_: impl Ctx, source: VectorDataTable) -> VectorDataTable {
+ let mut new_table = VectorDataTable:... | node-graph/gcore/src/vector/vector_nodes.rs | 26 | Rust | 0.5 | suggestion | 220 | 51 | 51 | false | New nodes: 'Point Inside Shape' and 'Close Path' | 2,673 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 0SlowPoke0 | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/vector/vector_nodes.rs
PR Title: New nodes: 'Point Inside Shape' and 'Close Path'
BEFORE CODE: #[node_macro::node(category("Vector"), path(graphene_core::vector))]
fn bevel(_: impl Ctx, source: VectorDataTable, #[default(10.)] distance: Leng... | Remove the name, since it must match its function name and we prefer to just call it "Point Inside". The name should be used only for changing the capitalization and whitespace styling if the autogeneration doesn't work. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
insert_new_segments(&mut vector_data, &new_segments);
vector_data
}
#[node_macro::node(category("Vector"), path(graphene_core::vector))]
fn bevel(_: impl Ctx, source: VectorDataTable, #[default(10.)] distance: Length) -> VectorDataTable {
let source_transform = source.transform();
let source = source.one_instance... | You don't need to construct a new instance composed of all the same fields as the current instance. Just push the current instance (`source_instance`). | insert_new_segments(&mut vector_data, &new_segments);
vector_data
}
#[node_macro::node(category("Vector"), path(graphene_core::vector))]
fn bevel(_: impl Ctx, source: VectorDataTable, #[default(10.)] distance: Length) -> VectorDataTable {
let source_transform = source.transform();
let source = source.one_instance... | @@ -1715,6 +1715,29 @@ fn bevel(_: impl Ctx, source: VectorDataTable, #[default(10.)] distance: Length)
result
}
+#[node_macro::node(name("Close Path"), category("Vector"), path(graphene_core::vector))]
+fn close_path(_: impl Ctx, source: VectorDataTable) -> VectorDataTable {
+ let mut new_table = VectorDataTable:... | node-graph/gcore/src/vector/vector_nodes.rs | 26 | Rust | 0.5 | suggestion | 151 | 51 | 51 | false | New nodes: 'Point Inside Shape' and 'Close Path' | 2,673 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 0SlowPoke0 | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/vector/vector_nodes.rs
PR Title: New nodes: 'Point Inside Shape' and 'Close Path'
BEFORE CODE: insert_new_segments(&mut vector_data, &new_segments);
vector_data
}
#[node_macro::node(category("Vector"), path(graphene_core::vector))]
fn be... | You don't need to construct a new instance composed of all the same fields as the current instance. Just push the current instance (`source_instance`). | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
pub fn closest_point_to_viewport(&self) -> DVec2 {
self.bezier_point_to_viewport
}
/// Updates this [`ClosestSegment`] with the viewport-space location of the closest point on the segment to the given mouse position.
pub fn update_closest_point(&mut self, document_metadata: &DocumentMetadata, mouse_position:... | ```suggestion
tolerance.powi(2) < self.distance_squared(mouse_position)
``` | }
pub fn points(&self) -> [PointId; 2] {
self.points
}
pub fn closest_point_to_viewport(&self) -> DVec2 {
self.bezier_point_to_viewport
}
pub fn closest_point(&self, document_metadata: &DocumentMetadata) -> DVec2 {
let transform = document_metadata.transform_to_viewport(self.layer);
let bezier_point = ... | @@ -182,10 +180,9 @@ impl ClosestSegment {
self.bezier_point_to_viewport.distance_squared(mouse_position)
}
- pub fn too_far(&self, mouse_position: DVec2, tolerance: f64, document_metadata: &DocumentMetadata) -> bool {
+ pub fn too_far(&self, mouse_position: DVec2, tolerance: f64) -> bool {
let dist_sq = self... | editor/src/messages/tool/common_functionality/shape_editor.rs | 26 | Rust | 0.643 | suggestion | 79 | 51 | 51 | false | Fix the Path tool's segment insertion line overlay having hysteresis with distance away from the cursor | 2,677 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | 4adex | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/common_functionality/shape_editor.rs
PR Title: Fix the Path tool's segment insertion line overlay having hysteresis with distance away from the cursor
BEFORE CODE: }
pub fn closest_point_to_viewport(&self) -> DVec2 {
self.bezier_poi... | ```suggestion
tolerance.powi(2) < self.distance_squared(mouse_position)
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
}
}
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq)]
#[serde(default)]
pub struct GridSnapping {
pub origin: DVec2,
pub grid_type: GridType,
pub rectangular_spacing: DVec2,
pub isometric_y_spacing: f64,
pub isometric_angle_a: f64,
pub isometric_angle_b: f64,
pub grid_color: Color,
... | ```suggestion
isometric_y_spacing: 1.,
isometric_angle_a: 30.,
isometric_angle_b: 30.,
``` | }
}
}
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq)]
#[serde(default)]
pub struct GridSnapping {
pub origin: DVec2,
pub grid_type: GridType,
pub rectangular_spacing: DVec2,
pub isometric_y_spacing: f64,
pub isometric_angle_a: f64,
pub isometric_angle_b: f64,
pub grid_color: Color,
... | @@ -227,6 +225,10 @@ impl Default for GridSnapping {
Self {
origin: DVec2::ZERO,
grid_type: Default::default(),
+ rectangular_spacing: DVec2::ONE,
+ isometric_y_spacing: 1.0,
+ isometric_angle_a: 30.0,
+ isometric_angle_b: 30.0, | editor/src/messages/portfolio/document/utility_types/misc.rs | 26 | Rust | 0.714 | suggestion | 103 | 51 | 51 | false | Fix grid overlay values getting wiped when switching between isometric/rectangular and back | 2,702 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | mTvare6 | Review this pull request change.
Language: Rust
File: editor/src/messages/portfolio/document/utility_types/misc.rs
PR Title: Fix grid overlay values getting wiped when switching between isometric/rectangular and back
BEFORE CODE: }
}
}
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq)]
#[s... | ```suggestion
isometric_y_spacing: 1.,
isometric_angle_a: 30.,
isometric_angle_b: 30.,
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
let mut used_length = total_length - start_offset - stop_offset;
if used_length <= 0. {
return None;
}
// Determine the number of points to generate along the path.
let sample_count = if adaptive_spacing {
// Calculate point count to evenly distribute points while covering the entire path.
// With adaptive... | ```suggestion
// Decide how many loop-iterations: if closed, skip the last duplicate point
``` | let mut used_length = total_length - start_offset - stop_offset;
if used_length <= 0. {
return None;
}
// Determine the number of points to generate along the path.
let sample_count = if adaptive_spacing {
// Calculate point count to evenly distribute points while covering the entire path.
// With adaptive... | @@ -50,11 +52,15 @@ pub fn sample_points_on_bezpath(bezpath: BezPath, spacing: f64, start_offset: f6
return None;
}
+ // decide how many loop-iterations: if closed, skip the last duplicate point | node-graph/gcore/src/vector/algorithms/bezpath_algorithms.rs | 26 | Rust | 0.571 | refactor | 97 | 51 | 51 | false | Fix Sample Points node to avoid duplicating endpoints instead of closing its sampled paths | 2,714 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | Ezbaze | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/vector/algorithms/bezpath_algorithms.rs
PR Title: Fix Sample Points node to avoid duplicating endpoints instead of closing its sampled paths
BEFORE CODE: let mut used_length = total_length - start_offset - stop_offset;
if used_length <= 0... | ```suggestion
// Decide how many loop-iterations: if closed, skip the last duplicate point
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
f.write_fmt(format_args!(
"node({}) → {}",
[&self.call_argument].into_iter().chain(&self.inputs).map(|input| input.to_string()).collect::<Vec<_>>().join(", "),
self.return_value
))
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, specta::Type)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde:... | I'm unsure whether this will cause breakage or not. While `core` would still compile, `alloc` shouldn't since I removed the `external crate alloc;`. Even if this particular migration code may be fine to be changed, it could indicate trouble with other documents in the wild. At least the demo artworks are unaffected. | f.write_fmt(format_args!(
"node({}) → {}",
[&self.call_argument].into_iter().chain(&self.inputs).map(|input| input.to_string()).collect::<Vec<_>>().join(", "),
self.return_value
))
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash, specta::Type)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde:... | @@ -144,7 +141,7 @@ fn migrate_type_descriptor_names<'de, D: serde::Deserializer<'de>>(deserializer:
let name = String::deserialize(deserializer)?;
let name = match name.as_str() {
"f32" => "f64".to_string(),
- "graphene_core::transform::Footprint" => "core::option::Option<alloc::sync::Arc<graphene_core::contex... | node-graph/gcore/src/types.rs | 26 | Rust | 0.643 | suggestion | 317 | 51 | 51 | false | Make `gcore` a std library and remove `std`, `alloc`, and more unused features | 2,724 | GraphiteEditor/Graphite | 17,935 | Rust | Firestar99 | Firestar99 | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/types.rs
PR Title: Make `gcore` a std library and remove `std`, `alloc`, and more unused features
BEFORE CODE: f.write_fmt(format_args!(
"node({}) → {}",
[&self.call_argument].into_iter().chain(&self.inputs).map(|input| input.to_stri... | I'm unsure whether this will cause breakage or not. While `core` would still compile, `alloc` shouldn't since I removed the `external crate alloc;`. Even if this particular migration code may be fine to be changed, it could indicate trouble with other documents in the wild. At least the demo artworks are unaffected. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
WidgetOverride::Number(NumberInputSettings {
min: Some(1.),
unit: Some(" px".to_string()),
..Default::default()
}),
),
PropertiesRow::with_override(
"Start Offset",
"Exclude some distance from the start of the path before the first instance.",
Widge... | Please be consistent with Title Case. | /// Defines the logic for inputs to display a custom properties panel widget.
fn static_input_properties() -> InputProperties {
let mut map: InputProperties = HashMap::new();
map.insert("hidden".to_string(), Box::new(|_node_id, _index, _context| Ok(Vec::new())));
map.insert(
"string".to_string(),
Box::new(|node_... | @@ -2397,6 +2399,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
}),
),
Into::<PropertiesRow>::into(("Adaptive Spacing", "Round 'Spacing' to a nearby value that divides into the path length evenly.")),
+ Into::<PropertiesRow>::into(("Count points", "Calculate the distance between poin... | editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs | 26 | Rust | 0.071 | suggestion | 37 | 51 | 51 | false | Rename 'Sample Points' node to 'Sample Polyline' and add a parameter spacing based on separation or quantity | 2,727 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | Moharum1 | Review this pull request change.
Language: Rust
File: editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs
PR Title: Rename 'Sample Points' node to 'Sample Polyline' and add a parameter spacing based on separation or quantity
BEFORE CODE: WidgetOverride::Number(NumberInputSettings {... | Please be consistent with Title Case. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
match segment {
PathSeg::Line(line) => line.deriv().eval(t),
PathSeg::Quad(quad_bez) => quad_bez.deriv().eval(t),
PathSeg::Cubic(cubic_bez) => cubic_bez.deriv().eval(t),
}
}
pub fn sample_points_on_bezpath(bezpath: BezPath, spacing: f64, start_offset: f64, stop_offset: f64, adaptive_spacing: bool, count_points... | You'll need to always run `rustfmt` before committing, if your editor isn't configured to do that on save. | let (segment_index, t) = t_value_to_parametric(bezpath, t, euclidian, None);
let segment = bezpath.get_seg(segment_index + 1).unwrap();
// Divide the segment.
let first_segment = segment.subsegment(0.0..t);
let second_segment = segment.subsegment(t..1.);
let mut first_bezpath = BezPath::new();
let mut second_b... | @@ -34,17 +34,21 @@ pub fn sample_points_on_bezpath(bezpath: BezPath, spacing: f64, start_offset: f6
}
// Determine the number of points to generate along the path.
- let sample_count = if adaptive_spacing {
- // Calculate point count to evenly distribute points while covering the entire path.
- // With adaptiv... | node-graph/gcore/src/vector/algorithms/bezpath_algorithms.rs | 26 | Rust | 0.5 | suggestion | 106 | 51 | 51 | false | Rename 'Sample Points' node to 'Sample Polyline' and add a parameter spacing based on separation or quantity | 2,727 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | Moharum1 | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/vector/algorithms/bezpath_algorithms.rs
PR Title: Rename 'Sample Points' node to 'Sample Polyline' and add a parameter spacing based on separation or quantity
BEFORE CODE: match segment {
PathSeg::Line(line) => line.deriv().eval(t),
Pat... | You'll need to always run `rustfmt` before committing, if your editor isn't configured to do that on save. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
}
if let Self::Dragging { .. } = self {
let quad = Quad::from_box([tool_data.drag_start, tool_data.drag_current]);
let document_start = document.metadata().document_to_viewport.inverse().transform_point2(quad.top_left());
let document_current = document.metadata().document_to_viewport.inverse().... | This overlay code is basically the same as for the <kbd>G</kbd> translation. Please consolidate this into a function inside overlay_context to reduce code duplication.
https://github.com/GraphiteEditor/Graphite/blob/49db963ce1067bc40af822e6e46d8777a4db7281/editor/src/messages/tool/transform_layer/transform_layer_messa... | let has_layers = document.network_interface.selected_nodes().has_selected_nodes();
let draw_pivot = tool_data.pivot_gizmo.state.is_pivot() && overlay_context.visibility_settings.pivot() && has_layers;
tool_data.pivot_gizmo.pivot.recalculate_pivot(document);
let pivot = draw_pivot.then_some(tool_data.piv... | @@ -837,6 +837,33 @@ impl Fsm for SelectToolFsmState {
(SelectionShapeType::Lasso, _) => overlay_context.polygon(polygon, None, fill_color),
}
}
+
+ if let Self::Dragging { .. } = self {
+ let quad = Quad::from_box([tool_data.drag_start, tool_data.drag_current]);
+ let document_start = docu... | editor/src/messages/tool/tool_messages/select_tool.rs | 26 | Rust | 0.571 | suggestion | 343 | 51 | 51 | false | Add X and Y offset distance overlay while dragging with the Select tool | 2,814 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | Kavin006 | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/select_tool.rs
PR Title: Add X and Y offset distance overlay while dragging with the Select tool
BEFORE CODE: }
if let Self::Dragging { .. } = self {
let quad = Quad::from_box([tool_data.drag_start, tool_data.... | This overlay code is basically the same as for the <kbd>G</kbd> translation. Please consolidate this into a function inside overlay_context to reduce code duplication.
https://github.com/GraphiteEditor/Graphite/blob/49db963ce1067bc40af822e6e46d8777a4db7281/editor/src/messages/tool/transform_layer/transform_layer_messa... | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
#[default(0.)]
tilt: f64,
) -> VectorDataTable {
let typesetting = TypesettingConfig {
font_size,
line_height_ratio,
character_spacing,
max_width,
max_height,
tilt,
};
let font_data = editor.font_cache.get(&font_name).map(|f| load_font(f));
let glyph_vectors = to_path(&text, font_data, typesetting);... | To position the glyph within the text, do we want to apply a transform here instead of to all of the points? | use crate::vector::VectorDataTable;
use graph_craft::wasm_application_io::WasmEditorApi;
use graphene_core::Ctx;
pub use graphene_core::text::*;
#[node_macro::node(category(""))]
fn text<'i: 'n>(
_: impl Ctx,
editor: &'i WasmEditorApi,
text: String,
font_name: Font,
#[unit(" px")]
#[default(24.)]
font_size: f64... | @@ -39,7 +40,23 @@ fn text<'i: 'n>(
let font_data = editor.font_cache.get(&font_name).map(|f| load_font(f));
- let result = VectorData::from_subpaths(to_path(&text, font_data, typesetting), false);
+ let glyph_vectors = to_path(&text, font_data, typesetting);
- VectorDataTable::new(result)
+ let mut glyph_table... | node-graph/gstd/src/text.rs | 26 | Rust | 0.429 | question | 108 | 35 | 48 | false | Separate the Text node's generated glyphs into separate vector table rows | 2,821 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | BKSalman | Review this pull request change.
Language: Rust
File: node-graph/gstd/src/text.rs
PR Title: Separate the Text node's generated glyphs into separate vector table rows
BEFORE CODE: #[default(0.)]
tilt: f64,
) -> VectorDataTable {
let typesetting = TypesettingConfig {
font_size,
line_height_ratio,
character_s... | To position the glyph within the text, do we want to apply a transform here instead of to all of the points? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
match self {
Self::GraphicGroup(instances) => instances.render_complexity(),
Self::VectorData(instances) => instances.render_complexity(),
Self::RasterDataCPU(instances) => instances.render_complexity(),
Self::RasterDataGPU(instances) => instances.render_complexity(),
}
}
}
impl RenderComplexity for V... | you can probably set the render complexity for gpu textures to infinite as we currently can't generate thumbnails for them anyway | impl RenderComplexity for GraphicElement {
fn render_complexity(&self) -> usize {
match self {
Self::GraphicGroup(instances) => instances.render_complexity(),
Self::VectorData(instances) => instances.render_complexity(),
Self::RasterDataCPU(instances) => instances.render_complexity(),
Self::RasterDataGPU... | @@ -0,0 +1,58 @@
+use crate::raster_types::{CPU, GPU, Raster};
+use crate::{Artboard, Color, GraphicElement, instances::Instances, vector::VectorData};
+use glam::DVec2;
+
+pub trait RenderComplexity {
+ fn render_complexity(&self) -> usize {
+ 0
+ }
+}
+
+impl<T: RenderComplexity> RenderComplexity for Instances<T> {
... | node-graph/gcore/src/render_complexity.rs | 26 | Rust | 0.357 | performance | 129 | 35 | 38 | false | Add a complexity limit on displaying layer thumbnails to improve performance | 2,828 | GraphiteEditor/Graphite | 17,935 | Rust | TrueDoctor | 0HyperCube | Review this pull request change.
Language: Rust
File: node-graph/gcore/src/render_complexity.rs
PR Title: Add a complexity limit on displaying layer thumbnails to improve performance
BEFORE CODE: match self {
Self::GraphicGroup(instances) => instances.render_complexity(),
Self::VectorData(instances) => inst... | you can probably set the render complexity for gpu textures to infinite as we currently can't generate thumbnails for them anyway | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
#[node_macro::node(category("Value"))]
fn gradient_value(_: impl Ctx, _primary: (), gradient: GradientStops) -> GradientStops {
gradient
}
/// Constructs a string value which may be set to any plain text.
#[node_macro::node(category("Value"))]
fn string_value(_: impl Ctx, _primary: (), string: TextArea) -> String {
... | The `normalize` function can cause a crash if the length is zero. Consider using `normalize_or_zero`. | #[node_macro::node(category("Value"))]
fn gradient_value(_: impl Ctx, _primary: (), gradient: GradientStops) -> GradientStops {
gradient
}
/// Constructs a string value which may be set to any plain text.
#[node_macro::node(category("Value"))]
fn string_value(_: impl Ctx, _primary: (), string: TextArea) -> String {
... | @@ -612,6 +612,18 @@ fn dot_product(_: impl Ctx, vector_a: DVec2, vector_b: DVec2) -> f64 {
vector_a.dot(vector_b)
}
+/// Gets the length or magnitude of a vector.
+#[node_macro::node(category("Math: Vector"))]
+fn length(_: impl Ctx, vector: DVec2) -> f64 {
+ vector.length()
+}
+
+/// Scales the input vector to u... | node-graph/gmath-nodes/src/lib.rs | 26 | Rust | 0.571 | bug | 101 | 51 | 51 | false | Add Normalize and Length nodes | 2,837 | GraphiteEditor/Graphite | 17,935 | Rust | 0HyperCube | celyk | Review this pull request change.
Language: Rust
File: node-graph/gmath-nodes/src/lib.rs
PR Title: Add Normalize and Length nodes
BEFORE CODE: #[node_macro::node(category("Value"))]
fn gradient_value(_: impl Ctx, _primary: (), gradient: GradientStops) -> GradientStops {
gradient
}
/// Constructs a string value whi... | The `normalize` function can cause a crash if the length is zero. Consider using `normalize_or_zero`. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Some(texture_view),
);
}
renderer
.render_to_texture(&self.context.device, &self.context.queue, scene, &surface.surface.target_view, &render_params)
.unwrap();
}
let surface_texture = surface_inner.get_current_texture()?;
let mut encoder = self.context.device.create_command_encoder(&wgpu::... | In wasm we're rendering to a texture of size 0...
Now I don't know why, but this code *sometimes* works for me on FF nightly anyway. (inconsistent) | },
);
let [r, g, b, _] = background.to_rgba8_srgb();
let render_params = RenderParams {
// We are using an explicit opaque color here to eliminate the alpha premultiplication step
// which would be required to support a transparent webgpu canvas
base_color: vello::peniko::Color::from_rgba8(r, g, b, 0... | @@ -105,12 +121,39 @@ impl WgpuExecutor {
#[cfg(target_arch = "wasm32")]
pub fn create_surface(&self, canvas: graphene_application_io::WasmSurfaceHandle) -> Result<SurfaceHandle<Surface>> {
let surface = self.context.instance.create_surface(wgpu::SurfaceTarget::Canvas(canvas.surface))?;
+ let size = UVec2::ZERO... | node-graph/wgpu-executor/src/lib.rs | 26 | Rust | 0.357 | suggestion | 150 | 51 | 51 | false | Upgrade vello to version 0.5.0 and wgpu to version 25 | 2,890 | GraphiteEditor/Graphite | 17,935 | Rust | Firestar99 | mTvare6 | Review this pull request change.
Language: Rust
File: node-graph/wgpu-executor/src/lib.rs
PR Title: Upgrade vello to version 0.5.0 and wgpu to version 25
BEFORE CODE: Some(texture_view),
);
}
renderer
.render_to_texture(&self.context.device, &self.context.queue, scene, &surface.surface.target_vie... | In wasm we're rendering to a texture of size 0...
Now I don't know why, but this code *sometimes* works for me on FF nightly anyway. (inconsistent) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
use crate::render_ext::RenderExt;
use crate::to_peniko::BlendModeExt;
use bezier_rs::Subpath;
use dyn_any::DynAny;
use glam::{DAffine2, DVec2};
use graphene_core::blending::BlendMode;
use graphene_core::bounds::BoundingBox;
use graphene_core::color::Color;
use graphene_core::instances::Instance;
use graphene_core::math... | Should this also be covered by the `#[cfg(feature = "vello")]`? | use crate::render_ext::RenderExt;
use crate::to_peniko::BlendModeExt;
use bezier_rs::Subpath;
use dyn_any::DynAny;
use glam::{DAffine2, DVec2};
use graphene_core::blending::BlendMode;
use graphene_core::bounds::BoundingBox;
use graphene_core::color::Color;
use graphene_core::instances::Instance;
use graphene_core::math... | @@ -16,10 +16,13 @@ use graphene_core::uuid::{NodeId, generate_uuid};
use graphene_core::vector::VectorDataTable;
use graphene_core::vector::click_target::{ClickTarget, FreePoint};
use graphene_core::vector::style::{Fill, Stroke, StrokeAlign, ViewMode};
-use graphene_core::{AlphaBlending, Artboard, ArtboardGroupTabl... | node-graph/gsvg-renderer/src/renderer.rs | 25 | Rust | 0.429 | question | 63 | 50 | 50 | false | Re-add upload texture | 2,915 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | Firestar99 | Review this pull request change.
Language: Rust
File: node-graph/gsvg-renderer/src/renderer.rs
PR Title: Re-add upload texture
BEFORE CODE: use crate::render_ext::RenderExt;
use crate::to_peniko::BlendModeExt;
use bezier_rs::Subpath;
use dyn_any::DynAny;
use glam::{DAffine2, DVec2};
use graphene_core::blending::Ble... | Should this also be covered by the `#[cfg(feature = "vello")]`? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
use render::FrameBuffer;
mod app;
use app::WinitApp;
#[derive(Debug)]
pub(crate) enum CustomEvent {
UiUpdate(FrameBuffer),
ScheduleBrowserWork(Instant),
}
fn main() {
tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init();
let cef_context = match cef::Context::<Setup>::new() {
Ok(c) =... | names could be more expressive | use render::FrameBuffer;
mod app;
use app::WinitApp;
mod dirs;
#[derive(Debug)]
pub(crate) enum CustomEvent {
UiUpdate(FrameBuffer),
ScheduleBrowserWork(Instant),
}
fn main() {
tracing_subscriber::fmt().with_env_filter(EnvFilter::from_default_env()).init();
let cef_context = match cef::Context::<Setup>::new() ... | @@ -146,20 +32,11 @@ fn main() {
}
};
- let window_state = WindowState::new().handle();
-
- window_state
- .with(|s| {
- s.width = Some(1200);
- s.height = Some(800);
- })
- .unwrap();
-
let event_loop = EventLoop::<CustomEvent>::with_user_event().build().unwrap();
- window_state.with(|s| s.event_loop... | desktop/src/main.rs | 26 | Rust | 0.143 | suggestion | 30 | 42 | 44 | false | Desktop: Refactor window state to not require locking | 2,928 | GraphiteEditor/Graphite | 17,935 | Rust | timon-schelling | TrueDoctor | Review this pull request change.
Language: Rust
File: desktop/src/main.rs
PR Title: Desktop: Refactor window state to not require locking
BEFORE CODE: use render::FrameBuffer;
mod app;
use app::WinitApp;
#[derive(Debug)]
pub(crate) enum CustomEvent {
UiUpdate(FrameBuffer),
ScheduleBrowserWork(Instant),
}
fn ma... | names could be more expressive | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
cef_schedule: Option<Instant>,
ui_frame_buffer: Option<FrameBuffer>,
window_size_sender: Sender<WindowSize>,
_viewport_frame_buffer: Option<FrameBuffer>,
graphics_state: Option<GraphicsState>,
event_loop_proxy: EventLoopProxy<CustomEvent>,
}
impl WinitApp {
pub(crate) fn new(cef_context: cef::Context<cef::Initi... | Why is this increased to 1 sec | cef_schedule: Option<Instant>,
ui_frame_buffer: Option<FrameBuffer>,
window_size_sender: Sender<WindowSize>,
_viewport_frame_buffer: Option<FrameBuffer>,
graphics_state: Option<GraphicsState>,
event_loop_proxy: EventLoopProxy<CustomEvent>,
}
impl WinitApp {
pub(crate) fn new(cef_context: cef::Context<cef::Initi... | @@ -1,46 +1,60 @@
use crate::CustomEvent;
-use crate::WindowState;
-use crate::WindowStateHandle;
+use crate::FrameBuffer;
+use crate::WindowSize;
use crate::render::GraphicsState;
use std::sync::Arc;
+use std::sync::mpsc::Sender;
use std::time::Duration;
use std::time::Instant;
use winit::application::Applicatio... | desktop/src/app.rs | 26 | Rust | 0.071 | suggestion | 30 | 51 | 51 | false | Desktop: Refactor window state to not require locking | 2,928 | GraphiteEditor/Graphite | 17,935 | Rust | timon-schelling | TrueDoctor | Review this pull request change.
Language: Rust
File: desktop/src/app.rs
PR Title: Desktop: Refactor window state to not require locking
BEFORE CODE: cef_schedule: Option<Instant>,
ui_frame_buffer: Option<FrameBuffer>,
window_size_sender: Sender<WindowSize>,
_viewport_frame_buffer: Option<FrameBuffer>,
graphic... | Why is this increased to 1 sec | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
impl WinitApp {
pub(crate) fn new(cef_context: cef::Context<cef::Initialized>, window_size_sender: Sender<WindowSize>, event_loop_proxy: EventLoopProxy<CustomEvent>) -> Self {
Self {
cef_context,
window: None,
cef_schedule: Some(Instant::now()),
_viewport_frame_buffer: None,
ui_frame_buffer: None,
... | Do we want to call work here? it is already called every millisecond |
impl WinitApp {
pub(crate) fn new(cef_context: cef::Context<cef::Initialized>, window_size_sender: Sender<WindowSize>, event_loop_proxy: EventLoopProxy<CustomEvent>) -> Self {
Self {
cef_context,
window: None,
cef_schedule: Some(Instant::now()),
_viewport_frame_buffer: None,
ui_frame_buffer: None,
... | @@ -1,46 +1,60 @@
use crate::CustomEvent;
-use crate::WindowState;
-use crate::WindowStateHandle;
+use crate::FrameBuffer;
+use crate::WindowSize;
use crate::render::GraphicsState;
use std::sync::Arc;
+use std::sync::mpsc::Sender;
use std::time::Duration;
use std::time::Instant;
use winit::application::Applicatio... | desktop/src/app.rs | 26 | Rust | 0.214 | question | 68 | 51 | 51 | false | Desktop: Refactor window state to not require locking | 2,928 | GraphiteEditor/Graphite | 17,935 | Rust | timon-schelling | TrueDoctor | Review this pull request change.
Language: Rust
File: desktop/src/app.rs
PR Title: Desktop: Refactor window state to not require locking
BEFORE CODE:
impl WinitApp {
pub(crate) fn new(cef_context: cef::Context<cef::Initialized>, window_size_sender: Sender<WindowSize>, event_loop_proxy: EventLoopProxy<CustomEvent>... | Do we want to call work here? it is already called every millisecond | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
use std::fmt::Debug;
use std::process::exit;
use std::time::Instant;
use tracing_subscriber::EnvFilter;
use winit::event_loop::EventLoop;
mod cef;
use cef::{Setup, WindowSize};
mod render;
use render::WgpuContext;
mod app;
use app::WinitApp;
mod dirs;
#[derive(Debug)]
pub(crate) enum CustomEvent {
UiUpdate((wgpu... | Could be something like:
```
UiUpdate {
Texture,
width,
height,
}
``` | use std::fmt::Debug;
use std::process::exit;
use std::time::Instant;
use tracing_subscriber::EnvFilter;
use winit::event_loop::EventLoop;
mod cef;
use cef::{Setup, WindowSize};
mod render;
use render::WgpuContext;
mod app;
use app::WinitApp;
mod dirs;
#[derive(Debug)]
pub(crate) enum CustomEvent {
UiUpdate(wgpu:... | @@ -18,7 +18,7 @@ mod dirs;
#[derive(Debug)]
pub(crate) enum CustomEvent {
- UiUpdate(FrameBuffer),
+ UiUpdate((wgpu::Texture, u32, u32)), | desktop/src/main.rs | 21 | Rust | 0.643 | suggestion | 77 | 46 | 46 | false | Desktop: Directly upload frame buffer | 2,930 | GraphiteEditor/Graphite | 17,935 | Rust | timon-schelling | TrueDoctor | Review this pull request change.
Language: Rust
File: desktop/src/main.rs
PR Title: Desktop: Directly upload frame buffer
BEFORE CODE: use std::fmt::Debug;
use std::process::exit;
use std::time::Instant;
use tracing_subscriber::EnvFilter;
use winit::event_loop::EventLoop;
mod cef;
use cef::{Setup, WindowSize};
m... | Could be something like:
```
UiUpdate {
Texture,
width,
height,
}
``` | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
use crate::CustomEvent;
use crate::WindowSize;
use crate::render::GraphicsState;
use crate::render::WgpuContext;
use std::sync::Arc;
use std::sync::mpsc::Sender;
use std::time::Duration;
use std::time::Instant;
use winit::application::ApplicationHandler;
use winit::dpi::PhysicalSize;
use winit::event::StartCause;
use w... | This will not be used In the future right?
I think you should remove both frame buffers | use crate::CustomEvent;
use crate::WindowSize;
use crate::render::GraphicsState;
use crate::render::WgpuContext;
use std::sync::Arc;
use std::sync::mpsc::Sender;
use std::time::Duration;
use std::time::Instant;
use winit::application::ApplicationHandler;
use winit::dpi::PhysicalSize;
use winit::event::StartCause;
use w... | @@ -22,33 +22,36 @@ pub(crate) struct WinitApp {
pub(crate) cef_context: cef::Context<cef::Initialized>,
pub(crate) window: Option<Arc<Window>>,
cef_schedule: Option<Instant>,
- ui_frame_buffer: Option<FrameBuffer>,
+ _ui_frame_buffer: Option<wgpu::Texture>,
window_size_sender: Sender<WindowSize>,
- _viewport_f... | desktop/src/app.rs | 26 | Rust | 0.286 | suggestion | 87 | 51 | 51 | false | Desktop: Directly upload frame buffer | 2,930 | GraphiteEditor/Graphite | 17,935 | Rust | timon-schelling | TrueDoctor | Review this pull request change.
Language: Rust
File: desktop/src/app.rs
PR Title: Desktop: Directly upload frame buffer
BEFORE CODE: use crate::CustomEvent;
use crate::WindowSize;
use crate::render::GraphicsState;
use crate::render::WgpuContext;
use std::sync::Arc;
use std::sync::mpsc::Sender;
use std::time::Durat... | This will not be used In the future right?
I think you should remove both frame buffers | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
responses.add(NodeGraphMessage::RunDocumentGraph);
} else {
let Some(network_metadata) = self.network_interface.network_metadata(&self.breadcrumb_network_path) else {
return;
};
let transform = self
.navigation_handler
.calculate_offset_transform(ipp.viewport_bounds.center(), ... | what parts? (answer: zooming to fill bounds) ~~Ideally the editor should not be aware of the bounds at all, since it treats the top left corner of the vieport at (0,0). Only the executor should know the bounds in order to evaluate the node graph.~~ | responses.add(NodeGraphMessage::RunDocumentGraph);
} else {
let Some(network_metadata) = self.network_interface.network_metadata(&self.breadcrumb_network_path) else {
return;
};
let transform = self
.navigation_handler
.calculate_offset_transform(ipp.viewport_bounds.center(), ... | @@ -1435,6 +1435,20 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
},
})
}
+ // Some parts of the editior depend on these bounds to be present | editor/src/messages/portfolio/document/document_message_handler.rs | 26 | Rust | 0.5 | question | 248 | 51 | 51 | false | Add handler for deferred execution of messages | 2,951 | GraphiteEditor/Graphite | 17,935 | Rust | adamgerhant | TrueDoctor | Review this pull request change.
Language: Rust
File: editor/src/messages/portfolio/document/document_message_handler.rs
PR Title: Add handler for deferred execution of messages
BEFORE CODE: responses.add(NodeGraphMessage::RunDocumentGraph);
} else {
let Some(network_metadata) = self.network_interface... | what parts? (answer: zooming to fill bounds) ~~Ideally the editor should not be aware of the bounds at all, since it treats the top left corner of the vieport at (0,0). Only the executor should know the bounds in order to evaluate the node graph.~~ | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
.navigation_handler
.calculate_offset_transform(ipp.viewport_bounds.center(), &network_metadata.persistent_metadata.navigation_metadata.node_graph_ptz);
self.network_interface.set_transform(transform, &self.breadcrumb_network_path);
responses.add(DocumentMessage::RenderRulers);
responses.add... | The bounds here refer to the bounds of all layers in document space. This has nothing to do with the viewport being ready | .navigation_handler
.calculate_offset_transform(ipp.viewport_bounds.center(), &network_metadata.persistent_metadata.navigation_metadata.node_graph_ptz);
self.network_interface.set_transform(transform, &self.breadcrumb_network_path);
responses.add(DocumentMessage::RenderRulers);
responses.add... | @@ -1435,6 +1435,20 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
},
})
}
+ // Some parts of the editior depend on these bounds to be present
+ let bounds = if self.graph_view_overlay_open {
+ self.network_interface.all_nodes_bounding_box(&self.breadcrum... | editor/src/messages/portfolio/document/document_message_handler.rs | 26 | Rust | 0.357 | suggestion | 121 | 51 | 51 | false | Add handler for deferred execution of messages | 2,951 | GraphiteEditor/Graphite | 17,935 | Rust | adamgerhant | TrueDoctor | Review this pull request change.
Language: Rust
File: editor/src/messages/portfolio/document/document_message_handler.rs
PR Title: Add handler for deferred execution of messages
BEFORE CODE: .navigation_handler
.calculate_offset_transform(ipp.viewport_bounds.center(), &network_metadata.persistent_metada... | The bounds here refer to the bounds of all layers in document space. This has nothing to do with the viewport being ready | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
use crate::messages::prelude::*;
#[derive(Debug, Default, ExtractField)]
pub struct DeferMessageHandler {
after_graph_run: Vec<(u64, Message)>,
after_viewport_resize: Vec<Message>,
current_graph_submission_id: u64,
}
#[message_handler_data]
impl MessageHandler<DeferMessage, ()> for DeferMessageHandler {
fn proces... | It should not be possible to add messages to this buffer if there are currently bounds. An if statement in here would be a good prevention. | use crate::messages::prelude::*;
#[derive(Debug, Default, ExtractField)]
pub struct DeferMessageHandler {
after_graph_run: Vec<(u64, Message)>,
after_viewport_resize: Vec<Message>,
current_graph_submission_id: u64,
}
#[message_handler_data]
impl MessageHandler<DeferMessage, ()> for DeferMessageHandler {
fn proces... | @@ -0,0 +1,36 @@
+use crate::messages::prelude::*;
+
+#[derive(Debug, Default, ExtractField)]
+pub struct DeferMessageHandler {
+ after_graph_run: Vec<(u64, Message)>,
+ after_viewport_resize: Vec<Message>,
+ current_graph_submission_id: u64,
+}
+
+#[message_handler_data]
+impl MessageHandler<DeferMessage, ()> for Defe... | editor/src/messages/defer/defer_message_handler.rs | 17 | Rust | 0.429 | suggestion | 139 | 37 | 37 | false | Add handler for deferred execution of messages | 2,951 | GraphiteEditor/Graphite | 17,935 | Rust | adamgerhant | TrueDoctor | Review this pull request change.
Language: Rust
File: editor/src/messages/defer/defer_message_handler.rs
PR Title: Add handler for deferred execution of messages
BEFORE CODE: use crate::messages::prelude::*;
#[derive(Debug, Default, ExtractField)]
pub struct DeferMessageHandler {
after_graph_run: Vec<(u64, Messag... | It should not be possible to add messages to this buffer if there are currently bounds. An if statement in here would be a good prevention. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
use crate::messages::prelude::*;
#[derive(Debug, Default, ExtractField)]
pub struct DeferMessageHandler {
after_graph_run: Vec<(u64, Message)>,
after_viewport_resize: Vec<Message>,
current_graph_submission_id: u64,
}
#[message_handler_data]
impl MessageHandler<DeferMessage, ()> for DeferMessageHandler {
fn proces... | ~~I don't see why we have to associate queued messages with their execution id, since they should always be run after the next execution.~~ (answer: If multiple graph evaluations are queued, we do not want messages which require data from a later evaluation to be run on the first evaluation ) | use crate::messages::prelude::*;
#[derive(Debug, Default, ExtractField)]
pub struct DeferMessageHandler {
after_graph_run: Vec<(u64, Message)>,
after_viewport_resize: Vec<Message>,
current_graph_submission_id: u64,
}
#[message_handler_data]
impl MessageHandler<DeferMessage, ()> for DeferMessageHandler {
fn proces... | @@ -0,0 +1,36 @@
+use crate::messages::prelude::*;
+
+#[derive(Debug, Default, ExtractField)]
+pub struct DeferMessageHandler {
+ after_graph_run: Vec<(u64, Message)>,
+ after_viewport_resize: Vec<Message>,
+ current_graph_submission_id: u64, | editor/src/messages/defer/defer_message_handler.rs | 7 | Rust | 0.5 | suggestion | 293 | 32 | 32 | false | Add handler for deferred execution of messages | 2,951 | GraphiteEditor/Graphite | 17,935 | Rust | adamgerhant | TrueDoctor | Review this pull request change.
Language: Rust
File: editor/src/messages/defer/defer_message_handler.rs
PR Title: Add handler for deferred execution of messages
BEFORE CODE: use crate::messages::prelude::*;
#[derive(Debug, Default, ExtractField)]
pub struct DeferMessageHandler {
after_graph_run: Vec<(u64, Messag... | ~~I don't see why we have to associate queued messages with their execution id, since they should always be run after the next execution.~~ (answer: If multiple graph evaluations are queued, we do not want messages which require data from a later evaluation to be run on the first evaluation ) | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
use crate::messages::prelude::*;
#[derive(Debug, Default, ExtractField)]
pub struct DeferMessageHandler {
after_graph_run: Vec<(u64, Message)>,
after_viewport_resize: Vec<Message>,
current_graph_submission_id: u64,
}
#[message_handler_data]
impl MessageHandler<DeferMessage, ()> for DeferMessageHandler {
fn proces... | I would prefer if we could remove this and let the executor handle it | use crate::messages::prelude::*;
#[derive(Debug, Default, ExtractField)]
pub struct DeferMessageHandler {
after_graph_run: Vec<(u64, Message)>,
after_viewport_resize: Vec<Message>,
current_graph_submission_id: u64,
}
#[message_handler_data]
impl MessageHandler<DeferMessage, ()> for DeferMessageHandler {
fn proces... | @@ -0,0 +1,36 @@
+use crate::messages::prelude::*;
+
+#[derive(Debug, Default, ExtractField)]
+pub struct DeferMessageHandler { | editor/src/messages/defer/defer_message_handler.rs | 4 | Rust | 0.429 | refactor | 69 | 29 | 29 | false | Add handler for deferred execution of messages | 2,951 | GraphiteEditor/Graphite | 17,935 | Rust | adamgerhant | TrueDoctor | Review this pull request change.
Language: Rust
File: editor/src/messages/defer/defer_message_handler.rs
PR Title: Add handler for deferred execution of messages
BEFORE CODE: use crate::messages::prelude::*;
#[derive(Debug, Default, ExtractField)]
pub struct DeferMessageHandler {
after_graph_run: Vec<(u64, Messag... | I would prefer if we could remove this and let the executor handle it | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
if let (Some(layer), true) = (selected_layer, append_to_selected_layer) {
tool_data.current_layer = Some(layer);
let transform = document.metadata().transform_to_viewport(layer);
let position = transform.inverse().transform_point2(input.mouse.position);
tool_data.next_point = position;
re... | This removal is different from all the other tool code changes, which besides this one all add a DeferMessage::AfterGraphRun call. Just bringing attention to this in case it's a bug. Otherwise this PR LGTM. | if let (Some(layer), true) = (selected_layer, append_to_selected_layer) {
tool_data.current_layer = Some(layer);
let transform = document.metadata().transform_to_viewport(layer);
let position = transform.inverse().transform_point2(input.mouse.position);
tool_data.next_point = position;
re... | @@ -360,8 +360,6 @@ impl Fsm for SplineToolFsmState {
tool_options.stroke.apply_stroke(tool_data.weight, layer, responses);
tool_data.current_layer = Some(layer);
- responses.add(Message::StartBuffer); | editor/src/messages/tool/tool_messages/spline_tool.rs | 26 | Rust | 0.643 | bug | 206 | 51 | 51 | false | Add handler for deferred execution of messages | 2,951 | GraphiteEditor/Graphite | 17,935 | Rust | Keavon | TrueDoctor | Review this pull request change.
Language: Rust
File: editor/src/messages/tool/tool_messages/spline_tool.rs
PR Title: Add handler for deferred execution of messages
BEFORE CODE: if let (Some(layer), true) = (selected_layer, append_to_selected_layer) {
tool_data.current_layer = Some(layer);
let transf... | This removal is different from all the other tool code changes, which besides this one all add a DeferMessage::AfterGraphRun call. Just bringing attention to this in case it's a bug. Otherwise this PR LGTM. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
impl<'i, T: 'i + AsRef<U> + Sync + Send, U: 'i + StaticType + Sync + Send> Node<'i, DAny<'i>> for UpcastAsRefNode<T, U> {
type Output = FutureAny<'i>;
#[inline(always)]
fn eval(&'i self, _: DAny<'i>) -> Self::Output {
Box::pin(async move { Box::new(self.0.as_ref()) as DAny<'i> })
}
}
impl<T: AsRef<U> + Sync + S... | #[serde(skip)] here is not possible right? Because is works only for structs? |
impl<'i, T: 'i + AsRef<U> + Sync + Send, U: 'i + StaticType + Sync + Send> Node<'i, DAny<'i>> for UpcastAsRefNode<T, U> {
type Output = FutureAny<'i>;
#[inline(always)]
fn eval(&'i self, _: DAny<'i>) -> Self::Output {
Box::pin(async move { Box::new(self.0.as_ref()) as DAny<'i> })
}
}
impl<T: AsRef<U> + Sync + S... | @@ -429,6 +429,7 @@ pub struct RenderOutput {
#[derive(Debug, Clone, Hash, PartialEq, dyn_any::DynAny, serde::Serialize, serde::Deserialize)]
pub enum RenderOutputType {
CanvasFrame(SurfaceFrame),
+ Texture(ImageTexture), | node-graph/graph-craft/src/document/value.rs | 26 | Rust | 0.286 | question | 77 | 51 | 51 | false | Desktop: Ready runtime and render node for desktop | 2,952 | GraphiteEditor/Graphite | 17,935 | Rust | timon-schelling | TrueDoctor | Review this pull request change.
Language: Rust
File: node-graph/graph-craft/src/document/value.rs
PR Title: Desktop: Ready runtime and render node for desktop
BEFORE CODE:
impl<'i, T: 'i + AsRef<U> + Sync + Send, U: 'i + StaticType + Sync + Send> Node<'i, DAny<'i>> for UpcastAsRefNode<T, U> {
type Output = Futur... | #[serde(skip)] here is not possible right? Because is works only for structs? | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
wgpu_context: WgpuContext,
event_loop_proxy: EventLoopProxy<CustomEvent>,
editor: Editor,
}
impl WinitApp {
pub(crate) fn new(cef_context: cef::Context<cef::Initialized>, window_size_sender: Sender<WindowSize>, wgpu_context: WgpuContext, event_loop_proxy: EventLoopProxy<CustomEvent>) -> Self {
Self {
cef_cont... | This should stay where it was previously since the extract if loops could remove messages and the only expensive part about this is sending the cef message | graphics_state: Option<GraphicsState>,
wgpu_context: WgpuContext,
event_loop_proxy: EventLoopProxy<CustomEvent>,
editor: Editor,
}
impl WinitApp {
pub(crate) fn new(cef_context: cef::Context<cef::Initialized>, window_size_sender: Sender<WindowSize>, wgpu_context: WgpuContext, event_loop_proxy: EventLoopProxy<Cust... | @@ -55,6 +55,10 @@ impl WinitApp {
}
fn send_messages_to_editor(&mut self, mut responses: Vec<FrontendMessage>) {
+ if responses.is_empty() { | desktop/src/app.rs | 26 | Rust | 0.429 | performance | 155 | 51 | 51 | false | Desktop: Open links in default browser and prevent popups | 3,006 | GraphiteEditor/Graphite | 17,935 | Rust | TrueDoctor | timon-schelling | Review this pull request change.
Language: Rust
File: desktop/src/app.rs
PR Title: Desktop: Open links in default browser and prevent popups
BEFORE CODE: wgpu_context: WgpuContext,
event_loop_proxy: EventLoopProxy<CustomEvent>,
editor: Editor,
}
impl WinitApp {
pub(crate) fn new(cef_context: cef::Context<cef::... | This should stay where it was previously since the extract if loops could remove messages and the only expensive part about this is sending the cef message | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
start_render_sender,
web_communication_initialized: false,
web_communication_startup_buffer: Vec::new(),
persistent_data,
native_window: Default::default(),
cli_files,
}
}
fn handle_desktop_frontend_message(&mut self, message: DesktopFrontendMessage) {
match message {
DesktopFrontendMessage:... | Not a blocker but will need to be rewritten after #3247. | last_ui_update: Instant::now(),
avg_frame_time: 0.,
start_render_sender,
web_communication_initialized: false,
web_communication_startup_buffer: Vec::new(),
persistent_data,
native_window: Default::default(),
launch_documents,
}
}
fn handle_desktop_frontend_message(&mut self, message: Deskt... | @@ -91,6 +94,20 @@ impl App {
};
self.send_or_queue_web_message(bytes);
}
+ DesktopFrontendMessage::Init => {
+ tracing::info!("Initializing application...");
+ if let Some(paths) = self.cli_files.clone() {
+ for path in paths {
+ tracing::info!("Opening file from command line: {}", path.... | desktop/src/app.rs | 26 | Rust | 0.214 | suggestion | 57 | 51 | 51 | false | Desktop: Add support for opening a .graphite file from a path passed as a launch argument | 3,059 | GraphiteEditor/Graphite | 17,935 | Rust | timon-schelling | c-mateo | Review this pull request change.
Language: Rust
File: desktop/src/app.rs
PR Title: Desktop: Add support for opening a .graphite file from a path passed as a launch argument
BEFORE CODE: start_render_sender,
web_communication_initialized: false,
web_communication_startup_buffer: Vec::new(),
persistent_da... | Not a blocker but will need to be rewritten after #3247. | You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.