mirror of
https://github.com/storytold/photocraft.git
synced 2026-10-24 09:57:08 -06:00
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user