mirror of
https://github.com/eliasstepanik/egui_node_graph.git
synced 2026-01-11 05:48:27 +00:00
Node can decide whether it can be deleted
This commit is contained in:
parent
070ff85bd3
commit
d2350d494a
@ -771,9 +771,16 @@ where
|
|||||||
// --- Interaction ---
|
// --- Interaction ---
|
||||||
|
|
||||||
// Titlebar buttons
|
// Titlebar buttons
|
||||||
|
let can_delete = self.graph.nodes[self.node_id].user_data.can_delete(
|
||||||
|
self.node_id,
|
||||||
|
self.graph,
|
||||||
|
user_state,
|
||||||
|
);
|
||||||
|
if can_delete {
|
||||||
if Self::close_button(ui, outer_rect).clicked() {
|
if Self::close_button(ui, outer_rect).clicked() {
|
||||||
responses.push(NodeResponse::DeleteNodeUi(self.node_id));
|
responses.push(NodeResponse::DeleteNodeUi(self.node_id));
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
let window_response = ui.interact(
|
let window_response = ui.interact(
|
||||||
outer_rect,
|
outer_rect,
|
||||||
|
|||||||
@ -102,6 +102,15 @@ where
|
|||||||
) -> Option<egui::Color32> {
|
) -> Option<egui::Color32> {
|
||||||
None
|
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
|
/// This trait can be implemented by any user type. The trait tells the library
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user