Properly handle pen tool undo and redo (#1587)

feat: properly handle pen tool undo and redo
This commit is contained in:
zhiyuan
2024-02-04 19:23:48 +00:00
committed by GitHub
parent aed30d78b8
commit 05b4582cd7
4 changed files with 45 additions and 1 deletions
@@ -177,6 +177,15 @@ impl MessageHandler<ToolMessage, (&DocumentMessageHandler, DocumentId, &InputPre
tool_data.active_tool_mut().process_message(ToolMessage::UpdateHints, responses, &mut data);
tool_data.active_tool_mut().process_message(ToolMessage::UpdateCursor, responses, &mut data);
}
ToolMessage::Redo => {
let tool_data = &mut self.tool_state.tool_data;
match tool_data.active_tool_type {
ToolType::Pen => {
responses.add(PenToolMessage::Redo);
}
_ => {}
}
}
ToolMessage::RefreshToolOptions => {
let tool_data = &mut self.tool_state.tool_data;
tool_data.tools.get(&tool_data.active_tool_type).unwrap().send_layout(responses, LayoutTarget::ToolOptions);
@@ -221,6 +230,17 @@ impl MessageHandler<ToolMessage, (&DocumentMessageHandler, DocumentId, &InputPre
document_data.update_working_colors(responses); // TODO: Make this an event
}
ToolMessage::Undo => {
let tool_data = &mut self.tool_state.tool_data;
match tool_data.active_tool_type {
ToolType::Pen => {
responses.add(PenToolMessage::Undo);
}
_ => {
responses.add(BroadcastEvent::ToolAbort);
}
}
}
// Sub-messages
#[remain::unsorted]
@@ -282,6 +302,7 @@ impl MessageHandler<ToolMessage, (&DocumentMessageHandler, DocumentId, &InputPre
SelectRandomPrimaryColor,
ResetColors,
SwapColors,
Undo,
);
list.extend(self.tool_state.tool_data.active_tool().actions());
list.extend(self.transform_layer_handler.actions());