forked from 1b-agent/opencadstudio-upstream
feat(snap): editable Snap X/Y spacing with Equal lock, grid snap locks
Drafting Settings dialog gets text inputs for Snap X/Y spacing plus a working Equal X and Y checkbox (mirrored inputs, Y follows X on apply). Snapper gains fixed snap_spacing_x/y (persisted in UserSettings, default 10) decoupled from the adaptive visible-grid step. Grid snap no longer aperture-gated: with Snap On it rounds every point to the grid, object snaps still override by tier. Adds parse/lock regression tests.
This commit is contained in:
1 parent
1057790456
commit
624fe53382
8 files changed
+238
-36
No files matched your search
@@ -434,6 +434,13 @@ pub struct UserSettings {
|
||||
deserialize_with = "deserialize_commandline_fade_ms"
|
||||
)]
|
||||
pub commandline_fade_ms: i32,
|
||||
/// SNAPUNIT X/Y spacing used by grid snap. 10 matches the Drafting
|
||||
/// Settings dialog defaults; older configs without these keys fall
|
||||
/// back via `default_snap_spacing`.
|
||||
#[serde(default = "default_snap_spacing")]
|
||||
pub snap_spacing_x: f32,
|
||||
#[serde(default = "default_snap_spacing")]
|
||||
pub snap_spacing_y: f32,
|
||||
/// Most-recently-inserted block names, most recent first, capped to 20.
|
||||
/// Used to rank INSERT suggestions without touching the drawing file.
|
||||
#[serde(default)]
|
||||
@@ -455,6 +462,20 @@ fn default_commandline_fade_ms() -> i32 {
|
||||
3000
|
||||
}
|
||||
|
||||
/// Default SNAPUNIT spacing shown in the Drafting Settings dialog.
|
||||
fn default_snap_spacing() -> f32 {
|
||||
10.0
|
||||
}
|
||||
|
||||
/// Clamp a snap spacing to the positive range the dialog accepts.
|
||||
pub fn sanitize_snap_spacing(v: f32) -> f32 {
|
||||
if v.is_finite() && v > 0.0 && v <= 1e9 {
|
||||
v
|
||||
} else {
|
||||
10.0
|
||||
}
|
||||
}
|
||||
|
||||
fn deserialize_commandline_fade_ms<'de, D>(de: D) -> Result<i32, D::Error>
|
||||
where
|
||||
D: serde::Deserializer<'de>,
|
||||
@@ -552,6 +573,8 @@ impl Default for UserSettings {
|
||||
language: crate::i18n::Language::default(),
|
||||
cliprompt_lines: 3,
|
||||
commandline_fade_ms: 3000,
|
||||
snap_spacing_x: 10.0,
|
||||
snap_spacing_y: 10.0,
|
||||
block_mru: Vec::new(),
|
||||
block_freq: std::collections::HashMap::new(),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user