fix(background): step-by-step prompt + Default preset (#217)

Bare BACKGROUND now opens an interactive colour prompt (via
ValuePromptCommand, same idiom as PDMODE/LTSCALE) instead of just
printing usage, so the command works both step-by-step and as a
one-shot `BACKGROUND <colour>`. Options reordered to
Default/Black/DarkGray/Gray/LightGray/White; DEFAULT restores the app
default, now unified to rgb(33,40,48) across startup, load and reset.
Also drop the unreachable OPTIONS arm in dispatch_display.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-30 17:55:44 +03:00
1 parent 970ee5a09f
commit 1d7f5d2618
3 files changed
+22 -9

No files matched your search

+1 -1
View File
@@ -821,7 +821,7 @@ impl OpenCADStudio {
}
"POINTCLOUDATTACH" | "RECAP" | "SYNCPVIEWPORTS" | "UNDERLAYLAYERS" | "OBJECTSCALE"
| "UOSNAP" | "OPTIONS" => {
| "UOSNAP" => {
self.command_line
.push_info(&format!("{cmd}: not yet implemented."));
}
+19 -6
View File
@@ -228,17 +228,30 @@ impl OpenCADStudio {
// ── Background color ───────────────────────────────────────────
// Usage: BACKGROUND <r> <g> <b> (0–255 each)
// BACKGROUND WHITE|BLACK|GRAY|DARKGRAY|LTGRAY (preset)
// BACKGROUND RESET (restore default)
// BACKGROUND DEFAULT|BLACK|DARKGRAY|GRAY|LIGHTGRAY|WHITE (preset)
// BACKGROUND DEFAULT (restore the app default, rgb 33,40,48)
// The chosen colour is also stored as the persisted default
// (`default_bg_color` / `default_paper_bg_color`) so it survives
// restarts and applies to new drawings (#188).
cmd if cmd == "BACKGROUND" || cmd.starts_with("BACKGROUND ") => {
// Bare BACKGROUND enters an interactive prompt for the colour, so
// the command works both as a one-shot (`BACKGROUND BLACK`) and as a
// type-then-choose flow (`BACKGROUND` ⏎, then `BLACK`). The prompt
// delegates back to the inline handler below via `Dispatch`.
"BACKGROUND" => {
use crate::command::ValuePromptCommand;
let c = ValuePromptCommand::new(
"BACKGROUND",
"BACKGROUND colour [Default/Black/DarkGray/Gray/LightGray/White] or R G B (0–255):",
);
self.command_line.push_info(&c.prompt());
self.tabs[i].active_cmd = Some(Box::new(c));
}
cmd if cmd.starts_with("BACKGROUND ") => {
let args = cmd.split_whitespace().skip(1).collect::<Vec<_>>();
let is_paper = self.tabs[i].scene.current_layout != "Model";
if args
.first()
.map(|s| s.eq_ignore_ascii_case("RESET"))
.map(|s| s.eq_ignore_ascii_case("DEFAULT") || s.eq_ignore_ascii_case("RESET"))
.unwrap_or(false)
{
if is_paper {
@@ -247,7 +260,7 @@ impl OpenCADStudio {
self.default_paper_bg_color = None;
} else {
self.tabs[i].bg_color = None;
self.tabs[i].scene.bg_color = [0.11, 0.11, 0.11, 1.0];
self.tabs[i].scene.bg_color = [33.0 / 255.0, 40.0 / 255.0, 48.0 / 255.0, 1.0];
self.default_bg_color = None;
}
// Wire colour adaptation (`adapt_to_bg`) reads the bg
@@ -285,7 +298,7 @@ impl OpenCADStudio {
// `persist_settings_if_changed()`.
} else {
self.command_line.push_info(
"Usage: BACKGROUND <r> <g> <b> (0–255) | WHITE|BLACK|GRAY|DARKGRAY|LTGRAY | RESET",
"Usage: BACKGROUND <r> <g> <b> (0–255) | DEFAULT|BLACK|DARKGRAY|GRAY|LIGHTGRAY|WHITE",
);
}
}
+2 -2
View File
@@ -212,7 +212,7 @@ pub fn build_derived_caches(doc: &CadDocument) -> DerivedCaches {
// bg is only relevant after the user enters a paper layout, and
// `synced_hatch_models` re-runs `render_style` per-frame anyway so
// the per-layout adaptation kicks in later regardless).
const LOAD_BG: [f32; 4] = [0.11, 0.11, 0.11, 1.0];
const LOAD_BG: [f32; 4] = [33.0 / 255.0, 40.0 / 255.0, 48.0 / 255.0, 1.0];
// hatches
let hatches: HashMap<Handle, HatchModel> = hatch_handles
@@ -946,7 +946,7 @@ impl Scene {
solid_models: HashMap::default(),
images: HashMap::default(),
active_viewport: None,
bg_color: [0.11, 0.11, 0.11, 1.0],
bg_color: [33.0 / 255.0, 40.0 / 255.0, 48.0 / 255.0, 1.0],
paper_bg_color: [1.0, 1.0, 1.0, 1.0],
local_extent_max: 1e9,
local_center: [0.0, 0.0],