forked from 1b-agent/opencadstudio-upstream
feat: editable grid spacing and major grid lines in Drafting Settings
The Snap and Grid tab showed static grid values with dead checkboxes, and every grid line stroked identically. Grid X/Y spacing and Major-line-every are now editable inputs (validated 2-100 for majors, dirty-tracked, applied with an error message on bad input); Adaptive-grid and Display-beyond-Limits checkboxes are wired to live state. Every Nth line partitions into major_segments and strokes subtly brighter (1.5x alpha, 0.75px) for the reference hierarchy. GRIDMAJOR state persists to UserSettings. Covers partition, invalidation, and parse tests.
This commit is contained in:
1 parent
05f462f294
commit
4aa699e08d
9 files changed
+249
-37
No files matched your search
@@ -464,6 +464,9 @@ pub struct UserSettings {
|
||||
pub grid_spacing_x: f32,
|
||||
#[serde(default = "default_snap_spacing")]
|
||||
pub grid_spacing_y: f32,
|
||||
/// GRIDMAJOR: every Nth grid line is a brighter major line.
|
||||
#[serde(default = "default_grid_major")]
|
||||
pub grid_major_every: u32,
|
||||
/// Adaptive grid scaling (default on).
|
||||
#[serde(default = "default_true")]
|
||||
pub grid_adaptive: bool,
|
||||
@@ -496,10 +499,19 @@ fn default_snap_spacing() -> f32 {
|
||||
10.0
|
||||
}
|
||||
|
||||
fn default_grid_major() -> u32 {
|
||||
5
|
||||
}
|
||||
|
||||
fn default_true() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
/// Clamp a major-line interval to the range the dialog accepts.
|
||||
pub fn sanitize_grid_major(v: u32) -> u32 {
|
||||
v.clamp(2, 100)
|
||||
}
|
||||
|
||||
/// 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 {
|
||||
@@ -616,6 +628,7 @@ impl Default for UserSettings {
|
||||
snap_spacing_y: 10.0,
|
||||
grid_spacing_x: 10.0,
|
||||
grid_spacing_y: 10.0,
|
||||
grid_major_every: 5,
|
||||
grid_adaptive: true,
|
||||
grid_beyond_limits: true,
|
||||
block_mru: Vec::new(),
|
||||
|
||||
Reference in new issue
Block a user