From ec12b7d5f31f4ae58be2ab29eeab84d6d69dd322 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Mon, 26 Oct 2026 23:42:11 +0700 Subject: [PATCH] #827: port the picker's new ids to egui 0.37 (Id::unique) --- crates/ui-egui/src/colorpicker.rs | 2 +- crates/ui-egui/src/field_tests.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/colorpicker.rs b/crates/ui-egui/src/colorpicker.rs index b09d0849..accb70fd 100644 --- a/crates/ui-egui/src/colorpicker.rs +++ b/crates/ui-egui/src/colorpicker.rs @@ -288,7 +288,7 @@ fn model_fields(ui: &mut Ui, c: Color) -> Option<(Color, bool)> { let Some(spec) = Polar::of(name) else { return }; // The values last shown or typed stay while the colour is theirs: a chroma lowered to // fit sRGB, or a hue on a grey, isn't read back from the colour on the next frame. - let kept_id = Id::new("cp_polar"); + let kept_id = Id::unique("cp_polar"); let rgba = c.to_rgba8(); let vals = ui .data(|d| d.get_temp::<(&'static str, [f64; 3], [u8; 4])>(kept_id)) diff --git a/crates/ui-egui/src/field_tests.rs b/crates/ui-egui/src/field_tests.rs index e0f516d2..012dd923 100644 --- a/crates/ui-egui/src/field_tests.rs +++ b/crates/ui-egui/src/field_tests.rs @@ -502,13 +502,13 @@ fn lch_and_oklch_picker_fields_edit_lightness_keeping_hue() { u.app.set_props(&[a], json!({"fills": [{"type": "solid", "color": "#0D99FF"}]})); let before = color(&u); assert_eq!(before.to_hex(), "0D99FF"); - u.ctx.data_mut(|d| d.insert_temp(Id::new("cp_model"), model)); + u.ctx.data_mut(|d| d.insert_temp(Id::unique("cp_model"), model)); u.app.ui.picker = Some(crate::colorpicker::PickerTarget::Paint { fills: true, index: 0, ids: vec![a] }); for _ in 0..3 { u.frame(vec![]); } let steps = undo_steps(&u); - let from = lead(&u, Id::new(("cp_f", l))); + let from = lead(&u, Id::unique(("cp_f", l))); drag(&mut u, from, -20.0, Modifiers::NONE); let after = color(&u); let hue = |c| figcraft_color::Oklch::from_color(c).h; @@ -520,7 +520,7 @@ fn lch_and_oklch_picker_fields_edit_lightness_keeping_hue() { /// Type `text` into the picker field `id` (`("cp_f", id)`) and press Enter. fn type_into_picker(u: &mut Ui, id: &str, text: &str) { - let rect = u.ctx.read_response(Id::new(("cp_f", id)).with("field")).unwrap_or_else(|| panic!("no picker field {id}")).rect; + let rect = u.ctx.read_response(Id::unique(("cp_f", id)).with("field")).unwrap_or_else(|| panic!("no picker field {id}")).rect; click(u, rect.center()); u.frame(vec![Event::Text(text.into())]); key(u, Key::Enter, Modifiers::NONE); @@ -529,7 +529,7 @@ fn type_into_picker(u: &mut Ui, id: &str, text: &str) { /// A picker on layer `a` in model `model` (an index into the model menu), drawn and settled. fn open_picker(u: &mut Ui, a: NodeId, model: usize) { - u.ctx.data_mut(|d| d.insert_temp(Id::new("cp_model"), model)); + u.ctx.data_mut(|d| d.insert_temp(Id::unique("cp_model"), model)); u.app.ui.picker = Some(crate::colorpicker::PickerTarget::Paint { fills: true, index: 0, ids: vec![a] }); for _ in 0..3 { u.frame(vec![]); @@ -537,7 +537,7 @@ fn open_picker(u: &mut Ui, a: NodeId, model: usize) { } fn kept_polar(u: &Ui) -> [f64; 3] { - u.ctx.data(|d| d.get_temp::<(&'static str, [f64; 3], [u8; 4])>(Id::new("cp_polar"))).unwrap().1 + u.ctx.data(|d| d.get_temp::<(&'static str, [f64; 3], [u8; 4])>(Id::unique("cp_polar"))).unwrap().1 } #[test]