Skip to content

Commit 5bab3de

Browse files
committed
WIP TaggedValue for Option<Color>, not fixing UI
1 parent 55696b9 commit 5bab3de

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ pub(crate) fn property_from_type(
181181
// ============
182182
// STRUCT TYPES
183183
// ============
184+
Some(x) if x == TypeId::of::<Option<Color>>() => color_widget(default_info, ColorInput::default().allow_none(true)),
184185
Some(x) if x == TypeId::of::<Table<Color>>() => color_widget(default_info, ColorInput::default().allow_none(true)),
185186
Some(x) if x == TypeId::of::<Table<GradientStops>>() => color_widget(default_info, ColorInput::default().allow_none(false)),
186187
Some(x) if x == TypeId::of::<GradientStops>() => color_widget(default_info, ColorInput::default().allow_none(false)),
@@ -909,6 +910,16 @@ pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button:
909910

910911
// Add the color input
911912
match &**tagged_value {
913+
TaggedValue::OptionalColor(color) => widgets.push(
914+
color_button
915+
.value(match color.iter().next() {
916+
Some(color) => FillChoice::Solid(*color),
917+
None => FillChoice::None,
918+
})
919+
.on_update(update_value(|input: &ColorInput| TaggedValue::OptionalColor(input.value.as_solid()), node_id, index))
920+
.on_commit(commit_value)
921+
.widget_holder(),
922+
),
912923
TaggedValue::Color(color_table) => widgets.push(
913924
color_button
914925
.value(match color_table.iter().next() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ impl NodeNetworkInterface {
578578
let skip_footprint = 1;
579579

580580
let Some(input_type) = std::iter::once(node_types.call_argument.clone()).chain(node_types.inputs.clone()).nth(input_index + skip_footprint) else {
581-
log::error!("Could not get type");
581+
log::error!("Could not get type of input {} of node '{protonode}'", input_index + skip_footprint);
582582
return (concrete!(()), TypeSource::Error("could not get the protonode's input"));
583583
};
584584

node-graph/graph-craft/src/document/value.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ tagged_value! {
195195
#[serde(alias = "ArtboardGroup")]
196196
Artboard(Table<Artboard>),
197197
#[cfg_attr(target_family = "wasm", serde(deserialize_with = "graphene_core::misc::migrate_color"))] // TODO: Eventually remove this migration document upgrade code
198-
#[serde(alias = "ColorTable", alias = "OptionalColor")]
198+
#[serde(alias = "ColorTable")]
199199
Color(Table<Color>),
200200
GradientTable(Table<GradientStops>),
201201
// ============
@@ -204,6 +204,7 @@ tagged_value! {
204204
#[serde(alias = "IVec2", alias = "UVec2")]
205205
DVec2(DVec2),
206206
DAffine2(DAffine2),
207+
OptionalColor(Option<Color>),
207208
Stroke(graphene_core::vector::style::Stroke),
208209
Gradient(graphene_core::vector::style::Gradient),
209210
#[serde(alias = "GradientPositions")] // TODO: Eventually remove this alias document upgrade code

0 commit comments

Comments
 (0)