Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

LRC-LIB-LIBFOLDERS: a count that gives way stays past the panel's edge when its row reaches past it

Nathaniel Ledforda521f0c59105
diff --git a/crates/ui-egui/src/panels/left/rows.rs b/crates/ui-egui/src/panels/left/rows.rs
index 43b624395..de1f3488d 100644
--- a/crates/ui-egui/src/panels/left/rows.rs
+++ b/crates/ui-egui/src/panels/left/rows.rs
@@ -199,7 +199,9 @@ fn draw_row(app: &mut LightcraftApp, ui: &mut egui::Ui, row: Row) -> egui::Respo
// a label's dot sits just before the count
let count_w = count_galley.as_ref().map(|g| g.size().x);
let past_edge = count_past_edge(label_left, full_w, mark_w, count_w, mark.is_some(), edge);
- let edge = past_edge.map_or(edge, |e| e.min(r.right()));
+ // (held to the row's end only when that ends inside the panel: a row that reaches past the
+ // panel's edge keeps the count wholly past it, not cut by it)
+ let edge = past_edge.map_or(edge, |e| if r.right() < visible_right { e.min(r.right()) } else { e });
let count_left = edge - 18.0 - count_w.unwrap_or(0.0);
if let Some(c) = mark {
let dot = Rect::from_center_size(pos2(count_left - MARK_W / 2.0, r.center().y), vec2(8.0, 8.0));
diff --git a/crates/ui-egui/src/tests/panels.rs b/crates/ui-egui/src/tests/panels.rs
index 3b35d37c0..6a0776fb4 100644
--- a/crates/ui-egui/src/tests/panels.rs
+++ b/crates/ui-egui/src/tests/panels.rs
@@ -1703,6 +1703,29 @@ fn a_count_that_gives_way_is_whole_in_the_frame_the_panel_changes() {
}
}
+/// A sideways scroll of many points in one frame (a flick) does not leave a count or dot cut in
+/// two by the panel's edge in the frame it lands.
+#[test]
+fn a_count_that_gives_way_is_whole_after_a_sideways_flick() {
+ let (mut h, _) = folders_app_with_deep_labeled_chain();
+ h.request("ui.move", json!({"x": 120.0, "y": 400.0}), T);
+ for dx in [-10.0, -20.0, -30.0, -40.0, -60.0, -90.0, 20.0, 40.0, 90.0] {
+ for width in [210, 230, 250, 290] {
+ h.request("ui.set", json!({"leftWidth": width}), T);
+ h.settle(SETTLE);
+ h.request("ui.scroll", json!({"dx": dx}), T);
+ h.step();
+ let panel = widget(&h, "panel:left_panel");
+ for (id, r) in h.app.widgets.iter().filter(|(w, _)| w.starts_with("count:libfolder:") || w.starts_with("labelMark:libfolder:")) {
+ assert!(
+ r.right() <= panel.right() || r.left() >= panel.right(),
+ "flick {dx} at {width} pt: {id} straddles the edge: {r:?} / {panel:?}"
+ );
+ }
+ }
+ }
+}
+
/// The same when the panel grows by more than a few points in one frame (a window resize, or a
/// drag that was held up): the content is still as wide as the last frame asked for.
#[test]