Remove additional boolean for mirroring distance (#965)

Removed the additional boolean for mirroring distance
This commit is contained in:
Oliver Davies
2023-01-13 15:00:20 -08:00
committed by Keavon Chambers
parent bf1a3e3daf
commit 0019340096
9 changed files with 21 additions and 62 deletions

View File

@@ -96,6 +96,7 @@ pub enum DocumentMessage {
MoveSelectedManipulatorPoints {
layer_path: Vec<LayerId>,
delta: (f64, f64),
mirror_distance: bool,
},
NodeGraphFrameGenerate,
NodeGraphFrameImaginate {
@@ -183,7 +184,6 @@ pub enum DocumentMessage {
},
ToggleSelectedHandleMirroring {
layer_path: Vec<LayerId>,
toggle_distance: bool,
toggle_angle: bool,
},
Undo,

View File

@@ -496,9 +496,9 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
.into(),
);
}
MoveSelectedManipulatorPoints { layer_path, delta } => {
MoveSelectedManipulatorPoints { layer_path, delta, mirror_distance } => {
if let Ok(_layer) = self.document_legacy.layer(&layer_path) {
responses.push_back(DocumentOperation::MoveSelectedManipulatorPoints { layer_path, delta }.into());
responses.push_back(DocumentOperation::MoveSelectedManipulatorPoints { layer_path, delta, mirror_distance }.into());
}
}
NodeGraphFrameGenerate => {
@@ -826,19 +826,8 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
responses.push_back(DocumentOperation::ToggleLayerVisibility { path: layer_path }.into());
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
}
ToggleSelectedHandleMirroring {
layer_path,
toggle_distance,
toggle_angle,
} => {
responses.push_back(
DocumentOperation::SetSelectedHandleMirroring {
layer_path,
toggle_distance,
toggle_angle,
}
.into(),
);
ToggleSelectedHandleMirroring { layer_path, toggle_angle } => {
responses.push_back(DocumentOperation::SetSelectedHandleMirroring { layer_path, toggle_angle }.into());
}
Undo => {
self.undo_in_progress = true;

View File

@@ -175,12 +175,13 @@ impl ShapeEditor {
}
/// Move the selected points by dragging the mouse.
pub fn move_selected_points(&self, delta: DVec2, responses: &mut VecDeque<Message>) {
pub fn move_selected_points(&self, delta: DVec2, mirror_distance: bool, responses: &mut VecDeque<Message>) {
for layer_path in &self.selected_layers {
responses.push_back(
DocumentMessage::MoveSelectedManipulatorPoints {
layer_path: layer_path.clone(),
delta: (delta.x, delta.y),
mirror_distance,
}
.into(),
);
@@ -193,13 +194,12 @@ impl ShapeEditor {
}
/// Toggle if the handles should mirror angle across the anchor position.
pub fn toggle_handle_mirroring_on_selected(&self, toggle_angle: bool, toggle_distance: bool, responses: &mut VecDeque<Message>) {
pub fn toggle_handle_mirroring_on_selected(&self, toggle_angle: bool, responses: &mut VecDeque<Message>) {
for layer_path in &self.selected_layers {
responses.push_back(
DocumentMessage::ToggleSelectedHandleMirroring {
layer_path: layer_path.clone(),
toggle_angle,
toggle_distance,
}
.into(),
);
@@ -391,7 +391,6 @@ impl ShapeEditor {
Operation::SetManipulatorHandleMirroring {
layer_path: layer_path.to_vec(),
id: bezier_id,
mirror_distance: false,
mirror_angle: true,
}
.into(),

View File

@@ -131,7 +131,6 @@ struct PathToolData {
drag_start_pos: DVec2,
alt_debounce: bool,
shift_debounce: bool,
}
impl Fsm for PathToolFsmState {
@@ -248,20 +247,16 @@ impl Fsm for PathToolFsmState {
tool_data.alt_debounce = alt_pressed;
// Only on alt down
if alt_pressed {
tool_data.shape_editor.toggle_handle_mirroring_on_selected(true, false, responses);
tool_data.shape_editor.toggle_handle_mirroring_on_selected(true, responses);
}
}
// Determine when shift state changes
let shift_pressed = input.keyboard.get(shift_mirror_distance as usize);
if shift_pressed != tool_data.shift_debounce {
tool_data.shift_debounce = shift_pressed;
tool_data.shape_editor.toggle_handle_mirroring_on_selected(false, true, responses);
}
// Move the selected points by the mouse position
let snapped_position = tool_data.snap_manager.snap_position(responses, document, input.mouse.position);
tool_data.shape_editor.move_selected_points(snapped_position - tool_data.drag_start_pos, responses);
tool_data.shape_editor.move_selected_points(snapped_position - tool_data.drag_start_pos, shift_pressed, responses);
tool_data.drag_start_pos = snapped_position;
PathToolFsmState::Dragging
}

View File

@@ -234,7 +234,6 @@ impl Fsm for PenToolFsmState {
let op = Operation::SetManipulatorHandleMirroring {
layer_path: layer.to_vec(),
id,
mirror_distance: false,
mirror_angle: false,
};
responses.push_back(op.into());
@@ -328,7 +327,6 @@ impl Fsm for PenToolFsmState {
let op = Operation::SetManipulatorHandleMirroring {
layer_path: layer_path.clone(),
id: previous_id,
mirror_distance: false,
mirror_angle: false,
};
responses.push_back(op.into());
@@ -386,7 +384,6 @@ impl Fsm for PenToolFsmState {
let op = Operation::SetManipulatorHandleMirroring {
layer_path: layer_path.clone(),
id: first_id,
mirror_distance: false,
mirror_angle: false,
};
responses.push_back(op.into());
@@ -475,7 +472,6 @@ impl Fsm for PenToolFsmState {
let op = Operation::SetManipulatorHandleMirroring {
layer_path: layer_path.clone(),
id: last_id,
mirror_distance: should_mirror,
mirror_angle: should_mirror,
};
responses.push_back(op.into());