mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-07 08:28:12 +08:00
add increase count when dragging
This commit is contained in:
@@ -178,6 +178,10 @@ pub fn input_mappings() -> Mapping {
|
|||||||
entry!(KeyDown(MouseRight); action_dispatch=OperationToolMessage::Confirm),
|
entry!(KeyDown(MouseRight); action_dispatch=OperationToolMessage::Confirm),
|
||||||
entry!(KeyDown(Escape); action_dispatch=OperationToolMessage::Abort),
|
entry!(KeyDown(Escape); action_dispatch=OperationToolMessage::Abort),
|
||||||
entry!(KeyDown(Enter); action_dispatch=OperationToolMessage::Confirm),
|
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
|
// ShapeToolMessage
|
||||||
entry!(KeyDown(MouseLeft); action_dispatch=ShapeToolMessage::DragStart),
|
entry!(KeyDown(MouseLeft); action_dispatch=ShapeToolMessage::DragStart),
|
||||||
|
|||||||
@@ -76,6 +76,11 @@ impl CircularRepeatOperation {
|
|||||||
|
|
||||||
for (layer, initial_radius) in &tool_data.circular_operation_data.layers_dragging {
|
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
|
// 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() {
|
let new_radius = if initial_radius.signum() == clicked_radius.signum() {
|
||||||
*initial_radius + delta
|
*initial_radius + delta
|
||||||
} else {
|
} else {
|
||||||
@@ -84,9 +89,9 @@ impl CircularRepeatOperation {
|
|||||||
|
|
||||||
responses.add(GraphOperationMessage::CircularRepeatSet {
|
responses.add(GraphOperationMessage::CircularRepeatSet {
|
||||||
layer: *layer,
|
layer: *layer,
|
||||||
angle: 0.,
|
angle,
|
||||||
radius: new_radius,
|
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<Message>) {
|
||||||
|
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) {
|
pub fn cleanup(tool_data: &mut OperationToolData) {
|
||||||
// Clear stored drag state at the end of the operation
|
// Clear stored drag state at the end of the operation
|
||||||
tool_data.circular_operation_data.layers_dragging.clear();
|
tool_data.circular_operation_data.layers_dragging.clear();
|
||||||
|
|||||||
@@ -230,6 +230,8 @@ pub fn extract_star_parameters(layer: Option<LayerNodeIdentifier>, document: &Do
|
|||||||
Some((sides, radius_1, radius_2))
|
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<LayerNodeIdentifier>, document: &DocumentMessageHandler) -> Option<(f64, f64, u32)> {
|
pub fn extract_circular_repeat_parameters(layer: Option<LayerNodeIdentifier>, document: &DocumentMessageHandler) -> Option<(f64, f64, u32)> {
|
||||||
let node_inputs = NodeGraphLayer::new(layer?, &document.network_interface).find_node_inputs("Circular Repeat")?;
|
let node_inputs = NodeGraphLayer::new(layer?, &document.network_interface).find_node_inputs("Circular Repeat")?;
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ pub enum OperationToolMessage {
|
|||||||
WorkingColorChanged,
|
WorkingColorChanged,
|
||||||
|
|
||||||
// Tool-specific messages
|
// Tool-specific messages
|
||||||
|
IncreaseCount,
|
||||||
|
DecreaseCount,
|
||||||
Confirm,
|
Confirm,
|
||||||
DragStart,
|
DragStart,
|
||||||
DragStop,
|
DragStop,
|
||||||
@@ -127,6 +129,8 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionMessageContext<'a>> for Oper
|
|||||||
PointerMove,
|
PointerMove,
|
||||||
Confirm,
|
Confirm,
|
||||||
Abort,
|
Abort,
|
||||||
|
IncreaseCount,
|
||||||
|
DecreaseCount,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -212,6 +216,20 @@ impl Fsm for OperationToolFsmState {
|
|||||||
|
|
||||||
OperationToolFsmState::Drawing
|
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) => {
|
(_, OperationToolMessage::PointerMove) => {
|
||||||
responses.add(OverlaysMessage::Draw);
|
responses.add(OverlaysMessage::Draw);
|
||||||
self
|
self
|
||||||
|
|||||||
Reference in New Issue
Block a user