Color: assigned profiles follow the document in front

The profiles Edit > Assign Profile gives a document stayed the active
color settings after another document came to the front, so a new,
opened or switched-to document drew and converted its colors through the
previous document's profile, and closing the last document left it in
use.

The session now puts the front document's profiles in use (the working
spaces where it has none, or no document is open) after a new or opened
document, a tab switch, a close, File > Revert, every command including
each batch step and Undo or Redo of Assign Profile, a failed batch or
plug-in call, a script's rollback and slice boundaries, a canceled
preview, undo group or undo scope, and for each document Export All Open
and the update of placed documents work in. The active settings are
rebuilt, and the documents redrawn, only when they change.
This commit is contained in:
dotCooCoo
2026-11-13 07:44:19 -08:00
parent 77970c6924
commit 5741c7bba0
13 changed files with 156 additions and 10 deletions
+4 -1
View File
@@ -132,8 +132,10 @@ fn export_all_open(s: &mut Session, p: &Value) -> Result<Value> {
let active = s.active;
for i in 0..s.docs.len() {
// Each document in turn is the one Save a Copy writes; switching tabs this way leaves every
// document's tool and interaction alone, and the active one comes back below.
// document's tool and interaction alone, and the active one comes back below. Its colors
// are written through its own profiles.
s.active = Some(i);
s.sync_front_profiles();
let Ok(st) = s.doc() else { continue };
let title = st.doc.title.clone();
let stem = fileio::file_stem(st.path.as_deref().unwrap_or(&title));
@@ -160,6 +162,7 @@ fn export_all_open(s: &mut Session, p: &Value) -> Result<Value> {
}
}
s.active = active;
s.sync_front_profiles();
Ok(json!({ "files": files, "failed": failed, "format": format.id }))
}
+6 -4
View File
@@ -5,9 +5,11 @@
//! Colour settings and the proof view are process-wide (`vectorcraft_color::cms::active`,
//! `vectorcraft_render::proof::view`). A document's assigned profiles are stored in
//! `Document::color_profiles` (files before format v3: `Document.unknown["colorProfiles"]`) and
//! take the place of the working spaces in the active settings when assigned, and when the working
//! settings change while the document is in front ([`use_front_profiles`]); the working spaces stay
//! as Edit → Color Settings set them.
//! take the place of the working spaces in the active settings while the document is in front
//! ([`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.
use std::collections::BTreeMap;
use std::sync::Arc;
@@ -181,7 +183,7 @@ fn touch_all(s: &mut Session) {
/// Make the active settings the working settings with the profiles the front document is assigned
/// in place of the working spaces (none, or no document open: the working spaces). The open
/// documents redraw when the active settings change.
fn use_front_profiles(s: &mut Session) {
pub(crate) fn use_front_profiles(s: &mut Session) {
let (rgb, cmyk) = s.active().map(|d| doc_profiles(&d.doc)).unwrap_or_default();
if cms::use_document_profiles(rgb.as_deref(), cmyk.as_deref()) {
touch_all(s);
+1
View File
@@ -41,6 +41,7 @@ pub(super) fn batch(s: &mut Session, p: &Value) -> Result<Value> {
roll_back(s, start, &stash);
s.notify_text_tool("batch.rollBack");
s.active = active;
s.sync_front_profiles();
(s.paint, s.fill_active, s.draw_mode, s.draw_inside, s.clipboard, s.untitled_counter, s.explicit_undo_group) = saved;
s.pending_paint = None;
return Err(e);
+4 -1
View File
@@ -1331,14 +1331,17 @@ pub(crate) fn refresh_placed(s: &mut Session, saved: u64, path: &str) {
if targets.is_empty() {
return;
}
// Each document is updated as the active one, without switching tools.
// Each document is updated as the active one, through its own profiles, without switching
// tools.
let back = s.active;
for i in targets {
s.active = Some(i);
s.sync_front_profiles();
// A file that can't be read leaves what its objects show: links.check reports it.
let _ = update_where(s, None, Some(&path));
}
s.active = back;
s.sync_front_profiles();
}
// ---------- relative paths ----------
+1
View File
@@ -413,6 +413,7 @@ pub(crate) fn transaction(s: &mut Session, label: &str, f: impl FnOnce(&mut Sess
st.interaction = None;
}
saved.restore(s);
s.sync_front_profiles();
Err(e)
}
}