fix(engine): prefs.set and prefs.reset apply the text blending gamma (#987) (#1709)

This commit is contained in:
MarekSpodBiedry
2026-10-09 18:00:29 +07:00
committed by GitHub
parent 66ab5012be
commit 088dbba090
2 changed files with 20 additions and 0 deletions
+3
View File
@@ -1410,6 +1410,8 @@ fn prefs_set(s: &mut Session, p: &Value) -> Result<Value> {
return Err(bad(cmd, e));
}
}
// `colorSettings.blendTextGamma` lives in the compositor too, as `edit.colorSettings` sets it.
photocraft_compose::psblend::set_text_gamma(s.color.settings.blend_text_gamma);
s.apply_prefs();
let view = s.prefs_view();
let out: Map<String, Value> = changes.iter().map(|(k, _)| (k.clone(), get_path(&view, k).cloned().unwrap_or(Value::Null))).collect();
@@ -1439,6 +1441,7 @@ fn prefs_reset(s: &mut Session, p: &Value) -> Result<Value> {
}
}
s.prefs.edit(|_| ());
photocraft_compose::psblend::set_text_gamma(s.color.settings.blend_text_gamma);
s.apply_prefs();
if path.is_some_and(|path| keyed(path).is_some()) {
// The removed override is absent, so reading its old path would report an error.
+17
View File
@@ -27,4 +27,21 @@ fn blend_text_gamma_setting() {
s.execute("edit.colorSettings", json!({"blendTextGamma": true})).unwrap();
assert!((s.color.settings.blend_text_gamma - 1.45).abs() < 1e-6);
assert!((photocraft_compose::psblend::text_gamma() - 1.45).abs() < 1e-6);
// `prefs.set` and `prefs.reset` on `colorSettings` move the compositor's gamma too (#987).
// Same function, not a second test: tests in one binary run concurrently.
let in_sync = |s: &Session| (photocraft_compose::psblend::text_gamma() - s.color.settings.blend_text_gamma).abs() < 1e-6;
s.execute("edit.colorSettings", json!({"blendTextGamma": 1.8})).unwrap();
s.execute("prefs.set", json!({"path": "colorSettings.blendTextGamma", "value": 1.0})).unwrap();
assert_eq!(photocraft_compose::psblend::text_gamma(), 1.0);
assert!(in_sync(&s));
s.execute("prefs.reset", json!({"path": "colorSettings.blendTextGamma"})).unwrap();
assert!((photocraft_compose::psblend::text_gamma() - 1.45).abs() < 1e-6);
assert!(in_sync(&s));
for reset in [json!({"path": "colorSettings"}), json!({})] {
s.execute("edit.colorSettings", json!({"blendTextGamma": 1.8})).unwrap();
s.execute("prefs.reset", reset).unwrap();
assert!((photocraft_compose::psblend::text_gamma() - 1.45).abs() < 1e-6);
assert!(in_sync(&s));
}
}