Repository: GraphiteEditor/Graphite
File: editor/src/messages/portfolio/document/node_graph/node_graph_message_handler/node_properties.rs (Rust)

Code before:

pub fn eq_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
	let operand = |name: &str, index| {
		let widgets = number_widget(document_node, node_id, index, name, NumberInput::default(), true);

		LayoutGroup::Row { widgets }
	};
	vec![operand("Equality", 1)]
}

pub fn modulo_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
	let operand = |name: &str, index| {
		let widgets = number_widget(document_node, node_id, index, name, NumberInput::default(), true);

		LayoutGroup::Row { widgets }
	};
	vec![operand("Modulo", 1)]
}

pub fn circle_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
	let operand = |name: &str, index| {
		let widgets = number_widget(document_node, node_id, index, name, NumberInput::default(), true);

		LayoutGroup::Row { widgets }
	};
	vec![operand("Radius", 1)]
}

pub fn elipse_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
	let operand = |name: &str, index| {
		let widgets = number_widget(document_node, node_id, index, name, NumberInput::default(), true);

		LayoutGroup::Row { widgets }
	};
	vec![operand("Radius X", 1), operand("Radius Y", 2)]
}

pub fn rectangle_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
	let operand = |name: &str, index| {
		let widgets = number_widget(document_node, node_id, index, name, NumberInput::default(), true);

		LayoutGroup::Row { widgets }
	};
	vec![operand("Size X", 1), operand("Size Y", 2)]
}

pub fn polygon_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
	let points = number_widget(document_node, node_id, 1, "Points", NumberInput::default().min(3.), true);
	let radius = number_widget(document_node, node_id, 2, "Radius", NumberInput::default(), true);

	vec![LayoutGroup::Row { widgets: points }, LayoutGroup::Row { widgets: radius }]

Review comment (suggestion):
There is no real need to have an operand closure only to call it once. Could be shortened to:
```rs
let radius = number_widget(document_node, node_id, 1, "radius", NumberInput::default(), true);
vec![LayoutGroup::Row { widgets: radius }]
```

Code after:
		LayoutGroup::Row { widgets }
	};
	vec![operand("Modulo", 1)]
}

pub fn circle_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
	vec![LayoutGroup::Row {
		widgets: number_widget(document_node, node_id, 1, "Radius", NumberInput::default(), true),
	}]
}

pub fn ellipse_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
	let operand = |name: &str, index| {
		let widgets = number_widget(document_node, node_id, index, name, NumberInput::default(), true);

		LayoutGroup::Row { widgets }
	};
	vec![operand("Radius X", 1), operand("Radius Y", 2)]
}

pub fn rectangle_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
	let operand = |name: &str, index| {
		let widgets = number_widget(document_node, node_id, index, name, NumberInput::default(), true);

		LayoutGroup::Row { widgets }
	};
	vec![operand("Size X", 1), operand("Size Y", 2)]
}

pub fn regular_polygon_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
	let points = number_widget(document_node, node_id, 1, "Points", NumberInput::default().min(3.), true);
	let radius = number_widget(document_node, node_id, 2, "Radius", NumberInput::default(), true);

	vec![LayoutGroup::Row { widgets: points }, LayoutGroup::Row { widgets: radius }]
}

pub fn star_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
	let points = number_widget(document_node, node_id, 1, "Points", NumberInput::default().min(2.), true);
	let radius = number_widget(document_node, node_id, 2, "Radius", NumberInput::default(), true);
	let inner_radius = number_widget(document_node, node_id, 3, "Inner Radius", NumberInput::default(), true);

	vec![LayoutGroup::Row { widgets: points }, LayoutGroup::Row { widgets: radius }, LayoutGroup::Row { widgets: inner_radius }]
}

pub fn line_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
	let operand = |name: &str, index| vec2_widget(document_node, node_id, index, name, "X", "Y", "px", add_blank_assist);
	vec![operand("Start", 1), operand("End", 2)]
}
pub fn spline_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
	vec![LayoutGroup::Row {
		widgets: vec_dvec2_input(document_node, node_id, 1, "Points", TextInput::default().centered(true), true),