Merge pull request #89 from kamirr/kek/separator

custom separators
This commit is contained in:
setzer22 2023-05-15 11:21:41 +02:00 committed by GitHub
commit 6b3ca47db0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 2 deletions

View File

@ -600,6 +600,14 @@ where
responses.extend(node_responses.into_iter().map(NodeResponse::User));
}
self.graph[self.node_id].user_data.separator(
ui,
self.node_id,
AnyParameterId::Input(param_id),
self.graph,
user_state,
);
self.graph[param_id].value = value;
let height_after = ui.min_rect().bottom();
@ -608,7 +616,7 @@ where
}
let outputs = self.graph[self.node_id].outputs.clone();
for (param_name, _param) in outputs {
for (param_name, param_id) in outputs {
let height_before = ui.min_rect().bottom();
responses.extend(
self.graph[self.node_id]
@ -616,6 +624,15 @@ where
.output_ui(ui, self.node_id, self.graph, user_state, &param_name)
.into_iter(),
);
self.graph[self.node_id].user_data.separator(
ui,
self.node_id,
AnyParameterId::Output(param_id),
self.graph,
user_state,
);
let height_after = ui.min_rect().bottom();
output_port_heights.push((height_before + height_after) / 2.0);
}

View File

@ -113,7 +113,7 @@ where
where
Self::Response: UserResponseTrait;
// UI to draw on the top bar of the node.
/// UI to draw on the top bar of the node.
fn top_bar_ui(
&self,
_ui: &mut egui::Ui,
@ -158,6 +158,24 @@ where
None
}
/// Separator to put between elements in the node.
///
/// Invoked between inputs, outputs and bottom UI. Useful for
/// complicated UIs that start to lose structure without explicit
/// separators. The `param_id` argument is the id of input or output
/// *preceeding* the separator.
///
/// Default implementation does nothing.
fn separator(
&self,
_ui: &mut egui::Ui,
_node_id: NodeId,
_param_id: AnyParameterId,
_graph: &Graph<Self, Self::DataType, Self::ValueType>,
_user_state: &mut Self::UserState,
) {
}
fn can_delete(
&self,
_node_id: NodeId,