Effect Controls: file parameters get Choose…, Apply Color LUT asks for its LUT on apply, and text parameters get a field (#514, #473)
Cause: Apply Color LUT's only parameter, `lut`, was ParamUi::Hidden (set only
through commands), so the effect could not be used from the UI. Effect
Controls also had no widget for any ParamUi::Text parameter (only EXtractoR's
channels had one), so Cryptomatte's Selection, the OCIO effects' config file /
file / config names and Colorama's Output Cycle could not be set either.
Fix: a new ParamUi::File { filters } for paths. Effect Controls shows the
file's name (None when empty) and a Choose... button that opens the host's
file dialog with those extensions and sets the path (prop.set, so agents use
the same command). As in After Effects, applying an effect with an empty file
parameter from the UI (Effect menu, Last Effect, drops, Effects & Presets)
opens the file dialog straight away; cancelling keeps the effect without a
file. Apply Color LUT's LUT (.cube) and the OCIO Config File (.ocio) and File
(.cube/.3dl/.csp/.cc/.ccc/.cdl/.spi1d/.spi3d/.spimtx) use it. Text
parameters get a single-line field that sets the value when it loses the
focus (Esc keeps the old text). Saved projects are upgraded on open: a
Hidden or Text parameter whose spec is now a File parameter takes the File
UI and keeps its path (effects::migrate). docs/effects.md regenerated.
This covers #473's first part (the Selection field); picking mattes in the
viewer, the layer popup from the file's metadata, the GPU path and quoted
commas are separate.
Tests: effects hidden_and_text_paths_become_file_parameters (migration); ui
file_and_text_parameters_have_widgets (the LUT is asked for on apply and
inverts red to cyan, the Choose... button picks another LUT, typing into
Cryptomatte's Selection sets it).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QiAJeFttZp83Fh7YuzAR5f
(cherry picked from commit 403863f703999d19d3a83d9976f76bdc7577e682)
This commit is contained in:
@@ -430,6 +430,10 @@ pub(crate) fn p(id: &'static str, name: &'static str, default: Value, ui: ParamU
|
||||
pub(crate) fn slider(min: f64, max: f64, smin: f64, smax: f64, decimals: u8) -> ParamUi {
|
||||
ParamUi::Slider { min, max, slider_min: smin, slider_max: smax, decimals }
|
||||
}
|
||||
/// A file parameter offering files with these extensions (Effect Controls' Choose…).
|
||||
pub(crate) fn file_ui(exts: &[&str]) -> ParamUi {
|
||||
ParamUi::File { filters: exts.iter().map(|s| s.to_string()).collect() }
|
||||
}
|
||||
pub(crate) fn popup(opts: &[&str]) -> ParamUi {
|
||||
ParamUi::Popup { options: opts.iter().map(|s| s.to_string()).collect() }
|
||||
}
|
||||
|
||||
@@ -236,6 +236,9 @@ fn refresh(pr: &mut Property, ps: &ParamSpec, spec: &EffectSpec) {
|
||||
}
|
||||
// A parameter that became internal (superseded by a new one) is hidden.
|
||||
(_, ParamUi::Hidden) => pr.ui = ParamUi::Hidden,
|
||||
// A path typed as text, or set only by commands, that got a Choose… button (Apply Color
|
||||
// LUT's LUT, the OCIO files, #514).
|
||||
(ParamUi::Hidden | ParamUi::Text, ParamUi::File { .. }) => pr.ui = ps.ui.clone(),
|
||||
// Same kind of value: take the spec's hints (units, ranges).
|
||||
(a, b) if std::mem::discriminant(a) == std::mem::discriminant(b) || is_numeric_ui(a) && is_numeric_ui(b) => pr.ui = ps.ui.clone(),
|
||||
_ => {}
|
||||
@@ -494,6 +497,23 @@ mod tests {
|
||||
assert_eq!(pr.ui, popup.ui);
|
||||
}
|
||||
|
||||
/// #514: Apply Color LUT's LUT was hidden (set only by commands) and the OCIO files were
|
||||
/// plain text; old projects get the Choose… file parameter, keeping the path.
|
||||
#[test]
|
||||
fn hidden_and_text_paths_become_file_parameters() {
|
||||
for (fx, pid, old) in [("ec.utility.applylut", "lut", ParamUi::Hidden), ("ec.color.ociofile", "file", ParamUi::Text)] {
|
||||
let mut next = 1;
|
||||
let (spec, mut g) = instance(fx, &mut next);
|
||||
let pr = g.get_mut(pid).unwrap();
|
||||
pr.ui = old;
|
||||
pr.value = Value::Str("/luts/look.cube".into());
|
||||
assert!(upgrade_instance(spec, &mut g, &mut Ids(&mut next), [100.0, 100.0]), "{fx}");
|
||||
let pr = g.get(pid).unwrap();
|
||||
assert!(matches!(&pr.ui, ParamUi::File { filters } if filters.iter().any(|f| f == "cube")), "{fx}: {:?}", pr.ui);
|
||||
assert_eq!(pr.value, Value::Str("/luts/look.cube".into()));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn upgrade_moves_params_into_twirl_down_groups() {
|
||||
let spec = find(crate::warp_stab::ID).unwrap();
|
||||
|
||||
@@ -1427,7 +1427,7 @@ pub fn specs() -> Vec<EffectSpec> {
|
||||
cc,
|
||||
vec![
|
||||
p("config", "Configuration", Value::Enum(0), popup(CONFIGS)),
|
||||
p("configFile", "Config File (.ocio)", Value::Str(String::new()), ParamUi::Text),
|
||||
p("configFile", "Config File (.ocio)", Value::Str(String::new()), crate::file_ui(&["ocio"])),
|
||||
space_param("source", "Source", lin709),
|
||||
p("sourceName", "Source (config name)", Value::Str(String::new()), ParamUi::Text),
|
||||
space_param("destination", "Destination", srgb),
|
||||
@@ -1442,7 +1442,7 @@ pub fn specs() -> Vec<EffectSpec> {
|
||||
cc,
|
||||
vec![
|
||||
p("config", "Configuration", Value::Enum(0), popup(CONFIGS)),
|
||||
p("configFile", "Config File (.ocio)", Value::Str(String::new()), ParamUi::Text),
|
||||
p("configFile", "Config File (.ocio)", Value::Str(String::new()), crate::file_ui(&["ocio"])),
|
||||
space_param("source", "Input Color Space", lin709),
|
||||
p("sourceName", "Source (config name)", Value::Str(String::new()), ParamUi::Text),
|
||||
p("display", "Display Device", Value::Enum(0), popup(&DISPLAYS.iter().map(|d| d.0).collect::<Vec<_>>())),
|
||||
@@ -1459,7 +1459,7 @@ pub fn specs() -> Vec<EffectSpec> {
|
||||
"OCIO File Transform",
|
||||
cc,
|
||||
vec![
|
||||
p("file", "File", Value::Str(String::new()), ParamUi::Text),
|
||||
p("file", "File", Value::Str(String::new()), crate::file_ui(&["cube", "3dl", "csp", "cc", "ccc", "cdl", "spi1d", "spi3d", "spimtx"])),
|
||||
p("cccId", "CCC ID", Value::Str(String::new()), ParamUi::Text),
|
||||
p("interpolation", "Interpolation", Value::Enum(3), popup(&["Nearest", "Linear", "Tetrahedral", "Best"])),
|
||||
direction(),
|
||||
|
||||
@@ -385,8 +385,9 @@ pub fn specs() -> Vec<EffectSpec> {
|
||||
],
|
||||
cineon,
|
||||
),
|
||||
// `lut`: a path to a `.cube` file, or the `.cube` text itself (set via commands/automation).
|
||||
spec("ec.utility.applylut", "Apply Color LUT", vec![p("lut", "LUT", Value::Str(String::new()), ParamUi::Hidden)], apply_lut),
|
||||
// `lut`: a path to a `.cube` file (Effect Controls' Choose…, asked for when the effect is
|
||||
// applied, as in After Effects), or the `.cube` text itself (commands/automation).
|
||||
spec("ec.utility.applylut", "Apply Color LUT", vec![p("lut", "LUT", Value::Str(String::new()), crate::file_ui(&["cube"]))], apply_lut),
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user