-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
added feature to snap at midpoint while using path tool #3766
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
Open
krVatsal
wants to merge
8
commits into
GraphiteEditor:master
Choose a base branch
from
krVatsal:shift-key-snaps-lines-from-middle-for-shpes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b3c30f4
added feature to snap at midpoint while using path tool
krVatsal 939e091
fix axes to be at midpoint of vertices
krVatsal 50bc9d7
added feature to snap at midpoint while using path tool
krVatsal 183ab31
fix axes to be at midpoint of vertices
krVatsal 0fb1b1b
shift logic to use midpoint of actual bezier curve than calculating m…
krVatsal a442060
shift logic to use midpoint of actual bezier curve than calculating m…
krVatsal 3966a91
fixed duplicate code bug
krVatsal db0547b
Merge branch 'master' into shift-key-snaps-lines-from-middle-for-shpes
krVatsal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -591,6 +591,7 @@ struct PathToolData { | |
| last_clicked_point_was_selected: bool, | ||
| last_clicked_segment_was_selected: bool, | ||
| snapping_axis: Option<Axis>, | ||
| snap_axis_origin: Option<DVec2>, | ||
| alt_clicked_on_anchor: bool, | ||
| alt_dragging_from_anchor: bool, | ||
| angle_locked: bool, | ||
|
|
@@ -1970,7 +1971,7 @@ impl Fsm for PathToolFsmState { | |
| // Draw the snapping axis lines | ||
| if tool_data.snapping_axis.is_some() { | ||
| let Some(axis) = tool_data.snapping_axis else { return self }; | ||
| let origin = tool_data.drag_start_pos; | ||
| let origin = tool_data.snap_axis_origin.or_else(|| tool_data.snap_manager.indicator_pos()).unwrap_or(tool_data.drag_start_pos); | ||
| let viewport_diagonal = viewport.size().into_dvec2().length(); | ||
|
|
||
| match axis { | ||
|
|
@@ -2107,16 +2108,43 @@ impl Fsm for PathToolFsmState { | |
| } | ||
|
|
||
| let break_molding = input.keyboard.get(break_colinear_molding as usize); | ||
| let snap_axis_state = input.keyboard.get(snap_angle as usize); | ||
|
|
||
| // Logic for molding segment | ||
| if let Some(segment) = &mut tool_data.segment | ||
| && let Some(molding_segment_handles) = tool_data.molding_info | ||
| { | ||
| // Constrain molding to a single axis when Shift is held | ||
| let mouse_position = if snap_axis_state { | ||
| // Calculate the midpoint along the actual bezier curve for the axis overlay. | ||
| // This uses the curve captured at mouse-down (which includes all prior modifications), | ||
| // so after a previous bulge the axis origin reflects the updated curve shape. | ||
| let transform = document.metadata().transform_to_viewport(segment.layer()); | ||
| let curve_midpoint = point_to_dvec2(segment.pathseg().eval(0.5)); | ||
| let midpoint = transform.transform_point2(curve_midpoint); | ||
| tool_data.snap_axis_origin = Some(midpoint); | ||
|
|
||
| // Constrain mouse movement relative to drag start so molding delta stays correct | ||
| let drag_start = tool_data.drag_start_pos; | ||
| let delta = input.mouse.position - drag_start; | ||
| let axis = if delta.x.abs() >= delta.y.abs() { Axis::X } else { Axis::Y }; | ||
| tool_data.snapping_axis = Some(axis); | ||
| match axis { | ||
| Axis::X => DVec2::new(input.mouse.position.x, drag_start.y), | ||
| Axis::Y => DVec2::new(drag_start.x, input.mouse.position.y), | ||
| _ => input.mouse.position, | ||
| } | ||
| } else { | ||
| tool_data.snapping_axis = None; | ||
| tool_data.snap_axis_origin = None; | ||
| input.mouse.position | ||
| }; | ||
|
|
||
| tool_data.temporary_adjacent_handles_while_molding = segment.mold_handle_positions( | ||
| document, | ||
| responses, | ||
| molding_segment_handles, | ||
| input.mouse.position, | ||
| mouse_position, | ||
| break_molding, | ||
| tool_data.temporary_adjacent_handles_while_molding, | ||
| ); | ||
|
|
@@ -2371,6 +2399,10 @@ impl Fsm for PathToolFsmState { | |
| tool_data.molding_segment = false; | ||
| tool_data.temporary_adjacent_handles_while_molding = None; | ||
| tool_data.angle_locked = false; | ||
| tool_data.snapping_axis = None; | ||
| tool_data.snap_axis_origin = None; | ||
| tool_data.snapping_axis = None; | ||
| tool_data.snap_axis_origin = None; | ||
| responses.add(DocumentMessage::AbortTransaction); | ||
| tool_data.snap_manager.cleanup(responses); | ||
| PathToolFsmState::Ready | ||
|
|
@@ -2619,6 +2651,8 @@ impl Fsm for PathToolFsmState { | |
| } | ||
|
|
||
| tool_data.snapping_axis = None; | ||
| tool_data.snap_axis_origin = None; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here ! |
||
| tool_data.snap_axis_origin = None; | ||
| tool_data.sliding_point_info = None; | ||
|
|
||
| if drag_occurred || extend_selection { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are you setting this to NONE twice ??