Skip to content

Nested layer transforms API #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 53 commits into from
Aug 6, 2021
Merged

Nested layer transforms API #301

merged 53 commits into from
Aug 6, 2021

Conversation

TrueDoctor
Copy link
Member

@TrueDoctor TrueDoctor commented Jul 24, 2021

Fixes #251
unblocks #149
Fixes #148
Fixes #290

This change is Reviewable

@Keavon Keavon changed the title Transform api Nested layer transforms API Jul 24, 2021
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jul 24, 2021

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 83a1a4b
Status: ✅  Deploy successful!
Preview URL: https://af316449.graphite-master.pages.dev

View logs

@TrueDoctor TrueDoctor force-pushed the transform-api branch 6 times, most recently from 5959ed8 to 407fbd9 Compare August 3, 2021 21:23
@TrueDoctor TrueDoctor marked this pull request as ready for review August 4, 2021 16:49
scale: 1.,
}
}
pub fn snapped_angle(&self) -> f64 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should be sure to always have blank lines between functions in impl blocks. Assuming you agree, check for this elsewhere in this CL.

Comment on lines +49 to +55
if !layer_data.contains_key(path) {
layer_data.insert(path.to_vec(), LayerData::new(false));
}
layer_data.get_mut(path).unwrap()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this can be achieved in one line... something like get_or_insert_with.

