Skip to content

Commit 6e66c79

Browse files
Keavonadamgerhant
andauthored
Fix 'Mask' node missing Properties widget; fix crash with 'Brightness/Contrast Classic' node (#3404)
* Fix 'Mask' node missing Properties widget; fix crash with 'Brightness/Contrast Classic' node Also clean up dead code and improve tooltip for the "-" Properties panel widget fallback. * format type --------- Co-authored-by: Adam <[email protected]>
1 parent 7afbeaa commit 6e66c79

File tree

5 files changed

+20
-76
lines changed

5 files changed

+20
-76
lines changed

editor/src/messages/dialog/simple_dialogs/about_graphite_dialog.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ impl DialogLayoutHolder for AboutGraphiteDialog {
2121
fn layout_column_2(&self) -> Layout {
2222
let links = [
2323
("Heart", "Donate", "https://graphite.rs/donate/"),
24-
("Volunteer", "Volunteer", "https://graphite.rs/volunteer/"),
2524
("GraphiteLogo", "Website", "https://graphite.rs"),
25+
("Volunteer", "Volunteer", "https://graphite.rs/volunteer/"),
2626
("Credits", "Credits", "https://github.com/GraphiteEditor/Graphite/graphs/contributors"),
2727
];
2828
let mut widgets = links

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

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2021,47 +2021,6 @@ fn static_input_properties() -> InputProperties {
20212021
Ok(vec![cellular_jitter.into()])
20222022
}),
20232023
);
2024-
map.insert(
2025-
"brightness".to_string(),
2026-
Box::new(|node_id, index, context| {
2027-
let document_node = node_properties::get_document_node(node_id, context)?;
2028-
let is_use_classic = document_node
2029-
.inputs
2030-
.iter()
2031-
.find_map(|input| match input.as_value() {
2032-
Some(&TaggedValue::Bool(use_classic)) => Some(use_classic),
2033-
_ => None,
2034-
})
2035-
.unwrap_or(false);
2036-
let (b_min, b_max) = if is_use_classic { (-100., 100.) } else { (-100., 150.) };
2037-
let brightness = node_properties::number_widget(
2038-
ParameterWidgetsInfo::new(node_id, index, true, context),
2039-
NumberInput::default().mode_range().range_min(Some(b_min)).range_max(Some(b_max)).unit("%").display_decimal_places(2),
2040-
);
2041-
Ok(vec![brightness.into()])
2042-
}),
2043-
);
2044-
map.insert(
2045-
"contrast".to_string(),
2046-
Box::new(|node_id, index, context| {
2047-
let document_node = node_properties::get_document_node(node_id, context)?;
2048-
2049-
let is_use_classic = document_node
2050-
.inputs
2051-
.iter()
2052-
.find_map(|input| match input.as_value() {
2053-
Some(&TaggedValue::Bool(use_classic)) => Some(use_classic),
2054-
_ => None,
2055-
})
2056-
.unwrap_or(false);
2057-
let (c_min, c_max) = if is_use_classic { (-100., 100.) } else { (-50., 100.) };
2058-
let contrast = node_properties::number_widget(
2059-
ParameterWidgetsInfo::new(node_id, index, true, context),
2060-
NumberInput::default().mode_range().range_min(Some(c_min)).range_max(Some(c_max)).unit("%").display_decimal_places(2),
2061-
);
2062-
Ok(vec![contrast.into()])
2063-
}),
2064-
);
20652024
map.insert(
20662025
"assign_colors_gradient".to_string(),
20672026
Box::new(|node_id, index, context| {
@@ -2091,21 +2050,6 @@ fn static_input_properties() -> InputProperties {
20912050
Ok(vec![repeat_every_row.into()])
20922051
}),
20932052
);
2094-
map.insert(
2095-
"mask_stencil".to_string(),
2096-
Box::new(|node_id, index, context| {
2097-
let mask = node_properties::color_widget(ParameterWidgetsInfo::new(node_id, index, true, context), ColorInput::default());
2098-
Ok(vec![mask])
2099-
}),
2100-
);
2101-
map.insert(
2102-
"spline_input".to_string(),
2103-
Box::new(|node_id, index, context| {
2104-
Ok(vec![LayoutGroup::Row {
2105-
widgets: node_properties::array_of_vec2_widget(ParameterWidgetsInfo::new(node_id, index, true, context), TextInput::default().centered(true)),
2106-
}])
2107-
}),
2108-
);
21092053
map.insert(
21102054
"transform_rotation".to_string(),
21112055
Box::new(|node_id, index, context| {

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,12 @@ pub(crate) fn property_from_type(
232232
.tooltip(format!(
233233
"This data can only be supplied through the node graph because no widget exists for its type:\n\
234234
{}",
235-
concrete_type.name
235+
// TODO: Avoid needing to remove spaces here by fixing how `alias` is generated
236+
concrete_type
237+
.alias
238+
.as_deref()
239+
.map(|s| s.to_string().replace(" ", ""))
240+
.unwrap_or_else(|| graphene_std::format_type(concrete_type.name.as_ref()))
236241
))
237242
.widget_holder(),
238243
]);
@@ -1087,7 +1092,9 @@ pub(crate) fn brightness_contrast_properties(node_id: NodeId, context: &mut Node
10871092
return Vec::new();
10881093
}
10891094
};
1090-
let use_classic_value = match document_node.inputs[UseClassicInput::INDEX].as_value() {
1095+
let use_classic_value = document_node.inputs.get(UseClassicInput::INDEX);
1096+
let includes_use_classic = use_classic_value.is_some();
1097+
let use_classic_value = match use_classic_value.and_then(|input| input.as_value()) {
10911098
Some(TaggedValue::Bool(use_classic_choice)) => *use_classic_choice,
10921099
_ => false,
10931100
};
@@ -1114,11 +1121,11 @@ pub(crate) fn brightness_contrast_properties(node_id: NodeId, context: &mut Node
11141121
.range_max(Some(100.)),
11151122
);
11161123

1117-
let layout = vec![
1118-
LayoutGroup::Row { widgets: brightness },
1119-
LayoutGroup::Row { widgets: contrast },
1120-
LayoutGroup::Row { widgets: use_classic },
1121-
];
1124+
let mut layout = vec![LayoutGroup::Row { widgets: brightness }, LayoutGroup::Row { widgets: contrast }];
1125+
if includes_use_classic {
1126+
// TODO: When we no longer use this function in the temporary "Brightness/Contrast Classic" node, remove this conditional pushing and just always include this
1127+
layout.push(LayoutGroup::Row { widgets: use_classic });
1128+
}
11221129

11231130
layout
11241131
}
@@ -1596,18 +1603,11 @@ pub(crate) fn generate_node_properties(node_id: NodeId, context: &mut NodeProper
15961603
return Vec::new();
15971604
};
15981605

1599-
let mut input_types = implementations
1600-
.keys()
1601-
.filter_map(|item| item.inputs.get(input_index))
1602-
.filter(|ty| property_from_type(node_id, input_index, ty, number_options, unit_suffix, display_decimal_places, step, context).is_ok())
1603-
.collect::<Vec<_>>();
1606+
let mut input_types = implementations.keys().filter_map(|item| item.inputs.get(input_index)).collect::<Vec<_>>();
16041607
input_types.sort_by_key(|ty| ty.type_name());
16051608
let input_type = input_types.first().cloned();
16061609

1607-
let Some(input_type) = input_type else {
1608-
return Vec::new();
1609-
};
1610-
1610+
let Some(input_type) = input_type else { return Vec::new() };
16111611
input_type.clone()
16121612
}
16131613
_ => context

node-graph/libraries/core-types/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ impl Type {
354354
}
355355
}
356356

357-
fn format_type(ty: &str) -> String {
357+
pub fn format_type(ty: &str) -> String {
358358
ty.split('<')
359359
.map(|path| path.split(',').map(|path| path.split("::").last().unwrap_or(path)).collect::<Vec<_>>().join(","))
360360
.collect::<Vec<_>>()

node-graph/nodes/raster/src/adjustments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ fn make_opaque<T: Adjust<Color>>(
141141
input
142142
}
143143

144-
/// See [`brightness_contrast`]
144+
// TODO: Remove this once GPU shader nodes are able to support the non-classic algorithm
145145
#[node_macro::node(
146-
name("Brightness/Contrast classic"),
146+
name("Brightness/Contrast Classic"),
147147
category("Raster: Adjustment"),
148148
properties("brightness_contrast_properties"),
149149
shader_node(PerPixelAdjust)

0 commit comments

Comments
 (0)