Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Actions: check boxes switch single steps on and off (#2855) (#2866)

Valentin Klein1d425ce8f9f6
diff --git a/crates/automation/tests/agent_tasks.rs b/crates/automation/tests/agent_tasks.rs
index 2a2b49048..8eb6ba725 100644
--- a/crates/automation/tests/agent_tasks.rs
+++ b/crates/automation/tests/agent_tasks.rs
@@ -330,6 +330,7 @@ async fn agent_play_refuses_a_recorded_file_open() {
headless.session.actions.list.push(photocraft_engine::actions_cmds::Action {
name: "Open".into(),
steps: vec![("file.open".into(), json!({"path": "/etc/passwd"})), ("layer.new.layer".into(), json!({}))],
+ disabled: Default::default(),
});
let (c, server) = connect_headless(headless).await;
let played = run(&c, "actions.play", json!({"action": "Open"})).await;
diff --git a/crates/engine/src/actions_cmds.rs b/crates/engine/src/actions_cmds.rs
index 3f96e4a56..348011f75 100644
--- a/crates/engine/src/actions_cmds.rs
+++ b/crates/engine/src/actions_cmds.rs
@@ -1,16 +1,19 @@
//! Window › Actions, as engine commands (`actions.record` / `stop` / `play` / `list` / `get` /
-//! `delete` / `move` / `rename`).
+//! `delete` / `move` / `rename` / `toggle`).
//!
//! The list lives on [`Session`] so the panel, the CLI, the control channel and MCP share one
//! copy. Recording copies replayable journal entries (commands whose [`CommandSpec::journal`] is
//! set, except action-editing commands and the already-expanded `edit.transform.again`) into an
//! action. Playback runs those steps with [`Session::execute`]
-//! and stops at the first error, leaving one history step per step that ran.
+//! and stops at the first error, leaving one history step per step that ran. Steps switched off
+//! with `actions.toggle` (the Actions panel check marks) are skipped by playback, Batch and droplets.
//!
//! An untrusted session installs [`Session::authorize`]. `actions.play` calls it for every nested
//! step, because the outer `actions.play` id would otherwise hide a recorded `file.*` command from
//! the top-level check.
+use std::collections::BTreeSet;
+
use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
@@ -23,11 +26,29 @@ fn bad(cmd: &str, msg: impl Into<String>) -> EngineError {
/// One recorded action. `steps` is the `[[id, params], …]` shape `file.automate.batch` and
/// droplets already accept.
-#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
+#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Action {
pub name: String,
#[serde(default)]
pub steps: Vec<(String, Value)>,
+ /// Indices of steps excluded from playback (unchecked in the Actions panel).
+ #[serde(default, skip_serializing_if = "BTreeSet::is_empty")]
+ pub disabled: BTreeSet<usize>,
+}
+
+impl Action {
+ pub fn new(name: impl Into<String>, steps: Vec<(String, Value)>) -> Self {
+ Self { name: name.into(), steps, disabled: BTreeSet::new() }
+ }
+
+ pub fn step_enabled(&self, step: usize) -> bool {
+ !self.disabled.contains(&step)
+ }
+
+ /// The steps playback runs, with their indices in `steps`.
+ pub fn enabled_steps(&self) -> impl Iterator<Item = (usize, &(String, Value))> {
+ self.steps.iter().enumerate().filter(|(i, _)| self.step_enabled(*i))
+ }
}
/// On-disk form of [`ActionState::list`] (`actions.json` in the preset store).
@@ -195,7 +216,7 @@ fn get(s: &mut Session, p: &Value) -> Result<Value> {
let idx = resolve(&s.actions.list, p, "actions.get")?;
let action = &s.actions.list[idx];
let steps: Vec<Value> = action.steps.iter().map(|(id, params)| json!([id, params])).collect();
- Ok(json!({"name": action.name, "steps": steps}))
+ Ok(json!({"name": action.name, "steps": steps, "disabled": action.disabled}))
}
fn record(s: &mut Session, p: &Value) -> Result<Value> {
@@ -221,7 +242,7 @@ fn record(s: &mut Session, p: &Value) -> Result<Value> {
if s.actions.list.iter().any(|action| action.name == name) {
return Err(bad("actions.record", "an action with this name already exists"));
}
- s.actions.list.push(Action { name, steps: Vec::new() });
+ s.actions.list.push(Action::new(name, Vec::new()));
s.actions.touch();
s.actions.list.len() - 1
};
@@ -261,10 +282,10 @@ fn stop(s: &mut Session, _p: &Value) -> Result<Value> {
Ok(json!({"action": action.name, "steps": action.steps.len()}))
}
-fn run_recorded(s: &mut Session, steps: &[(String, Value)], from: usize) -> (u64, Option<Value>) {
+fn run_recorded(s: &mut Session, action: &Action, from: usize) -> (u64, Option<Value>) {
let mut ran = 0u64;
let mut failed = None;
- for (i, (id, params)) in steps.iter().enumerate().skip(from) {
+ for (i, (id, params)) in action.enabled_steps().skip_while(|(i, _)| *i < from) {
if let Some(auth) = s.authorize
&& let Err(e) = auth(id, params)
{
@@ -327,7 +348,7 @@ pub fn nested_failure(id: &str, value: &Value) -> Option<String> {
fn play(s: &mut Session, p: &Value) -> Result<Value> {
let (action, from) = playback_plan(s, p)?;
let recording = begin_playback(s, &action)?;
- let (ran, failed) = run_recorded(s, &action.steps, from);
+ let (ran, failed) = run_recorded(s, &action, from);
finish_playback(s, recording, &action, from);
Ok(match failed {
Some(f) => json!({"action": action.name, "ran": ran, "failed": f}),
@@ -362,6 +383,7 @@ fn move_item(s: &mut Session, p: &Value) -> Result<Value> {
let action = &mut s.actions.list[idx];
let moved = action.steps.remove(step);
action.steps.insert(to, moved);
+ action.disabled = action.disabled.iter().map(|&i| moved_index(i, step, to)).collect();
let result = json!({"action": action.name, "step": to});
s.actions.touch();
Ok(result)
@@ -409,6 +431,7 @@ fn delete(s: &mut Session, p: &Value) -> Result<Value> {
}
let action = &mut s.actions.list[idx];
action.steps.remove(step);
+ action.disabled = action.disabled.iter().filter(|&&i| i != step).map(|&i| if i > step { i - 1 } else { i }).collect();
let result = json!({"action": action.name, "deletedStep": step, "steps": action.steps.len()});
s.actions.touch();
return Ok(result);
@@ -421,6 +444,45 @@ fn delete(s: &mut Session, p: &Value) -> Result<Value> {
Ok(json!({"deleted": name}))
}
+/// The Actions panel check marks. With `step`, switch one step on or off; without it, switch
+/// every step (all on unless all already are, like clicking the action's check mark).
+fn toggle(s: &mut Session, p: &Value) -> Result<Value> {
+ let cmd = "actions.toggle";
+ not_playing(s, cmd)?;
+ let idx = resolve(&s.actions.list, p, cmd)?;
+ let enabled = match p.get("enabled") {
+ None | Some(Value::Null) => None,
+ Some(Value::Bool(b)) => Some(*b),
+ Some(_) => return Err(bad(cmd, "\"enabled\" must be true or false")),
+ };
+ let step = match p.get("step") {
+ None | Some(Value::Null) => None,
+ Some(v) => Some(v.as_u64().and_then(|i| usize::try_from(i).ok()).ok_or_else(|| bad(cmd, "step must be a non-negative integer"))?),
+ };
+ let len = s.actions.list[idx].steps.len().saturating_add(pending_steps(s, idx).count());
+ if step.is_some_and(|step| step >= len) {
+ return Err(bad(cmd, "step is out of range"));
+ }
+ if s.actions.recording.is_some_and(|(_, i)| i == idx) {
+ flush_recording(s)?;
+ }
+ let action = &mut s.actions.list[idx];
+ match step {
+ Some(step) => {
+ if enabled.unwrap_or(!action.step_enabled(step)) {
+ action.disabled.remove(&step);
+ } else {
+ action.disabled.insert(step);
+ }
+ }
+ None if enabled.unwrap_or(!action.disabled.is_empty()) => action.disabled.clear(),
+ None => action.disabled = (0..action.steps.len()).collect(),
+ }
+ let result = json!({"action": action.name, "disabled": action.disabled});
+ s.actions.touch();
+ Ok(result)
+}
+
/// Prefix of the persisted shortcut override that plays a named action (`actions.play:<name>`).
pub const PLAY_SHORTCUT_PREFIX: &str = "actions.play:";
@@ -491,7 +553,7 @@ pub fn specs() -> Vec<CommandSpec> {
label: "Get Action",
menu: &[],
shortcut: None,
- params: r##"{"action":name|index} → {name, steps:[[id, params]…]} (the shape file.automate.batch and droplets take)"##,
+ params: r##"{"action":name|index} → {name, steps:[[id, params]…], disabled:[step…]} (steps is the shape file.automate.batch and droplets take; disabled lists the 0-based steps playback skips)"##,
enabled: always,
run: get,
journal: false,
@@ -521,7 +583,7 @@ pub fn specs() -> Vec<CommandSpec> {
label: "Play Action",
menu: &[],
shortcut: None,
- params: r##"{"action":name|index, "from":step?} → {action, ran, failed?:{step, id, error}}. step and from are 0-based. Stops at the first error (the command still returns ok, with failed set) and leaves one history step per step that ran. Nested calls are supported up to 16 levels; cycles are rejected. Recording stores a named call rather than its expanded commands. Each step is checked with Session::authorize when one is installed."##,
+ params: r##"{"action":name|index, "from":step?} → {action, ran, failed?:{step, id, error}}. step and from are 0-based; steps switched off with actions.toggle are skipped. Stops at the first error (the command still returns ok, with failed set) and leaves one history step per step that ran. Nested calls are supported up to 16 levels; cycles are rejected. Recording stores a named call rather than its expanded commands. Each step is checked with Session::authorize when one is installed."##,
enabled: always,
run: play,
journal: false,
@@ -536,6 +598,16 @@ pub fn specs() -> Vec<CommandSpec> {
run: delete,
journal: false,
},
+ CommandSpec {
+ id: "actions.toggle",
+ label: "Toggle Action Steps",
+ menu: &[],
+ shortcut: None,
+ params: r##"{"action":name|index, "step":index?, "enabled":bool?} → {action, disabled:[step…]}. Switch one 0-based step (including pending recorded steps) on or off for playback, Batch and droplets; omitted enabled flips it. Without step, switch every step: on unless all already are, or as enabled says."##,
+ enabled: always,
+ run: toggle,
+ journal: false,
+ },
CommandSpec {
id: "actions.rename",
label: "Rename Action",
@@ -558,11 +630,58 @@ mod tests {
s.active().unwrap().doc.layers[layer].surface().unwrap().pixel(x, y)
}
+ #[test]
+ fn unchecked_steps_are_skipped_and_follow_move_and_delete() {
+ let mut s = Session::new();
+ s.execute("file.new", json!({"width": 8, "height": 8})).unwrap();
+ let step = |name: &str| ("layer.new.layer".to_string(), json!({"name": name}));
+ s.actions.list.push(Action::new("Three", vec![step("A"), step("B"), step("C")]));
+ let names = |s: &Session| s.active().unwrap().doc.layers.iter().skip(1).map(|l| l.name.clone()).collect::<Vec<_>>();
+
+ assert_eq!(s.execute("actions.toggle", json!({"action": "Three", "step": 1})).unwrap()["disabled"], json!([1]));
+ let played = s.execute("actions.play", json!({"action": 0})).unwrap();
+ assert_eq!(played["ran"], 2);
+ assert_eq!(names(&s), ["A", "C"], "the unchecked step is skipped");
+ assert_eq!(s.execute("actions.get", json!({"action": 0})).unwrap()["disabled"], json!([1]));
+
+ // Moving step 3 to the top keeps B (now step 2) unchecked; deleting the moved step shifts it to 1.
+ s.execute("actions.move", json!({"action": 0, "step": 2, "to": 0})).unwrap();
+ let ids: Vec<_> = s.actions.list[0].steps.iter().map(|(_, p)| p["name"].as_str().unwrap()).collect();
+ assert_eq!((ids, s.actions.list[0].disabled.iter().copied().collect::<Vec<_>>()), (vec!["C", "A", "B"], vec![2]));
+ s.execute("actions.delete", json!({"action": 0, "step": 0})).unwrap();
+ assert_eq!(s.actions.list[0].steps, [step("A"), step("B")], "deleting removes only that step");
+ assert_eq!(s.actions.list[0].disabled.iter().copied().collect::<Vec<_>>(), [1]);
+
+ // The action's own check: all on unless all already are.
+ s.execute("actions.toggle", json!({"action": 0})).unwrap();
+ assert!(s.actions.list[0].disabled.is_empty());
+ s.execute("actions.toggle", json!({"action": 0})).unwrap();
+ assert_eq!(s.actions.list[0].disabled.len(), 2);
+ s.execute("actions.toggle", json!({"action": 0, "step": 0, "enabled": true})).unwrap();
+ assert_eq!(s.actions.list[0].disabled.iter().copied().collect::<Vec<_>>(), [1]);
+
+ for bad in [
+ json!({"action": 0, "step": 2}),
+ json!({"action": 0, "step": -1}),
+ json!({"action": 0, "step": "x"}),
+ json!({"action": 0, "step": 0, "enabled": "yes"}),
+ json!({"action": 7, "step": 0}),
+ json!({}),
+ ] {
+ assert!(s.execute("actions.toggle", bad.clone()).is_err(), "{bad}");
+ }
+ assert_eq!(s.actions.list[0].disabled.iter().copied().collect::<Vec<_>>(), [1], "rejected toggles change nothing");
+ }
+
#[test]
fn rename_keeps_calls_and_function_key_and_rejects_bad_names() {
let mut s = Session::new();
- s.actions.list.push(Action { name: "Action 1".into(), steps: vec![("layer.new.layer".into(), json!({}))] });
- s.actions.list.push(Action { name: "Caller".into(), steps: vec![("actions.play".into(), json!({"action": "Action 1"}))] });
+ s.actions.list.push(Action { name: "Action 1".into(), steps: vec![("layer.new.layer".into(), json!({}))], disabled: Default::default() });
+ s.actions.list.push(Action {
+ name: "Caller".into(),
+ steps: vec![("actions.play".into(), json!({"action": "Action 1"}))],
+ disabled: Default::default(),
+ });
s.edit_prefs(|p| p.shortcuts.insert(format!("{PLAY_SHORTCUT_PREFIX}Action 1"), "F2".into()));
assert_eq!(s.execute("actions.rename", json!({"action": 0, "name": "Sepia"})).unwrap()["action"], "Sepia");
assert_eq!(s.execute("actions.list", json!({})).unwrap()["actions"][0]["name"], "Sepia");
@@ -715,7 +834,7 @@ mod tests {
#[test]
fn play_refuses_recursion() {
let mut s = Session::new();
- s.actions.list.push(Action { name: "Loop".into(), steps: vec![("actions.play".into(), json!({"action": "Loop"}))] });
+ s.actions.list.push(Action { name: "Loop".into(), steps: vec![("actions.play".into(), json!({"action": "Loop"}))], disabled: Default::default() });
let r = s.execute("actions.play", json!({"action": "Loop"})).unwrap();
assert_eq!(r["ran"], 0);
assert_eq!(r["failed"]["id"], "actions.play");
@@ -730,9 +849,11 @@ mod tests {
}
let mut s = Session::new();
s.authorize = Some(deny_file);
- s.actions
- .list
- .push(Action { name: "Open".into(), steps: vec![("file.open".into(), json!({"path": "/etc/passwd"})), ("layer.new.layer".into(), json!({}))] });
+ s.actions.list.push(Action {
+ name: "Open".into(),
+ steps: vec![("file.open".into(), json!({"path": "/etc/passwd"})), ("layer.new.layer".into(), json!({}))],
+ disabled: Default::default(),
+ });
let r = s.execute("actions.play", json!({"action": "Open"})).unwrap();
assert_eq!(r["ran"], 0);
assert_eq!(r["failed"]["step"], 0);
@@ -805,7 +926,11 @@ mod tests {
fn nested_call_records_one_named_step_and_tracks_child_edits() {
let mut s = Session::new();
s.execute("file.new", json!({"width": 4, "height": 4})).unwrap();
- s.actions.list.push(Action { name: "Child".into(), steps: vec![("layer.new.layer".into(), json!({"name": "Child layer"}))] });
+ s.actions.list.push(Action {
+ name: "Child".into(),
+ steps: vec![("layer.new.layer".into(), json!({"name": "Child layer"}))],
+ disabled: Default::default(),
+ });
s.execute("actions.record", json!({"name": "Parent"})).unwrap();
s.execute("layer.new.layer", json!({"name": "Before"})).unwrap();
s.execute("actions.play", json!({"action": 0})).unwrap();
@@ -833,8 +958,9 @@ mod tests {
s.actions.list.push(Action {
name: "A".into(),
steps: vec![("actions.play".into(), json!({"action": "B"})), ("file.new".into(), json!({"width": 2,"height": 2}))],
+ disabled: Default::default(),
});
- s.actions.list.push(Action { name: "B".into(), steps: vec![("actions.play".into(), json!({"action": "A"}))] });
+ s.actions.list.push(Action { name: "B".into(), steps: vec![("actions.play".into(), json!({"action": "A"}))], disabled: Default::default() });
let r = s.execute("actions.play", json!({"action": "A"})).unwrap();
assert!(r["failed"]["error"].as_str().unwrap().contains("recursive"));
assert!(s.documents().is_empty());
@@ -849,6 +975,7 @@ mod tests {
s.actions.list.push(Action {
name: format!("N{i}"),
steps: if i < 16 { vec![("actions.play".into(), json!({"action":format!("N{}", i + 1)}))] } else { vec![] },
+ disabled: Default::default(),
});
}
let r = s.execute("actions.play", json!({"action": "N0"})).unwrap();
@@ -893,7 +1020,7 @@ mod tests {
#[test]
fn new_names_do_not_collide_with_named_calls() {
let mut s = Session::new();
- s.actions.list.push(Action { name: "Action 2".into(), steps: vec![] });
+ s.actions.list.push(Action { name: "Action 2".into(), steps: vec![], disabled: Default::default() });
assert_eq!(s.execute("actions.record", json!({})).unwrap()["action"], "Action 3");
s.execute("actions.stop", json!({})).unwrap();
assert!(s.execute("actions.record", json!({"name":"Action 2"})).is_err());
@@ -905,7 +1032,7 @@ mod tests {
let mut s = Session::new();
s.execute("file.new", json!({"width":4,"height":4})).unwrap();
for name in ["A", "B", "C"] {
- s.actions.list.push(Action { name: name.into(), steps: vec![] });
+ s.actions.list.push(Action { name: name.into(), steps: vec![], disabled: Default::default() });
}
s.execute("actions.record", json!({"action":"B"})).unwrap();
s.execute("layer.new.layer", json!({"name":"before"})).unwrap();
diff --git a/crates/engine/src/automate_cmds/tests.rs b/crates/engine/src/automate_cmds/tests.rs
index 6bd8a3111..03548d3ac 100644
--- a/crates/engine/src/automate_cmds/tests.rs
+++ b/crates/engine/src/automate_cmds/tests.rs
@@ -303,8 +303,8 @@ fn a_failed_step_inside_a_called_action_fails_scripts_and_batch() {
images(&dir, 1, 8, 4);
let mut s = Session::new();
s.execute("file.new", json!({"width": 8, "height": 6})).unwrap();
- s.actions.list.push(Action { name: "Rotate".into(), steps: vec![("image.imageRotation.90cw".into(), json!({}))] });
- s.actions.list.push(Action { name: "Bad".into(), steps: vec![("layer.delete".into(), json!({"layer": 999_999}))] });
+ s.actions.list.push(Action { name: "Rotate".into(), steps: vec![("image.imageRotation.90cw".into(), json!({}))], disabled: Default::default() });
+ s.actions.list.push(Action { name: "Bad".into(), steps: vec![("layer.delete".into(), json!({"layer": 999_999}))], disabled: Default::default() });
// A script stops at the failed call and reports it.
let r = s.execute("file.scripts.browse", json!({"steps": [["actions.play", {"action": "Bad"}], ["image.imageRotation.90cw", {}]]})).unwrap();
assert_eq!(r["ok"], false, "{r}");
@@ -321,6 +321,6 @@ fn a_failed_step_inside_a_called_action_fails_scripts_and_batch() {
assert!(r["errors"][0]["error"].as_str().unwrap().contains("no such layer"), "{r}");
// An action that batches itself stops as a recursive call instead of overflowing the stack.
let inner = json!({"steps": [["actions.play", {"action": "Loop"}]], "input": dir.clone(), "output": format!("{dir}/inner"), "format": "png"});
- s.actions.list.push(Action { name: "Loop".into(), steps: vec![("file.automate.batch".into(), inner)] });
+ s.actions.list.push(Action { name: "Loop".into(), steps: vec![("file.automate.batch".into(), inner)], disabled: Default::default() });
batch(&mut s, "Loop");
}
diff --git a/crates/ui-egui/src/actions.rs b/crates/ui-egui/src/actions.rs
index 6bc528231..cf0694022 100644
--- a/crates/ui-egui/src/actions.rs
+++ b/crates/ui-egui/src/actions.rs
@@ -57,9 +57,10 @@ fn playback_selection(app: &PhotocraftApp) -> Option<usize> {
if n == 0 { None } else { Some(app.ui.actions.selected.filter(|i| *i < n).unwrap_or(0)) }
}
-/// Steps in the `[[id, params], …]` shape batch and droplets already accept.
+/// Steps in the `[[id, params], …]` shape batch and droplets already accept, without the
+/// steps switched off in the panel.
pub fn action_steps(action: &Action) -> Vec<Value> {
- action.steps.iter().map(|(id, p)| json!([id, p])).collect()
+ action.enabled_steps().map(|(_, (id, p))| json!([id, p])).collect()
}
/// Named action bindings use the existing persisted shortcut overrides. Keeping the
@@ -91,7 +92,7 @@ pub(crate) fn play(app: &mut PhotocraftApp, params: &Value) -> Result<Value, Str
let recording = actions_cmds::begin_playback(&mut app.session, &action).map_err(|e| e.to_string())?;
let mut ran = 0u64;
let mut failed = None;
- for (i, (id, p)) in action.steps.iter().enumerate().skip(from) {
+ for (i, (id, p)) in action.enabled_steps().skip_while(|(i, _)| *i < from) {
let result = (|| {
if let Some(auth) = app.session.authorize {
auth(id, p).map_err(|e| e.to_string())?;
@@ -193,6 +194,20 @@ fn visible_steps(app: &PhotocraftApp, action: usize) -> Vec<(String, Value)> {
app.session.actions.list.get(action).into_iter().flat_map(|a| a.steps.iter()).chain(actions_cmds::pending_steps(&app.session, action)).cloned().collect()
}
+/// "3 steps", or "2/3 steps" when some are switched off (Photoshop shows a red partial check).
+fn step_count(steps: usize, disabled: usize) -> String {
+ if disabled == 0 { format!("{steps} steps") } else { format!("{}/{steps} steps", steps.saturating_sub(disabled)) }
+}
+
+fn paint_check(ui: &egui::Ui, rect: Rect, on: bool, t: &Tokens) {
+ let b = Rect::from_center_size(rect.center(), vec2(11.0, 11.0));
+ ui.painter().rect_stroke(b, 2.0, Stroke::new(1.0, t.text_faint), egui::StrokeKind::Inside);
+ if on {
+ let pts = vec![pos2(b.left() + 2.5, b.center().y), pos2(b.left() + 4.5, b.bottom() - 3.0), pos2(b.right() - 2.5, b.top() + 2.5)];
+ ui.painter().add(egui::Shape::line(pts, Stroke::new(1.5, t.text)));
+ }
+}
+
fn step_label(id: &str, params: &Value) -> String {
if id == "actions.play" {
let target = params.get("action").map(|v| v.as_str().map(str::to_owned).unwrap_or_else(|| v.to_string())).unwrap_or_default();
@@ -305,7 +320,7 @@ fn rename_action(app: &mut PhotocraftApp, index: usize, name: String) {
pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
let t = Tokens::get(ui.ctx());
let recording = app.session.actions.recording;
- let rows: Vec<_> = app.session.actions.list.iter().enumerate().map(|(i, a)| (a.name.clone(), visible_steps(app, i))).collect();
+ let rows: Vec<_> = app.session.actions.list.iter().enumerate().map(|(i, a)| (a.name.clone(), visible_steps(app, i), a.disabled.clone())).collect();
if app
.ui
.actions
@@ -322,10 +337,11 @@ pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
app.ui.actions.renaming = None;
}
let mut renamed = None;
+ let mut toggled = None;
let max_h = (ui.available_height() - 70.0).clamp(80.0, 320.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())));
+ let recording_row = recording.and_then(|(_, i)| rows.get(i).map(|(_, steps, _)| (i, steps.len())));
let reveal = recording_row.filter(|row| app.ui.actions.reveal_recording != Some(*row));
app.ui.actions.reveal_recording = recording_row;
if let Some((i, _)) = reveal {
@@ -354,7 +370,7 @@ pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
}
}
- for (i, (name, steps)) in rows.iter().enumerate() {
+ for (i, (name, steps, disabled)) in rows.iter().enumerate() {
let (rect, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 26.0), Sense::click_and_drag());
if reveal == Some((i, 0)) {
ui.scroll_to_rect(rect, Some(egui::Align::BOTTOM));
@@ -395,7 +411,7 @@ pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
.shortcuts
.get(&shortcut_id(name))
.filter(|s| !s.is_empty())
- .map_or_else(|| format!("{nsteps} steps"), |key| format!("{key} · {nsteps} steps")),
+ .map_or_else(|| step_count(nsteps, disabled.len()), |key| format!("{key} · {}", step_count(nsteps, disabled.len()))),
egui::FontId::proportional(11.0),
t.text_faint,
);
@@ -448,8 +464,20 @@ pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
if let Some(change) = drag_row(ui, &response, DragRow { action: i, step: Some(step) }, &t) {
moved = Some(change);
}
- ui.painter().text(pos2(r.left() + 44.0, r.center().y), Align2::LEFT_CENTER, label, egui::FontId::proportional(11.5), t.text_dim);
- if response.clicked() {
+ let on = !disabled.contains(&step);
+ let color = if on { t.text_dim } else { t.text_faint };
+ ui.painter().text(pos2(r.left() + 44.0, r.center().y), Align2::LEFT_CENTER, &label, egui::FontId::proportional(11.5), color);
+ // Photoshop's check column: unchecked steps are skipped by playback, Batch and droplets.
+ let check = ui.interact(
+ Rect::from_center_size(pos2(r.left() + 30.0, r.center().y), vec2(16.0, 16.0)),
+ ui.id().with(("action-step-check", i, step)),
+ Sense::click(),
+ );
+ check.widget_info(|| egui::WidgetInfo::selected(egui::WidgetType::Checkbox, true, on, format!("{}: {label}", tl!("Include in playback"))));
+ paint_check(ui, check.rect, on, &t);
+ if check.on_hover_text(tl!("Include in playback")).clicked() {
+ toggled = Some((i, step));
+ } else if response.clicked() {
app.ui.actions.selected = Some(i);
app.ui.actions.selected_step = Some(step);
}
@@ -457,6 +485,9 @@ pub fn panel(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
}
}
});
+ if let Some((action, step)) = toggled {
+ let _ = app.run("actions.toggle", json!({"action": action, "step": step}));
+ }
if let Some((index, name)) = renamed {
rename_action(app, index, name);
}
@@ -515,7 +546,7 @@ mod tests {
use egui_kittest::{Harness, kittest::Queryable};
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
app.run("file.new", json!({"width": 32, "height": 32})).unwrap();
- app.session.actions.list.push(Action { name: "Action 1".into(), steps: vec![("layer.new.layer".into(), json!({}))] });
+ app.session.actions.list.push(Action { name: "Action 1".into(), steps: vec![("layer.new.layer".into(), json!({}))], disabled: Default::default() });
let layers = app.session.active().unwrap().doc.layers.len();
// 60 fps steps, so two clicks a frame apart count as a double-click.
let mut h = Harness::builder().with_size(vec2(320.0, 260.0)).with_step_dt(1.0 / 60.0).build_ui_state(|ui, app| panel(app, ui), app);
@@ -549,8 +580,8 @@ mod tests {
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
app.run("file.new", json!({"width": 32, "height": 32})).unwrap();
assert_eq!(playback_selection(&app), None);
- app.session.actions.list.push(Action { name: "Make Layer".into(), steps: vec![("layer.new.layer".into(), json!({}))] });
- app.session.actions.list.push(Action { name: "Fit".into(), steps: vec![("view.fitOnScreen".into(), json!({}))] });
+ app.session.actions.list.push(Action { name: "Make Layer".into(), steps: vec![("layer.new.layer".into(), json!({}))], disabled: Default::default() });
+ app.session.actions.list.push(Action { name: "Fit".into(), steps: vec![("view.fitOnScreen".into(), json!({}))], disabled: Default::default() });
assert_eq!(playback_selection(&app), Some(0));
app.ui.actions.selected = Some(1);
assert_eq!(playback_selection(&app), Some(1));
@@ -568,12 +599,36 @@ mod tests {
assert!(!h.state().ui.status_error);
}
+ #[test]
+ fn step_check_box_excludes_the_step_from_playback_and_batch() {
+ use egui_kittest::{Harness, kittest::Queryable};
+ let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
+ app.run("file.new", json!({"width": 16, "height": 16})).unwrap();
+ let steps = ["A", "B", "C"].map(|n| ("layer.new.layer".to_string(), json!({"name": n})));
+ app.session.actions.list.push(Action::new("Three", steps.to_vec()));
+ app.ui.actions.expanded = vec![true];
+ let mut h = Harness::builder().with_size(vec2(320.0, 300.0)).build_ui_state(|ui, app| panel(app, ui), app);
+ h.run_steps(3);
+ let checks = h.query_all_by_role(egui::accesskit::Role::CheckBox).count();
+ assert_eq!(checks, 3);
+ h.query_all_by_role(egui::accesskit::Role::CheckBox).nth(1).unwrap().click();
+ h.run_steps(3);
+ let action = &h.state().session.actions.list[0];
+ assert_eq!(action.disabled.iter().copied().collect::<Vec<_>>(), [1]);
+ assert_eq!(action_steps(action).len(), 2, "Batch and droplets get only the checked steps");
+ assert_eq!(step_count(3, action.disabled.len()), "2/3 steps");
+ h.get_by_label("Play selection").click();
+ h.run_steps(3);
+ let names: Vec<_> = h.state().session.active().unwrap().doc.layers.iter().skip(1).map(|l| l.name.clone()).collect();
+ assert_eq!(names, ["A", "C"]);
+ }
+
#[test]
fn playback_errors_are_visible_in_status_bar() {
use egui_kittest::{Harness, kittest::Queryable};
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
app.run("file.new", json!({"width": 32, "height": 32})).unwrap();
- app.session.actions.list.push(Action { name: "Bad action".into(), steps: vec![("not.a.command".into(), json!({}))] });
+ app.session.actions.list.push(Action { name: "Bad action".into(), steps: vec![("not.a.command".into(), json!({}))], disabled: Default::default() });
let mut h = Harness::builder().with_size(vec2(400.0, 320.0)).build_ui_state(|ui, app| panel(app, ui), app);
h.run_steps(3);
h.get_by_label("Play selection").click();
@@ -588,7 +643,7 @@ mod tests {
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
app.run("file.new", json!({"width":4,"height":4})).unwrap();
for i in 0..30 {
- app.session.actions.list.push(Action { name: format!("Existing {i}"), steps: vec![] });
+ app.session.actions.list.push(Action { name: format!("Existing {i}"), steps: vec![], disabled: Default::default() });
}
let mut h = Harness::builder().with_size(vec2(320.0, 260.0)).build_ui_state(|ui, app| panel(app, ui), app);
h.run_steps(4);
@@ -612,8 +667,9 @@ mod tests {
app.session.actions.list.push(Action {
name: "First".into(),
steps: vec![("view.zoomOut".into(), json!({})), ("view.fitOnScreen".into(), json!({})), ("view.actualPixels".into(), json!({}))],
+ disabled: Default::default(),
});
- app.session.actions.list.push(Action { name: "Second".into(), steps: vec![] });
+ app.session.actions.list.push(Action { name: "Second".into(), steps: vec![], disabled: Default::default() });
app.ui.actions.expanded = vec![true, false];
let mut h = Harness::builder().with_size(vec2(320.0, 400.0)).build_ui_state(|ui, app| panel(app, ui), app);
h.run_steps(4);
@@ -649,10 +705,11 @@ mod tests {
fn nested_shell_actions_include_view_steps_and_propagate_failures() {
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
app.run("file.new", json!({"width":40,"height":40})).unwrap();
- app.session
- .actions
- .list
- .push(Action { name: "Child".into(), steps: vec![("layer.new.layer".into(), json!({})), ("view.fitOnScreen".into(), json!({}))] });
+ app.session.actions.list.push(Action {
+ name: "Child".into(),
+ steps: vec![("layer.new.layer".into(), json!({})), ("view.fitOnScreen".into(), json!({}))],
+ disabled: Default::default(),
+ });
app.run("actions.record", json!({"name":"Parent"})).unwrap();
app.run("actions.play", json!({"action":"Child"})).unwrap();
app.run("actions.stop", json!({})).unwrap();
@@ -740,10 +797,11 @@ mod tests {
#[test]
fn view_action_failure_resume_and_authorization() {
let mut app = PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default());
- app.session
- .actions
- .list
- .push(Action { name: "Fit".into(), steps: vec![("view.fitOnScreen".into(), json!({})), ("view.actualPixels".into(), json!({}))] });
+ app.session.actions.list.push(Action {
+ name: "Fit".into(),
+ steps: vec![("view.fitOnScreen".into(), json!({})), ("view.actualPixels".into(), json!({}))],
+ disabled: Default::default(),
+ });
let result = app.run("actions.play", json!({"action": "Fit"})).unwrap();
assert_eq!(result["ran"], 0);
assert_eq!(result["failed"]["step"], 0);
diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs
index 1dd80c722..1a668a6d9 100644
--- a/crates/ui-egui/src/control.rs
+++ b/crates/ui-egui/src/control.rs
@@ -2259,8 +2259,11 @@ mod tests {
let r = call(&mut app, &ctx, "engine.execute", json!({"command": command, "params": {"layer": smart.0}}));
assert_eq!(r["ok"], false, "{r}");
assert!(r["error"].as_str().unwrap().contains("ambient smart-object path denied"), "{r}");
- app.session.actions.list =
- vec![photocraft_engine::actions_cmds::Action { name: "Linked contents".into(), steps: vec![(command.into(), json!({"layer": smart.0}))] }];
+ app.session.actions.list = vec![photocraft_engine::actions_cmds::Action {
+ name: "Linked contents".into(),
+ steps: vec![(command.into(), json!({"layer": smart.0}))],
+ disabled: Default::default(),
+ }];
let r = call(&mut app, &ctx, "engine.execute", json!({"command": "actions.play", "params": {"action": "Linked contents"}}));
assert_eq!(r["ok"], true, "{r}");
assert_eq!(r["result"]["ran"], 0, "{r}");
@@ -2289,6 +2292,7 @@ mod tests {
app.session.actions.list.push(photocraft_engine::actions_cmds::Action {
name: "Open".into(),
steps: vec![("file.open".into(), json!({"path": "/etc/passwd"})), ("layer.new.layer".into(), json!({}))],
+ disabled: Default::default(),
});
let ctx = egui::Context::default();
let r = call(&mut app, &ctx, "engine.execute", json!({"command": "actions.play", "params": {"action": "Open"}}));
@@ -2307,6 +2311,7 @@ mod tests {
app.session.actions.list.push(photocraft_engine::actions_cmds::Action {
name: "Open".into(),
steps: vec![("file.open".into(), json!({"path": "/etc/passwd"})), ("layer.new.layer".into(), json!({}))],
+ disabled: Default::default(),
});
app.automation_input = true;
let r = app.run("actions.play", json!({"action": "Open"})).unwrap();
diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv
index ded6068e5..b94463adb 100644
--- a/crates/ui-egui/src/i18n/cs.tsv
+++ b/crates/ui-egui/src/i18n/cs.tsv
@@ -2490,6 +2490,7 @@ cameraData Lens Objektiv
Previous Document Předchozí dokument
W x H x Resolution Š x V x Rozlišení
Front Image Přední obraz
+ Include in playback Zahrnout do přehrávání
Perspective Crop Tool Nástroj perspektivní oříznutí
Show Grid Zobrazit mřížku
Drag a box or click four corners · drag the corners onto the edges of a skewed shape · {commit} commits · Esc cancels Táhněte rámeček nebo klikněte na čtyři rohy · přetáhněte rohy na okraje zkoseného tvaru · {commit} potvrdí · Esc zruší
diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv
index 065314131..b3cab47a6 100644
--- a/crates/ui-egui/src/i18n/de.tsv
+++ b/crates/ui-egui/src/i18n/de.tsv
@@ -2523,6 +2523,7 @@ cameraData Lens Objektiv
Previous Document Vorheriges Dokument
W x H x Resolution B x H x Auflösung
Front Image Vorderes Bild
+ Include in playback In Wiedergabe einbeziehen
Perspective Crop Tool Perspektivisches Freistellungswerkzeug
Show Grid Raster einblenden
Drag a box or click four corners · drag the corners onto the edges of a skewed shape · {commit} commits · Esc cancels Rahmen ziehen oder vier Ecken klicken · Ecken auf die Kanten einer schrägen Form ziehen · {commit} übernimmt · Esc bricht ab
diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv
index 6df9f67eb..e21aa5302 100644
--- a/crates/ui-egui/src/i18n/el.tsv
+++ b/crates/ui-egui/src/i18n/el.tsv
@@ -3587,6 +3587,7 @@ cameraData Lens Φακός
Previous Document Προηγούμενο έγγραφο
W x H x Resolution Π x Υ x Ανάλυση
Front Image Μπροστινή εικόνα
+ Include in playback Συμπερίληψη στην αναπαραγωγή
Perspective Crop Tool Περικοπή προοπτικής (Perspective Crop Tool)
Drag a box or click four corners · drag the corners onto the edges of a skewed shape · {commit} commits · Esc cancels Σύρετε ένα πλαίσιο ή κάντε κλικ σε τέσσερις γωνίες · σύρετε τις γωνίες στις άκρες ενός λοξού σχήματος · {commit} για εφαρμογή · Esc για ακύρωση
Artboard Tool Πίνακας σχεδίασης (Artboard Tool)
diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv
index 34d872015..96ccf427d 100644
--- a/crates/ui-egui/src/i18n/es.tsv
+++ b/crates/ui-egui/src/i18n/es.tsv
@@ -2564,6 +2564,7 @@ cameraData Lens Objetivo
Previous Document Documento anterior
W x H x Resolution An. x Al. x Resolución
Front Image Imagen frontal
+ Include in playback Incluir en la reproducción
Perspective Crop Tool Herramienta Recortar con perspectiva
Show Grid Mostrar cuadrícula
Drag a box or click four corners · drag the corners onto the edges of a skewed shape · {commit} commits · Esc cancels Arrastre un cuadro o haga clic en cuatro esquinas · arrastre las esquinas a los bordes de una forma inclinada · {commit} confirma · Esc cancela
diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv
index 98ce31f3f..ce9b19b03 100644
--- a/crates/ui-egui/src/i18n/fr.tsv
+++ b/crates/ui-egui/src/i18n/fr.tsv
@@ -2901,6 +2901,7 @@ cameraData Lens Objectif
Previous Document Document précédent
W x H x Resolution L x H x Résolution
Front Image Image de premier plan
+ Include in playback Inclure dans la lecture
Perspective Crop Tool Outil Recadrage perspective
Show Grid Afficher la grille
Drag a box or click four corners · drag the corners onto the edges of a skewed shape · {commit} commits · Esc cancels Tracez un cadre ou cliquez sur quatre coins · faites glisser les coins sur les bords d'une forme inclinée · {commit} valide · Échap annule
diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv
index 4ef02c1be..231108c3f 100644
--- a/crates/ui-egui/src/i18n/id.tsv
+++ b/crates/ui-egui/src/i18n/id.tsv
@@ -2888,6 +2888,7 @@ cameraData Lens Lensa
Previous Document Dokumen Sebelumnya
W x H x Resolution L x T x Resolusi
Front Image Gambar Depan
+ Include in playback Sertakan dalam pemutaran
Perspective Crop Tool Alat Crop Perspektif
Show Grid Tampilkan Grid
Drag a box or click four corners · drag the corners onto the edges of a skewed shape · {commit} commits · Esc cancels Seret kotak atau klik empat sudut · seret sudut ke tepi bentuk yang miring · {commit} menerapkan · Esc membatalkan
diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv
index 4f6e3833f..8a8eb96d2 100644
--- a/crates/ui-egui/src/i18n/it.tsv
+++ b/crates/ui-egui/src/i18n/it.tsv
@@ -2554,6 +2554,7 @@ cameraData Lens Obiettivo
Previous Document Documento precedente
W x H x Resolution L x A x Risoluzione
Front Image Immagine in primo piano
+ Include in playback Includi nella riproduzione
Perspective Crop Tool Strumento Taglierina prospettica
Show Grid Mostra griglia
Drag a box or click four corners · drag the corners onto the edges of a skewed shape · {commit} commits · Esc cancels Trascina un riquadro o fai clic su quattro angoli · trascina gli angoli sui bordi di una forma inclinata · {commit} conferma · Esc annulla
diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv
index 7083a779c..406698805 100644
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@ -3502,6 +3502,7 @@ cameraData Lens レンズ
Previous Document 前のドキュメント
W x H x Resolution 幅 x 高さ x 解像度
Front Image 前面の画像
+ Include in playback 再生に含める
Perspective Crop Tool 遠近法の切り抜きツール
Show Grid グリッドを表示
Drag a box or click four corners · drag the corners onto the edges of a skewed shape · {commit} commits · Esc cancels ボックスをドラッグするか 4 つの角をクリック · 角を傾いた形の端までドラッグ · {commit} で確定 · Esc でキャンセル
diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv
index b40b9466d..de32199a8 100644
--- a/crates/ui-egui/src/i18n/ko.tsv
+++ b/crates/ui-egui/src/i18n/ko.tsv
@@ -3068,6 +3068,7 @@ cameraData Lens 렌즈
Previous Document 이전 문서
W x H x Resolution 폭 x 높이 x 해상도
Front Image 전면 이미지
+ Include in playback 재생에 포함
Perspective Crop Tool 원근 자르기 도구
Show Grid 격자 표시
Drag a box or click four corners · drag the corners onto the edges of a skewed shape · {commit} commits · Esc cancels 상자를 드래그하거나 네 모서리를 클릭 · 모서리를 기울어진 모양의 가장자리로 드래그 · {commit} 적용 · Esc 취소
diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv
index 10e108af6..82b5fe62f 100644
--- a/crates/ui-egui/src/i18n/nl.tsv
+++ b/crates/ui-egui/src/i18n/nl.tsv
@@ -3675,3 +3675,4 @@ cameraData Lens Lens
Search settings… Instellingen zoeken…
No matching settings Geen overeenkomende instellingen
PhotoCraft — Screen Color Picker PhotoCraft — Schermkleurkiezer
+ Include in playback Opnemen in afspelen
diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv
index 8f82c364d..5a8effb2f 100644
--- a/crates/ui-egui/src/i18n/pl.tsv
+++ b/crates/ui-egui/src/i18n/pl.tsv
@@ -3503,6 +3503,7 @@ cameraData Lens Obiektyw
Previous Document Poprzedni dokument
W x H x Resolution Szer. x Wys. x Rozdzielczość
Front Image Obraz na wierzchu
+ Include in playback Uwzględnij w odtwarzaniu
Perspective Crop Tool Narzędzie Kadrowanie perspektywiczne
Show Grid Pokaż siatkę
Drag a box or click four corners · drag the corners onto the edges of a skewed shape · {commit} commits · Esc cancels Przeciągnij ramkę lub kliknij cztery narożniki · przeciągnij narożniki na krawędzie pochylonego kształtu · {commit} zatwierdza · Esc anuluje
diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv
index 5d5cb7793..18a47bcc2 100644
--- a/crates/ui-egui/src/i18n/pt-br.tsv
+++ b/crates/ui-egui/src/i18n/pt-br.tsv
@@ -2909,6 +2909,7 @@ cameraData Lens Lente
Previous Document Documento anterior
W x H x Resolution L x A x Resolução
Front Image Imagem frontal
+ Include in playback Incluir na reprodução
Perspective Crop Tool Ferramenta Corte demarcado em perspectiva
Show Grid Mostrar grade
Drag a box or click four corners · drag the corners onto the edges of a skewed shape · {commit} commits · Esc cancels Arraste uma caixa ou clique em quatro cantos · arraste os cantos até as bordas de uma forma inclinada · {commit} confirma · Esc cancela
diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv
index 1f4066a66..ba869419d 100644
--- a/crates/ui-egui/src/i18n/ru.tsv
+++ b/crates/ui-egui/src/i18n/ru.tsv
@@ -2830,6 +2830,7 @@ cameraData Lens Объектив
Previous Document Предыдущий документ
W x H x Resolution Ш x В x Разрешение
Front Image Изображение переднего плана
+ Include in playback Включить в воспроизведение
Perspective Crop Tool Кадрирование перспективы
Show Grid Показать сетку
Drag a box or click four corners · drag the corners onto the edges of a skewed shape · {commit} commits · Esc cancels Растяните рамку или щёлкните четыре угла · перетащите углы на края наклонной фигуры · {commit} применяет · Esc отменяет
diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv
index 706f278d2..08b690485 100644
--- a/crates/ui-egui/src/i18n/uk.tsv
+++ b/crates/ui-egui/src/i18n/uk.tsv
@@ -3603,6 +3603,7 @@ cameraData Lens Об'єктив
Search settings… Пошук налаштувань…
No matching settings Немає відповідних налаштувань
PhotoCraft — Screen Color Picker PhotoCraft — Піпетка кольору екрана
+ Include in playback Включити у відтворення
New Crop Preset… Новий набір параметрів кадрування…
Delete Crop Preset… Видалити набір параметрів кадрування…
Select the crop presets to delete: Виберіть набори параметрів кадрування для видалення:
diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv
index d0fa9b4a6..ecb5beb35 100644
--- a/crates/ui-egui/src/i18n/zh-hans.tsv
+++ b/crates/ui-egui/src/i18n/zh-hans.tsv
@@ -2497,6 +2497,7 @@ cameraData Lens 镜头
Previous Document 上一个文档
W x H x Resolution 宽 x 高 x 分辨率
Front Image 前面的图像
+ Include in playback 包含在播放中
Perspective Crop Tool 透视裁剪工具
Show Grid 显示网格
Drag a box or click four corners · drag the corners onto the edges of a skewed shape · {commit} commits · Esc cancels 拖动方框或单击四个角 · 将角拖到倾斜形状的边缘 · {commit} 确认 · Esc 取消
diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv
index 16d550287..6deddbfe0 100644
--- a/crates/ui-egui/src/i18n/zh-hant.tsv
+++ b/crates/ui-egui/src/i18n/zh-hant.tsv
@@ -2467,6 +2467,7 @@ cameraData Lens 鏡頭
Previous Document 上一個文件
W x H x Resolution 寬 x 高 x 解析度
Front Image 前面的影像
+ Include in playback 包含在播放中
Perspective Crop Tool 透視裁切工具
Show Grid 顯示格點
Drag a box or click four corners · drag the corners onto the edges of a skewed shape · {commit} commits · Esc cancels 拖曳方框或按一下四個角 · 將角拖曳到傾斜形狀的邊緣 · {commit} 確認 · Esc 取消
diff --git a/crates/ui-egui/src/shortcut_dispatch/tests.rs b/crates/ui-egui/src/shortcut_dispatch/tests.rs
index 5938421ec..3ed56aba5 100644
--- a/crates/ui-egui/src/shortcut_dispatch/tests.rs
+++ b/crates/ui-egui/src/shortcut_dispatch/tests.rs
@@ -529,8 +529,11 @@ fn delete_with_a_selection_clears_it() {
#[test]
fn named_action_function_key_replays_and_survives_preferences_roundtrip() {
let mut h = harness();
- let action =
- photocraft_engine::actions_cmds::Action { name: "LivePrint 2R".into(), steps: vec![("layer.new.layer".into(), json!({"name": "F6 overlay"}))] };
+ let action = photocraft_engine::actions_cmds::Action {
+ name: "LivePrint 2R".into(),
+ steps: vec![("layer.new.layer".into(), json!({"name": "F6 overlay"}))],
+ disabled: Default::default(),
+ };
h.state_mut().session.actions.list.push(action);
crate::actions::assign_shortcut(h.state_mut(), "LivePrint 2R", "F6").unwrap();
let saved = serde_json::to_value(h.state().session.prefs()).unwrap();
@@ -551,11 +554,11 @@ fn named_action_function_key_replays_and_survives_preferences_roundtrip() {
fn assigning_action_function_key_moves_it_and_reports_failed_steps() {
let mut h = harness();
for name in ["first", "second"] {
- h.state_mut()
- .session
- .actions
- .list
- .push(photocraft_engine::actions_cmds::Action { name: name.into(), steps: vec![("no.such.command".into(), json!({}))] });
+ h.state_mut().session.actions.list.push(photocraft_engine::actions_cmds::Action {
+ name: name.into(),
+ steps: vec![("no.such.command".into(), json!({}))],
+ disabled: Default::default(),
+ });
}
crate::actions::assign_shortcut(h.state_mut(), "first", "F6").unwrap();
crate::actions::assign_shortcut(h.state_mut(), "second", "F6").unwrap();
@@ -573,6 +576,7 @@ fn action_function_key_checks_automation_authorization() {
h.state_mut().session.actions.list.push(photocraft_engine::actions_cmds::Action {
name: "restricted".into(),
steps: vec![("layer.new.layer".into(), json!({"name": "should not exist"}))],
+ disabled: Default::default(),
});
crate::actions::assign_shortcut(h.state_mut(), "restricted", "F6").unwrap();
h.state_mut().services.automation_command = Some(Box::new(|id, _| if id == "actions.play" { Err("denied action playback".into()) } else { Ok(()) }));
@@ -609,6 +613,7 @@ fn f6_while_recording_records_a_named_call_not_the_child_steps() {
h.state_mut().session.actions.list.push(photocraft_engine::actions_cmds::Action {
name: "LivePrint 2R".into(),
steps: vec![("layer.new.layer".into(), json!({"name":"Nested overlay"})), ("view.fitOnScreen".into(), json!({}))],
+ disabled: Default::default(),
});
crate::actions::assign_shortcut(h.state_mut(), "LivePrint 2R", "F6").unwrap();
h.state_mut().run("actions.record", json!({"name":"Action 2"})).unwrap();
diff --git a/docs/control-protocol.md b/docs/control-protocol.md
index dc2857e7c..62dfe7145 100644
--- a/docs/control-protocol.md
+++ b/docs/control-protocol.md
@@ -108,12 +108,13 @@ store expose and persist the same setting; scripts keep using canonical command
| `type.caret` | `{"layer":id?,"index":char}`: caret segment in document pixels, `{"index","line","segment":[[x,y],[x,y]]}` (rotated and vertical type included) |
| `type.navigate` | `{"layer":id?,"index":char,"move":"wordPrev\|wordNext\|linePrev\|lineNext\|lineStart\|lineEnd\|start\|end","x":px?}`: neighbouring caret. `x` keeps the column across line moves. Result `{"index"}` |
| `actions.list` | `{}` → `{actions:[{name, steps}], recording}` (the name being recorded, or null) |
-| `actions.get` | `{"action": name or index}` → `{name, steps:[[id, params], …]}`, the shape `file.automate.batch` and droplets take |
+| `actions.get` | `{"action": name or index}` → `{name, steps:[[id, params], …], disabled:[step, …]}`. `steps` is the shape `file.automate.batch` and droplets take; `disabled` lists the 0-based steps playback skips |
| `actions.record` | `{"name":"Red"}` starts a new action (default name `Action N`). `{"action": name or index}` appends to one that exists |
| `actions.stop` | `{}` → `{action, steps}`. Copies replayable journal entries since `actions.record` (queries and action-editing commands omitted) |
| `actions.play` | `{"action": name or index, "from": step?}`. `from` and `failed.step` are 0-based. Returns `{action, ran, failed?:{step, id, error}}` and still returns ok when a step fails, so a partial run is reported. Leaves one history step per step that ran. Supports nested action calls up to 16 levels, rejecting cycles. While recording, playing another action appends one named `actions.play` step instead of its expanded commands. On an untrusted session each step is authorized the same way as a top-level command |
| `actions.move` | `{"action": name or index, "step": index?, "to": index}` moves a step within its action, or moves the whole action when `step` is omitted. `to` is the final zero-based index. Pending steps can be reordered while recording; invalid moves leave the list unchanged. |
| `actions.delete` | `{"action": name or index, "step": index?}`. With a zero-based `step`: `{action, deletedStep, steps}`, also allowed while recording. Without `step`: `{deleted}`, refused while recording |
+| `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 panel shows replayable steps immediately while recording. Click an individual