PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Merge PR #5940: History panel: scroll to the current state on document change (#5909)
David Mann3d64af4aecfc
diff --cc crates/ui-egui/src/panels.rsindex 1626eff45,6a22b41f8..5a430205c--- a/crates/ui-egui/src/panels.rs+++ b/crates/ui-egui/src/panels.rs@@@ -3358,8 -3091,11 +3358,12 @@@ fn history(app: &mut PhotocraftApp, uilet entries = st.history.entries();let current = entries.len() - 1;let redo: Vec<String> = st.history.redo_labels().map(str::to_string).collect();+ let source = photocraft_engine::history_source_cmds::source(st);let selected_snap = selected_snapshot(ui.ctx(), st);+ // The newest past state is a new document on every step, Undo and Redo, also at the state+ // limit, where the counts and a repeated name stay the same.+ let newest = st.history.past_len().checked_sub(1).and_then(|i| st.history.state(i)).map(|d| std::sync::Arc::as_ptr(&d) as usize);+ let spot = (doc.id, history_spot(st), newest);let ctx = ui.ctx().clone();// A row dragged onto the trash (#5324); a drag that never saw its release must not outlive it.if !ctx.input(|i| i.pointer.primary_down() || i.pointer.any_released()) {@@@ -3435,13 -3179,11 +3453,17 @@@ctx.data_mut(|d| d.remove::<SelectedSnapshot>(selected_snapshot_key(doc.id)));}}+ if follow && let Some(rect) = current_rect {+ // No alignment: a row already in view stays put. No animation, as the Layers panel reveal.+ ui.scroll_to_rect_animation(rect, None, egui::style::ScrollAnimation::none());+ }});+ if let Some(i) = set_source+ && let Err(e) = app.run("history.setSource", json!({"state": i}))+ {+ app.ui.status = e;+ app.ui.status_error = true;+ }if let Some(drag) = drag&& let Some(p) = ctx.input(|i| i.pointer.interact_pos()){