Skip to content

Commit

Permalink
Improve the Pen tool's colinearity and equidistance controls (#2242)
Browse files Browse the repository at this point in the history
* basic implementation done now refactor

* fixed overlays refactoring need to fix colinear(update it)

* more_refactoring ,only toggle C for grs to be done(if required)

* cleanup

* cleanup

* more formatting checks

* refactoring alt fixed hints fixed

* code-review-changes

* path-tool-tab-fix

* fixed bugs

* some refactor

* fixed ctrl_snap

* added lock-overlays and fixed grs bug

* Code review

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
  • Loading branch information
0SlowPoke0 and Keavon authored Feb 5, 2025
1 parent 133d872 commit 41ee1cf
Show file tree
Hide file tree
Showing 3 changed files with 353 additions and 77 deletions.
4 changes: 2 additions & 2 deletions editor/src/messages/input_mapper/input_mappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ pub fn input_mappings() -> Mapping {
entry!(KeyDown(Backspace); modifiers=[Accel], action_dispatch=PathToolMessage::DeleteAndBreakPath),
entry!(KeyDown(Delete); modifiers=[Shift], action_dispatch=PathToolMessage::BreakPath),
entry!(KeyDown(Backspace); modifiers=[Shift], action_dispatch=PathToolMessage::BreakPath),
entry!(KeyDown(Tab); action_dispatch=PathToolMessage::SwapSelectedHandles),
entry!(KeyDownNoRepeat(Tab); action_dispatch=PathToolMessage::SwapSelectedHandles),
entry!(KeyDown(MouseLeft); action_dispatch=PathToolMessage::MouseDown { direct_insert_without_sliding: Control, extend_selection: Shift, lasso_select: Control }),
entry!(KeyDown(MouseRight); action_dispatch=PathToolMessage::RightClick),
entry!(KeyDown(Escape); action_dispatch=PathToolMessage::Escape),
Expand Down Expand Up @@ -254,7 +254,7 @@ pub fn input_mappings() -> Mapping {
entry!(KeyDown(KeyJ); modifiers=[Accel], action_dispatch=ToolMessage::Path(PathToolMessage::ClosePath)),
//
// PenToolMessage
entry!(PointerMove; refresh_keys=[Control, Alt, Shift], action_dispatch=PenToolMessage::PointerMove { snap_angle: Shift, break_handle: Alt, lock_angle: Control}),
entry!(PointerMove; refresh_keys=[Control, Alt, Shift, KeyC], action_dispatch=PenToolMessage::PointerMove { snap_angle: Shift, break_handle: Alt, lock_angle: Control, colinear: KeyC }),
entry!(KeyDown(MouseLeft); action_dispatch=PenToolMessage::DragStart { append_to_selected: Shift }),
entry!(KeyUp(MouseLeft); action_dispatch=PenToolMessage::DragStop),
entry!(KeyDown(MouseRight); action_dispatch=PenToolMessage::Confirm),
Expand Down
39 changes: 27 additions & 12 deletions editor/src/messages/tool/tool_messages/path_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1185,16 +1185,9 @@ impl Fsm for PathToolFsmState {
.push(HintGroup(vec![HintInfo::mouse(MouseMotion::Rmb, ""), HintInfo::keys([Key::Escape], "Cancel").prepend_slash()]));

let drag_anchor = HintInfo::keys([Key::Space], "Drag Anchor");
let point_select_state_hint_group = match dragging_state.point_select_state {
PointSelectState::HandleNoPair => {
let mut hints = vec![drag_anchor];
hints.push(HintInfo::keys([Key::Shift], "Snap 15°"));
hints.push(HintInfo::keys([Key::Control], "Lock Angle"));
hints
}
PointSelectState::HandleWithPair => {
let mut hints = vec![drag_anchor];
hints.push(HintInfo::keys([Key::Tab], "Swap Selected Handles"));
let toggle_group = match dragging_state.point_select_state {
PointSelectState::HandleNoPair | PointSelectState::HandleWithPair => {
let mut hints = vec![HintInfo::keys([Key::Tab], "Swap Selected Handles")];
hints.push(HintInfo::keys(
[Key::KeyC],
if colinear == ManipulatorAngle::Colinear {
Expand All @@ -1203,18 +1196,40 @@ impl Fsm for PathToolFsmState {
"Make Handles Colinear"
},
));
hints
}
PointSelectState::Anchor => Vec::new(),
};
let hold_group = match dragging_state.point_select_state {
PointSelectState::HandleNoPair => {
let mut hints = vec![];
if colinear != ManipulatorAngle::Free {
hints.push(HintInfo::keys([Key::Alt], "Equidistant Handles"));
}
hints.push(HintInfo::keys([Key::Shift], "Snap 15°"));
hints.push(HintInfo::keys([Key::Control], "Lock Angle"));
hints.push(drag_anchor);
hints
}
PointSelectState::HandleWithPair => {
let mut hints = vec![];
if colinear != ManipulatorAngle::Free {
hints.push(HintInfo::keys([Key::Alt], "Equidistant Handles"));
}
hints.push(HintInfo::keys([Key::Shift], "Snap 15°"));
hints.push(HintInfo::keys([Key::Control], "Lock Angle"));
hints.push(drag_anchor);
hints
}
PointSelectState::Anchor => Vec::new(),
};

if !point_select_state_hint_group.is_empty() {
dragging_hint_data.0.push(HintGroup(point_select_state_hint_group));
if !toggle_group.is_empty() {
dragging_hint_data.0.push(HintGroup(toggle_group));
}

if !hold_group.is_empty() {
dragging_hint_data.0.push(HintGroup(hold_group));
}

dragging_hint_data
Expand Down
Loading

0 comments on commit 41ee1cf

Please sign in to comment.