Use craft_ui::ComboBox and Id::unique in Path alignment; fix test lifetime

This commit is contained in:
Khawar Zamman Wani committed 2026-11-12 12:12:16 +05:30
1 parent 5bfab0f449
commit 5b5e706f90
2 files changed
+6 -3

No files matched your search

@@ -105,9 +105,12 @@ fn reset_tool_restores_new_layer() {
assert_eq!(app.ui.tool_options.shape_path_op, "newLayer");
}
fn labels(e: &[(&'static str, &'static str)]) -> Vec<&'static str> {
e.iter().map(|(l, _)| *l).collect()
}
#[test]
fn entries_follow_the_reference_order() {
let labels = |e: &[(&str, &str)]| e.iter().map(|(l, _)| *l).collect::<Vec<_>>();
assert_eq!(
labels(&PATH_ALIGN_ENTRIES),
["Align Left Edges", "Align Horizontal Centers", "Align Right Edges", "Align Top Edges", "Align Vertical Centers", "Align Bottom Edges"]
+2 -2
View File
@@ -860,12 +860,12 @@ pub(super) fn path_alignment_menu(_app: &mut PhotocraftApp, ui: &mut egui::Ui) {
ui.add_enabled_ui(false, |ui| path_op_button(ui, glyph, tl!(label), false));
}
ui.separator();
let key = egui::Id::new("path-align-to");
let key = egui::Id::unique("path-align-to");
let mut canvas = ui.data(|d| d.get_temp::<bool>(key)).unwrap_or(false);
ui.horizontal(|ui| {
ui.label(tl!("Align To:"));
let text = if canvas { tl!("Canvas") } else { tl!("Selection") };
egui::ComboBox::from_id_salt("path-align-to-box").selected_text(text).show_ui(ui, |ui| {
craft_ui::ComboBox::from_id_salt("path-align-to-box").selected_text(text).show_ui(ui, |ui| {
ui.selectable_value(&mut canvas, false, tl!("Selection"));
ui.selectable_value(&mut canvas, true, tl!("Canvas"));
});