mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
fix(ui-egui): strip undocumented dialog keys only after reshaping
The closed-schema filter dropped Image Processor's jpeg/width rows before nest() turned them into the jpeg object the command takes, so OK wrote only a full-size JPEG. Apply Image is still on the incomplete list and needs sourceLayer, which the same filter had also removed. The filter now runs after nest() and the other command-specific rewrites, and it skips commands whose docs are still incomplete.
This commit is contained in:
1 parent
325c405c82
commit
60910bb9bb
3 files changed
+18
-9
No files matched your search
@@ -35,6 +35,7 @@ pub mod memory;
|
||||
pub mod memory_gate;
|
||||
pub mod new_layer;
|
||||
mod param_check;
|
||||
pub use param_check::is_incomplete;
|
||||
pub mod param_schema;
|
||||
mod pixels;
|
||||
pub mod prefs;
|
||||
|
||||
@@ -144,6 +144,11 @@ pub(crate) fn check(spec: &CommandSpec, params: &Value) -> Result<()> {
|
||||
/// `"channel"`/`"targetChannel"` (`adjust_params` reads them for all kinds), and `_`-prefixed
|
||||
/// keys are the engine's own bookkeeping (a PSD-embedded displacement map, an imported action's
|
||||
/// descriptor), never typed by a caller.
|
||||
/// Whether `id` is on the incomplete-docs list: unknown keys are not rejected yet.
|
||||
pub fn is_incomplete(id: &str) -> bool {
|
||||
INCOMPLETE.contains(&id)
|
||||
}
|
||||
|
||||
fn implied(id: &str, key: &str) -> bool {
|
||||
(key == "layer" && id.starts_with("filter."))
|
||||
|| (id.starts_with("image.adjustments.") && matches!(key, "layer" | "channel" | "targetChannel"))
|
||||
|
||||
@@ -683,15 +683,6 @@ pub(crate) fn command_params(command: &str, fields: &DialogFields) -> Value {
|
||||
if command == "image.adjustments.colorLookup" && map.get("data").and_then(Value::as_str).is_some_and(str::is_empty) {
|
||||
map.remove("data");
|
||||
}
|
||||
// Drop display-only and other keys a closed schema does not take (Bitmap's Input row is
|
||||
// `inputResolution`; dispatch would reject it and OK would leave the document unchanged).
|
||||
if let Some(spec) = photocraft_engine::commands::find(command)
|
||||
&& let Some(schema) = photocraft_engine::param_schema::of(spec)
|
||||
&& !schema.open()
|
||||
{
|
||||
const KEEP: &[&str] = &["coalesce", "target", "layer", "channel", "targetChannel", "document"];
|
||||
map.retain(|key, _| key.starts_with('_') || KEEP.contains(&key.as_str()) || schema.has_key(key));
|
||||
}
|
||||
if command == "image.mode.indexedColor" {
|
||||
// The matte colour row belongs to the "custom" choice, which the command takes as the colour itself.
|
||||
let color = map.remove(rows::MATTE_COLOR);
|
||||
@@ -723,6 +714,18 @@ pub(crate) fn command_params(command: &str, fields: &DialogFields) -> Value {
|
||||
if command == super::rotate_canvas_ui::COMMAND {
|
||||
super::rotate_canvas_ui::command_params(&mut map);
|
||||
}
|
||||
// After dialog keys have been reshaped into command keys (Image Processor's jpeg/width
|
||||
// becomes jpeg.width, and so on). Doing this earlier dropped those rows.
|
||||
// Drop display-only and other keys a closed schema does not take (Bitmap's Input row is
|
||||
// `inputResolution`; dispatch would reject it and OK would leave the document unchanged).
|
||||
if let Some(spec) = photocraft_engine::commands::find(command)
|
||||
&& let Some(schema) = photocraft_engine::param_schema::of(spec)
|
||||
&& !schema.open()
|
||||
&& !photocraft_engine::is_incomplete(command)
|
||||
{
|
||||
const KEEP: &[&str] = &["coalesce", "target", "layer", "channel", "targetChannel", "document"];
|
||||
map.retain(|key, _| key.starts_with('_') || KEEP.contains(&key.as_str()) || schema.has_key(key));
|
||||
}
|
||||
params_of(&map)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user