Files
craft-libs/crates/draw
aiongg 460bb5de7d craft-ui: MemoView, memoized views keyed by their props
A memoized view's content is a fn and its props are its only input, so the
framework sees every input it reads. While its key (the props type, the fn's
address and the props' inputs) equals the key after its last run, it adds
that run again and returns what the run returned. Lazy and MemoView share
one runner and one settled test; a memo view ignores the two rules that infer
a change of app data (input arrived, a repaint was asked), replays a run of an
earlier pass of the same frame when nothing it read was edited after the run
started and the run asked for no discard pass, and keeps its entry through
absence up to twice the shown views per viewport.

MemoProps gains identity() (the props type with its lifetimes erased, through
the typeid crate), &mut Tracked<T> by revision and Bind by value and place.
A binding's check takes its inputs as props: check(fn) and
check_with(inputs, fn), one mechanism; a composite hands its check on through
BindMut::check_of. The preset name check (NameCheck) takes inputs the same
way, with PresetNames as a library's names. Glyph is Any + MemoProps, and an
icon keys a glyph by its type, then by its key; the caption glyph owns an
Arc<CaptionIcons>.

Facts::register is journaled, layout memory notes discard asks into the open
record, and the settle counters become MemoRun and last_pass_memo_runs. The
idle-frame trial moves onto memo views, beside count trials of the mechanism.
2026-11-19 10:04:00 +00:00
..

craft-draw

Vector and shape tools for Craft apps. With the ui feature, craft_draw::ui has the pen, crop and free transform overlays (below), the gradient tools (GradientPalette, GradientSwatch, the on-canvas GradientOverlay with its gradient_line geometry, the GradientFillEditor and the GradientMapEditor; the stop bar GradientEditor, the stop rules gradient::stops and GradientRamp are craft_color_ui::ui::gradient's) and these tools and panels, each in its own module with its labels:

  • stroke: StrokeEditor, StrokeButton and StrokePreview over StrokeStyle; corner: CornerWidgets for corner radii;
  • shape and shape_drag: ShapePanel, ShapeBar, ShapeDragTool and CreateShapeDialog; slice: SliceTool, SliceOverlay, SliceBar and the Slice Options and Divide Slices dialogs; artboard and add_beside: ArtboardTool, ArtboardBar, ArtboardProperties and the add-beside buttons; connector: ConnectorTool, ConnectorOverlay and ConnectorBar;
  • pattern and picture_fill: PatternFillEditor, PatternFillDialog and PictureFillEditor;
  • transform: TransformSession with TransformOverlay, TransformBar and the Transform menu words; crop: CropTool, CropSession and CropBar beside the CropFrame; measure: RulerTool, RulerBar and box_distances; symmetry: Symmetry with SymmetryOverlay, SymmetryMenu and SymmetryTransform;
  • brush_presets and brush_settings: BrushPresetPicker, BrushesPanel, BrushPresetChip and BrushSettingsPanel (its answer is BrushSettingsPanelOutput); paths: PathsPanel.

The main types of every module are re-exported at craft_draw::ui.

The gradient parts use the gradient stop editor, the colour picker and the wells of craft-color-ui.

ui::pen, ui::crop and ui::transform hold the canvas overlays of the Pen, Crop and Free Transform tools. They sense through craft_ui::canvas (CanvasView, Claim, PartFocus, quad):

TransformBox draws Free Transform's box over the guides (a bare 1 pt line, 8 square handles, the reference point) and runs its gestures through quad::drag (PhotoCraft's rules by default; BoxRules, RotateZone and inside_moves set DesignCraft's, VectorCraft's or a Move tool's): the nearest handle within 12 pt, drags reported as edit gestures, a click outside or a double-click inside or Enter applies, Esc undoes a drag and then discards the box, the arrows move the picked part, an optional readout shows the angle, scale or move; one Tab stop whose Page keys pick the whole box, a corner, an edge or the reference point, each an AccessKit object named by the host's TransformNames. A host that runs its own input calls hit, press, track and release (canvas points, modifiers, the view; BoxPress is the state it keeps between press and release) and gets the box show would give; paint_pivot draws the reference point for a host that shows one outside the box. BezierOverlay draws paths (EditPath: subpaths of Knots, each an anchor with in and out handles; PathSelection is the host's) with their anchors and direction handles and edits them as Direct Selection (select, ⇧ toggle, ⌥ subpath, drag anchors, handles and segments, a marquee on empty canvas) or Convert Point does, reporting PathEdits for the host to apply; one Tab stop whose Page keys pick anchors and their handles, arrows move them, Insert and Delete report anchors to add and remove; above MAX_ANCHORS anchors it draws outlines only. PenDraft draws the path being drawn with the Pen and runs its gestures (click for a corner anchor, drag for symmetric handles, ⇧ at 45°, ⌥ breaks the pair, a press on the last anchor retracts its handle, a press on the first closes the path, a press on an open path's end resumes it) and keys (Enter and Esc end the path and keep it, Backspace and PenDraft::remove_last take back the last anchor), reporting the whole draft as an EditSubpath edit gesture; it is not a Tab stop and its anchors are AccessKit objects named by the host's PenNames.