mirror of
https://github.com/storytold/AniCraft.git
synced 2026-11-23 02:52:06 +01:00
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)
This commit is contained in:
1 parent
afe700b4df
commit
feda02ade4
12 files changed
+663
-12
No files matched your search
@@ -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.
|
||||
|
||||
@@ -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 |
|
||||
|---|---|---|
|
||||
|
||||
@@ -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
|
||||
|
||||
+15
-3
@@ -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
|
||||
|
||||
+1
-1
@@ -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 (`<mask>` 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 `<g opacity>`. **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 boLine truncated
|
||||
| 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 onLine truncated
|
||||
| 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 tLine truncated
|
||||
| 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 Line truncated
|
||||
| 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 `<settings>/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 <id>` 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`, `tLine truncated
|
||||
|
||||
+10
@@ -482,6 +482,11 @@ pub struct App {
|
||||
/// Selected frames on the timeline, and the drag on the frame grid.
|
||||
pub frame_sel: Option<timeline::FrameSel>,
|
||||
pub tl_drag: timeline::TlDrag,
|
||||
/// The layer being dragged by its name to another place in the stack (#407).
|
||||
pub tl_layer_drag: Option<anicraft_engine::doc::LayerId>,
|
||||
/// The layer column's width while its edge is dragged (#384); the preference takes it on
|
||||
/// release.
|
||||
pub tl_layer_w_drag: Option<f32>,
|
||||
/// 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());
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<Event>) {
|
||||
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<String> {
|
||||
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());
|
||||
}
|
||||
@@ -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;
|
||||
+38
-1
@@ -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<f32> = 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.
|
||||
|
||||
@@ -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<String, Vec<String>>,
|
||||
@@ -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<anicraft_engine::brush_library::BrushPreset>,
|
||||
#[serde(deserialize_with = "lenient_brush")]
|
||||
pub paint_brush_tool: Option<anicraft_engine::brush_library::BrushPreset>,
|
||||
/// 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<anicraft_eng
|
||||
Ok(serde_json::from_value::<RecentFiles>(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<Option<anicraft_engine::brush_library::BrushPreset>, D::Error> {
|
||||
let v = serde_json::Value::deserialize(d)?;
|
||||
Ok(serde_json::from_value::<anicraft_engine::brush_library::BrushPreset>(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<anicraft_engine::brush_library::BrushLibrary, D::Error> {
|
||||
let v = serde_json::Value::deserialize(d)?;
|
||||
@@ -295,6 +314,10 @@ pub const AUTOSAVE_EDITS_RANGE: std::ops::RangeInclusive<u32> = 0..=1000;
|
||||
|
||||
pub const SCALE_RANGE: std::ops::RangeInclusive<f32> = 0.75..=2.0;
|
||||
pub const GAP_RANGE: std::ops::RangeInclusive<f32> = 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<f32> = 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)
|
||||
|
||||
+232
-4
@@ -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<LayerId>,
|
||||
/// 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<LayerDrop> {
|
||||
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<FrameSel> {
|
||||
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<DropRow> = 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));
|
||||
|
||||
Reference in new issue
Block a user