ToolMessage::Eyedropper(EyedropperMessage::RightMouseDown) => responses.push_back(ToolMessage::SelectSecondaryColor(color).into()),
_ => {}
}
if let LayerDataType::Shape(s) = &layer.data {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of replacing and_then with nested maps - and_then is designed to achieve exactly this.

Copy link
Member Author

@TrueDoctor TrueDoctor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 54 files reviewed, 12 unresolved discussions (waiting on @0HyperCube, @henryksloan, @Keavon, @pkupper, and @TrueDoctor)


client/web/src/components/panels/LayerTree.vue, line 333 at r3 (raw file):

Previously, henryksloan (Henry Sloan) wrote…

Split this into multiple lines?

Done.


core/document/src/intersection.rs, line 14 at r3 (raw file):

Previously, henryksloan (Henry Sloan) wrote…

Add a blank line before this function signature

Done.


core/document/src/intersection.rs, line 44 at r3 (raw file):

Previously, henryksloan (Henry Sloan) wrote…

I think this for and if could be refactored to just an if using Iterator::any

Done.


core/document/src/intersection.rs, line 57 at r3 (raw file):

Previously, henryksloan (Henry Sloan) wrote…

This can also be refactored with Iterator::any

That would get pretty ugly if I don't want to loop through the iterator multiple times


core/document/src/layers/folder.rs, line 33 at r3 (raw file):

Previously, henryksloan (Henry Sloan) wrote…

Consider splitting this across multiple lines

Done.


core/document/src/layers/simple_shape.rs, line 87 at r3 (raw file):

Previously, henryksloan (Henry Sloan) wrote…

Parentheses around ((sides + 1) % 2) as f64 * PI would be nice, to be clear about the order of operations for the division.

Done.


core/editor/src/document/document_file.rs, line 86 at r1 (raw file):

Previously, henryksloan (Henry Sloan) wrote…

I believe this message is removed in master, replaced by FlipSelectedLayers. Also, FlipSelectedLayers should probably be down here, next to the other transformations of the selected layers.

Done.


core/editor/src/document/layer_panel.rs, line 43 at r3 (raw file):

Previously, henryksloan (Henry Sloan) wrote…

I'm not sure these variables need transform in their names; that makes it much more verbose, and I'm not sure it makes it clearer.

Just copied this over and found out that it is fundamentally broken and needs a fix anyway
Will add a todo


core/editor/src/document/layer_panel.rs, line 52 at r3 (raw file):

Previously, henryksloan (Henry Sloan) wrote…

I believe this can be achieved in one line... something like get_or_insert_with.

But then you need a owned path and can't clone on demand


core/editor/src/document/layer_panel.rs, line 58 at r3 (raw file):

Previously, henryksloan (Henry Sloan) wrote…

If these variables are only used to populate the struct, I don't think they need to be stored in variables at all.

Done.


core/editor/src/tool/tools/eyedropper.rs, line 26 at r3 (raw file):

Previously, henryksloan (Henry Sloan) wrote…

I'm not a fan of replacing and_then with nested maps - and_then is designed to achieve exactly this.

Done.

Copy link
Member Author

@TrueDoctor TrueDoctor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 54 files reviewed, 12 unresolved discussions (waiting on @0HyperCube, @henryksloan, @Keavon, and @pkupper)


core/editor/src/document/layer_panel.rs, line 31 at r3 (raw file):

Previously, henryksloan (Henry Sloan) wrote…

I think we should be sure to always have blank lines between functions in impl blocks. Assuming you agree, check for this elsewhere in this CL.

We'll try to add them as we got through the pr


core/editor/src/document/layer_panel.rs, line 43 at r3 (raw file):

Previously, TrueDoctor wrote…

Just copied this over and found out that it is fundamentally broken and needs a fix anyway
Will add a todo

Done.

Copy link
Member Author

@TrueDoctor TrueDoctor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 55 files reviewed, 20 unresolved discussions (waiting on @0HyperCube, @henryksloan, @Keavon, and @pkupper)


core/editor/src/consts.rs, line 14 at r5 (raw file):

Previously, Keavon (Keavon Chambers) wrote…

Wondering if this should be 15. However this already was 12 beforehand, yet the actual application does work in 15° increments while holding Shift.

Done.


core/editor/src/tool/tools/ellipse.rs, line 33 at r5 (raw file):

Previously, Keavon (Keavon Chambers) wrote…

Two spaces between DragStop, and Abort,

Done.


core/editor/src/tool/tools/ellipse.rs, line 98 at r5 (raw file):

Previously, Keavon (Keavon Chambers) wrote…

Is this comment still accurate? Also please switch from TODO - to TODO: for consistency (and because it helps with tooling which highlights TODO: blocks but apparently mine doesn't highlight TODO - ).

Yes that is still a thing we should do, should be a pretty small fix


core/editor/src/tool/tools/line.rs, line 33 at r5 (raw file):

Previously, Keavon (Keavon Chambers) wrote…

Remove double space and space before closing paren.

Done.


core/editor/src/tool/tools/rectangle.rs, line 33 at r5 (raw file):

Previously, Keavon (Keavon Chambers) wrote…

Double space before Abort,.

Done.


core/editor/src/tool/tools/select.rs, line 45 at r5 (raw file):

Previously, Keavon (Keavon Chambers) wrote…

Double space here also.

Done.


core/editor/src/tool/tools/select.rs, line 130 at r5 (raw file):

Previously, Keavon (Keavon Chambers) wrote…

Let's make the stroke width 1.0 and the hex code #00A8FF (0x00, 0xA8, 0xFF).

Done.


core/editor/src/tool/tools/shape.rs, line 33 at r5 (raw file):

Previously, Keavon (Keavon Chambers) wrote…

Double space here too.

Good thing I would never copy paste code, pretty weird chance that the duplicate whitespace was in all files!

@TrueDoctor TrueDoctor merged commit f79e6e3 into master Aug 6, 2021
@TrueDoctor TrueDoctor deleted the transform-api branch August 6, 2021 10:34
Keavon pushed a commit that referenced this pull request Jun 16, 2022
* Enforce cache dirtification

* Turn all shapes into one struct

* Remove working folder

* Remove old shapes

* Major restructuring

* Refactor Ellipse, Rectangle and ShapeTool

* Simplify bounding box calculation for folder

* Fix panic in select tool

*  Refactorselect tool

* Refactor Align

* Refactor flipping layers

* Zoom to fit all

* Refactor tools to avoid state keeping

* Refactor more tools to use state that is passed along

* Fix whitespace + change selection box style

* Set viewbox of svg export based on the contents
Keavon pushed a commit that referenced this pull request Jul 30, 2023
* Enforce cache dirtification

* Turn all shapes into one struct

* Remove working folder

* Remove old shapes

* Major restructuring

* Refactor Ellipse, Rectangle and ShapeTool

* Simplify bounding box calculation for folder

* Fix panic in select tool

*  Refactorselect tool

* Refactor Align

* Refactor flipping layers

* Zoom to fit all

* Refactor tools to avoid state keeping

* Refactor more tools to use state that is passed along

* Fix whitespace + change selection box style

* Set viewbox of svg export based on the contents
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants