From 51de1bfbb695e5a79ab0a2ea55069297fd0cedd7 Mon Sep 17 00:00:00 2001 From: skylartaylor Date: Wed, 25 Nov 2026 06:47:18 +0100 Subject: [PATCH 1/2] hold debug 5 --- crates/ui-egui/src/panels/right.rs | 18 ++++++++++++++++++ crates/ui-egui/src/panels/right/keywords.rs | 3 +++ crates/ui-egui/src/tests/keyword_list.rs | 2 ++ 3 files changed, 23 insertions(+) diff --git a/crates/ui-egui/src/panels/right.rs b/crates/ui-egui/src/panels/right.rs index 1b4addc9e4..2d19a95059 100644 --- a/crates/ui-egui/src/panels/right.rs +++ b/crates/ui-egui/src/panels/right.rs @@ -102,6 +102,24 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) { super::scroll_focus::reveal_focus(ui, egui::Id::unique("right-scroll-focus")); }); ui.data_mut(|d| d.insert_temp(egui::Id::unique(AREA), scrolled.id)); + { + let now = (scrolled.state.offset().y, scrolled.content_size.y); + let last = ui.data(|d| d.get_temp::<(f32, f32)>(egui::Id::unique("dbg-last"))); + ui.data_mut(|d| d.insert_temp(egui::Id::unique("dbg-last"), now)); + if last != Some(now) { + eprintln!( + "DBGSHOW pass={} sizing={} measure={} held={held:?} start={start:?} ended={ended:?} offset {:?} -> {} content {:?} -> {} inner={}", + ui.ctx().cumulative_pass_nr(), + ui.is_sizing_pass(), + craft::ui::runtime::measure::active(ui.ctx()), + last.map(|l| l.0), + now.0, + last.map(|l| l.1), + now.1, + scrolled.inner_rect.height() + ); + } + } // (the offset this real pass ended at: the next pass holds from it, not from the state a sizing or // measuring run in between may already have pulled back as the content shrank) if !(ui.is_sizing_pass() || craft::ui::runtime::measure::active(ui.ctx())) { diff --git a/crates/ui-egui/src/panels/right/keywords.rs b/crates/ui-egui/src/panels/right/keywords.rs index 322e75e0c8..0e62a6c772 100644 --- a/crates/ui-egui/src/panels/right/keywords.rs +++ b/crates/ui-egui/src/panels/right/keywords.rs @@ -336,6 +336,9 @@ fn hold_list_in_place(ui: &mut egui::Ui, top: f32) { ui.data_mut(|d| d.insert_temp(key, (height, pass))); let Some(before) = before else { return }; let grew = height - before; + if grew.abs() >= 0.5 { + eprintln!("DBGCHANGE pass={pass} grew={grew} top={top} clip_top={} ptr={:?}", ui.clip_rect().top(), ui.input(|i| i.pointer.latest_pos())); + } if !grew.is_finite() || grew.abs() < 0.5 || top >= ui.clip_rect().top() - 0.5 { return; } diff --git a/crates/ui-egui/src/tests/keyword_list.rs b/crates/ui-egui/src/tests/keyword_list.rs index dc25139550..6acc5ee978 100644 --- a/crates/ui-egui/src/tests/keyword_list.rs +++ b/crates/ui-egui/src/tests/keyword_list.rs @@ -645,7 +645,9 @@ fn ticking_a_keyword_keeps_the_list_in_place() { let picked: Vec = (30..36).map(|i| format!("zz{i}")).collect(); for (n, k) in picked.iter().chain(picked.iter().rev()).enumerate() { let (before, box_top) = (rect(&h, &format!("keywordRow:{k}")), rect(&h, "field:keyword").top()); + eprintln!("DBGTICK click {k} before={before:?}"); ask(&mut h, "ui.clickWidget", json!({"id": format!("keywordCheck:{k}")})); + eprintln!("DBGTICK done {k} after={:?}", rect(&h, &format!("keywordRow:{k}"))); assert_eq!(rect(&h, &format!("keywordRow:{k}")), before, "{k} stayed under the pointer"); // (the click found the row where it is drawn, not where a discarded pass had it) assert_eq!(keywords_of(&h, ids[0]).contains(k), n < picked.len(), "{k} was the one ticked: {:?}", keywords_of(&h, ids[0])); From b00add28e2612bc5c5e7af6ac03b95b326e9d127 Mon Sep 17 00:00:00 2001 From: skylartaylor Date: Wed, 25 Nov 2026 07:37:29 +0100 Subject: [PATCH 2/2] The Keyword List hold keeps the offset a real pass started at; a sizing run no longer overwrites it; remove debug --- crates/ui-egui/src/panels/right.rs | 35 +++++++-------------- crates/ui-egui/src/panels/right/keywords.rs | 3 -- crates/ui-egui/src/tests/keyword_list.rs | 2 -- 3 files changed, 11 insertions(+), 29 deletions(-) diff --git a/crates/ui-egui/src/panels/right.rs b/crates/ui-egui/src/panels/right.rs index 2d19a95059..1ad2a34d1c 100644 --- a/crates/ui-egui/src/panels/right.rs +++ b/crates/ui-egui/src/panels/right.rs @@ -77,12 +77,17 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) { let area_id = ui.data(|d| d.get_temp::(egui::Id::unique(AREA))); let ended = ui.data(|d| d.get_temp::(egui::Id::unique(ENDED))); let start = held.or(ended).or_else(|| area_id.and_then(|a| egui::scroll_area::State::load(ui.ctx(), a)).map(|s| s.clamped_offset().y)); - ui.data_mut(|d| match start { - Some(o) => { - d.insert_temp(egui::Id::unique(OFFSET), o); - } - None => d.remove::(egui::Id::unique(OFFSET)), - }); + // (only a real pass says where it started: a sizing or measuring run in the next pass would write the offset + // the last pass ended at, which egui has already pulled back as the content shrank, and the hold would count that + // change twice) + if !(ui.is_sizing_pass() || craft::ui::runtime::measure::active(ui.ctx())) { + ui.data_mut(|d| match start { + Some(o) => { + d.insert_temp(egui::Id::unique(OFFSET), o); + } + None => d.remove::(egui::Id::unique(OFFSET)), + }); + } let scrolled = area.show(ui, |ui| { ui.spacing_mut().item_spacing.y = 0.0; match app.ui.right { @@ -102,24 +107,6 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) { super::scroll_focus::reveal_focus(ui, egui::Id::unique("right-scroll-focus")); }); ui.data_mut(|d| d.insert_temp(egui::Id::unique(AREA), scrolled.id)); - { - let now = (scrolled.state.offset().y, scrolled.content_size.y); - let last = ui.data(|d| d.get_temp::<(f32, f32)>(egui::Id::unique("dbg-last"))); - ui.data_mut(|d| d.insert_temp(egui::Id::unique("dbg-last"), now)); - if last != Some(now) { - eprintln!( - "DBGSHOW pass={} sizing={} measure={} held={held:?} start={start:?} ended={ended:?} offset {:?} -> {} content {:?} -> {} inner={}", - ui.ctx().cumulative_pass_nr(), - ui.is_sizing_pass(), - craft::ui::runtime::measure::active(ui.ctx()), - last.map(|l| l.0), - now.0, - last.map(|l| l.1), - now.1, - scrolled.inner_rect.height() - ); - } - } // (the offset this real pass ended at: the next pass holds from it, not from the state a sizing or // measuring run in between may already have pulled back as the content shrank) if !(ui.is_sizing_pass() || craft::ui::runtime::measure::active(ui.ctx())) { diff --git a/crates/ui-egui/src/panels/right/keywords.rs b/crates/ui-egui/src/panels/right/keywords.rs index 0e62a6c772..322e75e0c8 100644 --- a/crates/ui-egui/src/panels/right/keywords.rs +++ b/crates/ui-egui/src/panels/right/keywords.rs @@ -336,9 +336,6 @@ fn hold_list_in_place(ui: &mut egui::Ui, top: f32) { ui.data_mut(|d| d.insert_temp(key, (height, pass))); let Some(before) = before else { return }; let grew = height - before; - if grew.abs() >= 0.5 { - eprintln!("DBGCHANGE pass={pass} grew={grew} top={top} clip_top={} ptr={:?}", ui.clip_rect().top(), ui.input(|i| i.pointer.latest_pos())); - } if !grew.is_finite() || grew.abs() < 0.5 || top >= ui.clip_rect().top() - 0.5 { return; } diff --git a/crates/ui-egui/src/tests/keyword_list.rs b/crates/ui-egui/src/tests/keyword_list.rs index 6acc5ee978..dc25139550 100644 --- a/crates/ui-egui/src/tests/keyword_list.rs +++ b/crates/ui-egui/src/tests/keyword_list.rs @@ -645,9 +645,7 @@ fn ticking_a_keyword_keeps_the_list_in_place() { let picked: Vec = (30..36).map(|i| format!("zz{i}")).collect(); for (n, k) in picked.iter().chain(picked.iter().rev()).enumerate() { let (before, box_top) = (rect(&h, &format!("keywordRow:{k}")), rect(&h, "field:keyword").top()); - eprintln!("DBGTICK click {k} before={before:?}"); ask(&mut h, "ui.clickWidget", json!({"id": format!("keywordCheck:{k}")})); - eprintln!("DBGTICK done {k} after={:?}", rect(&h, &format!("keywordRow:{k}"))); assert_eq!(rect(&h, &format!("keywordRow:{k}")), before, "{k} stayed under the pointer"); // (the click found the row where it is drawn, not where a discarded pass had it) assert_eq!(keywords_of(&h, ids[0]).contains(k), n < picked.len(), "{k} was the one ticked: {:?}", keywords_of(&h, ids[0]));