refactor(grip): square-only marker set + oriented stretch handles

Phase 1 of bringing the grip vocabulary in line with the standard
CAD convention: drop the per-position-type shape encoding (Diamond
for translate, Circle for parameter) and use a plain square for
every endpoint / vertex / centre grip. The behavioural midpoint vs
vertex distinction stays — it lives on `GripDef::is_midpoint` and
drives `Translate` vs `Absolute` in the grip-edit dispatcher — only
the marker shape collapses.

- `GripShape` keeps `Square`, `Rectangle`, `Triangle`. Diamond /
  Circle are gone.
- `GripDef` gains `dir: Option<[f32; 2]>` — a world-XY direction
  vector consumed by `Rectangle` to orient the box along its
  segment.
- `entities::common` exposes `square_grip`, `center_grip` (same
  square marker, flagged as translate), `rectangle_grip(id, world,
  dir)` for oriented mid-segment handles, and a kept-for-Phase-2
  `triangle_grip`.
- `overlay::GripMarker` / `grips_to_screen[_paper]` thread `dir`
  through to the canvas painter; the Rectangle path rotates the
  box around the grip centre using the world-XY direction (flipping
  the sin for screen-Y).

Every existing `diamond_grip(id, w)` call becomes `center_grip(id,
w)` — the visual change is square-replacing-diamond at line
midpoints / arc midpoints / circle centres / ellipse centres /
viewport / hatch loop centroids / dimension grips / image corners /
multileader / ray / underlay / ole2frame / solid3d.

`LwPolyline` grows a stretch handle on every segment (straight or
arc), drawn as the new oriented rectangle. The grip-edit path
translates both segment endpoints for straight segments and
adjusts the arc bulge from the new midpoint for arc segments.
This commit is contained in:
Hakan Seven committed 2026-05-29 02:07:34 +03:00
1 parent 1e33a9049c
commit 5755c2e130
20 files changed
+191 -140

No files matched your search

+21 -22
View File
@@ -127,44 +127,43 @@ pub fn square_grip(id: usize, world: Vec3) -> GripDef {
world,
is_midpoint: false,
shape: GripShape::Square,
dir: None,
}
}
pub fn diamond_grip(id: usize, world: Vec3) -> GripDef {
/// Centre / translate grip — same square marker as a vertex grip but
/// flagged as a "whole-object move" handle for the grip-edit code.
pub fn center_grip(id: usize, world: Vec3) -> GripDef {
GripDef {
id,
world,
is_midpoint: true,
shape: GripShape::Diamond,
shape: GripShape::Square,
dir: None,
}
}
/// Mid-segment stretch grip oriented along `dir` (the segment's in-plane
/// world-XY direction). Drawn as a small rectangle elongated along the
/// segment so the affordance reads as "stretch perpendicular".
pub fn rectangle_grip(id: usize, world: Vec3, dir: [f32; 2]) -> GripDef {
GripDef {
id,
world,
is_midpoint: true,
shape: GripShape::Rectangle,
dir: Some(dir),
}
}
#[allow(dead_code)]
pub fn triangle_grip(id: usize, world: Vec3) -> GripDef {
GripDef {
id,
world,
is_midpoint: false,
shape: GripShape::Triangle,
}
}
#[allow(dead_code)]
pub fn rectangle_grip(id: usize, world: Vec3) -> GripDef {
GripDef {
id,
world,
is_midpoint: true,
shape: GripShape::Rectangle,
}
}
#[allow(dead_code)]
pub fn circle_grip(id: usize, world: Vec3) -> GripDef {
GripDef {
id,
world,
is_midpoint: false,
shape: GripShape::Circle,
dir: None,
}
}