Skip to content

Commit 2835c3b

Browse files
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
1 parent 7a6e4f6 commit 2835c3b

1 file changed

Lines changed: 17 additions & 23 deletions

File tree

editor/src/messages/portfolio/document/node_graph/node_properties.rs

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2451,35 +2451,29 @@ pub(crate) fn fill_properties(node_id: NodeId, context: &mut NodePropertiesConte
24512451
widgets_first_row.push(
24522452
ColorInput::default()
24532453
.value(FillChoiceUI::from(&FillChoice::from(fill.clone())))
2454-
.on_update(move |x: &ColorInput| Message::Batched {
2455-
messages: Box::new([
2456-
match &fill2 {
2457-
Fill::None => NodeGraphMessage::SetInputValue {
2458-
node_id,
2459-
input_index: BackupColorInput::INDEX,
2460-
value: TaggedValue::Color(None),
2461-
}
2462-
.into(),
2463-
Fill::Solid(color) => NodeGraphMessage::SetInputValue {
2454+
.on_update(move |x: &ColorInput| {
2455+
let new_fill = FillChoice::from(&x.value).to_fill(fill2.as_gradient());
2456+
let (backup_index, backup_value) = match &new_fill {
2457+
Fill::None => (BackupColorInput::INDEX, TaggedValue::Color(None)),
2458+
Fill::Solid(color) => (BackupColorInput::INDEX, TaggedValue::Color(Some(*color))),
2459+
Fill::Gradient(gradient) => (BackupGradientInput::INDEX, TaggedValue::FillGradient(gradient.clone())),
2460+
};
2461+
Message::Batched {
2462+
messages: Box::new([
2463+
NodeGraphMessage::SetInputValue {
24642464
node_id,
2465-
input_index: BackupColorInput::INDEX,
2466-
value: TaggedValue::Color(Some(*color)),
2465+
input_index: backup_index,
2466+
value: backup_value,
24672467
}
24682468
.into(),
2469-
Fill::Gradient(gradient) => NodeGraphMessage::SetInputValue {
2469+
NodeGraphMessage::SetInputValue {
24702470
node_id,
2471-
input_index: BackupGradientInput::INDEX,
2472-
value: TaggedValue::FillGradient(gradient.clone()),
2471+
input_index: FillInput::<Color>::INDEX,
2472+
value: TaggedValue::Fill(new_fill),
24732473
}
24742474
.into(),
2475-
},
2476-
NodeGraphMessage::SetInputValue {
2477-
node_id,
2478-
input_index: FillInput::<Color>::INDEX,
2479-
value: TaggedValue::Fill(FillChoice::from(&x.value).to_fill(fill2.as_gradient())),
2480-
}
2481-
.into(),
2482-
]),
2475+
]),
2476+
}
24832477
})
24842478
.on_commit(commit_value)
24852479
.widget_instance(),

0 commit comments

Comments
 (0)