Canvas overrides
A canvas override adds to a tab's record canvas what the core cannot see: nodes, edges, column positions and display names. A code registry puts reference targets that live in code into the Data Studio and the web app. Both are opt-in.
What an override adds
The record canvas decides what to draw on its own. You open a record, the terminus. The canvas walks the reference index outward and collects everything that record consumes. It then lays the result out left to right. That works with no plugin at all.
A plugin adds what the core cannot see or cannot know:
- An identity that is not a sheet record.
- A link that is not written in a
RecordId@Tabcolumn. - An order that is domain rule rather than reference depth.
Register an override
Implement IRecordCanvasAugmenter and register it per tab through ISheetForgeGraphPlugin.
using SheetForge.Core.Graphing;
using SheetForge.Core.Plugins;
public sealed class SkillsPlugin : /* ... */, ISheetForgeGraphPlugin
{
public void RegisterGraphShapes(GraphShapeRegistry shapes)
{
shapes.Register("ExampleActions", new ExampleReactiveAugmenter()); // tab name → override
}
}
public sealed class ExampleReactiveAugmenter : IRecordCanvasAugmenter
{
public void Augment(GraphBuildContext context, CanvasAugmentBuilder builder,
string terminusTab, string terminusRecordId)
{
// context = Tables (parsed sheets) · References (indexed both ways) · CodeRegistries
// ① A virtual node: an identity that is not a sheet record. The tab may be empty —
// then the key alone identifies it. The last argument is where clicking it jumps.
builder.AddNode(string.Empty, "evt:impact_landed", "impact_landed", "event");
// ② An extra edge the core scanner cannot see (this link lives in a plain string column).
// Naming the field says *which cell* it is written in; leaving it out keeps the wire
// display-only. Direction is "A uses B", and B is drawn to the left of A.
builder.AddEdge(terminusTab, terminusRecordId, string.Empty, "evt:impact_landed",
/*label*/ "listen", /*fieldName*/ "listen");
// ②b An edge drawn one way whose cell lives on the other end, and a loop you know about.
// Both are trailing arguments — the short call above still compiles unchanged.
builder.AddEdge(string.Empty, "evt:impact_landed", terminusTab, terminusRecordId,
label: "raises", fieldName: "raises", fieldOnTarget: true,
isCyclic: true, cyclicNote: "brake 0s — no damping");
// ③ A layer hint. Absolute columns count from 0 at the left (negative goes further left);
// relative columns count from the terminus, which is what a fixed stage usually means.
builder.SetLayerRelative(string.Empty, "evt:impact_landed", -2);
// ④ A display hint: what a human calls this record. Only you know which column is a name.
builder.SetSubtitle(terminusTab, terminusRecordId, "Counter strike");
}
}The plugin demo holds two complete overrides.
| File | What it shows |
|---|---|
Assets/SheetForge.PluginDemo/Graphing/ExampleReactiveAugmenter.cs | A reaction that grows event nodes and a code block around the record |
ExamplePipelineAugmenter.cs, in the same folder | A cast whose fixed stages are pinned to their own columns |
Registration rules
Registration is per tab name. A tab you do not register still gets a canvas with the records the core collects on its own, so a plugin never has to cover every sheet.
A duplicate tab, an empty tab name and a null override are rejected. Register throws, and the rejection is surfaced as a PluginRegistrationConflict.
Add virtual nodes
AddNode adds a virtual node. An override adds and does not replace, because the core decides which records appear.
A virtual node whose (tab, key) is already on screen is dropped. The real record wins, so an override cannot invent a record that exists in a sheet. What it can do is bring in identities that have no sheet row at all.
Add edges
AddEdge adds an edge, and an edge brings its own node. If one end of an extra edge is not on screen, that end is added as a node, so the link never dangles.
An edge with an empty key on either end is ignored.
Cell position and arrow direction
Where the cell is and where the arrow points may differ. By default, the cell named by fieldName is assumed to sit on the departure record.
When the cell sits on the arrival record instead, pass fieldOnTarget: true. A published-event wire, for example, is drawn event → record, but its text is in the record's own column. With fieldOnTarget: true, the wire inspector points at the real cell rather than nothing.
Cycles
The core marks the cycles it can see. You declare the ones you know.
If your extra edges close a loop, the canvas classifies the back edge and draws it dashed on its own. Two arguments cover what the canvas cannot work out.
| Argument | Effect |
|---|---|
isCyclic | Marks a wire as a cycle for display, without touching the layout |
cyclicNote | Carries what only you know, such as a damping value |
Keep the label the column name and put the explanation in the note.
Judging whether a cycle is a problem is a domain validator's job, because the canvas only displays and never validates. See Add a domain validator.
Set layer hints
A layer hint places a node in a column. Layer hints come in two kinds.
| Method | How it counts |
|---|---|
SetLayer | Absolute. Column 0 is leftmost, and negatives go further left |
SetLayerRelative | From the terminus. −1 is the column immediately left of it |
SetLayerRelative is usually what a fixed stage means. The picture then reads the same whether the chain is shallow or deep. You do not have to pin the terminus itself to keep the stages from colliding.
These rules decide the result:
- Relative hints resolve against the terminus column before any hint moved it. The order you add hints in cannot change the result.
- If the result goes left of zero, the whole picture shifts right.
- A hint for a node that is not on screen is dropped.
- The first hint for a node wins.
Set display names
SetSubtitle sets a display hint: what a human calls a record. Names are the one exception to the rule that an override only adds. A display hint is presentation rather than identity, so it does apply to records that already exist.
A display hint may also name records that are not on screen at all. The connect picker reads those names. That is why a card's subtitle and a picker row say the same thing.
- Blank names are ignored. A blank name is the same as "use the default".
- The first name for a record wins.
Failures and compatibility
Augment runs inside try/catch, so a failure stays inside your override. An exception becomes an English console warning, and the canvas draws the core picture instead of a broken window.
Later additions to this surface do not break an existing override. Every capability added since the first release is a trailing argument or a new method, so an override written against the earlier surface compiles and behaves identically.
Code registries
Some reference targets are not authored in a sheet at all, such as the actions your runtime code dispatches to. Registering them as a locked virtual tab puts them in the Data Studio and the web app read-only. It also stops edges that point at them from being drawn as broken.
Implement ISheetForgeCodeRegistryPlugin.
using System.Collections.Generic;
using SheetForge.Core.Graphing;
using SheetForge.Core.Plugins;
public sealed class SkillsPlugin : /* ... */, ISheetForgeCodeRegistryPlugin
{
public void RegisterCodeRegistries(CodeRegistryCatalog catalog)
{
catalog.Register(new CodeRegistrySource("_Refs", new List<CodeRegistryEntry>
{
// key = the referenceable id · label = shown text · raises = optional related keys
new CodeRegistryEntry("action.projectile", "Projectile launch", new[] { "impact_landed" }),
new CodeRegistryEntry("effect.script", "Script effect", null),
}));
}
}The demo's registry is in Assets/SheetForge.PluginDemo/Graphing/ExampleCodeAtoms.cs.
Where the entries appear
A code registry has three consumption points.
| Place | What it does with the entries |
|---|---|
| Data Studio sidebar | Shows the virtual tab under Code (code badge, key count) as a read-only grid with the columns key, label and raises |
| Canvas override | Can look the entries up through context.CodeRegistries |
| Node inspector | Lists an entry's Raises |
The Data Studio also counts the keys as existing reference targets, so an edge whose target is a registered key is not painted as a broken reference. An IEdgeContributor typically declares such an edge, or your canvas override adds it. See Add an edge contributor.
Sheet columns and virtual tabs
The import validator does not know virtual tabs. Code registries exist only in the Data Studio and the web app.
Do not type a sheet column as RecordId@_Refs. The import would report UnknownTargetTab.
Connect sheet data to registered code entries the way the demo does: a type column plus an edge contributor or a lookup in your canvas override.
Virtual tab names
Pick a name that cannot collide with a real sheet. The demo prefixes its name with _.
If a name does collide, the Studio badges the clash in the sidebar rather than silently hiding either tab.
Rejected registrations
A null source, an empty tab name, or a duplicate tab name throws. The rejection is surfaced as a PluginRegistrationConflict.
A null Raises list is normalized to empty.
Core treats the key, the label and the raises list as opaque strings. It never interprets them.
Next steps
- Canvas editing contracts
Let people create records and connect wires on the canvas.
- Studio extensions
Add graph widgets, inspector actions and cell widgets.
- Validators and edges
Declare edges the core scanner cannot see and add domain rules.
- The record canvas
How the canvas draws a record and what it consumes.