Skip to content

Commit

Permalink
fix: handle hints, remove anchor to handle switch
Browse files Browse the repository at this point in the history
Added specific handle hints,
Can no longer switch to handle if just anchor is selected
typo fix
  • Loading branch information
DaraghD committed Oct 27, 2024
1 parent 68496b2 commit 2162e9e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
13 changes: 13 additions & 0 deletions editor/src/messages/tool/common_functionality/shape_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,6 +1061,16 @@ impl ShapeState {
}
}

/// Returns true if atleast one handle is selected
pub fn handle_selected(&mut self) -> bool {
for point in self.selected_points() {
if let Some(_) = point.as_handle() {
return true;
}
}
return false;
}

/// Alternate selected handles to mirrors
pub fn alternate_selected_handles(&mut self, network_interface: &NodeNetworkInterface) {
let mut handles_to_update = Vec::new();
Expand All @@ -1071,6 +1081,9 @@ impl ShapeState {
};

for point in self.selected_points() {
if let Some(_) = point.as_anchor() {
continue;
}
if let Some(handles) = point.get_handle_pair(&vector_data) {
//handle[0] is selected, handle[1] is opposite / mirror handle
handles_to_update.push((layer, handles[0].to_manipulator_point(), handles[1].to_manipulator_point()));
Expand Down
28 changes: 25 additions & 3 deletions editor/src/messages/tool/tool_messages/path_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,24 @@ pub enum PathToolMessage {
AlternateSelectedHandles,
}

fn handle_hint_data() -> HintData {
return HintData(vec![
HintGroup(vec![HintInfo::mouse(MouseMotion::Rmb, ""), HintInfo::keys([Key::Escape], "Cancel").prepend_slash()]),
HintGroup(vec![
// TODO: Switch this to the "S" key. Also, make the hint dynamically say "Make Colinear" or "Make Not Colinear" based on its current state. And only
// TODO: show this hint if a handle (not an anchor) is being dragged, and disable that shortcut so it can't be pressed even with the hint not shown.
HintInfo::keys([Key::Alt], "Toggle Colinear Handles"),
// TODO: Switch this to the "Alt" key (since it's equivalent to the "From Center" modifier when drawing a line). And show this only when a handle is being dragged.
HintInfo::keys([Key::Shift], "Equidistant Handles"),
HintInfo::keys([Key::Tab], "Select Opposite Handles"), //TODO: only show when handle selected
// TODO: Add "Snap 15°" modifier with the "Shift" key (only when a handle is being dragged).
// TODO: Add "Lock Angle" modifier with the "Ctrl" key (only when a handle is being dragged).
// TODO: Add "Snap 15°" modifier with the "Shift" key (only when a handle is being dragged).
// TODO: Add "Lock Angle" modifier with the "Ctrl" key (only when a handle is being dragged).
HintInfo::keys([Key::Space], "Drag anchor"),
]),
]);
}
impl ToolMetadata for PathTool {
fn icon_name(&self) -> String {
"VectorPathTool".into()
Expand Down Expand Up @@ -740,6 +758,10 @@ impl Fsm for PathToolFsmState {
PathToolFsmState::Ready
}
(_, PathToolMessage::SelectedPointUpdated) => {
if shape_editor.handle_selected() {
responses.add(FrontendMessage::UpdateInputHints { hint_data: handle_hint_data() });
}

tool_data.selection_status = get_selection_status(&document.network_interface, shape_editor);
self
}
Expand Down Expand Up @@ -786,9 +808,9 @@ impl Fsm for PathToolFsmState {
HintInfo::keys([Key::Alt], "Toggle Colinear Handles"),
// TODO: Switch this to the "Alt" key (since it's equivalent to the "From Center" modifier when drawing a line). And show this only when a handle is being dragged.
HintInfo::keys([Key::Shift], "Equidistant Handles"),
HintInfo::keys([Key::Tab], "Select Oppposite Handles"), //TODO: only show when handle selected
// TODO: Add "Snap 15°" modifier with the "Shift" key (only when a handle is being dragged).
// TODO: Add "Lock Angle" modifier with the "Ctrl" key (only when a handle is being dragged).
// HintInfo::keys([Key::Tab], "Select Opposite Handles"), //TODO: only show when handle selected
// TODO: Add "Snap 15°" modifier with the "Shift" key (only when a handle is being dragged).
// TODO: Add "Lock Angle" modifier with the "Ctrl" key (only when a handle is being dragged).
// TODO: Add "Snap 15°" modifier with the "Shift" key (only when a handle is being dragged).
// TODO: Add "Lock Angle" modifier with the "Ctrl" key (only when a handle is being dragged).
HintInfo::keys([Key::Space], "Drag anchor"),
Expand Down

0 comments on commit 2162e9e

Please sign in to comment.