A column of HUD instruments the reader can put away one at a time. More...
| Import Statement: | import Clayground.Lab |
A lab decides per instrument whether it belongs in the world - a dial printed on the part it measures - or on the HUD. The ones on the HUD go in a dock, and the reader may put any of them away: the panel folds and its name appears as a chip in a slim tray at the foot of the dock, which offers it back. Which instruments are essential is a per-lab call, so the kernel provides the mechanics and the lab declares the set.
The visible set rides in viewState(), so a lab that merges it into its own comes back after a reload showing exactly the instruments the reader had out. Declare the children as DockedInstrument; anything else in the dock is stacked but never hidable.
Example usage:
import Clayground.Lab InstrumentDock { id: dock anchors.left: parent.left anchors.top: parent.top anchors.margins: LabTheme.spaceXl itemWidth: LabTheme.px(220) DockedInstrument { key: "volts"; label: LabLang.t("inst.volts") Gauge { width: parent.width; height: LabTheme.px(112); scale: voltScale } } DockedInstrument { key: "level"; label: LabLang.t("inst.level") BarFace { width: parent.width; scale: levelScale; segments: 20 } } }
In the lab's conventions block:
function viewState() {
return Object.assign(Lab.viewState(), { dock: dock.viewState() })
}
function applyViewState(s) {
if (!s) return
dock.applyViewState(s.dock)
Lab.applyViewState(s.lab)
}
See also DockedInstrument, InstrumentScale, and LabPanel.
content : Item |
The docked instruments (the default property).
The keys currently put away, in the order they were dismissed.
Assignable, so a scenario or a flow can stage the dock. viewState() carries it.
isInstrumentDock : bool |
Marker a DockedInstrument finds its dock by.
itemWidth : real |
Width every docked instrument takes.
revision : int |
Bumps whenever an instrument registers.
showTray : bool |
Offer the put-away instruments back.
spacing : int |
Gap between stacked instruments.
changed() |
The visible set changed.
Note: The corresponding handler is onChanged.
void applyViewState(var s) |
void hide(string key) |
Folds an instrument into the tray.
bool isShown(string key) |
var keys() |
Every declared instrument key, in dock order.
string labelOf(string key) |
The declared caption of an instrument, for the tray chip.
void show(string key) |
Takes it back out.
void showAll() |
Empties the tray.
void toggle(string key) |
var viewState() |
{ hidden: [...] }.