Merge pull request #7534 from dotCooCoo/fix/tiled-documents-own-profiles

Color management: documents behind the front one draw through their own profiles
This commit is contained in:
BFlat
2026-11-14 21:51:30 +07:00
committed by GitHub
8 changed files with 417 additions and 42 deletions
+25 -1
View File
@@ -9,7 +9,8 @@
//! ([`use_front_profiles`]): when they are assigned, when the working settings change, and when the
//! document comes to the front or its assignment comes back (an open, a switch, a close, a revert,
//! an undo or a rollback, [`Session::sync_front_profiles`]); the working spaces stay as Edit → Color
//! Settings set them.
//! Settings set them. A document drawn while another is in front draws through its own profiles
//! ([`doc_cms`]).
use std::collections::BTreeMap;
use std::sync::Arc;
@@ -236,6 +237,9 @@ fn load_profile(s: &mut Session, p: &Value) -> Result<Value> {
} else if proof_targets(&info.name) {
// A new file of the CMYK profile View → Proof Setup targets: redraw.
touch_all(s);
} else {
// Documents behind the front one draw through their own profiles: those assigned it redraw.
touch_assigned(s, &info.name);
}
Ok(json!({"name": info.name, "kind": info.kind, "remembered": remembered}))
}
@@ -266,9 +270,21 @@ fn remove_profile(s: &mut Session, p: &Value) -> Result<Value> {
if proof_targets(&info.name) {
touch_all(s);
}
// Documents behind the front one draw through their own profiles: those assigned it redraw.
touch_assigned(s, &info.name);
Ok(json!({"removed": info.name}))
}
/// Redraw the open documents assigned the profile `name`.
fn touch_assigned(s: &mut Session, name: &str) {
for d in &mut s.docs {
let (rgb, cmyk) = doc_profiles(&d.doc);
if [rgb, cmyk].iter().any(|n| n.as_deref() == Some(name)) {
d.revision += 1;
}
}
}
/// Whether View → Proof Setup targets the CMYK profile `name`.
fn proof_targets(name: &str) -> bool {
matches!(proof::view().setup.target, ProofTarget::Cmyk(t) if t == name)
@@ -285,6 +301,14 @@ pub fn doc_profiles(d: &vectorcraft_doc::Document) -> (Option<String>, Option<St
(get(&d.color_profiles.rgb), get(&d.color_profiles.cmyk))
}
/// The color-management context the document draws through: the working settings with its
/// assigned profiles in place of the working spaces, whether or not it is in front
/// ([`cms::for_document`]).
pub fn doc_cms(d: &vectorcraft_doc::Document) -> Arc<cms::Cms> {
let (rgb, cmyk) = doc_profiles(d);
cms::for_document(rgb.as_deref(), cmyk.as_deref())
}
fn assign_profile(s: &mut Session, p: &Value) -> Result<Value> {
const C: &str = "edit.assignProfile";
let (mut rgb, mut cmyk) = doc_profiles(&s.doc()?.doc);