Merge pull request #76 from huisedenanhai/main

Node can decide whether it can be deleted
This commit is contained in:
setzer22 2022-12-10 12:43:55 +01:00 committed by GitHub
commit b5af1c745c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -771,7 +771,13 @@ where
// --- Interaction ---
// Titlebar buttons
if Self::close_button(ui, outer_rect).clicked() {
let can_delete = self.graph.nodes[self.node_id].user_data.can_delete(
self.node_id,
self.graph,
user_state,
);
if can_delete && Self::close_button(ui, outer_rect).clicked() {
responses.push(NodeResponse::DeleteNodeUi(self.node_id));
};

View File

@ -102,6 +102,15 @@ where
) -> Option<egui::Color32> {
None
}
fn can_delete(
&self,
_node_id: NodeId,
_graph: &Graph<Self, Self::DataType, Self::ValueType>,
_user_state: &mut Self::UserState,
) -> bool {
true
}
}
/// This trait can be implemented by any user type. The trait tells the library