View backgrounds: image colours as stored, viewport style name, adjust automation

- The background image texture is not an sRGB view: the image is drawn with
  its own colours, as the solid and gradient colours are.
- An entered paper-space viewport shows its named visual style (Realistic,
  ...) in the render-mode picker, and a mode picked there is recorded as the
  viewport's visual style.
- The view_background automation action takes offset=x,y and scale=x,y.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
ramox81andClaude Opus 5.5 committed 2026-10-13 09:44:49 +03:00
1 parent b5b505ee9d
commit 064da8829e
8 files changed
+80 -19

No files matched your search

+16 -1
View File
@@ -1798,7 +1798,7 @@ impl OpenCADStudio {
"ribbon_dropdown" => Message::ToggleRibbonDropdown(string(req, "value")?.into()),
// The -VIEW Background dialog, one field per call: "type=gradient",
// "color|top|middle|bottom=r,g,b", "three=1", "rotation=30",
// "image=<path>", "position=center|stretch|tile", "aspect=1",
// "image=<path>", "position=center|stretch|tile", "aspect=1", "offset=x,y" (pixels), "scale=x,y" (non-zero),
// "apply" or "cancel".
"view_background" => {
use crate::ui::window::pdf_dialogs::{BgKind, BgPosition, PdfDialogMsg as P};
@@ -1840,6 +1840,21 @@ impl OpenCADStudio {
_ => return Err(bad()),
})),
"aspect" => Message::PdfDialog(P::BgAspect(value == "1")),
"offset" | "scale" => {
let pair: Vec<f64> = value
.split(',')
.map(|part| part.trim().parse::<f64>())
.collect::<Result<_, _>>()
.map_err(|_| bad())?;
let pair = <[f64; 2]>::try_from(pair).map_err(|_| bad())?;
if key == "offset" {
Message::PdfDialog(P::BgOffset(pair))
} else if pair.iter().all(|v| v.is_finite() && *v != 0.0) {
Message::PdfDialog(P::BgScale(pair))
} else {
return Err(bad());
}
}
_ => return Err(bad()),
}
}