Make GUI instance properties and methods accessible (#345)

This commit is contained in:
Nigel Fletton
2024-06-23 18:39:46 -03:00
committed by GitHub
parent e58322768d
commit b7ee7dcf79

View File

@@ -16,8 +16,10 @@ class WindowedGUI(
val windowAlwaysOntop: Boolean = false, val windowAlwaysOntop: Boolean = false,
) : Extension { ) : Extension {
override var enabled: Boolean = true override var enabled: Boolean = true
val gui: GUI = GUI(appearance, defaultStyles)
private val addedObjects = mutableListOf<Pair<Any, String?>>() private val addedObjects = mutableListOf<Pair<Any, String?>>()
fun <T : Any> add(objectWithParameters: T, label: String? = objectWithParameters.title()): T { fun <T : Any> add(objectWithParameters: T, label: String? = objectWithParameters.title()): T {
addedObjects.add(Pair(objectWithParameters, label)) addedObjects.add(Pair(objectWithParameters, label))
return objectWithParameters return objectWithParameters
@@ -58,9 +60,8 @@ class WindowedGUI(
// launch because at this stage Driver.instance.contextID points to the context of the parent window // launch because at this stage Driver.instance.contextID points to the context of the parent window
cw.program.launch { cw.program.launch {
val gui = GUI(appearance, defaultStyles) for ((obj, label) in addedObjects) {
for (o in addedObjects) { gui.add(obj, label)
gui.add(o.first, o.second)
} }
cw.program.extend(gui) cw.program.extend(gui)
program.produceAssets.listen { program.produceAssets.listen {