diff --git a/editor/src/messages/input_mapper/input_mappings.rs b/editor/src/messages/input_mapper/input_mappings.rs index 9cc018ba23..a8276f93a4 100644 --- a/editor/src/messages/input_mapper/input_mappings.rs +++ b/editor/src/messages/input_mapper/input_mappings.rs @@ -178,6 +178,10 @@ pub fn input_mappings() -> Mapping { entry!(KeyDown(MouseRight); action_dispatch=OperationToolMessage::Confirm), entry!(KeyDown(Escape); action_dispatch=OperationToolMessage::Abort), entry!(KeyDown(Enter); action_dispatch=OperationToolMessage::Confirm), + entry!(KeyDown(ArrowUp);action_dispatch=OperationToolMessage::IncreaseCount), + entry!(KeyDown(ArrowDown);action_dispatch=OperationToolMessage::DecreaseCount), + entry!(KeyDown(BracketRight);action_dispatch=OperationToolMessage::IncreaseCount), + entry!(KeyDown(BracketLeft);action_dispatch=OperationToolMessage::DecreaseCount), // // ShapeToolMessage entry!(KeyDown(MouseLeft); action_dispatch=ShapeToolMessage::DragStart), diff --git a/editor/src/messages/tool/common_functionality/operations/circular_repeat.rs b/editor/src/messages/tool/common_functionality/operations/circular_repeat.rs index 2ba25d1af8..19ed343c3c 100644 --- a/editor/src/messages/tool/common_functionality/operations/circular_repeat.rs +++ b/editor/src/messages/tool/common_functionality/operations/circular_repeat.rs @@ -76,6 +76,11 @@ impl CircularRepeatOperation { for (layer, initial_radius) in &tool_data.circular_operation_data.layers_dragging { // If the layer’s sign differs from the clicked layer, invert delta to preserve consistent in/out dragging behavior + + let Some((angle, _, count)) = extract_circular_repeat_parameters(Some(*layer), document) else { + return; + }; + let new_radius = if initial_radius.signum() == clicked_radius.signum() { *initial_radius + delta } else { @@ -84,9 +89,9 @@ impl CircularRepeatOperation { responses.add(GraphOperationMessage::CircularRepeatSet { layer: *layer, - angle: 0., + angle, radius: new_radius, - count: 6, + count, }); } @@ -136,6 +141,24 @@ impl CircularRepeatOperation { } } + pub fn increase_decrease_count(tool_data: &mut OperationToolData, increase: bool, document: &DocumentMessageHandler, responses: &mut VecDeque) { + for (layer, _) in &tool_data.circular_operation_data.layers_dragging { + let Some((angle, radius, mut count)) = extract_circular_repeat_parameters(Some(*layer), document) else { + return; + }; + + if increase { + count += 1 + } else { + count = (count - 1).max(1) + } + + responses.add(GraphOperationMessage::CircularRepeatSet { layer: *layer, angle, radius, count }); + } + + responses.add(NodeGraphMessage::RunDocumentGraph); + } + pub fn cleanup(tool_data: &mut OperationToolData) { // Clear stored drag state at the end of the operation tool_data.circular_operation_data.layers_dragging.clear(); diff --git a/editor/src/messages/tool/common_functionality/shapes/shape_utility.rs b/editor/src/messages/tool/common_functionality/shapes/shape_utility.rs index 5dfad7d169..b049612948 100644 --- a/editor/src/messages/tool/common_functionality/shapes/shape_utility.rs +++ b/editor/src/messages/tool/common_functionality/shapes/shape_utility.rs @@ -230,6 +230,8 @@ pub fn extract_star_parameters(layer: Option, document: &Do Some((sides, radius_1, radius_2)) } +/// Extract the node input values of Circular Repeat Node. +/// Returns an option of (angle_offset, radius, count). pub fn extract_circular_repeat_parameters(layer: Option, document: &DocumentMessageHandler) -> Option<(f64, f64, u32)> { let node_inputs = NodeGraphLayer::new(layer?, &document.network_interface).find_node_inputs("Circular Repeat")?; diff --git a/editor/src/messages/tool/tool_messages/operation_tool.rs b/editor/src/messages/tool/tool_messages/operation_tool.rs index 9db24457d0..c8e5bf3f6d 100644 --- a/editor/src/messages/tool/tool_messages/operation_tool.rs +++ b/editor/src/messages/tool/tool_messages/operation_tool.rs @@ -37,6 +37,8 @@ pub enum OperationToolMessage { WorkingColorChanged, // Tool-specific messages + IncreaseCount, + DecreaseCount, Confirm, DragStart, DragStop, @@ -127,6 +129,8 @@ impl<'a> MessageHandler> for Oper PointerMove, Confirm, Abort, + IncreaseCount, + DecreaseCount, ), } } @@ -212,6 +216,20 @@ impl Fsm for OperationToolFsmState { OperationToolFsmState::Drawing } + (OperationToolFsmState::Drawing, OperationToolMessage::IncreaseCount) => { + match tool_options.operation_type { + OperationType::CircularRepeat => CircularRepeatOperation::increase_decrease_count(tool_data, true, document, responses), + _ => {} + } + self + } + (OperationToolFsmState::Drawing, OperationToolMessage::DecreaseCount) => { + match tool_options.operation_type { + OperationType::CircularRepeat => CircularRepeatOperation::increase_decrease_count(tool_data, false, document, responses), + _ => {} + } + self + } (_, OperationToolMessage::PointerMove) => { responses.add(OverlaysMessage::Draw); self