Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub enum NodeGraphMessage {
SetInputValue {
node_id: NodeId,
input_index: usize,
value: TaggedValue,
value: Box<TaggedValue>,
},
SetInput {
input_connector: InputConnector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1764,6 +1764,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
NodeGraphMessage::SetInputValue { node_id, input_index, value } => {
use graphene_std::vector::generator_nodes::*;

let value = *value;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit ugly since without inlay hints, it is a bit hard to understand what this does. We could change the name of one of the variables to make this clearer, but this is not a big issue

let is_fill = matches!(value, TaggedValue::Fill(_));
let reference = network_interface.reference(&node_id, selection_network_path);
let is_text_node = reference.as_ref().is_some_and(|r| *r == DefinitionIdentifier::ProtoNode(graphene_std::text::text::IDENTIFIER));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ pub(crate) fn string_properties(text: &str) -> Vec<LayoutGroup> {

fn optionally_update_value<T>(value: impl Fn(&T) -> Option<TaggedValue> + 'static + Send + Sync, node_id: NodeId, input_index: usize) -> impl Fn(&T) -> Message + 'static + Send + Sync {
move |input_value: &T| match value(input_value) {
Some(value) => NodeGraphMessage::SetInputValue { node_id, input_index, value }.into(),
Some(value) => {
let value = Box::new(value);
NodeGraphMessage::SetInputValue { node_id, input_index, value }.into()
}
Comment thread
Keavon marked this conversation as resolved.
None => Message::NoOp,
}
}
Expand Down Expand Up @@ -831,7 +834,7 @@ pub fn font_inputs(parameter_widgets_info: ParameterWidgetsInfo) -> (Vec<WidgetI
NodeGraphMessage::SetInputValue {
node_id,
input_index: graphene_std::text::text::FontInput::INDEX,
value: TaggedValue::Resource(resource_id),
value: Box::new(TaggedValue::Resource(resource_id)),
}
.into(),
]),
Expand Down Expand Up @@ -1401,7 +1404,7 @@ fn build_shared_spectrum_section(node_id: NodeId, context: &mut NodePropertiesCo
NodeGraphMessage::SetInputValue {
node_id,
input_index,
value: TaggedValue::F32(percent.clamp(0., 100.) as f32),
value: Box::new(TaggedValue::F32(percent.clamp(0., 100.) as f32)),
}
.into()
}
Expand Down Expand Up @@ -1558,7 +1561,7 @@ fn spectrum_slider_row(
NodeGraphMessage::SetInputValue {
node_id,
input_index,
value: TaggedValue::F32(position_to_value(new_position).clamp(value_min, value_max) as f32),
value: Box::new(TaggedValue::F32(position_to_value(new_position).clamp(value_min, value_max) as f32)),
}
.into()
})
Expand Down Expand Up @@ -2112,13 +2115,13 @@ pub(crate) fn string_capitalization_properties(node_id: NodeId, context: &mut No
NodeGraphMessage::SetInputValue {
node_id,
input_index: UseJoinerInput::INDEX,
value: TaggedValue::Bool(true),
value: Box::new(TaggedValue::Bool(true)),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For these I would generally prefer to write this using .into() instead of the more verbose Box::new but this is personal preference

}
.into(),
NodeGraphMessage::SetInputValue {
node_id,
input_index: JoinerInput::INDEX,
value: TaggedValue::String(value.clone()),
value: Box::new(TaggedValue::String(value.clone())),
}
.into(),
]),
Expand Down Expand Up @@ -2178,13 +2181,13 @@ pub(crate) fn rectangle_properties(node_id: NodeId, context: &mut NodeProperties
NodeGraphMessage::SetInputValue {
node_id,
input_index: IndividualCornerRadiiInput::INDEX,
value: TaggedValue::Bool(false),
value: Box::new(TaggedValue::Bool(false)),
}
.into(),
NodeGraphMessage::SetInputValue {
node_id,
input_index: CornerRadiusInput::<f64>::INDEX,
value: TaggedValue::F64(uniform_val),
value: Box::new(TaggedValue::F64(uniform_val)),
}
.into(),
]),
Expand All @@ -2198,13 +2201,13 @@ pub(crate) fn rectangle_properties(node_id: NodeId, context: &mut NodeProperties
NodeGraphMessage::SetInputValue {
node_id,
input_index: IndividualCornerRadiiInput::INDEX,
value: TaggedValue::Bool(true),
value: Box::new(TaggedValue::Bool(true)),
}
.into(),
NodeGraphMessage::SetInputValue {
node_id,
input_index: CornerRadiusInput::<f64>::INDEX,
value: TaggedValue::F64Array(individual_val_for_switch.clone()),
value: Box::new(TaggedValue::F64Array(individual_val_for_switch.clone())),
}
.into(),
]),
Expand Down Expand Up @@ -2454,13 +2457,13 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
NodeGraphMessage::SetInputValue {
node_id,
input_index: backup_index,
value: backup_value,
value: Box::new(backup_value),
}
.into(),
NodeGraphMessage::SetInputValue {
node_id,
input_index: FillInput::<Color>::INDEX,
value: TaggedValue::Fill(new_fill),
value: Box::new(TaggedValue::Fill(new_fill)),
}
.into(),
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2694,12 +2694,12 @@ impl NodeNetworkInterface {
DocumentNodeClickTargets {
node_click_target,
port_click_targets,
node_type_metadata: NodeTypeClickTargets::Layer(LayerClickTargets {
node_type_metadata: NodeTypeClickTargets::Layer(Box::new(LayerClickTargets {
visibility_click_target,
lock_click_target,
grip_click_target,
name_click_target,
}),
})),
}
};

