fix(dyn-input): support cartesian coords via "," (#35)

Typing \`,\` while DYN was on appended the character to the focused
field's buffer (treated as a European decimal point), so users
couldn't switch to cartesian coordinates mid-command. The dynamic
input was stuck in polar \`[Distance, Angle]\` whenever a base point
existed.

\`,\` now acts as the coordinate separator (matching the AutoCAD
convention): pressing it locks the current field's buffer, then
either advances within the existing cartesian set or reshapes a
polar configuration into cartesian:

- \`[Distance, Angle]\` + \`,\` on the first field → \`[X(buf), Y]\`
- \`[X, Y]\` + \`,\` on Y → \`[X, Y, Z]\`
- otherwise advances to the next field (Tab-equivalent)

\`sync_dyn_fields\` accepts both polar and cartesian shapes as valid
\`Point\` configurations so a mouse-move after the reshape doesn't
revert to polar. \`dyn_resolve_point\` and the overlay's live-value
formatter treat cartesian inputs as RELATIVE to the base point when
one exists — matching the DYN-on relative-coords convention from
#26. \`DynComponent::Z\` plus its label / value paths fill out the
3-D variant.

Closes #35

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Hakan SevenandClaude Opus 4.7 committed 2026-05-29 00:46:18 +03:00
1 parent 4c60dce81a
commit f952fc9bb7
3 files changed
+125 -4

No files matched your search

+10
View File
@@ -2124,6 +2124,7 @@ fn dyn_component_label(c: DynComponent) -> String {
match c {
DynComponent::X => "X".into(),
DynComponent::Y => "Y".into(),
DynComponent::Z => "Z".into(),
DynComponent::Distance => "d".into(),
DynComponent::Angle => "<".into(),
}
@@ -2143,9 +2144,18 @@ fn dyn_component_value(
let b = base.unwrap_or(glam::Vec3::ZERO);
let dx = (w.x - b.x) as f64;
let dy = (w.y - b.y) as f64;
// When a base point exists (DYN-on after the first pick) the cartesian
// fields show relative deltas — matching the typed-value convention
// in `dyn_resolve_point` so the live preview and the committed
// coordinate use the same frame. See #35.
let has_base = base.is_some();
match f.component {
DynComponent::X if has_base => format!("{:.4}", dx),
DynComponent::Y if has_base => format!("{:.4}", dy),
DynComponent::Z if has_base => "0.0000".to_string(),
DynComponent::X => format!("{:.4}", w.x),
DynComponent::Y => format!("{:.4}", w.y),
DynComponent::Z => format!("{:.4}", b.z),
DynComponent::Distance => format!("{:.4}", (dx * dx + dy * dy).sqrt()),
DynComponent::Angle => format!("{:.1}", dy.atan2(dx).to_degrees().rem_euclid(360.0)),
}