Skip to content

Commit f1cbc4b

Browse files
Make the node graph use Table<GradientStops> instead of GradientStops (#3837)
* Switch from GradientStops to Table<GradientStops> in all nodes * Remove TaggedValue::ColorNotInTable * Fix bug Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> * Add migrations * Fix default gradient on empty table * Update demo artwork --------- Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
1 parent 81c73d1 commit f1cbc4b

File tree

26 files changed

+132
-111
lines changed

26 files changed

+132
-111
lines changed

demo-artwork/changing-seasons.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/isometric-fountain.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/marbled-mandelbrot.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/painted-dreams.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/parametric-dunescape.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/procedural-string-lights.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/red-dress.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/valley-of-spires.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -214,19 +214,19 @@ pub(crate) fn property_from_type(
214214
Some(x) if x == TypeId::of::<String>() => text_widget(default_info).into(),
215215
Some(x) if x == TypeId::of::<DVec2>() => vec2_widget(default_info, "X", "Y", "", None, false),
216216
Some(x) if x == TypeId::of::<DAffine2>() => transform_widget(default_info, &mut extra_widgets),
217-
Some(x) if x == TypeId::of::<Color>() => color_widget(default_info, ColorInput::default()),
218-
Some(x) if x == TypeId::of::<Option<Color>>() => color_widget(default_info, ColorInput::default()),
219217
// ==========================
220218
// PRIMITIVE COLLECTION TYPES
221219
// ==========================
222220
Some(x) if x == TypeId::of::<Vec<f64>>() => array_of_number_widget(default_info, TextInput::default()).into(),
223221
Some(x) if x == TypeId::of::<Vec<DVec2>>() => array_of_vec2_widget(default_info, TextInput::default()).into(),
222+
// ===========
223+
// TABLE TYPES
224+
// ===========
225+
Some(x) if x == TypeId::of::<Table<Color>>() => color_widget(default_info, ColorInput::default().allow_none(true)),
226+
Some(x) if x == TypeId::of::<Table<GradientStops>>() => color_widget(default_info, ColorInput::default().allow_none(false)),
224227
// ============
225228
// STRUCT TYPES
226229
// ============
227-
Some(x) if x == TypeId::of::<Table<Color>>() => color_widget(default_info, ColorInput::default().allow_none(true)),
228-
Some(x) if x == TypeId::of::<Table<GradientStops>>() => color_widget(default_info, ColorInput::default().allow_none(false)),
229-
Some(x) if x == TypeId::of::<GradientStops>() => color_widget(default_info, ColorInput::default().allow_none(false)),
230230
Some(x) if x == TypeId::of::<Font>() => font_widget(default_info),
231231
Some(x) if x == TypeId::of::<Curve>() => curve_widget(default_info),
232232
Some(x) if x == TypeId::of::<Footprint>() => footprint_widget(default_info, &mut extra_widgets),
@@ -1145,14 +1145,6 @@ pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button:
11451145

11461146
// Add the color input
11471147
match &**tagged_value {
1148-
TaggedValue::ColorNotInTable(color) => widgets.push(
1149-
color_button
1150-
.value(FillChoice::Solid(*color))
1151-
.allow_none(false)
1152-
.on_update(update_value(|input: &ColorInput| TaggedValue::ColorNotInTable(input.value.as_solid().unwrap()), node_id, index))
1153-
.on_commit(commit_value)
1154-
.widget_instance(),
1155-
),
11561148
TaggedValue::Color(color_table) => widgets.push(
11571149
color_button
11581150
.value(match color_table.iter().next() {
@@ -1171,7 +1163,7 @@ pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button:
11711163
color_button
11721164
.value(match gradient_table.iter().next() {
11731165
Some(row) => FillChoice::Gradient(row.element.clone()),
1174-
None => FillChoice::None,
1166+
None => FillChoice::Gradient(GradientStops::default()),
11751167
})
11761168
.on_update(update_value(
11771169
|input: &ColorInput| TaggedValue::GradientTable(input.value.as_gradient().iter().map(|&gradient| TableRow::new_from_element(gradient.clone())).collect()),
@@ -1181,18 +1173,7 @@ pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button:
11811173
.on_commit(commit_value)
11821174
.widget_instance(),
11831175
),
1184-
TaggedValue::GradientStops(gradient_stops) => widgets.push(
1185-
color_button
1186-
.value(FillChoice::Gradient(gradient_stops.clone()))
1187-
.on_update(update_value(
1188-
|input: &ColorInput| TaggedValue::GradientStops(input.value.as_gradient().cloned().unwrap_or_default()),
1189-
node_id,
1190-
index,
1191-
))
1192-
.on_commit(commit_value)
1193-
.widget_instance(),
1194-
),
1195-
x => warn!("Colour {x:?}"),
1176+
x => warn!("Color {x:?}"),
11961177
}
11971178

11981179
LayoutGroup::Row { widgets }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl FrontendGraphDataType {
3535
TaggedValue::Raster(_) => Self::Raster,
3636
TaggedValue::Vector(_) => Self::Vector,
3737
TaggedValue::Color(_) => Self::Color,
38-
TaggedValue::Gradient(_) | TaggedValue::GradientStops(_) | TaggedValue::GradientTable(_) => Self::Gradient,
38+
TaggedValue::Gradient(_) | TaggedValue::GradientTable(_) => Self::Gradient,
3939
TaggedValue::String(_) | TaggedValue::VecString(_) => Self::Typography,
4040
_ => Self::General,
4141
}

0 commit comments

Comments
 (0)