Fix the Fill node not restoring its solid color after switching to gradient and back (#4159)

* fix: Fill node solid colour backup update

* chore: refactor
This commit is contained in:
Jatin Bharti
2026-06-08 04:18:10 +00:00
committed by GitHub
parent 7a6e4f6f25
commit 2835c3b536
@@ -2451,35 +2451,29 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
widgets_first_row.push( widgets_first_row.push(
ColorInput::default() ColorInput::default()
.value(FillChoiceUI::from(&FillChoice::from(fill.clone()))) .value(FillChoiceUI::from(&FillChoice::from(fill.clone())))
.on_update(move |x: &ColorInput| Message::Batched { .on_update(move |x: &ColorInput| {
messages: Box::new([ let new_fill = FillChoice::from(&x.value).to_fill(fill2.as_gradient());
match &fill2 { let (backup_index, backup_value) = match &new_fill {
Fill::None => NodeGraphMessage::SetInputValue { Fill::None => (BackupColorInput::INDEX, TaggedValue::Color(None)),
Fill::Solid(color) => (BackupColorInput::INDEX, TaggedValue::Color(Some(*color))),
Fill::Gradient(gradient) => (BackupGradientInput::INDEX, TaggedValue::FillGradient(gradient.clone())),
};
Message::Batched {
messages: Box::new([
NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: BackupColorInput::INDEX, input_index: backup_index,
value: TaggedValue::Color(None), value: backup_value,
} }
.into(), .into(),
Fill::Solid(color) => NodeGraphMessage::SetInputValue { NodeGraphMessage::SetInputValue {
node_id, node_id,
input_index: BackupColorInput::INDEX, input_index: FillInput::<Color>::INDEX,
value: TaggedValue::Color(Some(*color)), value: TaggedValue::Fill(new_fill),
} }
.into(), .into(),
Fill::Gradient(gradient) => NodeGraphMessage::SetInputValue { ]),
node_id, }
input_index: BackupGradientInput::INDEX,
value: TaggedValue::FillGradient(gradient.clone()),
}
.into(),
},
NodeGraphMessage::SetInputValue {
node_id,
input_index: FillInput::<Color>::INDEX,
value: TaggedValue::Fill(FillChoice::from(&x.value).to_fill(fill2.as_gradient())),
}
.into(),
]),
}) })
.on_commit(commit_value) .on_commit(commit_value)
.widget_instance(), .widget_instance(),