PhotoCraft: An open-source, photo editor written by scratch in pure Rust
fix(actions): fill the resizable panel with the step list (#3460)
kotulsky7c2e8c3d958d
diff --git a/crates/ui-egui/src/actions.rs b/crates/ui-egui/src/actions.rsindex b486e2536..504ecf2be 100644--- a/crates/ui-egui/src/actions.rs+++ b/crates/ui-egui/src/actions.rs@@ -345,7 +345,7 @@ pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {}let mut renamed = None;let mut toggled = None;- let max_h = (ui.available_height() - 70.0).clamp(80.0, 320.0);+ let max_h = (ui.available_height() - 38.0).max(0.0);let mut play_idx = None;let mut moved = None;let recording_row = recording.and_then(|(_, i)| rows.get(i).map(|(_, steps, _)| (i, steps.len())));@@ -357,7 +357,7 @@ pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {*expanded = true;}}- egui::ScrollArea::vertical().id_salt("actions-rows").max_height(max_h).auto_shrink([false, true]).show(ui, |ui| {+ egui::ScrollArea::vertical().id_salt("actions-rows").max_height(max_h).min_scrolled_height(max_h).auto_shrink([false, false]).show(ui, |ui| {if rows.is_empty() {ui.label(egui::RichText::new(tl!("Record ● a sequence of edits, then play ▶ it on any document.")).color(t.text_faint).size(11.5));}@@ -549,6 +549,24 @@ pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {mod tests {use super::*;+ #[test]+ fn actions_list_grows_with_panel_and_keeps_footer_visible() {+ use egui_kittest::{Harness, kittest::Queryable};+ let bottom = |height: f32| {+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());+ for i in 0..50 {+ app.session.actions.list.push(Action { name: format!("Action {i}"), steps: vec![], disabled: Default::default() });+ }+ let mut h = Harness::builder().with_size(vec2(320.0, height)).build_ui_state(|ui, app| panel(app, ui), app);+ h.run_steps(3);+ let rect = h.get_by_label("Play selection").rect();+ assert!(rect.bottom() <= height, "footer must fit: {rect:?}");+ rect.top()+ };+ assert!(bottom(700.0) - bottom(300.0) > 350.0, "list uses the additional panel height instead of stopping at 320 px");+ assert!(crate::dock::Group::History.scrolls_itself(1));+ }+#[test]fn double_clicking_an_action_name_renames_it_in_place() {use egui_kittest::{Harness, kittest::Queryable};@@ -658,14 +676,14 @@ mod tests {begin_recording(h.state_mut(), false);h.run_steps(20);let rect = h.get_by_label("Action 31").rect();- assert!(rect.top() >= 0.0 && rect.bottom() <= 205.0, "new action visible: {rect:?}");+ assert!(rect.top() >= 0.0 && rect.bottom() <= h.get_by_label("Play selection").rect().top(), "new action visible: {rect:?}");for _ in 0..20 {h.state_mut().run("view.zoomOut", json!({})).unwrap();}h.state_mut().run("view.fitOnScreen", json!({})).unwrap();h.run_steps(20);let rect = h.get_by_label("Fit on Screen").rect();- assert!(rect.top() >= 0.0 && rect.bottom() <= 205.0, "latest step visible: {rect:?}");+ assert!(rect.top() >= 0.0 && rect.bottom() <= h.get_by_label("Play selection").rect().top(), "latest step visible: {rect:?}");}#[test]diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rsindex 9d89213a3..7d70a72e7 100644--- a/crates/ui-egui/src/dock.rs+++ b/crates/ui-egui/src/dock.rs@@ -114,7 +114,7 @@ impl Group {/// Tabs that lay out their own scrolling list and footer, or size themselves to the group/// (the Navigator's preview grows with it, as in Photoshop: #2726).pub fn scrolls_itself(self, tab: usize) -> bool {- matches!((self, tab), (Group::Layers, 0) | (Group::History, 0) | (Group::Navigator, 0))+ matches!((self, tab), (Group::Layers, 0) | (Group::History, 0) | (Group::History, 1) | (Group::Navigator, 0))}pub(crate) fn tab_mut(self, tabs: &mut DockTabs) -> &mut usize {diff --git a/docs/control-protocol.md b/docs/control-protocol.mdindex 87d1bbf65..4ee966801 100644--- a/docs/control-protocol.md+++ b/docs/control-protocol.md@@ -121,6 +121,8 @@ store expose and persist the same setting; scripts keep using canonical command| `actions.toggle` | `{"action": name or index, "step": index?, "enabled": bool?}` → `{action, disabled}`. Switches one 0-based step (pending recorded steps included) on or off; omitting `enabled` flips it. Without `step`, switches every step: on unless all already are. Playback, Batch and droplets skip steps that are off. In the desktop panel, click a step's check box || `actions.rename` | `{"action": name or index, "name": str}` → `{action, index}`. Empty, whitespace-only or duplicate names are rejected and keep the old name. Nested `actions.play` steps that call the action by name and its function key follow the new name. In the desktop panel, double-click an action's name to rename it in place (Enter commits, Esc cancels) |+The Actions list fills the resizable dock group.+The Actions panel shows replayable steps immediately while recording. Click an individualstep to select it, then use the trash button to remove that step; selecting the actionheading instead targets the whole action. Step deletion also works during recording