From feda02ade4ffa5a3df938176349a33d2de8f4f93 Mon Sep 17 00:00:00 2001 From: Tanish Manku Date: Tue, 17 Nov 2026 17:37:10 -0700 Subject: [PATCH] feat(shell): drag layers to reorder, all-layer buttons, a draggable layer column, Size in Properties, brushes keep their settings (#407, #422, #384, #294, #331) (M8) --- CHANGELOG.md | 18 ++ docs/guide/drawing.md | 7 +- docs/guide/symbols-and-library.md | 5 +- docs/guide/timeline.md | 18 +- docs/roadmap.md | 2 +- src/app.rs | 10 ++ src/brushtool.rs | 44 +++++ src/layer_ui_tests.rs | 270 ++++++++++++++++++++++++++++++ src/main.rs | 2 + src/panels.rs | 39 ++++- src/prefs.rs | 24 +++ src/timeline.rs | 236 +++++++++++++++++++++++++- 12 files changed, 663 insertions(+), 12 deletions(-) create mode 100644 src/layer_ui_tests.rs diff --git a/CHANGELOG.md b/CHANGELOG.md index bec44f83..ab6e4f7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,24 @@ ## Unreleased +* **Requests from the issue tracker: layers by drag, all-layer buttons, sizes and more** (M8). + * **Drag a layer to reorder it** (#407, and part of #241 and #331): drag a layer by its name; + a line shows where it lands, a folder lights up when the layer goes inside it, **Esc** + cancels. Folders, masks and guides move with everything in them, a drop is one undo step, + and the list scrolls when the drag nears its top or bottom. Headless: `layer.move {layer?, + before | after | into}`. The up and down buttons and menu items stay for the keyboard. + * **The eye, padlock and outline square above the layer names** show, lock or outline every + layer at once, as in Animate (#422); `all: true` (and `on`) on `layer.toggle_visible`, + `layer.toggle_lock` and `layer.toggle_outline`. The camera layer is left alone. + * **The line between the layer names and the frames drags** (#384), from 150 to 600 points; + double-click it to put it back. The width is kept in the preferences. + * **Symbol types are listed as Movie clip, Button, Graphic**, and Convert to Symbol offers a + movie clip the first time, as Animate does (#419). The `modify.convert_to_symbol` command's + own default is still a graphic, so scripts make what they made. + * **Size in Properties** (#294): the selection's width and height in stage pixels; a new + value stretches it from its top-left corner. + * **The Brush and the Paint Brush keep their settings between sessions** (#331): size, tip, + smoothing, pressure, taper and texture, each tool its own. * **Fixes and polish from outside contributors.** Thank you all. * **Shape tweens carry a raw shape's line with its fill** (#119, NetterSilver): when the two keyframes' lines have different numbers of pieces (a triangle into a hexagon), the pieces join into outlines that morph as the fill does, with no side left bare and no line left standing; a line on one keyframe only grows in or shrinks away, and shape hints steer the line too. * **Flipping no longer squashes a shape to 1 %** (#116, jayzed80): the Scale fields in Properties show a mirrored scale as a negative percentage and never rewrite a value they only show. diff --git a/docs/guide/drawing.md b/docs/guide/drawing.md index 5bb89fa8..92c09b58 100644 --- a/docs/guide/drawing.md +++ b/docs/guide/drawing.md @@ -159,6 +159,9 @@ stipple. Both are still ordinary vector shapes: they merge, erase, scale and exp other paint, and the same stroke always comes out the same. The **Charcoal** and **Spatter** brushes in the Brush menu use them. +The Brush and the Paint Brush keep their settings (size, tip, smoothing, pressure and the rest) +when you close AniCraft, each tool its own. + **Tilt.** Brushes can follow a pen's tilt: the tip turns with the way the pen leans (so a flat nib follows your hand), and paints wider as it leans, up to twice as wide lying flat. A mouse is never affected. Windows, macOS and Linux don't pass a pen's tilt on to AniCraft yet, so the @@ -346,7 +349,9 @@ changes everywhere it's used. With the **Free Transform** tool (**Q**), drag a corner or edge to **scale** (**Shift** keeps the proportions, **Alt** scales from the centre), just outside a corner to **rotate** (**Shift** snaps to 15°), or inside the box to **move**. You can also type exact -**Position**, **Scale** and **Rotation** values in Properties. +**Position**, **Size**, **Scale** and **Rotation** values in Properties. **Size** is the +width (**W**) and height (**H**) of the selection's box in stage pixels: a new value stretches +the artwork from the box's top-left corner, which stays where it is. | Command | Menu | Key | |---|---|---| diff --git a/docs/guide/symbols-and-library.md b/docs/guide/symbols-and-library.md index e86394c6..c2046cf5 100644 --- a/docs/guide/symbols-and-library.md +++ b/docs/guide/symbols-and-library.md @@ -35,8 +35,9 @@ To turn artwork into a symbol: 1. Select the artwork. It can be on several layers. 2. Choose **Modify › Convert to Symbol…** (**F8**), or click **Convert to Symbol** at the bottom of Properties. -3. Type a **Name**, choose a **Type** (Graphic, Movie clip or Button), and choose the Library - **Folder** it goes into. +3. Type a **Name**, choose a **Type** (Movie clip, Button or Graphic), and choose the Library + **Folder** it goes into. The first time, the type is Movie clip, as in Animate; after that + the dialog offers the type and folder you chose last. 4. Press **OK**. The artwork is replaced by an instance of the new symbol. If you selected artwork on several diff --git a/docs/guide/timeline.md b/docs/guide/timeline.md index a27ce791..44bae818 100644 --- a/docs/guide/timeline.md +++ b/docs/guide/timeline.md @@ -37,7 +37,9 @@ wheel. Layer**. It goes above the active layer. * **Delete a layer**: select it and click the delete button under the list, or choose **Modify › Timeline › Delete Layer**. Undo brings it back. -* **Reorder layers**: use the up and down buttons under the list, or **Modify › Timeline › Move +* **Reorder layers**: drag a layer by its name to where you want it. A line shows where it + will land; **Esc** cancels the drag. A folder, a mask or a guide moves with everything in it. + From the keyboard, use the up and down buttons under the list, or **Modify › Timeline › Move Layer Up** and **Move Layer Down**. * **Rename a layer**: double-click its name, or right-click it and choose **Rename Layer**. @@ -56,6 +58,15 @@ Each layer row has three toggles: Outlines are a working aid only. They show on the stage, but Test Movie and every export draw the artwork as it really is. +The eye, the padlock and the square **above the layer names** act on every layer at once, as in +Animate: one click hides, locks or outlines them all, and the next click brings them all back. +When only some layers are hidden (or locked, or outlined), the first click makes them all alike. +The camera layer is left alone. + +To give the frames more room, drag the line between the layer names and the frames to the left +(or to the right for long layer names). Double-click the line to put it back. AniCraft remembers +the width. + ### Layer colours Every layer has a colour, used for its outlines and its bar on the timeline. Click the thin @@ -83,8 +94,9 @@ Folders keep big timelines tidy. 1. Click the folder button under the layer list, or choose **Insert › Timeline › New Folder**. The folder appears above the active layer. -2. Select a layer and use the up and down buttons to move it in under the folder. Moving a layer - off either end of the folder takes it out again. +2. Drag a layer by its name onto the folder to put it inside, or between two layers of an open + folder. Drag it above or below a layer outside the folder to take it out again. (With the up + and down buttons: move a layer in under the folder, and off either end to take it out.) 3. Click the folder's chevron to open or close it. Hiding or locking a folder hides or locks everything inside it. Folders can nest, and a folder diff --git a/docs/roadmap.md b/docs/roadmap.md index d778bc1f..65cec9a0 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -14,7 +14,7 @@ This integration depends on craft-libs #1962 and still requires hosted parity va |---|---| | Architecture | M0 skeleton in place: geom → doc → render → engine → cli → shell, layering enforced by `cargo test` (`src/architecture_tests.rs`: lower layers only, no UI crates below the shell, and the AGENTS.md map must match). | | Rendering | CPU oracle with analytic AA, non-zero/even-odd, solid + linear/radial gradients (with reflect/repeat, focal points, elliptical radials and linear RGB, ADR 0074), round-join strokes. **Mask clipping**: the display list carries nested clips; a clip is the anti-aliased union of its mask fills (strokes and opacity ignored), intersected with any enclosing clip, computed once per render band; an empty mask hides everything under it. **Soft masks** (ADR 0070): a mask layer's mask type is Shape (coverage), Alpha (its artwork's opacity as drawn: gradients, faded shapes, strokes, bitmaps) or Luminance (brightness × opacity, SVG's coefficients), in the CPU oracle (analytic tests), the GPU stage (parity: mean 0.00006, worst 1 step of 255), SVG export (`` with `mask-type`), Lottie (alpha and luma track mattes) and the HTML canvas; Layer Properties › Mask type. **Group alpha**: a symbol instance below full opacity is a group in the display list; each render band composites the group's run of ops into its own buffer (nested groups stack) and blends it once at the group's alpha, so overlaps don't show through; SVG export writes ``. **Blend modes** (Animate's 14, on movie clip and button instances): an instance with one is an isolated group that blends at its close with the W3C separable formulas on premultiplied colour (Alpha and Erase keep or clear the backdrop); SVG gets CSS `mix-blend-mode`, Lottie the layer `bm`. **Bitmaps**: `Paint::Bitmap` fills (once or tiled) with bilinear sampling in premultiplied space, colour effects per sample; PNG/JPEG import to stage (a rectangle of the image's size); stored in the document as PNG (base64 in `.anicraft`), decoded once on first use; SVG export embeds each image once as a pattern. **Filters**: a filtered group is drawn on its own (by the same renderer, recursively, so nested filters work) into a buffer over its artwork grown by the filters' reach, filtered (box-blur passes; shadow and glow from the blurred, offset opacity; **bevel and gradient bevel** from the difference of the blurred opacity offset towards and away from the light, **gradient glow** from the glow's intensity, both through a colour ramp whose rest stop is pinned transparent, inner/outer/full and knockout, ADR 0025; colour matrix), and composited back as one image in its group, so alpha and blend apply; clips from inside the symbol apply before filtering and the instance's own clip after. Filters apply in list order and may be switched off (ADR 0091): `evaluate` leaves switched-off ones out, so every renderer and export draws them as absent. **GPU stage, first slice** (M3, ADR 0019; `--features gpu-stage`, off by default): Preferences › Stage › Renderer *GPU (preview)* draws the stage with wgpu compute from the oracle's own prepared fills (tile binning with per-row backdrops on the CPU, exact area coverage and src-over per pixel on the GPU): solid and gradient fills and strokes, non-zero and even-odd; masks, group opacity, blend modes, filters and bitmaps fall back to the CPU per tile, and the status bar says so. Parity with the oracle: max 1/255, mean < 0.0001/255 on the sample, stress and analytic scenes (tests skip without an adapter). 4K with 1,000 shapes: 8.8–9.0 ms vs the CPU's 17.4–17.8 ms. **Second slice** (ADR 0029): on the window's wgpu device the stage tiles are drawn straight into textures egui shows (no readback; a headless device with readback when the window is on OpenGL); **masks** (nested, united artwork), **group opacity** and **all 14 blend modes** on the GPU, same parity (max 1/255, mean ≤ 0.0011/255); 4K: 1,000 shapes in 2.1–2.4 ms, 10k shapes in 10.2 ms as stage tiles, masked scenes 7× the CPU. **Third slice** (ADR 0032): **bitmap fills** (textures uploaded once per image and cached under a 256 MB budget, sampled with the oracle's own bilinear filter, colour effect and repeat rules: byte-identical) and **all seven filters** (each filtered symbol drawn into a layer of its own and filtered by compute passes that run the oracle's resolved steps: max 1/255, mean ≤ 0.007/255) on the GPU; the shaders now build with Direct3D's FXC, so DX12 windows get the GPU stage too (parity suite green on Vulkan and DX12); software adapters are refused (the CPU is faster), the start-up self-test compares with the oracle. **The GPU is the default stage renderer**: the shell's `gpu-stage` feature is on by default, Preferences › Stage › Renderer defaults to *Graphics card (GPU)*, and the CPU draws whenever there is no usable card, a tile is past the GPU's limits (more than 16 images, filters nested deeper than 4) or anything fails. 4K: the filtered sample in 3.9 ms (CPU 31.5), 200 bitmap fills in 4.4 ms (CPU 37.2). **Fourth slice** (ADR 0048): **tile binning on the GPU** for heavy frames without masks or groups (count, prefix sum, scatter and tile-list passes, no atomics, no readback; the CPU binning stays the reference and does the rest; one tile format for both: an integer backdrop per tile and steps on the tiles' left edges): on Vulkan, 10k shapes at 4K in one texture 21.7 → 4.7 ms, 50k shapes 122 → 22.5 ms, the 50k-shape 4K stage 75 → 37 ms (Direct3D 12 keeps CPU binning: slower there in stage tiles); and **hairlines** for outline mode in both renderers (coverage by distance, one edge per segment): onion outlines on the 2,000-item stress scene as fast as tinted (GPU stage 73 → 10 ms, CPU stage 34–39 → 17 ms at 1080p). **Mid-session failures** (ADR 0092): a broken GPU stage hands the stage to the CPU at once with a status-bar notice and a log line, and is retried with a bounded backoff; driver errors on the window's device are logged instead of panicking (the #255 `Surface::configure` panic), and a lost window device autosaves and reopens the window on a safer way. Not yet: sharing a filtered layer across a frame's tiles, more than 16 images per tile, GPU binning inside masks and groups, flattening and stroking on the GPU, buffer reuse and fewer dispatches across tiles, hairlines for sub-pixel strokes, GPU exports, a GPU runner in CI; the CPU stays the oracle and the export path. | -| Timeline | **Frame selection**: click, Shift-click or drag across frames and layers; F5/Shift+F5, F6/F7 and Shift+F6 (keys, icon buttons and right-click menu) act on the whole selection; with no frame selection F5 extends every layer with frames at or after the playhead, and F5/F6/F7 move the playhead on as in Animate (F6/F7 on a keyframe key the next frame; `all_layers`/`advance` headless); drag selected keyframes left or right to move them, and up or down onto other layers (the source keeps empty frames) (with a drop outline; one undo step; keys they land on are replaced, and spans fill the frames left behind); removing or clearing selected frames that hold artwork asks first. **Cut/Copy/Paste Frames** (Ctrl+Alt+X/C/V, and plain Ctrl+X/C/V after clicking the timeline): own clipboard, copies cut exactly at the selection edges (mid-tween state kept), paste inserts like Animate, several layers paste onto the layers below (missing ones are created), fresh element ids, symbols travel with them. **Span length by dragging its end** (resize cursor, live outline with the length in frames and seconds; later frames move with it; a motion tween's keys stretch in proportion, ADR 0083). Side dock tab strips never run under the panel menu (names shrink with an ellipsis, then the strip scrolls). Headless: `layers`/`count` on the frame commands, `timeline.move_keyframes`, `timeline.cut_frames/copy_frames/paste_frames`. Layers (show/lock/outline), **timeline polish** (ADR 0061): a per-layer **onion skin toggle** column (Alt-click solos; left-out layers aren't onion-skinned; Edit Multiple Frames unaffected), the colour square toggles **View as Outlines** in the layer colour **on the stage only** (exports, Test Movie and the player draw the artwork as it is), the **colour chip** opens the layer colour (swatches, hex, More…), **onion frames of the parent timeline** dimmed around a symbol edited in place, **Layer Height** 100/200/300 %, **Layer Properties** (double-click the layer icon; name, show/lock, type, outline colour, outlines, onion, height; one undo step), **Frame View** (Tiny/Small/Normal/Medium/Large, Short rows) with the frame zoom in the timeline's bottom bar (the header fits at the default window size, tested); headless `layer.set_onion/set_color/set_height/set_properties/properties`; XFL `heightMultiplier`. Not yet: folder onion toggles, onion of deeper parent timelines, multi-layer Layer Properties and layer transparency, frame thumbnails (Preview). Keyframes, blank keyframes, insert/remove frames, classic tweens with **ease presets and custom eases** (ADR 0081: Classic Ease with a strength and Quad, Cubic, Quart, Quint, Sine, Back, Circ, Bounce and Elastic In/Out/In Out; custom eases of up to 64 Bézier points in the Custom Ease window, x kept monotonic, overshoot allowed, keyboard operable, **shape tweens** (morph between any two shapes: segments made cubic, subpaths paired by size and grown from or shrunk to a point when counts differ, segment counts equalized by subdivision, windings matched and start points aligned; amber spans; classic ⇄ shape keeps the easing; **shape hints** (ADR 0023): Modify › Shape › Add Shape Hint (Ctrl+Shift+H) adds lettered markers `a`–`z` that the artist drags onto an edge on the first and last keyframe (rose until placed, amber placed on the first, mint on the last; right-click removes), the morph cuts both outlines at the hinted points and matches the pieces in order by length; `tween.add_hint/move_hint/remove_hint/clear_hints/hints`; not yet: View › Show Shape Hints, hints inside symbols edited in place), auto-key when editing inside a tween, frame labels, symbol nesting: graphics keep step with their timeline (loop, play once, single frame, first frame; set in Properties), movie clips loop their own timeline from when the instance appears (continuous across keyframes holding the same instance), buttons show their Up frame, looping playback. **Onion skin and Edit Multiple Frames** (ADR 0047): onion markers on the frame ruler (drag the start and end brackets; Always Show Markers, Anchor Markers, Onion 2 / Onion 5 / Onion All, also on a right-click on the ruler), frames before and after the playhead tinted in their own colours (theme blue and green, changeable in the onion menu, Reset) and fading with distance, Outlines, Keyframes Only, locked layers left out as in Animate, each layer's onion frames under its own artwork and over the layers below; options saved in the preferences; the stage's frame cache keys every look apart. **Edit Multiple Frames** shows every keyframe within the markers at full strength and selects (click, Shift-click, marquee, Select All) and moves (drag, arrow keys) artwork across them, one undo step, motion tween paths moving with their objects. Headless: `frames.artwork`, `frames.edit_multiple`. **Edit Multiple Frames, complete** (ADR 0051): Cut, Copy, Paste (current frame), Paste in Place (back keyframe by keyframe, or a one-frame copy onto every keyframe between the markers), Clear, Align (Ctrl+Alt+1…6, To Stage), Rotate 90° and Flip, and **Free Transform** of the selection on every keyframe about one shared pivot (one box, one undo step per drag); raw shapes moved, transformed or pasted merge again on their own keyframe; **onion skin and Edit Multiple Frames inside a symbol edited in place**, on its own timeline and markers. Headless: `frames.transform`, `frames.align`, `frames.delete`, `frames.copy`, `frames.cut`, `frames.paste`, `frames.merge`, `merge` on `frames.edit_multiple`. Not yet: Duplicate/Distribute/Arrange and recolouring across keyframes, scaling a motion tween's object on several frames, a draggable pivot. **Mask layers**: right-click a layer › Mask turns it into a mask over the layer below (Masked adds more layers to it); masked layers are indented under a stencil icon; the mask applies on the stage and in every export alike, and while the mask layer is unlocked its edge shows in the layer colour so it can be picked and reshaped; masked-away parts cannot be picked; layers moved in under a mask join it, moved out leave it, and a mask moves with its whole group; masks inside symbols nest. Headless: `layer.toggle_mask`, `layer.set_type`. **Scenes** (ADR 0011): the movie is an ordered list of scenes, each its own timeline, edited one at a time (scene menu on the edit bar, Insert › Scene, Modify › Scene, Shift+PageUp/PageDown); add, duplicate (fresh ids), rename, reorder and remove (asks when the scene has artwork; undoable); PNG-sequence and GIF exports play every scene in order. **Layer folders**: nestable folders (depth ≤ 16) holding layers and masks through `Layer.parent`, one invariant (`Timeline::repair_masks`: a child sits below its parent inside the parent's unbroken run; broken links fall back to the nearest valid ancestor); hiding or locking a folder hides or locks its contents (rendering, picking, drawing); folders open and close on the timeline (view state); layers move in and out with Up/Down, a folder moves with its contents; deleting a folder deletes its contents (asks first). **Motion tweens** (ADR 0016): a span's object animated property by property (x, y, scale, colour, filters, and instance filters tween; XFL custom and per-property eases import exactly; `ease.*` headless) + curve preview, rotation, skew, alpha, tint), each property its own curve of property keyframes with a per-segment ease (any preset, saved ease or custom ease of several segments, ADR 0081; overshoot allowed); auto-key turns any edit of the object inside the span into property keys (every command, through the session), F6 keys every property, splits and copies keep the motion; sky-blue spans with property-key diamonds; **Motion Editor** tab beside the timeline: property list with values at the playhead, curve graph with draggable keys and Bézier handles, one undo step per drag. **Retiming** (ADR 0083): keys drag sideways in time (snapped to frames, never past a neighbour), Shift-click picks keys across properties, an All lane picks a frame's keys, Left/Right move picked keys with the curve focused; dragging a span's end stretches a motion tween's keys in proportion (Shift keeps them); a click picks a whole motion span and dragging (or a selection of whole tween spans) moves it at its length, Alt-drag copies; **Split Motion** / **Join Motion** (split then join is exact). Headless: `motion.move_keys`, `timeline.resize_span`, `timeline.move_spans`, `motion.split`, `motion.join`. Not yet: joining two independent motion paths, retiming from a span's left edge. **Motion paths** (ADR 0030): a motion tween may carry a cubic path its object travels by arc length, timed by the X/Y curves (a straight path reproduces them exactly, overshoot included); shown on the stage in the motion colour with a dot per frame when the object or span is selected; Selection drags the path to bend it and its ends to move them, Subselection drags anchors and handles; moving the object reshapes the path; Orient to path and Straighten in Properties; splits cut the path. **Path points** (ADR 0038): with Subselection, double-click the path to add a point (shape and motion unchanged), Shift-click to select several anchors, Delete to remove them (the path refits through the rest; the ends stay), right-click for smooth/corner and Straighten; the Pen's Alt-click adds a point to a motion path or a selected shape; Ctrl-drag (⌘-drag) the path or its object, or edit Properties › Path start, to move the whole path with its timing exact. **Anchors pinned to frames** (ADR 0049): moving the object at a frame pins a path point there (a new anchor where it was put; after the last position key the path carries on), and the object passes every pinned point exactly on its frame, the X/Y eases timing it between pins; pinned points are diamonds with their frame number on the stage, blue keys in the Motion Editor's X/Y (dragging one moves its point) and holed diamonds on the timeline; Subselection's right-click pins to the playhead's frame or unpins, Properties › Frame has Pin Here / Unpin, F6 pins where the object is; point edits keep pins on their anchors; files without pins evaluate exactly as before. Headless: `timeline.create_motion_tween`, `motion.*` (`motion.set_path/clear_path/orient/add_point/delete_points/convert_point/move_path/pin_point/unpin_point`; `motion.info` reports `pins`). Not yet: retiming a pin by dragging its key in time, two pins on one anchor, XFL motion path keyframes, a marquee over path anchors, nudging or transforming a whole path, retiming keys, rescaling keys with the span, XFL motion-tween import. **Bones and IK, first slice** (ADR 0043): the Bone tool (M) drags from one symbol instance to another to join them with a bone on an armature layer (chains join end to start: a bone from a chained instance always starts at its joint; branches allowed, up to 256 bones); bones show as wedges in the layer colour; the Selection tool drags a bone (the grabbed point follows) or a posed instance to pose by cyclic coordinate descent (joint limits, pinned bones, one undo step per drag) and the root to move it all; poses are joint angles keyed per frame and tweened with the span's easing; Properties › Bone (angle, constrain min/max, pin, remove); `bone.*` headless; every export sees the pose. **Shape armatures** (ADR 0071): the Bone tool draws bones inside a shape (it moves to an armature layer as an object, outside merge drawing); its points are bound to the nearest bones automatically (weights by distance to each bone, up to four, summing to 1) and bend by linear blend skinning (handles with their anchors, strokes keep their width, the rest pose exact); the **Bind tool** (Shift+M) shows the points (squares, triangles where shared) and binds them by click, Shift/Ctrl-click or box; the same IK, poses and tweens; `bone.add_in_shape`, `bone.bind`, `bone.info {points}`. **Painted weights and reshaping** (ADR 0090): the Bind tool's **Paint Weights** brush (Add, Subtract, Smooth; size with `[`/`]`, strength; soft falloff) paints a bone's share onto the points under it, shown live as a heat map (blue none to red all) on the outline and points; weights stay normalised per point (the other bones share the rest, a point's only bone gives way to its nearest other bones), painted points are hand-bound, one undo step per stroke (1.15 ms for 32 dabs over 20,000 points); a focused point's weights as numbers in Properties › Bone (keyboard); Subselection edits a bound shape's outline at the rest pose (move, add, delete, smooth/corner) keeping the binding: moved points keep their weights, new points blend their neighbours', deleted points drop theirs, the rest pose exact; `bone.paint_weights`, `bone.set_weight`. **Springs, joint translation and members in place** (ADR 0084): joints slide along X/Y of what they start on, freely or within pixel limits, as part of each pose (IK slides only where turning can't reach); per-bone Spring and Damping swing bones after the motion and settle, evaluated as a pure replay of up to six seconds of motion (seeking equals playing bit for bit; 0.33 ms a frame for 16 sprung bones), shown on the stage, in Test Movie and every export, switched off per armature for posing; a picked bone's instance takes colour effect, blending and filters in place on every pose; `bone.set_translation`, `bone.set_spring`, `bone.enable_springs`. Not yet: runtime armatures, XFL import, mixing instances and shapes in one armature (proposed in ADR 0084 and 0090), reshaping at a posed frame, gravity and wind. **Asset Warp** (ADR 0079): the **Asset Warp tool** (Shift+Q) pins a shape or a bitmap (the first pin covers it with a warp mesh: a grid over its bounds, 2–48 cells along the longer side, Properties › Asset Warp); dragging a pin bends the artwork around the other pins by rigid moving least squares (Schaefer et al. 2006) at the mesh's vertices, live, one undo step per drag; Delete removes a pin; pins are added to every keyframe holding the artwork and their poses tween with classic tweens and easing; shapes bend through the mesh (straight edges exactly, curves split), bitmaps are drawn through its triangles by the CPU oracle (bilinear) and the GPU stage takes the same prepared fill (parity exact); the rest pose is the drawing bit for bit; every raster export, SVG (a bent bitmap baked as an image), Lottie and HTML (a bent bitmap reported) go through `evaluate`; `warp.add`, `warp.pin_add`, `warp.pin_move`, `warp.pin_remove`, `warp.remove`, `warp.info`. Not yet: as-rigid-as-possible solving on a mesh that follows the outline, symbols and text, binding warp pins to bones, a GPU textured-triangle path, bent bitmaps in HTML and Lottie, XFL import of warped assets. eases saved in the document and offered everywhere; copy/paste of an ease; classic tweens eased per property group: position, **Camera layer** (ADR 0027): the camera button in the timeline header or the Camera tool (C) adds a Camera layer on top; its frame shows on the stage in orange; drag to pan, turn with the round handle, wheel to zoom (one undo step per drag); Properties › Camera (position, zoom, rotation, tint, reset); keyframes and classic or motion tweens animate it; layer Depth gives pan parallax; View › Preview Through Camera shows the movie's picture (artwork tools pause there); hiding the camera layer turns it off; every export, Test Movie and the GPU stage see it. Headless: `camera.add/remove/set/info`, `layer.set_depth`. **Camera, second slice** (ADR 0082): layer depth in a pinhole perspective (deeper layers move and zoom less, draw behind nearer ones; depth 0 bit-exact), depth keyed over time (linear between keys), **Window › Layer Depth** (layers by depth, drag nearer or farther, key, attach), **Attach Layer to Camera** (timeline toggle; HUDs stay on screen), camera colour effects (Brightness, Tint, Advanced), and the Selection tool picking and moving artwork while previewing through the camera; headless `layer.set_depth {key, frame}`, `layer.remove_depth_key`, `layer.set_attached`, `layer.depths`, `element.pick {view: camera}`. Not yet: other tools while previewing, depth inside symbols, depth keys moving with inserted frames, XFL camera and layer-depth import (no public format description). **Motion guides**: guided layers (children of a guide through `Layer.parent`) have their classic tweens follow the guide's first path by arc length, from the point nearest each start keyframe to the point nearest its end (`geom::walk::PathWalk`), optionally orienting to the path; guide artwork is listed for picking and editing, drawn on the stage as a line, and never rendered or exported. | +| Timeline | **Frame selection**: click, Shift-click or drag across frames and layers; F5/Shift+F5, F6/F7 and Shift+F6 (keys, icon buttons and right-click menu) act on the whole selection; with no frame selection F5 extends every layer with frames at or after the playhead, and F5/F6/F7 move the playhead on as in Animate (F6/F7 on a keyframe key the next frame; `all_layers`/`advance` headless); drag selected keyframes left or right to move them, and up or down onto other layers (the source keeps empty frames) (with a drop outline; one undo step; keys they land on are replaced, and spans fill the frames left behind); removing or clearing selected frames that hold artwork asks first. **Cut/Copy/Paste Frames** (Ctrl+Alt+X/C/V, and plain Ctrl+X/C/V after clicking the timeline): own clipboard, copies cut exactly at the selection edges (mid-tween state kept), paste inserts like Animate, several layers paste onto the layers below (missing ones are created), fresh element ids, symbols travel with them. **Span length by dragging its end** (resize cursor, live outline with the length in frames and seconds; later frames move with it; a motion tween's keys stretch in proportion, ADR 0083). Side dock tab strips never run under the panel menu (names shrink with an ellipsis, then the strip scrolls). Headless: `layers`/`count` on the frame commands, `timeline.move_keyframes`, `timeline.cut_frames/copy_frames/paste_frames`. Layers (show/lock/outline), **timeline polish** (ADR 0061): a per-layer **onion skin toggle** column (Alt-click solos; left-out layers aren't onion-skinned; Edit Multiple Frames unaffected), the colour square toggles **View as Outlines** in the layer colour **on the stage only** (exports, Test Movie and the player draw the artwork as it is), the **colour chip** opens the layer colour (swatches, hex, More…), **onion frames of the parent timeline** dimmed around a symbol edited in place, **Layer Height** 100/200/300 %, **Layer Properties** (double-click the layer icon; name, show/lock, type, outline colour, outlines, onion, height; one undo step), **Frame View** (Tiny/Small/Normal/Medium/Large, Short rows) with the frame zoom in the timeline's bottom bar (the header fits at the default window size, tested); headless `layer.set_onion/set_color/set_height/set_properties/properties`; XFL `heightMultiplier`. Not yet: folder onion toggles, onion of deeper parent timelines, multi-layer Layer Properties and layer transparency, frame thumbnails (Preview). **Layers by drag and all at once** (M8, from the issue tracker): drag a layer by its name to reorder it or drop it on a folder (a line shows where it lands; folders, masks and guides move whole; one undo step; `layer.move {before | after | into}`), the eye, padlock and outline square above the layer names act on every layer (`all` on the three toggles), and the line between the layer names and the frames drags (150–600 pt, kept in the preferences). Not yet: several selected layers dragged together, dragging a layer onto another scene. Keyframes, blank keyframes, insert/remove frames, classic tweens with **ease presets and custom eases** (ADR 0081: Classic Ease with a strength and Quad, Cubic, Quart, Quint, Sine, Back, Circ, Bounce and Elastic In/Out/In Out; custom eases of up to 64 Bézier points in the Custom Ease window, x kept monotonic, overshoot allowed, keyboard operable, **shape tweens** (morph between any two shapes: segments made cubic, subpaths paired by size and grown from or shrunk to a point when counts differ, segment counts equalized by subdivision, windings matched and start points aligned; amber spans; classic ⇄ shape keeps the easing; **shape hints** (ADR 0023): Modify › Shape › Add Shape Hint (Ctrl+Shift+H) adds lettered markers `a`–`z` that the artist drags onto an edge on the first and last keyframe (rose until placed, amber placed on the first, mint on the last; right-click removes), the morph cuts both outlines at the hinted points and matches the pieces in order by length; `tween.add_hint/move_hint/remove_hint/clear_hints/hints`; not yet: View › Show Shape Hints, hints inside symbols edited in place), auto-key when editing inside a tween, frame labels, symbol nesting: graphics keep step with their timeline (loop, play once, single frame, first frame; set in Properties), movie clips loop their own timeline from when the instance appears (continuous across keyframes holding the same instance), buttons show their Up frame, looping playback. **Onion skin and Edit Multiple Frames** (ADR 0047): onion markers on the frame ruler (drag the start and end brackets; Always Show Markers, Anchor Markers, Onion 2 / Onion 5 / Onion All, also on a right-click on the ruler), frames before and after the playhead tinted in their own colours (theme blue and green, changeable in the onion menu, Reset) and fading with distance, Outlines, Keyframes Only, locked layers left out as in Animate, each layer's onion frames under its own artwork and over the layers below; options saved in the preferences; the stage's frame cache keys every look apart. **Edit Multiple Frames** shows every keyframe within the markers at full strength and selects (click, Shift-click, marquee, Select All) and moves (drag, arrow keys) artwork across them, one undo step, motion tween paths moving with their objects. Headless: `frames.artwork`, `frames.edit_multiple`. **Edit Multiple Frames, complete** (ADR 0051): Cut, Copy, Paste (current frame), Paste in Place (back keyframe by keyframe, or a one-frame copy onto every keyframe between the markers), Clear, Align (Ctrl+Alt+1…6, To Stage), Rotate 90° and Flip, and **Free Transform** of the selection on every keyframe about one shared pivot (one box, one undo step per drag); raw shapes moved, transformed or pasted merge again on their own keyframe; **onion skin and Edit Multiple Frames inside a symbol edited in place**, on its own timeline and markers. Headless: `frames.transform`, `frames.align`, `frames.delete`, `frames.copy`, `frames.cut`, `frames.paste`, `frames.merge`, `merge` on `frames.edit_multiple`. Not yet: Duplicate/Distribute/Arrange and recolouring across keyframes, scaling a motion tween's object on several frames, a draggable pivot. **Mask layers**: right-click a layer › Mask turns it into a mask over the layer below (Masked adds more layers to it); masked layers are indented under a stencil icon; the mask applies on the stage and in every export alike, and while the mask layer is unlocked its edge shows in the layer colour so it can be picked and reshaped; masked-away parts cannot be picked; layers moved in under a mask join it, moved out leave it, and a mask moves with its whole group; masks inside symbols nest. Headless: `layer.toggle_mask`, `layer.set_type`. **Scenes** (ADR 0011): the movie is an ordered list of scenes, each its own timeline, edited one at a time (scene menu on the edit bar, Insert › Scene, Modify › Scene, Shift+PageUp/PageDown); add, duplicate (fresh ids), rename, reorder and remove (asks when the scene has artwork; undoable); PNG-sequence and GIF exports play every scene in order. **Layer folders**: nestable folders (depth ≤ 16) holding layers and masks through `Layer.parent`, one invariant (`Timeline::repair_masks`: a child sits below its parent inside the parent's unbroken run; broken links fall back to the nearest valid ancestor); hiding or locking a folder hides or locks its contents (rendering, picking, drawing); folders open and close on the timeline (view state); layers move in and out with Up/Down, a folder moves with its contents; deleting a folder deletes its contents (asks first). **Motion tweens** (ADR 0016): a span's object animated property by property (x, y, scale, colour, filters, and instance filters tween; XFL custom and per-property eases import exactly; `ease.*` headless) + curve preview, rotation, skew, alpha, tint), each property its own curve of property keyframes with a per-segment ease (any preset, saved ease or custom ease of several segments, ADR 0081; overshoot allowed); auto-key turns any edit of the object inside the span into property keys (every command, through the session), F6 keys every property, splits and copies keep the motion; sky-blue spans with property-key diamonds; **Motion Editor** tab beside the timeline: property list with values at the playhead, curve graph with draggable keys and Bézier handles, one undo step per drag. **Retiming** (ADR 0083): keys drag sideways in time (snapped to frames, never past a neighbour), Shift-click picks keys across properties, an All lane picks a frame's keys, Left/Right move picked keys with the curve focused; dragging a span's end stretches a motion tween's keys in proportion (Shift keeps them); a click picks a whole motion span and dragging (or a selection of whole tween spans) moves it at its length, Alt-drag copies; **Split Motion** / **Join Motion** (split then join is exact). Headless: `motion.move_keys`, `timeline.resize_span`, `timeline.move_spans`, `motion.split`, `motion.join`. Not yet: joining two independent motion paths, retiming from a span's left edge. **Motion paths** (ADR 0030): a motion tween may carry a cubic path its object travels by arc length, timed by the X/Y curves (a straight path reproduces them exactly, overshoot included); shown on the stage in the motion colour with a dot per frame when the object or span is selected; Selection drags the path to bend it and its ends to move them, Subselection drags anchors and handles; moving the object reshapes the path; Orient to path and Straighten in Properties; splits cut the path. **Path points** (ADR 0038): with Subselection, double-click the path to add a point (shape and motion unchanged), Shift-click to select several anchors, Delete to remove them (the path refits through the rest; the ends stay), right-click for smooth/corner and Straighten; the Pen's Alt-click adds a point to a motion path or a selected shape; Ctrl-drag (⌘-drag) the path or its object, or edit Properties › Path start, to move the whole path with its timing exact. **Anchors pinned to frames** (ADR 0049): moving the object at a frame pins a path point there (a new anchor where it was put; after the last position key the path carries on), and the object passes every pinned point exactly on its frame, the X/Y eases timing it between pins; pinned points are diamonds with their frame number on the stage, blue keys in the Motion Editor's X/Y (dragging one moves its point) and holed diamonds on the timeline; Subselection's right-click pins to the playhead's frame or unpins, Properties › Frame has Pin Here / Unpin, F6 pins where the object is; point edits keep pins on their anchors; files without pins evaluate exactly as before. Headless: `timeline.create_motion_tween`, `motion.*` (`motion.set_path/clear_path/orient/add_point/delete_points/convert_point/move_path/pin_point/unpin_point`; `motion.info` reports `pins`). Not yet: retiming a pin by dragging its key in time, two pins on one anchor, XFL motion path keyframes, a marquee over path anchors, nudging or transforming a whole path, retiming keys, rescaling keys with the span, XFL motion-tween import. **Bones and IK, first slice** (ADR 0043): the Bone tool (M) drags from one symbol instance to another to join them with a bone on an armature layer (chains join end to start: a bone from a chained instance always starts at its joint; branches allowed, up to 256 bones); bones show as wedges in the layer colour; the Selection tool drags a bone (the grabbed point follows) or a posed instance to pose by cyclic coordinate descent (joint limits, pinned bones, one undo step per drag) and the root to move it all; poses are joint angles keyed per frame and tweened with the span's easing; Properties › Bone (angle, constrain min/max, pin, remove); `bone.*` headless; every export sees the pose. **Shape armatures** (ADR 0071): the Bone tool draws bones inside a shape (it moves to an armature layer as an object, outside merge drawing); its points are bound to the nearest bones automatically (weights by distance to each bone, up to four, summing to 1) and bend by linear blend skinning (handles with their anchors, strokes keep their width, the rest pose exact); the **Bind tool** (Shift+M) shows the points (squares, triangles where shared) and binds them by click, Shift/Ctrl-click or box; the same IK, poses and tweens; `bone.add_in_shape`, `bone.bind`, `bone.info {points}`. **Painted weights and reshaping** (ADR 0090): the Bind tool's **Paint Weights** brush (Add, Subtract, Smooth; size with `[`/`]`, strength; soft falloff) paints a bone's share onto the points under it, shown live as a heat map (blue none to red all) on the outline and points; weights stay normalised per point (the other bones share the rest, a point's only bone gives way to its nearest other bones), painted points are hand-bound, one undo step per stroke (1.15 ms for 32 dabs over 20,000 points); a focused point's weights as numbers in Properties › Bone (keyboard); Subselection edits a bound shape's outline at the rest pose (move, add, delete, smooth/corner) keeping the binding: moved points keep their weights, new points blend their neighbours', deleted points drop theirs, the rest pose exact; `bone.paint_weights`, `bone.set_weight`. **Springs, joint translation and members in place** (ADR 0084): joints slide along X/Y of what they start on, freely or within pixel limits, as part of each pose (IK slides only where turning can't reach); per-bone Spring and Damping swing bones after the motion and settle, evaluated as a pure replay of up to six seconds of motion (seeking equals playing bit for bit; 0.33 ms a frame for 16 sprung bones), shown on the stage, in Test Movie and every export, switched off per armature for posing; a picked bone's instance takes colour effect, blending and filters in place on every pose; `bone.set_translation`, `bone.set_spring`, `bone.enable_springs`. Not yet: runtime armatures, XFL import, mixing instances and shapes in one armature (proposed in ADR 0084 and 0090), reshaping at a posed frame, gravity and wind. **Asset Warp** (ADR 0079): the **Asset Warp tool** (Shift+Q) pins a shape or a bitmap (the first pin covers it with a warp mesh: a grid over its bounds, 2–48 cells along the longer side, Properties › Asset Warp); dragging a pin bends the artwork around the other pins by rigid moving least squares (Schaefer et al. 2006) at the mesh's vertices, live, one undo step per drag; Delete removes a pin; pins are added to every keyframe holding the artwork and their poses tween with classic tweens and easing; shapes bend through the mesh (straight edges exactly, curves split), bitmaps are drawn through its triangles by the CPU oracle (bilinear) and the GPU stage takes the same prepared fill (parity exact); the rest pose is the drawing bit for bit; every raster export, SVG (a bent bitmap baked as an image), Lottie and HTML (a bent bitmap reported) go through `evaluate`; `warp.add`, `warp.pin_add`, `warp.pin_move`, `warp.pin_remove`, `warp.remove`, `warp.info`. Not yet: as-rigid-as-possible solving on a mesh that follows the outline, symbols and text, binding warp pins to bones, a GPU textured-triangle path, bent bitmaps in HTML and Lottie, XFL import of warped assets. eases saved in the document and offered everywhere; copy/paste of an ease; classic tweens eased per property group: position, **Camera layer** (ADR 0027): the camera button in the timeline header or the Camera tool (C) adds a Camera layer on top; its frame shows on the stage in orange; drag to pan, turn with the round handle, wheel to zoom (one undo step per drag); Properties › Camera (position, zoom, rotation, tint, reset); keyframes and classic or motion tweens animate it; layer Depth gives pan parallax; View › Preview Through Camera shows the movie's picture (artwork tools pause there); hiding the camera layer turns it off; every export, Test Movie and the GPU stage see it. Headless: `camera.add/remove/set/info`, `layer.set_depth`. **Camera, second slice** (ADR 0082): layer depth in a pinhole perspective (deeper layers move and zoom less, draw behind nearer ones; depth 0 bit-exact), depth keyed over time (linear between keys), **Window › Layer Depth** (layers by depth, drag nearer or farther, key, attach), **Attach Layer to Camera** (timeline toggle; HUDs stay on screen), camera colour effects (Brightness, Tint, Advanced), and the Selection tool picking and moving artwork while previewing through the camera; headless `layer.set_depth {key, frame}`, `layer.remove_depth_key`, `layer.set_attached`, `layer.depths`, `element.pick {view: camera}`. Not yet: other tools while previewing, depth inside symbols, depth keys moving with inserted frames, XFL camera and layer-depth import (no public format description). **Motion guides**: guided layers (children of a guide through `Layer.parent`) have their classic tweens follow the guide's first path by arc length, from the point nearest each start keyframe to the point nearest its end (`geom::walk::PathWalk`), optionally orienting to the path; guide artwork is listed for picking and editing, drawn on the stage as a line, and never rendered or exported. | | Drawing | Selection (click, shift-add, marquee, drag-move, arrow nudge; **across layers**, ADR 0044: a selection holds artwork on several visible, unlocked layers, the timeline marks them, Properties shows mixed values), **Free Transform (Q)**: scale from corner/edge handles (Shift proportional, Alt from centre), rotate outside corners (Shift snaps 15°), move; one undo step per drag. Rectangle (corner radius), oval, PolyStar, line (45° snap), hand, zoom. **Pen (P)**: click for corners, drag for smooth handles (Alt breaks them), close on the first point, Enter/Esc/last-point click finishes, Backspace takes back a point; one undo step per path. **Pencil (Shift+Y)**: Smooth (Schneider curve fitting with corner detection), Straighten and Ink modes, smoothing relative to the screen. **Subselection (A)**: anchors and handles on selected shapes, drag points/handles (anchors bring their handles; one undo step per drag), point marquee, double-click an edge to add a point, Delete removes points, right-click Make Smooth/Corner; closed shapes' start point and closing edge edit like any other. **Cut/Copy/Paste in Center/Paste in Place** (the clipboard carries symbols across documents). **Rotate 90° CW/CCW, Flip H/V. Align** left/centre/right/top/middle/bottom (Ctrl+Alt+1…6; a single element aligns to the stage) and distribute. Convert to symbol / break apart; arrange; duplicate. Headless: `draw.path`, `draw.freehand`, `path.move_points/add_point/delete_points/convert_point`. **Paint Bucket (K)**: click a fill to recolour it, or inside an outline (one shape or several) to fill the enclosed area; gap size None/Small/Medium/Large closes openings; the fill is traced and curve-fitted into a new shape placed under its lines; open areas say so instead of flooding. **Ink Bottle (S)**: gives the clicked shape the current stroke. Headless: `paint.bucket`, `paint.ink`. Tool options show first in Properties while a drawing tool is active. **Text (T)** (ADR 0012): click to type on the stage, click or double-click text to edit it; font (installed families, plus the embedded Inter), size, colour, under or over the artwork, snap accuracy up to Always); Snap to Pixels; one snap engine for every drawing tool, the Selection tool's moves and Free Transform's handles (point › guide › line › grid › pixel, guides and grid per axis); stage only, never exported, on the CPU and GPU stage. Headless: `view.rulers`, `view.grid_show/grid_snap/grid_set`, `view.guides_show/guides_lock/guides_snap/guides_set`, `view.guide_add/guide_move/guide_delete/guides_clear`, `view.snap_pixels`, `view.aids`, `moving` on `draw.snap`. *Not yet:* units other than px, a movable ruler origin, a symbol's own guides, guides and grid from Animate files, Snap Align and Edit Snapping, snapping while rotating. bold, italic, alignment, letter/line spacing, wrap width; the last style is kept for new text; laid out by `anicraft-text` (`fontdb` discovery, `harfrust` shaping, `skrifa` outlines) and stored as outlines with the source, so rendering never needs the font; Break Apart makes a shape. **Variable-width strokes** (ADR 0018): a stroke's width varies along it through width points (position by arc length, a width on each side as a factor of the stroke width, smooth monotone interpolation); built-in profiles (Uniform, Taper both ends, Taper start, Taper end, Bulge, Pinch) in Properties › Width with a picture of each, and in the drawing tools' options for new strokes; the **Width tool (U)**: hover a stroke to see its width points, drag a handle to widen or narrow (Alt: one side), drag the dot to slide a point, drag anywhere on the stroke to add one, Delete removes; one undo step per drag; rendered by the oracle as trapezoids with outer round joins and cross-section caps, written by SVG and Lottie export as the same filled outlines; shape tweens blend profiles; `.anicraft` keeps them (older files open as uniform). Headless: `stroke.set_profile`, `stroke.set_width_point`, `stroke.delete_width_point`, `stroke.width_at`, `profile` on `element.set_stroke`, the drawing commands and `paint.ink`. Not yet: width data from or to Animate files, saved custom profiles, pressure. **Stroke styles** (ADR 0046): Properties › Style (Solid, Dashed with dash and gap, Dotted with spacing), Cap (None, Round, Square), Join (Miter, Round, Bevel) and Miter limit, also in the drawing tools' options for new strokes; drawn exactly by the oracle (butt and square caps, miters bevelled past the limit, dashes by arc length restarting per subpath, round dots, dashes keeping a width profile's widths; sub-pixel patterns solid and faded) and so by the GPU stage; the Ink Bottle carries the style and the Eyedropper picks it; merge drawing keeps it on cut pieces; shape tweens blend miter limits and dash lengths; SVG, HTML canvas and Lottie export write it. Headless: `stroke.set_style`, and `cap`, `join`, `miter`, `style`, `dash`, `dash_offset`, `dot_spacing` on `element.set_stroke`, the drawing commands and `paint.ink`. Not yet: Animate's ragged, stipple and hatched styles, multi-dash patterns in Properties (kept and editable by command), stroke scale modes and hairlines. **Merge drawing** (ADR 0031, first slice): with Object Drawing (J) off, the editor's default, the shape tools, Pen and Pencil draw raw strokes and fills that cut and join the raw shapes they touch (a fill on top replaces what it covers or joins the same colour, lines cut each other and the fills they cross, a fill hides the lines under it, points within 0.2 px are one; exact Bézier pieces, `anicraft_geom::planar`); one element per fill region and stroke run, selected with Animate's dot pattern; double-click selects connected strokes, or a fill with its outline; a dragged or nudged raw shape merges where it lands; arrows move 1 screen pixel (Shift 10). Headless: `object` on the drawing commands (scripts draw objects by default), `draw.object_drawing`, `draw.drop`, `element.select_connected`. **Selection tool on raw shapes** (ADR 0041): drag an unselected segment or fill edge to bend it through the pointer (every shape sharing the edge bends with it), an unselected corner or end to move it with every raw shape that shares it, a fill to move only that fill; points and selections snap to points, strokes and fill edges within 10 screen px (snap ring), and arrow nudges join ends within 0.2 px at their midpoint or onto a line that stays put; a corner or curve mark by the pointer shows what a drag does; the marquee selects the parts of raw fills and strokes under it, cut at its edges (taken back if nothing uses them, no undo step), and objects wholly inside; each drag one undo step, merged on release. Headless: `path.bend_segment`, `raw.move_point`, `raw.select_rect`, `raw.merge`, `raw.hit`, `snap` on `element.translate`. **Subselection on raw shapes and merging everywhere** (ADR 0042): with Subselection (A), a click on a raw line or fill shows the anchors of everything connected to it (once per shared point; hollow, selected ones solid) and the handles of the selected anchors' curves and of the clicked edge; drag an anchor to move it with the other selected ones and every shape on them, a handle to change the curve in every shape that has the edge, a line or fill to move everything connected; Shift adds or removes anchors; the marquee takes whole shapes on the active layer and selects the anchors inside; arrows nudge 1 screen px (Shift 10); one undo step per gesture, merged on release. **Snap to Objects** (View › Snapping, a magnet under the tools, the selection tools' options) switches the Selection and Subselection tools' snapping. The Paint Bucket's raw fills are exact (up to the lines and fill edges, from the planar merge) and join fills of their colour; pasted raw shapes cut what they land on; raw shapes from Animate files open raw and merged; gradient and bitmap fills take part in the merge. Headless: `raw.subselect`, `raw.subselect_rect`, `raw.points`, `raw.move_handle`, `with` on `raw.move_point`, `draw.snap_to_objects`, `object` on `paint.bucket`. Width profiles take part in the merge since ADR 0093. **Raw points and symbols in place** (ADR 0045): add a point on a raw edge (Pen Alt-click, Subselection double-click; every shape on the edge gets it, the curve unchanged), delete raw points (Delete; the shapes on each are joined across it so the drawing stays connected; points where three edges meet are kept), Make Smooth / Corner on raw points, smooth handle pairs (Alt breaks them; drawing objects too); the Line, Rectangle, Oval, PolyStar and Pen tools snap their points within 10 screen px (Snap to Objects, Ctrl+Shift+/); a double-click on an instance (or Ctrl+E, or a double-click in the Library) opens the symbol in place, the stage dimmed around it, the edit bar showing the path back, and every tool and command works on its timeline. Headless: `raw.add_point`, `raw.delete_points`, `raw.convert_points`, `draw.snap`, `smooth` on `raw.move_handle` and `path.move_points`, `symbol.edit`, `symbol.exit`. Not yet: rotated instances in place (they open upright). Onion skin and Edit Multiple Frames work inside a symbol since ADR 0051. **Brush (B)** (ADR 0033, first slice): paints filled shapes in the fill colour, the exact area the tip sweeps (a distance field traced and fitted with cubics); round or square tip with size, angle and roundness (oval and flat calligraphic tips), pen pressure from a tablet (10–100 % of the size; a mouse paints full size), smoothing relative to the screen, Paint Normal, Paint Fills and Paint Behind; a raw shape that merges with the drawing, or a drawing object with Object Drawing on; a click paints a dab; live preview while dragging; `[` and `]` change the size; one undo step per stroke. Headless: `draw.brush`. **Paint Selection and Paint Inside** (ADR 0080): the paint is clipped to the selected fills' union, or to the fill (or closed-off empty area) the stroke starts in, exactly on the planar map, then merged under the lines; Paint Selection keeps the selection for the next stroke. Not yet: the live preview clipped as it paints. **Brush library, pressure curves and the Paint Brush (Y)** (ADR 0068, first slice): Window › Brush Library with seven built-in brushes made only of parameters (Pencil, Ink Pen, Flat Calligraphy, Round Taper, Marker, Chalk with a deterministic worn edge, Dotted stamps), each with a stroke preview drawn by the renderer; brushes of your own saved by name in your preferences, renamed, deleted (asks first) and moved between computers as a JSON brush set; a pressure curve editor (Linear, Soft, Firm, or your own points) driving size and, optionally, the stroke's opacity; tapers, dab spacing and a rough edge in Properties; Velocity (mouse speed as pressure, off by default); the Paint Brush draws a width-profiled stroke in the stroke colour that the Width tool edits. Headless: `brush.preset_list/save/rename/delete/export/import`, `preset`, `curve`, `as_stroke` and the shaping params on `draw.brush`. **Tilt, texture and scatter** (ADR 0093): per-sample pen tilt (Pointer Events altitude and azimuth in `draw.brush` points) turns the tip by the azimuth and widens it up to 2× as the pen leans (Brush › Tilt: Angle, Width, shown once a pen reports tilt; the Paint Brush's width too), a fixed paper grain of holes (Texture) and dabs thrown either side (Scatter), all vector fills; built-in Charcoal and Spatter (nine brushes). Not yet: reading tilt from the pen on desktop systems (winit 0.30 reports it only on iOS), opacity varying along a stroke, bitmap or art brushes, Eraser presets and pressure. **Eraser (E)** (ADR 0034, first slice): sweeps the Brush's tip and takes what it covers out of the raw shapes on the active layer (the sweep is a fill in the planar merge that comes out empty); Erase Normal, Erase Fills, Erase Lines, Erase Selected Fills and Erase Inside; the Faucet deletes a whole fill or line with a click; drawing objects, symbols and text are kept; a stroke that erases nothing leaves no undo step; live preview, `[` and `]` sizes, one undo step per stroke; double-clicking the tool (or Erase Everything… in its options) clears the visible, unlocked layers at this frame after asking. **Eyedropper (I)** (first slice): a click on a fill picks its paint (solid, or a gradient or bitmap kept where it is on the stage, as Lock Fill) into the fill swatch, a click on a line picks its colour, width and profile; with shapes selected it applies the style to them; then it becomes the Paint Bucket or the Ink Bottle; Shift-click picks into the other swatch only. Headless: `draw.erase`, `draw.faucet`, `draw.erase_all`, `paint.pick`, `paint.apply_style`. Since ADR 0093: width-profiled lines erase and merge, each piece keeping its widths; gradient pieces keep their gradient where it was; inside an open symbol or drawing object the Eraser erases its shapes, and on the stage the status bar says how. Not yet: eraser pressure, picking a bitmap's pixel colour or text styles, an eyedropper cursor. **Colour picker and drawing-tool fixes from user reports** (M1): every colour swatch (the Tools panel's fill and stroke squares too) opens one picker with Animate's web-safe swatches (216 colours, greys and primaries), the colours mixed or typed this session, a hex field and the full mixer; the Tools squares offer No Colour and recolour selected shapes; drawing tools leave nothing selected after a stroke and the Selection tool's box has no handles (they are Free Transform's); Break Apart turns drawing objects into merged drawing; Ctrl-drag on a raw edge adds a corner point; the Pencil and Line show no fill. **Swatches panel** (ADR 0078): Window › Swatches, the document's saved colours and gradients (in the `.anicraft` file; a default set for new documents and older files); click applies to the selection and the tool colour, to the stroke or fill that is active (Tools squares, Colour panel or the panel's toggle; gradients always to the fill); + adds the active colour or gradient, Duplicate, Delete, drag (or Alt+arrows) to reorder, names on hover, Clear (keeps black and white) and Load Default Swatches (ask first, undoable); import and export as a JSON swatch file, GIMP `.gpl` import; the colour picker shows the document's swatches and the fill picker its gradient swatches. Headless: `swatch.list/add/remove/move/duplicate/rename/apply/clear/reset/import/export`. Not yet: swatch folders, sorting by colour, bitmap swatches, Save as Default, XFL swatch import (no public description), Adobe `.aco`/`.ase`/`.clr` (proprietary). The layer footer is icon buttons (New Layer, Delete, New Folder, Up, Down) that fit at any size and language. **Groups and Combine Objects** (ADR 0073): Modify › Group (Ctrl+G) / Ungroup (Ctrl+Shift+G), a group element whose members are a one-layer, one-frame timeline, opened in place by a double-click like a symbol (every tool works inside; raw shapes merge only with each other); nested groups; exports, player, sounds and the Library see inside; XFL `DOMGroup` imports as groups. Combine Objects › Union, Intersect, Punch, Crop on the planar map (analytic area tests). Selection tool: Alt-drag copies, Shift constrains to 45° (Ctrl/⌘-drag corners: #257). **Drawing parity leftovers** (ADR 0080): PolyStar's Shape (Polygon or Star), sides 3–32 and star point size 0–1 in its options (`shape`, `sides`, `point_size` on `draw.star`); a double-click (or Ctrl+E) opens a drawing object in place, its raw shapes merging only with each other, and it closes as one object again (a group of the pieces when an edit leaves several); **Modify › Transform › Envelope**: a Bézier mesh of corner and tangent handles bends the selected shapes and drawing objects, one undo step per drag, baked like Animate's (no Delete Envelope needed), undo restoring the mesh; headless `modify.envelope`, `modify.envelope_move`, `modify.envelope_close`. *Not yet:* gradient and bitmap strokes (proposed in ADR 0080), envelope handles from the keyboard, an envelope on symbols, text or groups, drawing objects edited without opening them (#181), Combine across layers. **Rulers, grid and guides** (ADR 0076): View › Rulers (stage pixels, following zoom and pan, pointer marked); guides per scene saved in the document, dragged from a ruler, moved with the Selection tool, dragged back to delete, Show/Lock/Snap/Edit/Add/Clear (Edit Guides lists and adds them from the keyboard); a grid (spacing, | | Plug-ins | **WebAssembly plug-ins** (ADR 0017, `docs/plugins.md`): sandboxed modules run by `wasmi` with no imports but the AniCraft ABI (`anicraft.call`/`anicraft.response`: JSON requests that run registry commands, read a compact document view or the active layer's elements, and log); fuel (10⁹ instructions), memory (256 MiB), wall-clock (5 s), request, size and log limits, a fresh instance per run; file, plug-in, undo and clipboard commands refused. `plugin.install/list/run/remove/reload`; a run is atomic and one undo step named after the plug-in. App: **Commands** menu (Plug-ins, Install, Manage, Reload), palette entries, a dialog generated from the manifest's parameters with a live preview; plug-ins load from `/plugins` or `ANICRAFT_PLUGINS`; CLI `--plugins`. Samples in Rust (Star Field, Jitter Selection, guest SDK) in `examples/plugins`. Frame scripts: see Interactivity. **Exporter and ease plug-ins** (ADR 0088): `kind: "exporter"` declares a format (name, extension, options) and gets evaluated frames (`movie`, `frame`: the flattened display list, never the document), returning the file's bytes from `ac_export` (64 MiB cap, 5·10¹⁰ instructions, 10 min); File › Export lists it with an Export window (options, frames, file, progress bar and Cancel on a worker thread); `file.export_plugin`, `file.export_formats`, `anicraft-cli export --format ` and `formats`. `kind: "ease"` declares named eases, `ac_ease(i, t)` sampled into 257 values at load (NaN, unbounded or end-missing eases refused); `Easing::Sampled` keeps the table in the document, so it plays the same without the plug-in; the ease menus list them under Plug-in eases; `{plugin, ease}` easing params. Samples: Plain Text Frames and Stepped Eases, built and run in CI. Not yet: plug-in formats in Publish, bitmaps' pixels and sounds for exporters, ease plug-ins with parameters, background runs of command plug-ins, a binary document view. | | Interactivity | **Frame actions, frame scripts and Test Movie, first slice** (ADR 0024): a typed timeline action IR (`anicraft-actions`: stop, play, go to a frame or label in a scene, next/previous frame and scene, trace, set x/y/alpha/visible/rotation/scale, instance-name target paths) on keyframes and on button and movie clip instances (click, press, release, over, out); a pure, deterministic, budgeted player in `anicraft-doc` (`step(doc, &state, &events)`; movie clip playheads, button Up/Over/Down states with Hit-frame hit tests, script-set properties) drawn by `evaluate_player`, while `evaluate` and exports stay script-free. **Actions panel** (F9: structured lists, targets/labels/scenes picked from the document; movie clip timelines too), instance name and events in Properties, an "a" on keyframes with actions. **Frame scripts** on the plug-in host (`kind: "frame-script"`, entry points, `player`/`action` ops, 20 M instructions per frame shared, no document access). **Test Movie** (Control › Test Movie, Ctrl+Enter): the player at the document frame rate in its own window with the pointer, restart/pause/step and an Output panel. **A window of its own on the desktop** (ADR 0062): sized to the stage at 100 % (smaller to fit the screen), titled with the document, back where it was last (not on Wayland, where the desktop places windows), with the keyboard when it opens; Esc or Ctrl+W (⌘W) closes it, Ctrl+Enter restarts it in place, and the editor's Ctrl/Alt shortcuts work from it; floating inside the editor in the web build, where the system can't open windows (it says so), or by choice in Preferences › Test Movie. Not yet: full screen, zoom in the movie window, remembering its size. Headless: `actions.set/clear/list`, `instance.set_name`, `control.test_movie` (timed pointer events, returns output and state). **HTML canvas export** (ADR 0028, `file.export_html`, File › Export › Export HTML Canvas…): one self-contained page (data, player and drawing code inline; images and sounds embedded) that plays in any browser with canvas 2D; every used timeline baked frame by frame (tweens of every kind exact, identical paths, paints and frames stored once), movie clips, buttons with Hit areas and every action run by `player.js`, a port of the Rust player checked against it step by step in Boa (state, output and display list); masks and fading/blending groups on offscreen layers; **filters and Subtract/Invert in the page** (ADR 0072: `filters.js`, a port of the renderer's filters run over the group's pixels on a layer that reaches past the canvas by the filters' reach, Subtract and Invert composited per pixel, results kept while the group is unchanged; equal to the oracle's pixels within 9.3e-4 in Boa; 3.4 ms a frame for the demo's filters at 1080p while they change); Web Audio for Event/Start/Stop/Stream sounds; bitmap tints, 9-slice scaling and plug-in frame scripts reported. Not yet: 9-slice in the page, keeping a moving filtered group's pixels, filters off the main thread. **Kept frame scripts** (ADR 0013 tier 1): scripts written in another language (an Animate document's ActionScript) kept verbatim on keyframes with their language, symbol linkage classes and the document class; the Actions panel's **Script** view (monospace editor with line numbers, language, live and undoable), the same "a" marker, Class rows in Properties; `script.set/clear/list/set_class`; **ActionScript timeline subset runs** (ADR 0013 tier 2): a hand-written, bounded lexer and parser (`anicraft_actions::as3`) lower stop/play/go to/next and previous frame and scene on instance-name paths, mouse listeners (click, down, up, roll over and out; named or inline functions, `currentTarget`), `trace` and property settings to the action IR, compiled once per script; anything else is reported with line and column and the script doesn't run (never half-run), `navigateToURL` and the like are ignored and noted; the player keeps listeners per instance, Test Movie's Output says which scripts run and which don't and why, the Script view lists problems in place, the XFL report and `script.list/check` say what runs, and the HTML page runs the same steps (`player.js` checked against the Rust player). **ActionScript small logic** (ADR 0052): scripts compile to a small typed script IR evaluated by the player with fuel (100,000 per script or listener call, 1,000,000 per step; an endless loop or a run-time error stops its script with an Output line and the movie plays on): typed variables (Number, int, uint, Boolean, String, untyped) kept per timeline instance across its frame scripts, expressions as ECMA-262 has them, `if`/`else`, `for`/`while`/`do`, functions with parameters, results and recursion, called from any frame of the same timeline (a timeline-level link step; names that aren't there keep the script from running, said in place), property reads of instances and timelines (`x`, `y`, `alpha`, `visible`, `rotation`, `scaleX/Y`, `currentFrame`, `totalFrames`, `currentLabel`, `mouseX/Y`, `name`), `removeEventListener`, `Event.ENTER_FRAME`, `KeyboardEvent.KEY_DOWN/KEY_UP` on the stage with `e.keyCode`, `e.target`/`e.currentTarget`, seeded `Math.random()`; keyboard in Test Movie and the HTML page, `control.test_movie` key events and `seed`; `player.js` mirrors the evaluator, checked step by step in Boa. Not yet: ActionScript `switch`, `for in`, arrays and objects, string methods, closures, event bubbling, mouse listeners on the stage, ActionScript 1.0/2.0, scripts on instances, filters and keyboard focus in the HTML page, sound actions, keyboard events, variables, persistent script state, masks in hit tests, a separate OS window. **Buttons, complete** (ADR 0057): a button open in place names its frames Up, Over, Down and Hit on the timeline and shows its Hit area translucent over the other states; Test Movie has **Show hit areas**; sounds on its frames play as its state changes. | diff --git a/src/app.rs b/src/app.rs index 2e7b270a..c44df8b8 100644 --- a/src/app.rs +++ b/src/app.rs @@ -482,6 +482,11 @@ pub struct App { /// Selected frames on the timeline, and the drag on the frame grid. pub frame_sel: Option, pub tl_drag: timeline::TlDrag, + /// The layer being dragged by its name to another place in the stack (#407). + pub tl_layer_drag: Option, + /// The layer column's width while its edge is dragged (#384); the preference takes it on + /// release. + pub tl_layer_w_drag: Option, /// Where the panels are (ADR 0075): the current workspace's arrangement. pub dock: crate::dock::Layout, /// The dock's view state: a tab being dragged, where groups were drawn. @@ -764,6 +769,8 @@ impl App { motion_drag: None, frame_sel: None, tl_drag: timeline::TlDrag::None, + tl_layer_drag: None, + tl_layer_w_drag: None, dock: prefs.workspaces.layout(), dock_view: Default::default(), manage_workspaces: Default::default(), @@ -833,6 +840,7 @@ impl App { macros: Default::default(), }; app.apply_prefs(ctx); + crate::brushtool::restore(&mut app); app.decode_sounds(); app.status_ok(tr!("Welcome to AniCraft. Press Enter to play the sample animation.")); if let Some(e) = recovery_err { @@ -4070,6 +4078,8 @@ impl App { crate::brush_panel::sync(self); crate::panels::sync_filter_presets(self); crate::rulers::sync(self); + let pointer_down = ctx.input(|i| i.pointer.any_down()); + crate::brushtool::sync(self, pointer_down); // A browser asks before leaving a page with unsaved work (its close guard). platform::set_unsaved(self.s.is_dirty()); diff --git a/src/brushtool.rs b/src/brushtool.rs index 9a3c85dd..fe108aff 100644 --- a/src/brushtool.rs +++ b/src/brushtool.rs @@ -58,6 +58,50 @@ impl Default for BrushOptions { } } +/// The name the tools' own settings are kept under in the preferences. +const KEPT: &str = "tool"; + +/// The Brush's and the Paint Brush's settings as the preferences kept them (#331). +pub fn restore(app: &mut App) { + if let Some(p) = &app.prefs.brush_tool { + app.brush.apply(p); + } + if let Some(p) = &app.prefs.paint_brush_tool { + app.paint_brush.apply(p); + } +} + +/// The brushes' settings changed: into the preferences, so the next start has them (#331). +/// Not while a slider is being dragged (one write when it is let go), and not in screenshot or +/// test runs, which never write the user's preferences. Returns whether they changed. +pub fn sync(app: &mut App, pointer_down: bool) -> bool { + if pointer_down { + return false; + } + let mut changed = false; + for paint in [false, true] { + let (tool, default) = if paint { (app.paint_brush, BrushOptions::paint_brush()) } else { (app.brush, BrushOptions::default()) }; + let now = tool.preset(KEPT); + let kept = if paint { &mut app.prefs.paint_brush_tool } else { &mut app.prefs.brush_tool }; + // Untouched defaults stay unwritten, so they follow new defaults. + let same = match kept { + Some(k) => *k == now, + None => now == default.preset(KEPT), + }; + if !same { + *kept = Some(now); + changed = true; + } + } + if changed + && app.shot.is_none() + && let Err(e) = app.prefs.save() + { + app.status_err(tr!("Could not save preferences: {e}", e = e)); + } + changed +} + /// Sizes the tool offers (the command takes 0.1..2000). pub const SIZE_MIN: f32 = 1.0; pub const SIZE_MAX: f32 = 400.0; diff --git a/src/layer_ui_tests.rs b/src/layer_ui_tests.rs new file mode 100644 index 00000000..c23c1fa3 --- /dev/null +++ b/src/layer_ui_tests.rs @@ -0,0 +1,270 @@ +//! The timeline's layer column, driven by pointer events: a layer dragged by its name to another +//! place (#407), the eye, padlock and square above the layers (#422), the line between the +//! layers and the frames (#384); and the Properties panel's W and H (#294). + +use crate::app::App; +use crate::timeline::{DropRow, LayerDrop, layer_drop}; +use anicraft_engine::doc::LayerId; +use egui::{Event, Modifiers, PointerButton, Pos2, Rect, pos2, vec2}; + +fn opened() -> (App, egui::Context) { + let ctx = egui::Context::default(); + let session = anicraft_engine::Session::new(anicraft_engine::doc::sample::demo()); + let mut app = App::with_context(&ctx, session, Some(std::path::PathBuf::from("unused.png"))); + settle(&ctx, &mut app); + (app, ctx) +} + +fn frame(ctx: &egui::Context, app: &mut App, events: Vec) { + let mut all = vec![Event::ModifiersChanged(Modifiers::NONE)]; + all.extend(events); + let input = egui::RawInput { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(1600.0, 940.0))), events: all, ..Default::default() }; + ctx.run_ui(input, |ui| app.frame(ui)).textures_delta.clear(); +} + +fn settle(ctx: &egui::Context, app: &mut App) { + for _ in 0..3 { + frame(ctx, app, Vec::new()); + } +} + +fn button(pos: Pos2, pressed: bool) -> Event { + Event::PointerButton { pos, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE } +} + +/// Presses at `from` and moves to `to` in steps, the button still down. +fn press_and_move(ctx: &egui::Context, app: &mut App, from: Pos2, to: Pos2) { + frame(ctx, app, vec![Event::PointerMoved(from)]); + frame(ctx, app, vec![button(from, true)]); + for i in 1..=10 { + frame(ctx, app, vec![Event::PointerMoved(from + (to - from) * (i as f32 / 10.0))]); + } +} + +fn drag(ctx: &egui::Context, app: &mut App, from: Pos2, to: Pos2) { + press_and_move(ctx, app, from, to); + frame(ctx, app, vec![button(to, false)]); + settle(ctx, app); +} + +fn click(ctx: &egui::Context, app: &mut App, at: Pos2) { + frame(ctx, app, vec![Event::PointerMoved(at)]); + frame(ctx, app, vec![button(at, true)]); + frame(ctx, app, vec![button(at, false)]); + settle(ctx, app); +} + +/// The layer names top down. +fn names(app: &App) -> Vec { + app.s.timeline().layers.iter().map(|l| l.name.clone()).collect() +} + +/// The row of the layer called `name`, and where the frames start. +fn row(app: &App, name: &str) -> (Rect, f32) { + let geo = app.drop.timeline.as_ref().expect("the timeline is drawn"); + let id = app.s.timeline().layers.iter().find(|l| l.name == name).map(|l| l.id).expect("the layer"); + let rect = geo.rows.iter().find(|(_, l)| *l == id).map(|(r, _)| *r).expect("its row shows"); + (rect, geo.cells_left) +} + +/// A point on the layer's name, `t` of the way down its row. +fn on_name(app: &App, name: &str, t: f32) -> Pos2 { + let (r, _) = row(app, name); + pos2(r.left() + 70.0, r.top() + r.height() * t) +} + +#[test] +fn a_drop_lands_above_below_or_inside() { + let l = LayerId; + let plain = |n: u64, top: f32| DropRow { top, bottom: top + 28.0, id: l(n), folder: false, first_child: None, dragged: false }; + // A, an open folder F holding B, then C; D is being dragged (not among the rows hovered). + let rows = [plain(1, 0.0), DropRow { folder: true, first_child: Some(l(3)), ..plain(2, 28.0) }, plain(3, 56.0), plain(4, 84.0)]; + assert_eq!(layer_drop(&rows, -5.0), Some(LayerDrop::Before(l(1))), "above the list: the top"); + assert_eq!(layer_drop(&rows, 5.0), Some(LayerDrop::Before(l(1)))); + assert_eq!(layer_drop(&rows, 20.0), Some(LayerDrop::After(l(1)))); + assert_eq!(layer_drop(&rows, 30.0), Some(LayerDrop::Before(l(2))), "a folder's top quarter: above it"); + assert_eq!(layer_drop(&rows, 42.0), Some(LayerDrop::Into(l(2))), "its middle: inside"); + assert_eq!(layer_drop(&rows, 54.0), Some(LayerDrop::Into(l(2))), "under an open folder: inside, first"); + assert_eq!(layer_drop(&rows, 80.0), Some(LayerDrop::After(l(3))), "under the folder's last layer: still inside"); + assert_eq!(layer_drop(&rows, 86.0), Some(LayerDrop::Before(l(4))), "above the layer after the folder: out of it"); + assert_eq!(layer_drop(&rows, 500.0), Some(LayerDrop::After(l(4))), "below the list: the bottom"); + // A closed or empty folder: its bottom quarter is below it; a mask's lower half is above + // its first masked layer. + let closed = [DropRow { folder: true, ..plain(2, 0.0) }]; + assert_eq!(layer_drop(&closed, 26.0), Some(LayerDrop::After(l(2)))); + let mask = [DropRow { first_child: Some(l(3)), ..plain(2, 0.0) }, plain(3, 28.0)]; + assert_eq!(layer_drop(&mask, 20.0), Some(LayerDrop::Before(l(3)))); + // Over the dragged layer's own rows, or with no rows: nowhere. + let own = [DropRow { dragged: true, ..plain(1, 0.0) }]; + assert_eq!(layer_drop(&own, 10.0), None); + assert_eq!(layer_drop(&[], 10.0), None); + // The parameters `layer.move` takes. + assert_eq!(LayerDrop::Into(l(2)).params(l(9)), serde_json::json!({"layer": 9, "into": 2})); + assert_eq!(LayerDrop::After(l(2)).params(l(9)), serde_json::json!({"layer": 9, "after": 2})); +} + +#[test] +fn a_layer_dragged_by_its_name_moves_in_one_undo_step() { + let (mut app, ctx) = opened(); + assert_eq!(names(&app), ["Ball", "Star", "Sun", "Hills", "Sky"]); + let undo_before = app.s.history_len(); + // Ball onto the lower half of Hills: just below it. + let (from, to) = (on_name(&app, "Ball", 0.5), on_name(&app, "Hills", 0.8)); + drag(&ctx, &mut app, from, to); + assert_eq!(names(&app), ["Star", "Sun", "Hills", "Ball", "Sky"]); + assert_eq!(app.s.history_len(), undo_before + 1, "one step"); + assert!(app.tl_layer_drag.is_none()); + assert_eq!(app.s.active_layer().map(|l| l.name.clone()).as_deref(), Some("Ball"), "the dragged layer is the active one"); + // Sky onto the upper half of Star: the top. + let (from, to) = (on_name(&app, "Sky", 0.5), on_name(&app, "Star", 0.2)); + drag(&ctx, &mut app, from, to); + assert_eq!(names(&app), ["Sky", "Star", "Sun", "Hills", "Ball"]); + app.run("edit.undo", serde_json::json!({})); + assert_eq!(names(&app), ["Star", "Sun", "Hills", "Ball", "Sky"]); + + // Esc during the drag, or a release over the frames, leaves the stack alone. + let before = names(&app); + let (from, to) = (on_name(&app, "Star", 0.5), on_name(&app, "Ball", 0.8)); + press_and_move(&ctx, &mut app, from, to); + assert!(app.tl_layer_drag.is_some(), "dragging"); + frame(&ctx, &mut app, vec![Event::Key { key: egui::Key::Escape, physical_key: None, pressed: true, repeat: false, modifiers: Modifiers::NONE }]); + assert!(app.tl_layer_drag.is_none()); + frame(&ctx, &mut app, vec![button(to, false)]); + settle(&ctx, &mut app); + assert_eq!(names(&app), before); + let (r, cells) = row(&app, "Ball"); + let from = on_name(&app, "Star", 0.5); + drag(&ctx, &mut app, from, pos2(cells + 200.0, r.center().y)); + assert_eq!(names(&app), before); + + // A click on the name still only picks the layer. + let at = on_name(&app, "Sun", 0.5); + click(&ctx, &mut app, at); + assert_eq!(names(&app), before); + assert_eq!(app.s.active_layer().map(|l| l.name.clone()).as_deref(), Some("Sun")); +} + +#[test] +fn a_layer_dropped_on_a_folder_goes_inside() { + let (mut app, ctx) = opened(); + app.run("layer.select", serde_json::json!({"index": 0})); + app.run("layer.new_folder", serde_json::json!({"name": "Cast"})); + settle(&ctx, &mut app); + assert_eq!(names(&app).first().map(String::as_str), Some("Cast")); + let (from, to) = (on_name(&app, "Sun", 0.5), on_name(&app, "Cast", 0.5)); + drag(&ctx, &mut app, from, to); + let tl = app.s.timeline(); + let (folder, sun) = (tl.layers.iter().find(|l| l.name == "Cast").map(|l| l.id), tl.layers.iter().find(|l| l.name == "Sun").and_then(|l| l.parent)); + assert_eq!(sun, folder, "Sun is in the folder"); + assert_eq!(names(&app).get(1).map(String::as_str), Some("Sun")); +} + +#[test] +fn the_buttons_above_the_layers_act_on_every_layer() { + let (mut app, ctx) = opened(); + let (first, cells) = row(&app, "Ball"); + // The header is the ruler's band above the first row; the buttons head their columns. + let head = |k: f32| pos2(cells - 16.0 - k * 26.0, first.top() - 12.0); + let all = |app: &App, f: fn(&anicraft_engine::doc::Layer) -> bool| app.s.timeline().layers.iter().all(|l| f(l)); + click(&ctx, &mut app, head(2.0)); + assert!(all(&app, |l| !l.visible), "the eye hides every layer"); + click(&ctx, &mut app, head(2.0)); + assert!(all(&app, |l| l.visible), "and shows them again"); + click(&ctx, &mut app, head(1.0)); + assert!(all(&app, |l| l.locked), "the padlock locks every layer (Sky was locked already)"); + click(&ctx, &mut app, head(1.0)); + assert!(all(&app, |l| !l.locked)); + click(&ctx, &mut app, head(0.0)); + assert!(all(&app, |l| l.outline), "the square shows every layer as outlines"); + click(&ctx, &mut app, head(0.0)); + assert!(all(&app, |l| !l.outline)); +} + +#[test] +fn the_line_between_layers_and_frames_drags_and_resets() { + let (mut app, ctx) = opened(); + let (r, cells) = row(&app, "Star"); + let w = app.prefs.timeline_layer_w; + assert_eq!(w, crate::prefs::LAYER_W_DEFAULT); + // Narrower: the frames start further left, and the width is kept in the preferences. + drag(&ctx, &mut app, pos2(cells, r.center().y), pos2(cells - 60.0, r.center().y)); + assert!((app.prefs.timeline_layer_w - (w - 60.0)).abs() < 1.5, "{}", app.prefs.timeline_layer_w); + let (_, now) = row(&app, "Star"); + assert!((now - (cells - 60.0)).abs() < 1.5, "the frames moved with it: {now}"); + assert!(app.tl_layer_w_drag.is_none()); + // Never narrower than the toggles need, nor wider than the limit. + drag(&ctx, &mut app, pos2(now, r.center().y), pos2(now - 900.0, r.center().y)); + assert_eq!(app.prefs.timeline_layer_w, *crate::prefs::LAYER_W_RANGE.start()); + // A double-click puts it back. + let (_, now) = row(&app, "Star"); + let at = pos2(now, r.center().y); + frame(&ctx, &mut app, vec![Event::PointerMoved(at)]); + for _ in 0..2 { + frame(&ctx, &mut app, vec![button(at, true)]); + frame(&ctx, &mut app, vec![button(at, false)]); + } + settle(&ctx, &mut app); + assert_eq!(app.prefs.timeline_layer_w, crate::prefs::LAYER_W_DEFAULT); + // A hand-edited or damaged preference comes back in range. + let p = crate::prefs::Prefs::from_json(r#"{"timeline_layer_w": 99999}"#); + assert_eq!(p.timeline_layer_w, *crate::prefs::LAYER_W_RANGE.end()); + assert_eq!(crate::prefs::Prefs::from_json("{}").timeline_layer_w, crate::prefs::LAYER_W_DEFAULT, "older preference files"); +} + +#[test] +fn width_and_height_stretch_the_selection_from_its_top_left_corner() { + use crate::panels::resize_affine; + // Twice as wide, half as high: the corner (10, 20) stays. + let m = resize_affine([10.0, 20.0, 110.0, 60.0], 200.0, 20.0).expect("a change"); + assert_eq!(m, [2.0, 0.0, 0.0, 0.5, -10.0, 10.0]); + assert_eq!((m[0] * 10.0 + m[4], m[3] * 20.0 + m[5]), (10.0, 20.0)); + assert_eq!((m[0] * 110.0 + m[4], m[3] * 60.0 + m[5]), (210.0, 40.0)); + // The same size, a size that isn't a positive number, or an empty box: nothing to do. + assert_eq!(resize_affine([10.0, 20.0, 110.0, 60.0], 100.0, 40.0), None); + for (w, h) in [(0.0, 40.0), (-5.0, 40.0), (f32::NAN, 40.0), (100.0, f32::INFINITY)] { + assert_eq!(resize_affine([10.0, 20.0, 110.0, 60.0], w, h), None); + } + assert_eq!(resize_affine([f32::INFINITY, 0.0, f32::NEG_INFINITY, 0.0], 10.0, 10.0), None); + // A level line has no height to stretch: only its width changes. + assert_eq!(resize_affine([0.0, 5.0, 50.0, 5.0], 100.0, 30.0), Some([2.0, 0.0, 0.0, 1.0, 0.0, 0.0])); + + // Through the command the panel sends: a 100 × 40 rectangle becomes 200 × 20 in place. + let (mut app, _ctx) = opened(); + app.run("layer.select", serde_json::json!({"index": 0})); + app.run("draw.rect", serde_json::json!({"x": 10, "y": 20, "w": 100, "h": 40, "fill": "#336699", "stroke": null, "object": true})); + let b = app.s.selection_bounds(); + let m = resize_affine([b.min.x, b.min.y, b.max.x, b.max.y], 200.0, 20.0).expect("a change"); + app.run("modify.transform", serde_json::json!({"a": m[0], "b": m[1], "c": m[2], "d": m[3], "e": m[4], "f": m[5]})); + let b = app.s.selection_bounds(); + for (got, want) in [(b.min.x, 10.0), (b.min.y, 20.0), (b.max.x, 210.0), (b.max.y, 40.0)] { + assert!((got - want).abs() < 0.01, "{got} vs {want}"); + } +} + +#[test] +fn brush_settings_come_back_with_the_next_start() { + let (mut app, _ctx) = opened(); + // Untouched tools write nothing, so they keep following the defaults. + assert!(!crate::brushtool::sync(&mut app, false)); + assert_eq!((app.prefs.brush_tool.as_ref(), app.prefs.paint_brush_tool.as_ref()), (None, None)); + // A changed size and smoothing are kept once the slider is let go, each tool its own. + app.brush.size = 37.0; + app.brush.smoothing = 80.0; + app.paint_brush.size = 3.0; + assert!(!crate::brushtool::sync(&mut app, true), "not while the pointer is down"); + assert!(crate::brushtool::sync(&mut app, false)); + assert!(!crate::brushtool::sync(&mut app, false), "written once"); + // What the preferences file holds brings them back in a fresh window. + let json = serde_json::to_string(&app.prefs).expect("preferences serialise"); + let (mut next, _ctx) = opened(); + assert_ne!(next.brush.size, 37.0); + next.prefs = crate::prefs::Prefs::from_json(&json); + crate::brushtool::restore(&mut next); + assert_eq!((next.brush.size, next.brush.smoothing, next.paint_brush.size), (37.0, 80.0, 3.0)); + assert!(!crate::brushtool::sync(&mut next, false), "restored settings are the kept ones"); + // Older files have none; junk is ignored and values out of range are clamped. + let p = crate::prefs::Prefs::from_json(r#"{"brush_tool": 7, "paint_brush_tool": {"size": 999999}}"#); + assert!(p.brush_tool.is_none()); + assert!(p.paint_brush_tool.is_some_and(|b| b.size <= 2000.0)); + assert!(crate::prefs::Prefs::from_json("{}").brush_tool.is_none()); +} diff --git a/src/main.rs b/src/main.rs index 85f381fd..a16c4d1c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -434,4 +434,6 @@ mod rulers_tests; #[cfg(test)] mod retime_ui_tests; #[cfg(test)] +mod layer_ui_tests; +#[cfg(test)] mod tilt_ui_tests; diff --git a/src/panels.rs b/src/panels.rs index ba1e87da..4d7ecb79 100644 --- a/src/panels.rs +++ b/src/panels.rs @@ -40,6 +40,27 @@ fn tool_icon(tool: Tool) -> Icon { } } +/// The sizes the Properties panel's W and H take, in stage pixels. +const SIZE_RANGE: std::ops::RangeInclusive = 0.1..=100_000.0; + +/// The stage-space affine `[a, b, c, d, e, f]` that makes the box `[x0, y0, x1, y1]` `w` wide and +/// `h` high with its top-left corner where it is (#294). A side with no extent (a level line's +/// height) can't be stretched and stays as it is; `None` when nothing would change or a size +/// isn't a positive number. +pub fn resize_affine(b: [f32; 4], w: f32, h: f32) -> Option<[f32; 6]> { + let [x0, y0, x1, y1] = b; + let (w0, h0) = (x1 - x0, y1 - y0); + if !(w.is_finite() && h.is_finite() && w > 0.0 && h > 0.0 && w0.is_finite() && h0.is_finite()) { + return None; + } + let kx = if w0 > 1e-3 { w / w0 } else { 1.0 }; + let ky = if h0 > 1e-3 { h / h0 } else { 1.0 }; + if (kx - 1.0).abs() < 1e-6 && (ky - 1.0).abs() < 1e-6 { + return None; + } + Some([kx, 0.0, 0.0, ky, x0 * (1.0 - kx), y0 * (1.0 - ky)]) +} + /// How the tools are laid out where they are (ADR 0087). #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub enum ToolFlow { @@ -935,6 +956,22 @@ fn selection_props(app: &mut App, ui: &mut egui::Ui, e: &anicraft_engine::doc::E } }); } + // Size (#294): the selection's box in stage pixels, as Animate's W and H. A change + // stretches the artwork from the box's top-left corner, which stays where it is. + let sb = app.s.selection_bounds(); + if !sb.is_empty() && !matches!(e.kind, ElementKind::Camera) { + let (w0, h0) = (sb.max.x - sb.min.x, sb.max.y - sb.min.y); + let (mut w, mut h) = (w0, h0); + row(ui, tr!("Size"), |ui| { + let a = ui.add(egui::DragValue::new(&mut w).prefix("W ").speed(1.0).range(SIZE_RANGE).clamp_existing_to_range(false).max_decimals(1)).named(tr!("Width")); + let c = ui.add(egui::DragValue::new(&mut h).prefix("H ").speed(1.0).range(SIZE_RANGE).clamp_existing_to_range(false).max_decimals(1)).named(tr!("Height")); + if (a.changed() || c.changed()) + && let Some(m) = resize_affine([sb.min.x, sb.min.y, sb.max.x, sb.max.y], w, h) + { + live(app, tr_noop!("Resize"), "modify.transform", json!({"a": m[0], "b": m[1], "c": m[2], "d": m[3], "e": m[4], "f": m[5]})); + } + }); + } row(ui, tr!("Scale"), |ui| { // Negative is a mirror (Flip). Only edits are clamped: a scale merely shown is never // rewritten (#116). The engine refuses a scale too near zero. @@ -982,9 +1019,9 @@ fn selection_props(app: &mut App, ui: &mut egui::Ui, e: &anicraft_engine::doc::E row_prose(ui, tr!("Type"), |ui| { egui::ComboBox::from_id_salt("prop_symkind").width(crate::theme::fit(ui, 150.0)).selected_text(symbol_kind_label(kind)).show_ui(ui, |ui| { for (k, id, tip) in [ - (SymbolKind::Graphic, "graphic", tr!("Keeps step with the timeline it is on (looping options below)")), (SymbolKind::MovieClip, "movie_clip", tr!("Plays its own timeline on a loop, from when it appears")), (SymbolKind::Button, "button", tr!("Shows its Up frame")), + (SymbolKind::Graphic, "graphic", tr!("Keeps step with the timeline it is on (looping options below)")), ] { if ui.selectable_label(kind == k, symbol_kind_label(k)).on_hover_text(tip).clicked() && (kind != k || m.kind) { // Every selected instance's symbol (ADR 0053), or just this one's. diff --git a/src/prefs.rs b/src/prefs.rs index b1d531a1..6a8b493f 100644 --- a/src/prefs.rs +++ b/src/prefs.rs @@ -129,6 +129,9 @@ pub struct Prefs { pub timeline_start_gap: f32, /// Frame view › Short (ADR 0061): timeline rows at their short height. pub timeline_short_rows: bool, + /// How wide the timeline's layer column is, in points: the line between the layers and + /// the frames drags (#384). A narrow dock still takes what it needs for the frames. + pub timeline_layer_w: f32, /// Keyboard shortcuts the user changed: action id → its full list of keys (empty = /// unbound). Actions not listed keep their defaults (`keymap`). pub shortcuts: std::collections::BTreeMap>, @@ -151,6 +154,12 @@ pub struct Prefs { /// Brushes of your own (ADR 0068), for the Brush and the Paint Brush. #[serde(deserialize_with = "lenient_brushes")] pub brushes: anicraft_engine::brush_library::BrushLibrary, + /// The Brush's and the Paint Brush's settings as they were left (#331): size, tip, + /// smoothing, pressure and the rest come back with the next start. None until changed. + #[serde(deserialize_with = "lenient_brush")] + pub brush_tool: Option, + #[serde(deserialize_with = "lenient_brush")] + pub paint_brush_tool: Option, /// Filter presets of your own (ADR 0091), for movie clips and buttons in any document. #[serde(deserialize_with = "lenient_filter_presets")] pub filter_presets: anicraft_engine::filter_library::FilterLibrary, @@ -232,6 +241,7 @@ impl Default for Prefs { native_dialogs: true, timeline_start_gap: 0.0, timeline_short_rows: false, + timeline_layer_w: LAYER_W_DEFAULT, shortcuts: Default::default(), autosave: true, autosave_secs: 60, @@ -241,6 +251,8 @@ impl Default for Prefs { recent: Default::default(), start_screen: true, brushes: Default::default(), + brush_tool: None, + paint_brush_tool: None, filter_presets: Default::default(), filter_presets_hidden: Vec::new(), test_movie_window: true, @@ -268,6 +280,13 @@ fn lenient_recent<'de, D: serde::Deserializer<'de>>(d: D) -> Result(serde_json::to_value(good).unwrap_or_default()).unwrap_or_default()) } +/// A tool's brush settings as written, values clamped; anything that isn't settings is none +/// (a hand-edited file), and the tool starts with its defaults. +fn lenient_brush<'de, D: serde::Deserializer<'de>>(d: D) -> Result, D::Error> { + let v = serde_json::Value::deserialize(d)?; + Ok(serde_json::from_value::(v).ok().map(anicraft_engine::brush_library::BrushPreset::sanitized)) +} + /// Your brushes as written, skipping entries that aren't one (a hand-edited file). fn lenient_brushes<'de, D: serde::Deserializer<'de>>(d: D) -> Result { let v = serde_json::Value::deserialize(d)?; @@ -295,6 +314,10 @@ pub const AUTOSAVE_EDITS_RANGE: std::ops::RangeInclusive = 0..=1000; pub const SCALE_RANGE: std::ops::RangeInclusive = 0.75..=2.0; pub const GAP_RANGE: std::ops::RangeInclusive = 0.0..=48.0; +/// The timeline's layer column: its width until dragged, and how narrow and wide it goes (the +/// toggles stay whole at the narrowest; names are cut short). +pub const LAYER_W_DEFAULT: f32 = 252.0; +pub const LAYER_W_RANGE: std::ops::RangeInclusive = 150.0..=600.0; impl Prefs { /// Whether the theme follows the system ("Follow system", the default): its contrast setting @@ -330,6 +353,7 @@ impl Prefs { pub fn sanitized(mut self) -> Prefs { self.ui_scale = if self.ui_scale.is_finite() { self.ui_scale.clamp(*SCALE_RANGE.start(), *SCALE_RANGE.end()) } else { 1.0 }; self.timeline_start_gap = if self.timeline_start_gap.is_finite() { self.timeline_start_gap.clamp(*GAP_RANGE.start(), *GAP_RANGE.end()) } else { 0.0 }; + self.timeline_layer_w = if self.timeline_layer_w.is_finite() { self.timeline_layer_w.clamp(*LAYER_W_RANGE.start(), *LAYER_W_RANGE.end()) } else { LAYER_W_DEFAULT }; for f in [&mut self.ui_font, &mut self.data_font] { if let FontChoice::System(name) = f && (name.trim().is_empty() || name.len() > 256) diff --git a/src/timeline.rs b/src/timeline.rs index 37ed1f9b..e9f52dea 100644 --- a/src/timeline.rs +++ b/src/timeline.rs @@ -10,9 +10,8 @@ use egui::{Align2, Color32, Rect, Sense, Stroke, StrokeKind, WidgetType, pos2, v use serde_json::json; use std::sync::Arc; -const LAYER_W: f32 = 252.0; /// The narrowest the layer column goes, and the least room kept for frames beside it. -const MIN_LAYER_W: f32 = 150.0; +const MIN_LAYER_W: f32 = *crate::prefs::LAYER_W_RANGE.start(); const MIN_FRAMES_W: f32 = 40.0; /// Rows are click targets (≥ `theme::TARGET`). const ROW_H: f32 = TARGET; @@ -183,6 +182,73 @@ pub enum TlDrag { Span { layer: LayerId, start: u32, end: u32, to: u32 }, } +/// Where a layer dragged by its name lands (#407), as `layer.move` takes it. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum LayerDrop { + /// Just above this layer, beside it. + Before(LayerId), + /// Just below this layer and whatever it holds, beside it. + After(LayerId), + /// First inside this folder. + Into(LayerId), +} + +impl LayerDrop { + /// The `layer.move` parameters that put `layer` there. + pub fn params(self, layer: LayerId) -> serde_json::Value { + match self { + LayerDrop::Before(t) => json!({"layer": layer.0, "before": t.0}), + LayerDrop::After(t) => json!({"layer": layer.0, "after": t.0}), + LayerDrop::Into(t) => json!({"layer": layer.0, "into": t.0}), + } + } +} + +/// A layer row as somewhere to drop a dragged layer. +#[derive(Clone, Copy, Debug, PartialEq)] +pub struct DropRow { + pub top: f32, + pub bottom: f32, + pub id: LayerId, + pub folder: bool, + /// The row under this one, when it shows and is inside this layer (an open folder's first + /// layer, a mask's first masked layer). + pub first_child: Option, + /// The dragged layer itself, or a layer inside it: nowhere to drop. + pub dragged: bool, +} + +/// Where a layer dropped at height `y` over `rows` (top down) lands. The upper half of a row +/// is above it and the lower half below it; a folder's middle half is inside it. Below a row +/// that shows layers of its own is inside it, above the first of them. `None` over the dragged +/// layer's own rows, or with no rows at all. +pub fn layer_drop(rows: &[DropRow], y: f32) -> Option { + let first = rows.first()?; + let row = if y < first.top { first } else { rows.iter().find(|r| y < r.bottom).or(rows.last())? }; + if row.dragged { + return None; + } + let t = ((y - row.top) / (row.bottom - row.top).max(1.0)).clamp(0.0, 1.0); + let below = match row.first_child { + Some(_) if row.folder => LayerDrop::Into(row.id), + Some(c) => LayerDrop::Before(c), + None => LayerDrop::After(row.id), + }; + Some(if row.folder { + if t < 0.25 { + LayerDrop::Before(row.id) + } else if t > 0.75 { + below + } else { + LayerDrop::Into(row.id) + } + } else if t < 0.5 { + LayerDrop::Before(row.id) + } else { + below + }) +} + /// The motion tween span holding `frame` on `layer`, as a frame selection. fn whole_motion_span(layer: &Layer, frame: u32) -> Option { let k = layer.keyframe_at(frame).filter(|k| k.motion.is_some())?; @@ -394,7 +460,8 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) { // In a narrow dock (ADR 0087) the layer column gives up width to keep a strip of frames; // the layers' toggles stay whole and their names are cut short. - let layer_w = LAYER_W.min(body.width() - MIN_FRAMES_W).max(MIN_LAYER_W); + // Its width is the user's (the line between the layers and the frames drags, #384). + let layer_w = app.tl_layer_w_drag.unwrap_or(app.prefs.timeline_layer_w).min(body.width() - MIN_FRAMES_W).max(MIN_LAYER_W); let grid = Rect::from_min_max(pos2(body.left() + layer_w, body.top()), body.right_bottom()); let frames_total = app.s.frame_count(); app.tl_cell_w = app.tl_cell_w.clamp(*CELL_RANGE.start(), *CELL_RANGE.end()); @@ -499,6 +566,49 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) { painter.rect_filled(ruler, 0.0, T.panel_alt); painter.rect_filled(Rect::from_min_max(body.left_top(), pos2(grid.left(), ruler.bottom())), 0.0, T.panel_alt); painter.text(pos2(body.left() + 10.0, ruler.center().y), Align2::LEFT_CENTER, tr!("Layers"), font(Type::Heading), color(Type::Heading)); + // The eye, the padlock and the square above the columns they head show, lock or outline + // every layer at once, as in Animate (#422). Each shows its other face once every layer + // is that way, and the next click brings them all back. + { + let (all_hidden, all_locked, all_outline) = { + let tl = app.s.timeline(); + let plain = || tl.layers.iter().filter(|l| l.kind != LayerKind::Camera); + let any = plain().next().is_some(); + (any && plain().all(|l| !l.visible), any && plain().all(|l| l.locked), any && plain().all(|l| l.outline)) + }; + let side = TOGGLE.min(RULER_H); + let head = |k: f32| Rect::from_center_size(pos2(grid.left() - 16.0 - k * (TOGGLE + 2.0), ruler.center().y), vec2(side, side)); + let hover = ui.input(|inp| inp.pointer.hover_pos()); + for (k, id, salt, name, away) in [ + (2.0, "layer.toggle_visible", "eye", if all_hidden { tr!("Show all layers") } else { tr!("Hide all layers") }, all_hidden), + (1.0, "layer.toggle_lock", "lock", if all_locked { tr!("Unlock all layers") } else { tr!("Lock all layers") }, all_locked), + (0.0, "layer.toggle_outline", "outline", if all_outline { tr!("Show all layers as artwork") } else { tr!("Show all layers as outlines") }, all_outline), + ] { + let r = head(k); + if hover.is_some_and(|h| r.contains(h)) { + painter.rect_filled(r, T.rc(), T.hover); + } + let tint = if away { T.text } else { T.text_dim }; + let glyph = Rect::from_center_size(r.center(), vec2(15.0, 15.0)); + match salt { + "eye" => icons::paint(&painter, glyph, if away { Icon::EyeOff } else { Icon::Eye }, tint), + "lock" => icons::paint(&painter, glyph, if away { Icon::Lock } else { Icon::Unlock }, tint), + _ => { + let sq = Rect::from_center_size(r.center(), vec2(10.0, 10.0)); + if away { + painter.rect_stroke(sq, 0.0, Stroke::new(1.5, tint), StrokeKind::Inside); + } else { + painter.rect_filled(sq, 0.0, tint); + } + } + } + let rr = ui.interact(r, ui.id().with(("all_layers", salt)), Sense::click()); + a11y::control(ui, &rr, WidgetType::Button, name, None); + if rr.on_hover_text(name).clicked() { + app.run(id, json!({"all": true})); + } + } + } let step = [1u32, 2, 5, 10, 20, 50, 100, 200, 500].into_iter().find(|s| *s as f32 * cell_w >= 28.0).unwrap_or(1000); let minor = if cell_w >= 6.0 { 1 } else { step / 5 }.max(1); for f in first..first + visible_cols + 1 { @@ -666,7 +776,18 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) { painter.rect_filled(sw, 0.0, to_color32(layer.color)); } let name_rect = Rect::from_min_max(left.left_top(), pos2(attach_t.or(speaker).or(onion_t).unwrap_or(eye).left() - 4.0, left.bottom())); - let nr = ui.interact(name_rect, ui.id().with(("lname", layer.id.0)), Sense::click()); + // The name is the row's handle too: drag it to move the layer (#407). The camera stays + // on top. + let nr = ui.interact(name_rect, ui.id().with(("lname", layer.id.0)), if layer.kind == LayerKind::Camera { Sense::click() } else { Sense::click_and_drag() }); + if nr.drag_started_by(egui::PointerButton::Primary) && layer.kind != LayerKind::Camera { + app.tl_layer_drag = Some(layer.id); + if app.s.layer != layer.id { + app.run("layer.select", json!({"layer": layer.id.0})); + } + } + if app.tl_layer_drag == Some(layer.id) { + painter.rect_filled(left, 0.0, T.accent.gamma_multiply(0.18)); + } // Screen readers hear the row as a selectable item, "Ball · layer", then its toggles. let name = &layer.name; let row_name = match layer.kind { @@ -1234,6 +1355,113 @@ pub fn show(app: &mut App, ui: &mut egui::Ui) { }); painter.line_segment([row.left_bottom(), row.right_bottom()], Stroke::new(1.0, T.separator)); } + // A layer dragged by its name (#407): a line shows where it will land, a folder lights up + // when it goes inside. Released there it moves in one undo step; Esc, or a release away + // from the layers, leaves it where it was. + if let Some(dragged) = app.tl_layer_drag { + let (pointer, down, cancel) = ui.input(|i| (i.pointer.latest_pos(), i.pointer.primary_down(), i.key_pressed(egui::Key::Escape))); + let index_of = |id: LayerId| tl_now.layers.iter().position(|l| l.id == id); + let targets: Vec = drop_rows + .iter() + .enumerate() + .filter_map(|(n, (rect, id))| { + let i = index_of(*id)?; + let next = drop_rows.get(n + 1).map(|(_, c)| *c); + Some(DropRow { + top: rect.top(), + bottom: rect.bottom(), + id: *id, + folder: tl_now.layers.get(i).is_some_and(|l| l.kind == LayerKind::Folder), + first_child: next.filter(|c| index_of(*c).is_some_and(|ci| tl_now.is_inside(ci, *id))), + dragged: *id == dragged || tl_now.is_inside(i, dragged), + }) + }) + .collect(); + let over = pointer.filter(|p| p.x >= body.left() && p.x < grid.left() && p.y >= ruler.top() && p.y <= body.bottom()); + let target = over.and_then(|p| layer_drop(&targets, p.y)); + if cancel || index_of(dragged).is_none() { + app.tl_layer_drag = None; + } else if !down { + app.tl_layer_drag = None; + if let Some(t) = target { + app.run("layer.move", t.params(dragged)); + } + } else { + ui.ctx().set_cursor_icon(if target.is_some() { egui::CursorIcon::Grabbing } else { egui::CursorIcon::NoDrop }); + let row_of = |id: LayerId| targets.iter().find(|r| r.id == id); + let indent = |id: LayerId| body.left() + 8.0 + index_of(id).map_or(0, |i| tl_now.depth(i)) as f32 * INDENT; + let line = |x: f32, y: f32| { + let y = y.clamp(rows_top + 1.0, rows_bottom - 1.0); + painter.circle_filled(pos2(x, y), 3.0, T.accent); + painter.line_segment([pos2(x, y), pos2(grid.left(), y)], Stroke::new(2.0, T.accent)); + }; + match target { + Some(LayerDrop::Before(id)) => { + if let Some(r) = row_of(id) { + line(indent(id), r.top); + } + } + Some(LayerDrop::After(id)) => { + if let Some(r) = row_of(id) { + line(indent(id), r.bottom); + } + } + Some(LayerDrop::Into(id)) => { + if let Some(r) = row_of(id) { + painter.rect_stroke(Rect::from_min_max(pos2(body.left(), r.top), pos2(grid.left(), r.bottom)), 0.0, Stroke::new(2.0, T.accent), StrokeKind::Inside); + } + } + None => {} + } + // Near the top or bottom edge the list scrolls, so any row can be reached. + if let Some(p) = over { + let edge = base_h * 0.5; + if p.y < rows_top + edge { + app.tl_vscroll = (app.tl_vscroll - 0.15).max(0.0); + } else if p.y > rows_bottom - edge { + app.tl_vscroll += 0.15; + } + } + ui.ctx().request_repaint(); + } + } + + // The line between the layers and the frames drags (#384): narrower gives the frames more + // room, as in Animate; a double-click puts it back. Kept in the preferences. + { + let split = Rect::from_min_max(pos2(grid.left() - 2.0, body.top()), pos2(grid.left() + 3.0, rows_bottom)); + let sid = ui.id().with("layer_column_split"); + let sr = ui.interact(split, sid, Sense::click_and_drag()); + ui.ctx().accesskit_node_builder(sid, |node| { + node.set_role(egui::accesskit::Role::Splitter); + node.set_label(tr!("Resize the layer names and the frames")); + }); + if (sr.hovered() || sr.dragged()) && app.tl_layer_drag.is_none() { + ui.ctx().set_cursor_icon(egui::CursorIcon::ResizeHorizontal); + painter.rect_filled(Rect::from_center_size(pos2(grid.left(), split.center().y), vec2(2.0, split.height())), 0.0, T.accent); + } + let range = crate::prefs::LAYER_W_RANGE; + if sr.dragged() + && let Some(p) = sr.interact_pointer_pos() + { + app.tl_layer_w_drag = Some((p.x - body.left()).clamp(*range.start(), *range.end())); + } + let set = if sr.double_clicked() { + app.tl_layer_w_drag = None; + Some(crate::prefs::LAYER_W_DEFAULT) + } else if sr.drag_stopped() { + app.tl_layer_w_drag.take() + } else { + None + }; + if let Some(w) = set.filter(|w| (*w - app.prefs.timeline_layer_w).abs() > 0.01) { + let mut p = app.prefs.clone(); + p.timeline_layer_w = w; + let ctx = ui.ctx().clone(); + app.set_prefs(&ctx, p); + } + } + // Layout lines: layer list | frame grid, and the header above. painter.line_segment([pos2(grid.left(), body.top()), pos2(grid.left(), body.bottom())], Stroke::new(1.0, T.border)); painter.line_segment([body.left_top(), body.right_top()], Stroke::new(1.0, T.border));