Vixen
dd8b0a81
csharp
public sealed class CurvePresetLibrary

The curves somebody has kept, which travel with the person rather than with the project.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

⚠ Doc 20 § B5 decided where this goes and the decision is worth keeping: a library of saved presets is a user-store file rather than an editor surface — it belongs beside the layouts and the keymap, not in an asset editor. The consequence is the point of saying it: presets are not project assets, get no importer, and do not travel with the repository. A team-shared library is a different feature and must not be smuggled in by making this one an asset.

⚠ The shipped shapes are defaults rather than entries, which is what Shipped is for. A store seeded with linear and the three eases is one where deleting a built-in is a thing that can happen and cannot be undone — so they are offered by this class and never written to the file. An emptied store still offers them.

⚠ Curves only, and the gradient half of that doc row is refused rather than forgotten. GradientEditor has no caller anywhere in the editor — no drawer, no asset editor, no panel; the only uses in the tree are its own tests and the sample gallery — so a gradient preset library would be a library with nothing to apply a preset to, which is this repository's commonest defect written down deliberately. The curve control, by contrast, is a drawer in the inspector and is in two AI asset editors.

⚠ That refusal was already written down before this file existed, and the record is the thing to read rather than re-derive. Core/Vixen.Ui.Controls.Advanced/README.md § GradientEditor gives three reasons that are all outside the control — no gradient asset, doc 48's predicted consumer shipped taking a texture name, and the obvious host does not reference the controls assembly — and docs/overview.md §1.7 carries the same sentence. #1147 re-found the sweep and asked for a record that was already there, which is worth knowing: a *.cs plus *.vxml sweep answers "is it called" and not "was this decided".

⚠ The three panes that edit a curve without a row do not offer these yet, and the two things stopping them are both measured rather than assumed. Ai/QueryView, Ai/UtilitySetView and Animation/AnimationClipView hold a CurveEditor directly, so they never pass through the InspectorRow the menu lines are attached to. First, they cannot see this type: the project reference runs Vixen.Editor.App → Vixen.Editor.AssetEditors, so offering the presets there means moving the library down to Vixen.Editor.Core and giving the views a seam to reach the instance. Second — and this is the part that rules out the cheap workaround — a context menu attached from the host would be competing with the control's own gesture: CurveEditor.Begin takes a Secondary press as a pan and captures the pointer for it, and Pointed marks every press handled. So the surface has to be a control beside the curve, in the view, which is why this is #1148's second half rather than three lines here.

Fields and properties (2)

  • public List<CurvePreset> Curves

    What the user has saved, in the order they saved it.

  • public static IReadOnlyList<(string Name, AnimationCurve Curve)> Shipped

    The shapes the editor always offers, whatever the file holds.

Methods (4)

  • public IReadOnlyList<(string Name, AnimationCurve Curve)> Offered()

    Every shape on offer: the shipped ones first, then what the user saved.

  • public void Save(string name, AnimationCurve curve)

    Keeps a curve under a name, replacing one of that name.

  • public bool Forget(string name)

    Forgets a saved curve.

  • public static AnimationCurve ToCurve(CurvePreset preset)

    Reads a saved curve back as something a control can be given.

Used by (4)

  • CurvePresetTestsVixen.Editor.App.Tests
  • EditorApplicationVixen.Editor.App
  • EditorSessionVixen.Editor.Testing
  • TypeRegistrationVixen.Editor.App