Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::document_node_definitions::{NODE_OVERRIDES, NodePropertiesContext};
use super::utility_types::FrontendGraphDataType;
use crate::messages::layout::utility_types::widget_prelude::*;
use crate::messages::portfolio::document::node_graph::document_node_definitions::resolve_document_node_type;
use crate::messages::portfolio::document::utility_types::network_interface::InputConnector;
use crate::messages::portfolio::document::utility_types::network_interface::{InputConnector, NodeNetworkInterface};
use crate::messages::portfolio::utility_types::{FontCatalogStyle, PersistentData};
use crate::messages::prelude::*;
use choice::enum_choice;
Expand Down Expand Up @@ -78,6 +78,20 @@ pub fn add_blank_assist(widgets: &mut Vec<WidgetInstance>) {
]);
}

pub fn jump_to_source_widget(input: &NodeInput, network_interface: &NodeNetworkInterface, selection_network_path: &[NodeId]) -> WidgetInstance {
match input {
NodeInput::Node { node_id: source_id, .. } => {
let source_id = *source_id;
let node_name = network_interface.implementation_name(&source_id, selection_network_path);
TextButton::new(format!("Select Source: {}", node_name))
.tooltip_description("Jump to the source node connected to this input.")
.on_update(move |_| NodeGraphMessage::SelectedNodesSet { nodes: vec![source_id] }.into())
.widget_instance()
}
_ => TextLabel::new("Input Not Connected").tooltip_description("No node connected.").widget_instance(),
}
}

pub fn start_widgets(parameter_widgets_info: ParameterWidgetsInfo) -> Vec<WidgetInstance> {
let ParameterWidgetsInfo {
document_node,
Expand All @@ -88,6 +102,8 @@ pub fn start_widgets(parameter_widgets_info: ParameterWidgetsInfo) -> Vec<Widget
input_type,
blank_assist,
exposable,
network_interface,
selection_network_path,
..
} = parameter_widgets_info;

Expand All @@ -105,6 +121,17 @@ pub fn start_widgets(parameter_widgets_info: ParameterWidgetsInfo) -> Vec<Widget
widgets.push(expose_widget(node_id, index, input_type, input.is_exposed()));
}
widgets.push(TextLabel::new(name).tooltip_description(description).widget_instance());

let mut blank_assist = blank_assist;
if input.is_exposed() {
if blank_assist {
add_blank_assist(&mut widgets);
blank_assist = false;
}
widgets.push(Separator::new(SeparatorStyle::Unrelated).widget_instance());
widgets.push(jump_to_source_widget(input, network_interface, selection_network_path));
}

if blank_assist {
add_blank_assist(&mut widgets);
}
Expand Down Expand Up @@ -230,14 +257,19 @@ pub(crate) fn property_from_type(
// OTHER
// =====
_ => {
let is_exposed = default_info.is_exposed();

let mut widgets = start_widgets(default_info);
widgets.extend_from_slice(&[
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
TextLabel::new("-")
.tooltip_label(format!("Data Type: {concrete_type}"))
.tooltip_description("This data can only be supplied through the node graph because no widget exists for its type.")
.widget_instance(),
]);

if !is_exposed {
widgets.extend_from_slice(&[
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
TextLabel::new("-")
.tooltip_label(format!("Data Type: {concrete_type}"))
.tooltip_description("This data can only be supplied through the node graph because no widget exists for its type.")
.widget_instance(),
]);
}
return Err(vec![widgets.into()]);
}
}
Expand Down Expand Up @@ -2141,6 +2173,8 @@ pub fn math_properties(node_id: NodeId, context: &mut NodePropertiesContext) ->

pub struct ParameterWidgetsInfo<'a> {
persistent_data: &'a PersistentData,
network_interface: &'a NodeNetworkInterface,
selection_network_path: &'a [NodeId],
document_node: Option<&'a DocumentNode>,
node_id: NodeId,
index: usize,
Expand All @@ -2162,6 +2196,8 @@ impl<'a> ParameterWidgetsInfo<'a> {

ParameterWidgetsInfo {
persistent_data: context.persistent_data,
network_interface: context.network_interface,
selection_network_path: context.selection_network_path,
document_node,
node_id,
index,
Expand All @@ -2172,6 +2208,10 @@ impl<'a> ParameterWidgetsInfo<'a> {
exposable: true,
}
}

pub fn is_exposed(&self) -> bool {
self.document_node.and_then(|node| node.inputs.get(self.index)).map(|input| input.is_exposed()).unwrap_or(false)
}
}

pub mod choice {
Expand Down
Loading