Builtin Library
README.md
edui.inspector.settingsSection
The Settings section: every field of ctx.schema as its typed control (a
dropdown for an enum, a ranged number, a toggle, a colour, a vector, an asset
chip, a nested group for a struct or settingsOf, an editable list), in the
order the schema declares them, with ctx.settings as the values and
ctx.setSettings as the one write. A field's last rejected edit shows its
message beneath it.
local SettingsSection = require("@builtin::editor.edui.inspector.settingsSection")
local Inspector = require("@builtin::editor.edui.inspector")
local ctx = Inspector.valuesContext{
subject = "my-values", schema = schema, values = values,
write = function(patch) --[[ store the checked patch ]] end,
selection = { scope = "asset", id = "my-values" },
}
local nodes = SettingsSection.build(ctx)
build(ctx) reads only ctx.schema, ctx.schemaProblem, ctx.settings,
ctx.setSettings, ctx.rejected, ctx.widgets and ctx.keyPrefix, so any
source of values renders through it: an asset's settings.yaml, a component's
live values, a preset's stored values.
Actions
SettingsSection.ACTIONS is the list of buttons offered beneath the fields:
{ id, label, applies(ctx) -> boolean, run(ctx), panel?(ctx) -> { node }? }.
Every action whose applies(ctx) is true renders, in list order, with the
callback key <ctx.keyPrefix>:setact:<id>; while an action is open its
panel(ctx) returns the nodes shown beneath the row (a name field, a list to
pick from). Appending an entry offers that action on every Settings section.
It ships with:
reset("Reset to defaults") — writes every declared default throughctx.setSettings.saveAsPreset("Save as preset") — a name field and Save: captures the values as a preset targeting their declarer (preset.capture) and selects it.applyPreset("Apply preset…") — lists the presets whose target is this subject's declarer; picking one applies it as one undo step.
The two preset actions are edui.inspector.presetActions; they apply to an
asset's Settings section and to a component card's.
A Context whose actions is set offers only the actions it names:
actions = {} offers none, which is what a preset's own values use.
SettingsSection.release(keyPrefix) forgets what the actions keep under a
Context's key prefix.