Skip to content

Add proportional editing to the Path tool #2556

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

Draft
wants to merge 48 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
869d376
Setup Proportional Edit for path tool
singhutsav5502 Apr 11, 2025
cbf5fe6
Setup defaults, fix toolbar labels, fix falloff type selection
singhutsav5502 Apr 11, 2025
3303996
Merge branch 'master' into proportional_editing
singhutsav5502 Apr 11, 2025
6039b27
Implement storing original selection center and affected points for p…
singhutsav5502 Apr 12, 2025
4c15fea
Fix Proportional Edit influence circle render to selection center
singhutsav5502 Apr 12, 2025
3ff5a0f
Merge branch 'master' into proportional_editing
singhutsav5502 Apr 12, 2025
1a87daa
Setup Proportional Edit for path tool
singhutsav5502 Apr 11, 2025
18c4506
Setup defaults, fix toolbar labels, fix falloff type selection
singhutsav5502 Apr 11, 2025
b2b07bd
Implement storing original selection center and affected points for p…
singhutsav5502 Apr 12, 2025
eef4164
Fix Proportional Edit influence circle render to selection center
singhutsav5502 Apr 12, 2025
8f5d4eb
Merge branch 'proportional_editing' of github.com:singhutsav5502/Grap…
singhutsav5502 Apr 12, 2025
d78ed5b
Setup initial GRS functionality
singhutsav5502 Apr 12, 2025
52563b9
Basic integration with GRS tool, Edge Cases that still need handling:…
singhutsav5502 Apr 13, 2025
eb9be0e
Update Transform proportional edit data on radius update
singhutsav5502 Apr 13, 2025
953c42d
All selected points are used as centers to find affeted points
singhutsav5502 Apr 13, 2025
588d63a
Switching TransformOperation wthin GRS persists proportional_edit_dat…
singhutsav5502 Apr 13, 2025
b960b10
Finalise GRS integration
singhutsav5502 Apr 13, 2025
4e12de2
Merge branch 'master' into proportional_editing
singhutsav5502 Apr 13, 2025
d60f6ea
Merge branch 'master' into proportional_editing
singhutsav5502 Apr 13, 2025
a6d36a0
make sure radius change correctly repaints data position on proportio…
singhutsav5502 Apr 13, 2025
ad14ffe
Merge branch 'proportional_editing' of github.com:singhutsav5502/Grap…
singhutsav5502 Apr 13, 2025
a26379c
Setup initial point location storage in path_tool and use it to calcu…
singhutsav5502 Apr 13, 2025
a2ffa55
Setup initial point location storage in path_tool and use it to calcu…
singhutsav5502 Apr 13, 2025
ddb99af
Merge branch 'proportional_editing' of github.com:singhutsav5502/Grap…
singhutsav5502 Apr 13, 2025
cb1b0cf
Change default falloff type and dropdown ordering
singhutsav5502 Apr 13, 2025
835beb2
Fix broken dropdown
singhutsav5502 Apr 13, 2025
7d83ec7
Add proper falloff updates for normal path tool proprtional edit
singhutsav5502 Apr 13, 2025
e917781
Merge branch 'master' into proportional_editing
singhutsav5502 Apr 13, 2025
69e2036
Setup popover menu for frontend controls
singhutsav5502 Apr 13, 2025
b35d2a1
Merge branch 'master' into proportional_editing
singhutsav5502 Apr 13, 2025
c2df0a0
Invert radius change direction and set scroll factor to 10x
singhutsav5502 Apr 14, 2025
b6702e0
Invert radius change direction and set scroll factor to 10x
singhutsav5502 Apr 14, 2025
0d5d78d
merge
singhutsav5502 Apr 14, 2025
0d22f1d
path tool update affected point calculation logic
singhutsav5502 Apr 14, 2025
f8a61c6
Merge branch 'master' into proportional_editing
Keavon Apr 15, 2025
502cb68
Improve popover UI
Keavon Apr 15, 2025
a0698b0
Remove falloff strength factor
singhutsav5502 Apr 15, 2025
f392e45
Draw overlay circle only when dragging
singhutsav5502 Apr 15, 2025
232229e
Reset initial position when GRS begins
singhutsav5502 Apr 15, 2025
ce2cf2e
Treate non-collinear handles similar to collinear handles for single …
singhutsav5502 Apr 15, 2025
3141627
Logarithmic radius scaling
singhutsav5502 Apr 15, 2025
9e9effb
Merge branch 'master' into proportional_editing
singhutsav5502 Apr 15, 2025
6cb4395
Merge branch 'master' into proportional_editing
singhutsav5502 Apr 18, 2025
77d2e34
Fix merge issues and introduce rotation fixes ( introductory pivot ca…
singhutsav5502 Apr 18, 2025
9e2594c
Merge branch 'master' into proportional_editing
singhutsav5502 Apr 19, 2025
0a3c2c9
Merge branch 'GraphiteEditor:master' into proportional_editing
singhutsav5502 Apr 22, 2025
fcaa2de
Merge branch 'master' into proportional_editing
Keavon Apr 24, 2025
075768b
Code reivew + fix some paper cuts
Keavon Apr 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions editor/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ pub const ASYMPTOTIC_EFFECT: f64 = 0.5;
pub const SCALE_EFFECT: f64 = 0.5;

// COLORS
pub const COLOR_OVERLAY_TRANSPARENT: &str = "transparent";
pub const COLOR_OVERLAY_BLUE: &str = "#00a8ff";
pub const COLOR_OVERLAY_YELLOW: &str = "#ffc848";
pub const COLOR_OVERLAY_GREEN: &str = "#63ce63";
Expand Down
8 changes: 5 additions & 3 deletions editor/src/messages/input_mapper/input_mappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ pub fn input_mappings() -> Mapping {
entry!(KeyDown(ArrowDown); modifiers=[Shift, ArrowLeft], action_dispatch=PathToolMessage::NudgeSelectedPoints { delta_x: -BIG_NUDGE_AMOUNT, delta_y: BIG_NUDGE_AMOUNT }),
entry!(KeyDown(ArrowDown); modifiers=[Shift, ArrowRight], action_dispatch=PathToolMessage::NudgeSelectedPoints { delta_x: BIG_NUDGE_AMOUNT, delta_y: BIG_NUDGE_AMOUNT }),
entry!(KeyDown(KeyJ); modifiers=[Accel], action_dispatch=ToolMessage::Path(PathToolMessage::ClosePath)),
entry!(KeyDown(KeyP); modifiers=[Alt], action_dispatch=PathToolMessage::ToggleProportionalEditing),
entry!(WheelScroll; action_dispatch=PathToolMessage::AdjustProportionalRadius),
//
// PenToolMessage
entry!(PointerMove; refresh_keys=[Control, Alt, Shift, KeyC], action_dispatch=PenToolMessage::PointerMove { snap_angle: Shift, break_handle: Alt, lock_angle: Control, colinear: KeyC, move_anchor_with_handles: Space }),
Expand Down Expand Up @@ -376,9 +378,9 @@ pub fn input_mappings() -> Mapping {
entry!(KeyDown(ArrowRight); action_dispatch=DocumentMessage::NudgeSelectedLayers { delta_x: NUDGE_AMOUNT, delta_y: 0., resize: Alt, resize_opposite_corner: Control }),
//
// TransformLayerMessage
entry!(KeyDown(KeyG); action_dispatch=TransformLayerMessage::BeginGRS { transform_type: TransformType::Grab }),
entry!(KeyDown(KeyR); action_dispatch=TransformLayerMessage::BeginGRS { transform_type: TransformType::Rotate }),
entry!(KeyDown(KeyS); action_dispatch=TransformLayerMessage::BeginGRS { transform_type: TransformType::Scale }),
entry!(KeyDown(KeyG); action_dispatch=TransformLayerMessage::BeginGRS { transform_type: TransformType::Grab, proportional_editing_data: None }),
entry!(KeyDown(KeyR); action_dispatch=TransformLayerMessage::BeginGRS { transform_type: TransformType::Rotate, proportional_editing_data: None }),
entry!(KeyDown(KeyS); action_dispatch=TransformLayerMessage::BeginGRS { transform_type: TransformType::Scale, proportional_editing_data: None }),
entry!(KeyDown(Digit0); action_dispatch=TransformLayerMessage::TypeDigit { digit: 0 }),
entry!(KeyDown(Digit1); action_dispatch=TransformLayerMessage::TypeDigit { digit: 1 }),
entry!(KeyDown(Digit2); action_dispatch=TransformLayerMessage::TypeDigit { digit: 2 }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ pub struct DropdownInput {

#[serde(skip)]
pub tooltip_shortcut: Option<ActionKeys>,

// Styling
#[serde(rename = "minWidth")]
pub min_width: u32,
//
// Callbacks
// `on_update` exists on the `MenuListEntry`, not this parent `DropdownInput`
Expand Down
28 changes: 28 additions & 0 deletions editor/src/messages/tool/common_functionality/shape_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,34 @@ impl ClosestSegment {

// TODO Consider keeping a list of selected manipulators to minimize traversals of the layers
impl ShapeState {
/// Calculates the center point of all selected manipulator points (anchors and handles)
pub fn selection_center(&self, document: &DocumentMessageHandler) -> Option<DVec2> {
let mut sum = DVec2::ZERO;
let mut count = 0;

// Iterate through all selected layers and their selection states
for (&layer, state) in &self.selected_shape_state {
// Get the transform from layer space to document space
let transform = document.metadata().transform_to_document(layer);

// Get the vector data for this layer
if let Some(vector_data) = document.network_interface.compute_modified_vector(layer) {
// Process each selected point in this layer
for point in state.selected() {
// Get the position in layer space coordinates
if let Some(position) = point.get_position(&vector_data) {
// Convert to document space and accumulate
sum += transform.transform_point2(position);
count += 1;
}
}
}
}

// Return average position if we have any points
if count > 0 { Some(sum / count as f64) } else { None }
}

pub fn close_selected_path(&self, document: &DocumentMessageHandler, responses: &mut VecDeque<Message>) {
// First collect all selected anchor points across all layers
let all_selected_points: Vec<(LayerNodeIdentifier, PointId)> = self
Expand Down
Loading
Loading