Expand Down Expand Up @@ -6771,7 +6771,7 @@ pub struct LayerTransientMetadata {

#[derive(Debug, Clone)]
pub enum NodeTypeClickTargets {
Layer(LayerClickTargets),
Layer(Box<LayerClickTargets>),
Node, // No transient click targets are stored exclusively for nodes
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ pub fn set_stroke_weight_for_selected_layers(weight: f64, document: &DocumentMes
for layer in layers {
if let Some(node_id) = get_stroke_id(layer, &document.network_interface) {
let input_index = graphene_std::vector::stroke::WeightInput::INDEX;
let value = TaggedValue::F64(weight);
let value = Box::new(TaggedValue::F64(weight));
responses.add(NodeGraphMessage::SetInputValue { node_id, input_index, value });
} else if weight > 0. {
let stroke = graphene_std::vector::style::Stroke::default().with_weight(weight);
Expand Down Expand Up @@ -817,7 +817,7 @@ pub fn set_stroke_color_for_selected_layers(color: Option<Color>, weight: f64, d
for layer in layers {
if let Some(node_id) = get_stroke_id(layer, &document.network_interface) {
let input_index = graphene_std::vector::stroke::ColorInput::INDEX;
let value = TaggedValue::Color(color);
let value = Box::new(TaggedValue::Color(color));
responses.add(NodeGraphMessage::SetInputValue { node_id, input_index, value });
} else {
let stroke = graphene_std::vector::style::Stroke::new(color, weight);
Expand Down Expand Up @@ -885,11 +885,8 @@ pub fn set_proto_node_input_for_selected_layers(
let Some(node_id) = NodeGraphLayer::new(layer, &document.network_interface).upstream_node_id_from_name(&identifier) else {
continue;
};
responses.add(NodeGraphMessage::SetInputValue {
node_id,
input_index,
value: value.clone(),
});
let value = Box::new(value.clone());
responses.add(NodeGraphMessage::SetInputValue { node_id, input_index, value });
}
}

Expand Down
8 changes: 4 additions & 4 deletions editor/src/messages/tool/tool_messages/gradient_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1992,7 +1992,7 @@ mod test_gradient {
.handle_message(NodeGraphMessage::SetInputValue {
node_id: gradient_node_id,
input_index: 1,
value: TaggedValue::Gradient(GradientStops::new([
value: Box::new(TaggedValue::Gradient(GradientStops::new([
GradientStop {
position: 0.,
midpoint: 0.5,
Expand All @@ -2003,7 +2003,7 @@ mod test_gradient {
midpoint: 0.5,
color: Color::BLUE,
},
])),
]))),
})
.await;

Expand Down Expand Up @@ -2585,7 +2585,7 @@ mod test_gradient {
.handle_message(NodeGraphMessage::SetInputValue {
node_id: gradient_value_id,
input_index: 1,
value: TaggedValue::Gradient(GradientStops::new([
value: Box::new(TaggedValue::Gradient(GradientStops::new([
GradientStop {
position: 0.,
midpoint: 0.5,
Expand All @@ -2596,7 +2596,7 @@ mod test_gradient {
midpoint: 0.5,
color: Color::BLUE,
},
])),
]))),
})
.await;

Expand Down
6 changes: 3 additions & 3 deletions editor/src/messages/tool/tool_messages/text_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ fn create_text_widgets(tool: &TextTool, font_catalog: &FontCatalog, document: &D
NodeGraphMessage::SetInputValue {
node_id,
input_index: graphene_std::text::text::FontInput::INDEX,
value: TaggedValue::Resource(resource_id),
value: Box::new(TaggedValue::Resource(resource_id)),
}
.into(),
]),
Expand Down Expand Up @@ -349,7 +349,7 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionMessageContext<'a>> for Text
responses.add(NodeGraphMessage::SetInputValue {
node_id,
input_index: graphene_std::text::text::SizeInput::INDEX,
value: TaggedValue::F64(font_size),
value: Box::new(TaggedValue::F64(font_size)),
});
}
}
Expand All @@ -364,7 +364,7 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionMessageContext<'a>> for Text
responses.add(NodeGraphMessage::SetInputValue {
node_id,
input_index: graphene_std::text::text::AlignInput::INDEX,
value: TaggedValue::TextAlign(align),
value: Box::new(TaggedValue::TextAlign(align)),
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions editor/src/node_graph_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub struct CompilationResponse {
}

pub enum NodeGraphUpdate {
ExecutionResponse(ExecutionResponse),
ExecutionResponse(Box<ExecutionResponse>),
CompilationResponse(CompilationResponse),
EyedropperPreview(Raster<CPU>),
NodeGraphUpdateMessage(NodeGraphUpdateMessage),
Expand Down Expand Up @@ -352,7 +352,7 @@ impl NodeGraphExecutor {
responses: existing_responses,
vector_modify,
inspect_result,
} = execution_response;
} = *execution_response;

while let Some(&(queued_execution_id, _)) = self.futures.front() {
if queued_execution_id < execution_id {
Expand Down
2 changes: 1 addition & 1 deletion editor/src/node_graph_executor/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl InternalNodeGraphUpdateSender {
}

fn send_execution_response(&self, response: ExecutionResponse) {
self.0.send(NodeGraphUpdate::ExecutionResponse(response)).expect("Failed to send response")
self.0.send(NodeGraphUpdate::ExecutionResponse(Box::new(response))).expect("Failed to send response")
}

fn send_eyedropper_preview(&self, raster: Raster<CPU>) {
Expand Down
2 changes: 1 addition & 1 deletion node-graph/node-macro/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
}
}
ParsedValueSource::Scope(data) => {
if let syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Str(_), .. }) = data {
if let syn::Expr::Lit(syn::ExprLit { lit: syn::Lit::Str(_), .. }) = data.as_ref() {
quote!(RegistryValueSource::Scope(#data))
} else {
quote!(RegistryValueSource::Scope(#data.as_static_str()))
Expand Down
4 changes: 2 additions & 2 deletions node-graph/node-macro/src/parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub enum ParsedValueSource {
#[default]
None,
Default(TokenStream2),
Scope(Expr),
Scope(Box<Expr>),
}

// #[widget(ParsedWidgetOverride::Hidden)]
Expand Down Expand Up @@ -676,7 +676,7 @@ fn parse_field(pat_ident: PatIdent, ty: Type, attrs: &[Attribute]) -> syn::Resul
let value_source = match (default_value, scope) {
(Some(_), Some(_)) => return Err(Error::new_spanned(&pat_ident, "Cannot have both `default` and `scope` attributes")),
(Some(default_value), _) => ParsedValueSource::Default(default_value),
(_, Some(scope)) => ParsedValueSource::Scope(scope),
(_, Some(scope)) => ParsedValueSource::Scope(Box::new(scope)),
_ => ParsedValueSource::None,
};

Expand Down
2 changes: 1 addition & 1 deletion node-graph/node-macro/src/shader_nodes/per_pixel_adjust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl PerPixelAdjustCodegen<'_> {
ty: ParsedFieldType::Regular(RegularParsedField {
ty: parse_quote!(&'a WgpuExecutor),
exposed: true,
value_source: ParsedValueSource::Scope(parse_quote!("graphene_std::platform_application_io::WgpuExecutorNode")),
value_source: ParsedValueSource::Scope(Box::new(parse_quote!("graphene_std::platform_application_io::WgpuExecutorNode"))),
number_soft_min: None,
number_soft_max: None,
number_hard_min: None,
Expand Down
Loading