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
@@ -443,6 +443,8 @@ impl OpenCADStudio {
|
||||
commandline_fade_ms: crate::app::settings::clamp_commandline_fade_ms(
|
||||
self.commandline_fade_ms,
|
||||
),
|
||||
snap_spacing_x: self.snapper.snap_spacing_x,
|
||||
snap_spacing_y: self.snapper.snap_spacing_y,
|
||||
block_mru: self.block_mru.clone(),
|
||||
block_freq: self.block_freq.clone(),
|
||||
}
|
||||
@@ -540,6 +542,10 @@ impl OpenCADStudio {
|
||||
crate::app::settings::clamp_commandline_fade_ms(s.commandline_fade_ms);
|
||||
self.command_line
|
||||
.set_commandline_fade_ms(self.commandline_fade_ms.clamp(0, 60000) as u32);
|
||||
self.snapper.snap_spacing_x =
|
||||
crate::app::settings::sanitize_snap_spacing(s.snap_spacing_x);
|
||||
self.snapper.snap_spacing_y =
|
||||
crate::app::settings::sanitize_snap_spacing(s.snap_spacing_y);
|
||||
// Block usage: clone but cap to sane sizes (MRU 20, freq map 200)
|
||||
self.block_mru = s.block_mru.iter().take(20).cloned().collect();
|
||||
self.block_freq = s
|
||||
|
||||
+37
-8
@@ -4484,6 +4484,33 @@ impl OpenCADStudio {
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
Message::DraftingSettingsSnapXChanged(value) => {
|
||||
if let Some(state) = &mut self.drafting_settings_state {
|
||||
state.snap_x_input = value.clone();
|
||||
if state.snap_equal {
|
||||
state.snap_y_input = value;
|
||||
}
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
Message::DraftingSettingsSnapYChanged(value) => {
|
||||
if let Some(state) = &mut self.drafting_settings_state {
|
||||
state.snap_y_input = value.clone();
|
||||
if state.snap_equal {
|
||||
state.snap_x_input = value;
|
||||
}
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
Message::DraftingSettingsToggleEqualSnap => {
|
||||
if let Some(state) = &mut self.drafting_settings_state {
|
||||
state.snap_equal = !state.snap_equal;
|
||||
if state.snap_equal {
|
||||
state.snap_y_input = state.snap_x_input.clone();
|
||||
}
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
Message::DraftingSettingsToggleIsometric => {
|
||||
if let Some(state) = &mut self.drafting_settings_state {
|
||||
state.isometric = !state.isometric;
|
||||
@@ -4574,17 +4601,19 @@ impl OpenCADStudio {
|
||||
Task::none()
|
||||
}
|
||||
Message::DraftingSettingsApply => {
|
||||
self.apply_drafting_settings();
|
||||
self.drafting_settings_saved = self.drafting_settings_state.clone();
|
||||
self.persist_settings_if_changed();
|
||||
if self.apply_drafting_settings() {
|
||||
self.drafting_settings_saved = self.drafting_settings_state.clone();
|
||||
self.persist_settings_if_changed();
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
Message::DraftingSettingsOk => {
|
||||
self.apply_drafting_settings();
|
||||
self.drafting_settings_saved = self.drafting_settings_state.clone();
|
||||
self.drafting_settings_close_confirm = false;
|
||||
self.persist_settings_if_changed();
|
||||
self.close_active_modal();
|
||||
if self.apply_drafting_settings() {
|
||||
self.drafting_settings_saved = self.drafting_settings_state.clone();
|
||||
self.drafting_settings_close_confirm = false;
|
||||
self.persist_settings_if_changed();
|
||||
self.close_active_modal();
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
Message::DraftingSettingsClose => {
|
||||
|
||||
@@ -1928,7 +1928,9 @@ impl OpenCADStudio {
|
||||
)
|
||||
}
|
||||
};
|
||||
// Sync grid-snap spacing to the adaptive spacing of the visible grid.
|
||||
// Sync the adaptive visible-grid step. It drives display and
|
||||
// snap-aperture tolerances — grid *snap* itself locks to the
|
||||
// fixed SNAPUNIT X/Y spacing from the Drafting Settings dialog.
|
||||
self.snapper.grid_spacing = grid_spacing;
|
||||
// Cursor and wires are model-space; the snap result is model.
|
||||
let snap_cursor = cursor_world;
|
||||
|
||||
Reference in new issue
Block a user