1240d25011
- Add `selection/state.rs` to manage selection masks, including combining masks and calculating bounds. - Introduce `vector_edit.rs` for vector shape manipulation, handling drag sessions, and hit testing for handles. - Create `feature_scorecard.rs` to ensure stable feature identifiers and regression gates for GUI components. - Implement raster behavior tests in `raster_test.rs` to validate gradient application against masks.
5.2 KiB
5.2 KiB
Vector Tool Migration — Scoring & Implementation Plan
All Vector Tool Features — Current ICED Score (0-10)
| # | Feature | egui | ICED | Gap |
|---|---|---|---|---|
| 1 | Shape creation (15 types) via drag | 10 | 8 | Previews for 11 shapes are bounding-box fallback |
| 2 | Auto-vector-layer creation | 10 | 10 | None |
| 3 | VectorSelect click-to-select | 10 | 0 | MISSING |
| 4 | VectorEditHandle hit-testing | 10 | 0 | MISSING |
| 5 | Shape drag-move via handles | 10 | 0 | MISSING |
| 6 | Shape resize via handles | 10 | 0 | MISSING |
| 7 | Shape rotation via handle | 10 | 0 | MISSING |
| 8 | Shape cycling (overlapping) | 10 | 0 | MISSING |
| 9 | Geometry panel: shape list | 10 | 2 | Hardcoded &[], no selection |
| 10 | Geometry panel: shape selection | 10 | 0 | MISSING |
| 11 | Geometry panel: X1/Y1/X2/Y2 bounds | 10 | 0 | MISSING |
| 12 | Geometry panel: fill toggle | 10 | 0 | MISSING |
| 13 | Geometry panel: fill color picker | 10 | 0 | MISSING |
| 14 | Geometry panel: stroke color picker | 10 | 0 | MISSING |
| 15 | Geometry panel: opacity slider | 10 | 0 | MISSING |
| 16 | Geometry panel: hardness slider | 10 | 0 | MISSING |
| 17 | Geometry panel: line cap controls | 10 | 0 | MISSING |
| 18 | Geometry panel: boolean operations | 10 | 0 | MISSING |
| 19 | Shape Apply/Cancel overlay | 10 | 0 | MISSING |
| 20 | Shape Flip H/V | 10 | 0 | MISSING |
| 21 | shape_sync bidirectional sync | 10 | 0 | MISSING |
| 22 | Shape deletion | 10 | 0 | MISSING |
| 23 | Accurate previews (Arrow, etc.) | 10 | 3 | 11 shapes use bounding-box fallback |
| 24 | Tool settings panel (stroke, fill, etc.) | 10 | 7 | Missing hardness, line cap |
| 25 | Shape-specific preview (Star, Polygon) | 10 | 6 | Only 4 shapes have accurate preview |
Overall ICED Score: ~2.5/10 — Shape creation works but selection/editing is completely missing.
Implementation Phases
Phase A: VectorSelect Core (Features 3-8, 21-22) — Score Target: 8/10
Sub-goal A1: VectorSelect state and click-to-select
- Add
selected_vector_shape: Option<usize>to app state - Add
vector_shapes_snapshot: Option<Vec<VectorShape>>for undo - Add
vector_edit_handle: VectorEditHandlestate - Add
vector_drag_last: Option<(f32, f32)>tracking - Implement
VectorSelectclick handling in canvas - Call
engine.find_vector_shape_at()for hit-testing - Support overlapping shape cycling
Sub-goal A2: VectorEditHandle rendering on canvas
- Render 8 resize handles (white squares with black stroke)
- Render rotation handle (blue circle above top-center)
- Render selection outline (blue stroke around shape)
- Hit-test handles on click
Sub-goal A3: Shape drag/resize/rotate via handles
- Move: drag shape body →
engine.modify_vector_shape() - Resize: drag corner/edge handles →
engine.modify_vector_shape() - Rotate: drag rotation handle →
engine.set_vector_shape_angle()
Sub-goal A4: Apply/Cancel overlay
- Show Apply (checkmark) and Cancel (X) buttons when shape is selected
- Apply: commit changes, clear snapshot, deselect
- Cancel: restore snapshot, deselect
- Flip H/V buttons for applicable shapes
Sub-goal A5: Shape deletion
- Delete key or X button in geometry panel
engine.delete_vector_shape()or equivalent
Phase B: Geometry Panel (Features 9-18) — Score Target: 8/10
Sub-goal B1: Shape list with selection
- Render all shapes in active vector layer
- Click to select/deselect
- Delete button per shape
Sub-goal B2: Bounds editing (X1/Y1/X2/Y2)
- 4 sliders for shape bounds
engine.set_vector_shape_bounds()on change
Sub-goal B3: Fill toggle + fill color
- Checkbox for fill on/off
- Color picker for fill color
engine.set_vector_shape_fill()andset_vector_shape_fill_color()
Sub-goal B4: Stroke color picker
- Color picker for stroke color
engine.set_vector_shape_color()
Sub-goal B5: Opacity and Hardness sliders
- Slider for opacity (0-1)
- Slider for hardness (0-1)
engine.set_vector_shape_opacity()andset_vector_shape_hardness()
Sub-goal B6: Line cap controls
- Start/End cap combo boxes (for Line shapes)
engine.set_vector_shape_line_caps()
Sub-goal B7: Boolean operations
- Shape A/B selectors
- Union/Intersect/Subtract/Xor buttons
engine.boolean_vector_shapes()
Phase C: Shape Sync & Polish (Features 21, 23-25) — Score Target: 9/10
Sub-goal C1: shape_sync bidirectional sync
sync_shape_from_tool(): push tool state to selected shapesync_tool_from_shape(): pull shape properties to tool state
Sub-goal C2: Accurate previews for all 15 shapes
- Arrow, Rhombus, Cylinder, Heart, Bubble, Gear, Cross, Crescent, Bolt, Arrow4
- FreePath preview
Sub-goal C3: Tool settings panel completion
- Add hardness slider
- Add line cap controls
Execution Order
- A1 → A2 → A3 → A4 → A5 (VectorSelect core)
- B1 → B2 → B3 → B4 → B5 → B6 → B7 (Geometry panel)
- C1 → C2 → C3 (Sync & polish)
Recheck Points
After each phase, recheck scores:
- After Phase A: VectorSelect features should be 8/10
- After Phase B: Geometry panel features should be 8/10
- After Phase C: All vector features should be 9/10