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 <noreply@anthropic.com>
This commit is contained in:
parent
970ee5a09f
commit
1d7f5d2618
3 changed files with 22 additions and 9 deletions
|
|
@ -821,7 +821,7 @@ impl OpenCADStudio {
|
||||||
}
|
}
|
||||||
|
|
||||||
"POINTCLOUDATTACH" | "RECAP" | "SYNCPVIEWPORTS" | "UNDERLAYLAYERS" | "OBJECTSCALE"
|
"POINTCLOUDATTACH" | "RECAP" | "SYNCPVIEWPORTS" | "UNDERLAYLAYERS" | "OBJECTSCALE"
|
||||||
| "UOSNAP" | "OPTIONS" => {
|
| "UOSNAP" => {
|
||||||
self.command_line
|
self.command_line
|
||||||
.push_info(&format!("{cmd}: not yet implemented."));
|
.push_info(&format!("{cmd}: not yet implemented."));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -228,17 +228,30 @@ impl OpenCADStudio {
|
||||||
|
|
||||||
// ── Background color ───────────────────────────────────────────
|
// ── Background color ───────────────────────────────────────────
|
||||||
// Usage: BACKGROUND <r> <g> <b> (0–255 each)
|
// Usage: BACKGROUND <r> <g> <b> (0–255 each)
|
||||||
// BACKGROUND WHITE|BLACK|GRAY|DARKGRAY|LTGRAY (preset)
|
// BACKGROUND DEFAULT|BLACK|DARKGRAY|GRAY|LIGHTGRAY|WHITE (preset)
|
||||||
// BACKGROUND RESET (restore default)
|
// BACKGROUND DEFAULT (restore the app default, rgb 33,40,48)
|
||||||
// The chosen colour is also stored as the persisted default
|
// The chosen colour is also stored as the persisted default
|
||||||
// (`default_bg_color` / `default_paper_bg_color`) so it survives
|
// (`default_bg_color` / `default_paper_bg_color`) so it survives
|
||||||
// restarts and applies to new drawings (#188).
|
// 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 args = cmd.split_whitespace().skip(1).collect::<Vec<_>>();
|
||||||
let is_paper = self.tabs[i].scene.current_layout != "Model";
|
let is_paper = self.tabs[i].scene.current_layout != "Model";
|
||||||
if args
|
if args
|
||||||
.first()
|
.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)
|
.unwrap_or(false)
|
||||||
{
|
{
|
||||||
if is_paper {
|
if is_paper {
|
||||||
|
|
@ -247,7 +260,7 @@ impl OpenCADStudio {
|
||||||
self.default_paper_bg_color = None;
|
self.default_paper_bg_color = None;
|
||||||
} else {
|
} else {
|
||||||
self.tabs[i].bg_color = None;
|
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;
|
self.default_bg_color = None;
|
||||||
}
|
}
|
||||||
// Wire colour adaptation (`adapt_to_bg`) reads the bg
|
// Wire colour adaptation (`adapt_to_bg`) reads the bg
|
||||||
|
|
@ -285,7 +298,7 @@ impl OpenCADStudio {
|
||||||
// `persist_settings_if_changed()`.
|
// `persist_settings_if_changed()`.
|
||||||
} else {
|
} else {
|
||||||
self.command_line.push_info(
|
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",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,7 @@ pub fn build_derived_caches(doc: &CadDocument) -> DerivedCaches {
|
||||||
// bg is only relevant after the user enters a paper layout, and
|
// bg is only relevant after the user enters a paper layout, and
|
||||||
// `synced_hatch_models` re-runs `render_style` per-frame anyway so
|
// `synced_hatch_models` re-runs `render_style` per-frame anyway so
|
||||||
// the per-layout adaptation kicks in later regardless).
|
// 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
|
// hatches
|
||||||
let hatches: HashMap<Handle, HatchModel> = hatch_handles
|
let hatches: HashMap<Handle, HatchModel> = hatch_handles
|
||||||
|
|
@ -946,7 +946,7 @@ impl Scene {
|
||||||
solid_models: HashMap::default(),
|
solid_models: HashMap::default(),
|
||||||
images: HashMap::default(),
|
images: HashMap::default(),
|
||||||
active_viewport: None,
|
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],
|
paper_bg_color: [1.0, 1.0, 1.0, 1.0],
|
||||||
local_extent_max: 1e9,
|
local_extent_max: 1e9,
|
||||||
local_center: [0.0, 0.0],
|
local_center: [0.0, 0.0],
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue