mirror of
https://github.com/eliasstepanik/egui_node_graph.git
synced 2026-01-11 05:48:27 +00:00
widget response
This commit is contained in:
parent
a1223b58cc
commit
ad3c9b1383
@ -52,7 +52,7 @@ where
|
||||
ValueType = ValueType,
|
||||
>,
|
||||
UserResponse: UserResponseTrait,
|
||||
ValueType: WidgetValueTrait,
|
||||
ValueType: WidgetValueTrait<Response = UserResponse>,
|
||||
NodeTemplate:
|
||||
NodeTemplateTrait<NodeData = NodeData, DataType = DataType, ValueType = ValueType>,
|
||||
DataType: DataTypeTrait,
|
||||
@ -297,7 +297,7 @@ where
|
||||
ValueType = ValueType,
|
||||
>,
|
||||
UserResponse: UserResponseTrait,
|
||||
ValueType: WidgetValueTrait,
|
||||
ValueType: WidgetValueTrait<Response = UserResponse>,
|
||||
DataType: DataTypeTrait,
|
||||
{
|
||||
pub const MAX_NODE_SIZE: [f32; 2] = [200.0, 200.0];
|
||||
@ -373,7 +373,13 @@ where
|
||||
if self.graph.connection(param_id).is_some() {
|
||||
ui.label(param_name);
|
||||
} else {
|
||||
self.graph[param_id].value.value_widget(¶m_name, ui);
|
||||
responses.extend(
|
||||
self.graph[param_id]
|
||||
.value
|
||||
.value_widget(¶m_name, ui)
|
||||
.into_iter()
|
||||
.map(NodeResponse::User),
|
||||
);
|
||||
}
|
||||
let height_after = ui.min_rect().bottom();
|
||||
input_port_heights.push((height_before + height_after) / 2.0);
|
||||
|
||||
@ -4,7 +4,8 @@ use super::*;
|
||||
/// [`Graph`]. The trait allows drawing custom inline widgets for the different
|
||||
/// types of the node graph.
|
||||
pub trait WidgetValueTrait {
|
||||
fn value_widget(&mut self, param_name: &str, ui: &mut egui::Ui);
|
||||
type Response;
|
||||
fn value_widget(&mut self, param_name: &str, ui: &mut egui::Ui) -> Vec<Self::Response>;
|
||||
}
|
||||
|
||||
/// This trait must be implemented by the `DataType` generic parameter of the
|
||||
|
||||
@ -250,7 +250,8 @@ impl NodeTemplateIter for AllMyNodeTemplates {
|
||||
}
|
||||
|
||||
impl WidgetValueTrait for MyValueType {
|
||||
fn value_widget(&mut self, param_name: &str, ui: &mut egui::Ui) {
|
||||
type Response = MyResponse;
|
||||
fn value_widget(&mut self, param_name: &str, ui: &mut egui::Ui) -> Vec<MyResponse> {
|
||||
// This trait is used to tell the library which UI to display for the
|
||||
// inline parameter widgets.
|
||||
match self {
|
||||
@ -270,6 +271,8 @@ impl WidgetValueTrait for MyValueType {
|
||||
});
|
||||
}
|
||||
}
|
||||
// This allows you to retorn your responses from the inline widgets.
|
||||
Vec::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user