Add text last-line alignment modes for "Justify Center", "Justify Right", and "Justify All" (#4024)

* feat: Add justify proper alignments(right/left/centre/all)

* chore: fmt

* chore: refactor

* Cleanup

* Fix crash when changing selected layer's alignment from the Text tool control bar

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Jatin Bharti
2026-05-06 19:16:19 -07:00
committed by GitHub
co-authored by Keavon Chambers
parent 1c2ac19b16
commit c0a8241f50
8 changed files with 142 additions and 32 deletions
@@ -1728,6 +1728,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
}
NodeGraphMessage::SetInputValue { node_id, input_index, value } => {
let is_fill = matches!(value, TaggedValue::Fill(_));
let is_text_align = matches!(value, TaggedValue::TextAlign(_));
let input = NodeInput::value(value, false);
responses.add(NodeGraphMessage::SetInput {
input_connector: InputConnector::node(node_id, input_index),
@@ -1737,6 +1738,9 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
if is_fill {
responses.add(OverlaysMessage::Draw);
}
if is_text_align {
responses.add(TextToolMessage::SelectionChanged);
}
if network_interface.connected_to_output(&node_id, selection_network_path) {
responses.add(NodeGraphMessage::RunDocumentGraph);
}
@@ -2953,7 +2953,7 @@ pub mod choice {
if let Some(icon) = var_meta.icon { entry.icon(icon) } else { entry.label(var_meta.label) }
})
.collect();
RadioInput::new(items).selected_index(Some(current.as_u32())).widget_instance()
RadioInput::new(items).selected_index(Some(current.as_u32())).disabled(self.disabled).widget_instance()
}
}
@@ -241,7 +241,7 @@ pub fn text_width(text: &str, font_size: f64) -> f64 {
max_width: None,
max_height: None,
tilt: 0.0,
align: TextAlign::Left,
align: TextAlign::AlignLeft,
};
// Load Source Sans Pro font data
@@ -1112,7 +1112,7 @@ impl OverlayContextInternal {
max_width: None,
max_height: None,
tilt: 0.,
align: TextAlign::Left, // We'll handle alignment manually via pivot
align: TextAlign::AlignLeft,
};
// Load Source Sans Pro font data