Skip to content

Commit 5cdcc37

Browse files
0HyperCubeKeavon
andauthored
Make the Transform node's skew parameter input actually in degrees (#2431)
* Make skew actually in degrees * Add min and max --------- Co-authored-by: Keavon Chambers <keavon@keavon.com>
1 parent 3e56113 commit 5cdcc37

File tree

1 file changed

+47
-9
lines changed

1 file changed

+47
-9
lines changed

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

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,15 +2252,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
22522252
..Default::default()
22532253
}),
22542254
),
2255-
PropertiesRow::with_override(
2256-
"Skew",
2257-
WidgetOverride::Vec2(Vec2InputSettings {
2258-
x: "X".to_string(),
2259-
y: "Y".to_string(),
2260-
unit: "°".to_string(),
2261-
..Default::default()
2262-
}),
2263-
),
2255+
PropertiesRow::with_override("Skew", WidgetOverride::Custom("transform_skew".to_string())),
22642256
PropertiesRow::with_override("Pivot", WidgetOverride::Hidden),
22652257
],
22662258
output_names: vec!["Data".to_string()],
@@ -3360,6 +3352,52 @@ fn static_input_properties() -> InputProperties {
33603352
Ok(vec![LayoutGroup::Row { widgets }])
33613353
}),
33623354
);
3355+
// Skew has a custom override that maps to degrees
3356+
map.insert(
3357+
"transform_skew".to_string(),
3358+
Box::new(|node_id, index, context| {
3359+
let (document_node, input_name) = node_properties::query_node_and_input_name(node_id, index, context)?;
3360+
3361+
let mut widgets = node_properties::start_widgets(document_node, node_id, index, input_name, super::utility_types::FrontendGraphDataType::Number, true);
3362+
3363+
let Some(input) = document_node.inputs.get(index) else {
3364+
return Err("Input not found in transform skew input override".to_string());
3365+
};
3366+
if let Some(&TaggedValue::DVec2(val)) = input.as_non_exposed_value() {
3367+
let to_skew = |input: &NumberInput| input.value.unwrap().to_radians().tan();
3368+
widgets.extend_from_slice(&[
3369+
Separator::new(SeparatorType::Unrelated).widget_holder(),
3370+
NumberInput::new(Some(val.x.atan().to_degrees()))
3371+
.label("X")
3372+
.unit("°")
3373+
.min(-89.9)
3374+
.max(89.9)
3375+
.on_update(node_properties::update_value(
3376+
move |input: &NumberInput| TaggedValue::DVec2(DVec2::new(to_skew(input), val.y)),
3377+
node_id,
3378+
index,
3379+
))
3380+
.on_commit(node_properties::commit_value)
3381+
.widget_holder(),
3382+
Separator::new(SeparatorType::Related).widget_holder(),
3383+
NumberInput::new(Some(val.y.atan().to_degrees()))
3384+
.label("Y")
3385+
.unit("°")
3386+
.min(-89.9)
3387+
.max(89.9)
3388+
.on_update(node_properties::update_value(
3389+
move |input: &NumberInput| TaggedValue::DVec2(DVec2::new(val.x, to_skew(input))),
3390+
node_id,
3391+
index,
3392+
))
3393+
.on_commit(node_properties::commit_value)
3394+
.widget_holder(),
3395+
]);
3396+
}
3397+
3398+
Ok(vec![LayoutGroup::Row { widgets }])
3399+
}),
3400+
);
33633401
map.insert(
33643402
"text_area".to_string(),
33653403
Box::new(|node_id, index, context| {

0 commit comments

Comments
 (0)