Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Add ParamId to output_ui & value_widget{,_connected} methods #99

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion egui_node_graph/src/editor_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,7 @@ where
let node_responses = value.value_widget_connected(
&param_name,
self.node_id,
param_id,
ui,
user_state,
&self.graph[self.node_id].user_data,
Expand All @@ -595,6 +596,7 @@ where
let node_responses = value.value_widget(
&param_name,
self.node_id,
param_id,
ui,
user_state,
&self.graph[self.node_id].user_data,
Expand Down Expand Up @@ -624,7 +626,14 @@ where
responses.extend(
self.graph[self.node_id]
.user_data
.output_ui(ui, self.node_id, self.graph, user_state, &param_name)
.output_ui(
ui,
self.node_id,
self.graph,
user_state,
param_id,
&param_name,
)
.into_iter(),
);

Expand Down
9 changes: 6 additions & 3 deletions egui_node_graph/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ pub trait WidgetValueTrait: Default {
&mut self,
param_name: &str,
node_id: NodeId,
param_id: InputId,
ui: &mut egui::Ui,
user_state: &mut Self::UserState,
node_data: &Self::NodeData,
) -> Vec<Self::Response>;

/// This method will be called for each input parameter with a widget with a connected
/// input only. To display UI for diconnected inputs use [`WidgetValueTrait::value_widget`].
/// input only. To display UI for disconnected inputs use [`WidgetValueTrait::value_widget`].
/// The return value is a vector of custom response objects which can be used
/// to implement handling of side effects. If unsure, the response Vec can
/// be empty.
Expand All @@ -39,6 +40,7 @@ pub trait WidgetValueTrait: Default {
&mut self,
param_name: &str,
_node_id: NodeId,
_param_id: InputId,
ui: &mut egui::Ui,
_user_state: &mut Self::UserState,
_node_data: &Self::NodeData,
Expand Down Expand Up @@ -136,6 +138,7 @@ where
_node_id: NodeId,
_graph: &Graph<Self, Self::DataType, Self::ValueType>,
_user_state: &mut Self::UserState,
_param_id: OutputId,
param_name: &str,
) -> Vec<NodeResponse<Self::Response, Self>>
where
Expand Down Expand Up @@ -163,7 +166,7 @@ where
/// 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.
/// *preceding* the separator.
///
/// Default implementation does nothing.
fn separator(
Expand Down Expand Up @@ -199,7 +202,7 @@ pub trait NodeTemplateIter {
/// Used by [`NodeTemplateTrait::node_finder_categories`] to categorize nodes
/// templates into groups.
///
/// If all nodes in a program are known beforehand, it's usefult to define
/// If all nodes in a program are known beforehand, it's useful to define
/// an enum containing all categories and implement [`CategoryTrait`] for it. This will
/// make it impossible to accidentally create a new category by mis-typing an existing
/// one, like in the case of using string types.
Expand Down
1 change: 1 addition & 0 deletions egui_node_graph_example/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ impl WidgetValueTrait for MyValueType {
&mut self,
param_name: &str,
_node_id: NodeId,
_param_id: InputId,
ui: &mut egui::Ui,
_user_state: &mut MyGraphState,
_node_data: &MyNodeData,
Expand Down