Skip to content

Commit

Permalink
removed the fsm code
Browse files Browse the repository at this point in the history
  • Loading branch information
0SlowPoke0 authored and 0HyperCube committed Dec 16, 2024
1 parent 032f5fc commit a63fe80
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1585,22 +1585,42 @@ impl NodeNetworkInterface {
/// Mutably get the selected nodes for the network at the network_path. Every time they are mutated, the transient metadata for the top of the stack gets unloaded.
pub fn selected_nodes_mut(&mut self, network_path: &[NodeId]) -> Option<&mut SelectedNodes> {
self.unload_stack_dependents(network_path);

let last_selection_state = {
let Some(network_metadata) = self.network_metadata_mut(network_path) else {
log::error!("Could not get nested network_metadata in selected_nodes");
return None;
};

network_metadata.persistent_metadata.selection_undo_history.back().cloned().unwrap_or_default()
};

let layers_except_artboards: Vec<_> = last_selection_state.selected_layers_except_artboards(self).collect();

// If the selection is empty or contains only artboards, skip the undo history update.
if layers_except_artboards.is_empty() {
let Some(network_metadata) = self.network_metadata_mut(network_path) else {
log::error!("Could not get nested network_metadata in selected_nodes");
return None;
};

return network_metadata.persistent_metadata.selection_undo_history.back_mut();
}

let Some(network_metadata) = self.network_metadata_mut(network_path) else {
log::error!("Could not get nested network_metadata in selected_nodes");
return None;
};

let last_selection_state = network_metadata.persistent_metadata.selection_undo_history.back().cloned().unwrap_or_default();

network_metadata.persistent_metadata.selection_undo_history.push_back(last_selection_state);
network_metadata.persistent_metadata.selection_redo_history.clear();

if network_metadata.persistent_metadata.selection_undo_history.len() > crate::consts::MAX_UNDO_HISTORY_LEN {
network_metadata.persistent_metadata.selection_undo_history.pop_front();
}

network_metadata.persistent_metadata.selection_undo_history.back_mut()
}

pub fn selection_step_back(&mut self, network_path: &[NodeId]) {
let Some(network_metadata) = self.network_metadata_mut(network_path) else {
log::error!("Could not get nested network_metadata in selection_step_back");
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/tool/tool_messages/select_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ impl Fsm for SelectToolFsmState {
let new_selected: HashSet<_> = document.intersect_quad_no_artboards(quad, input).collect();
let current_selected: HashSet<_> = document.network_interface.selected_nodes(&[]).unwrap().selected_layers(document.metadata()).collect();

if new_selected != current_selected && !new_selected.is_empty() {
if new_selected != current_selected {
tool_data.layers_dragging = new_selected.into_iter().collect();
responses.add(NodeGraphMessage::SelectedNodesSet {
nodes: tool_data
Expand Down

0 comments on commit a63fe80

Please sign in to comment.