[orx-gui] Fix compatibility with updated openndr-dialog api
This commit is contained in:
@@ -27,7 +27,7 @@ import kotlin.reflect.KMutableProperty1
|
|||||||
There is a 6-step incantation to add a new parameter type
|
There is a 6-step incantation to add a new parameter type
|
||||||
0) Add your parameter type to orx-parameters, follow the instructions provided there.
|
0) Add your parameter type to orx-parameters, follow the instructions provided there.
|
||||||
|
|
||||||
1) Setup a control style, very likely analogous to the styles already in place.
|
1) Set up a control style, very likely analogous to the styles already in place.
|
||||||
2) Add control creation code.
|
2) Add control creation code.
|
||||||
3) Add value serialization code, may need to update ParameterValue too.
|
3) Add value serialization code, may need to update ParameterValue too.
|
||||||
4) Add value deserialization code.
|
4) Add value deserialization code.
|
||||||
@@ -112,7 +112,7 @@ class GUI(
|
|||||||
|
|
||||||
// Randomize button
|
// Randomize button
|
||||||
private var shiftDown = false
|
private var shiftDown = false
|
||||||
private var randomizeButton: Button? = null // FIXME should this be null or is there a better way?
|
private var randomizeButton: Button? = null
|
||||||
|
|
||||||
fun onChange(listener: (name: String, value: Any?) -> Unit) {
|
fun onChange(listener: (name: String, value: Any?) -> Unit) {
|
||||||
onChangeListener = listener
|
onChangeListener = listener
|
||||||
@@ -295,7 +295,7 @@ class GUI(
|
|||||||
label = "Load"
|
label = "Load"
|
||||||
clicked {
|
clicked {
|
||||||
openFileDialog(
|
openFileDialog(
|
||||||
supportedExtensions = listOf("json"),
|
supportedExtensions = listOf("GUI parameters" to listOf("json")),
|
||||||
contextID = "gui.parameters"
|
contextID = "gui.parameters"
|
||||||
) {
|
) {
|
||||||
loadParameters(it)
|
loadParameters(it)
|
||||||
@@ -330,7 +330,7 @@ class GUI(
|
|||||||
saveFileDialog(
|
saveFileDialog(
|
||||||
suggestedFilename = "parameters.json",
|
suggestedFilename = "parameters.json",
|
||||||
contextID = "gui.parameters",
|
contextID = "gui.parameters",
|
||||||
supportedExtensions = listOf("json")
|
supportedExtensions = listOf("GUI parameters" to listOf("json"))
|
||||||
) {
|
) {
|
||||||
saveParameters(it)
|
saveParameters(it)
|
||||||
}
|
}
|
||||||
@@ -455,7 +455,7 @@ class GUI(
|
|||||||
compartment.label,
|
compartment.label,
|
||||||
parameter.property as KMutableProperty1<Any, Int>,
|
parameter.property as KMutableProperty1<Any, Int>,
|
||||||
obj
|
obj
|
||||||
)?.let {
|
).let {
|
||||||
value = it.toDouble()
|
value = it.toDouble()
|
||||||
setAndPersist(compartment.label, parameter.property as KMutableProperty1<Any, Int>, obj, it)
|
setAndPersist(compartment.label, parameter.property as KMutableProperty1<Any, Int>, obj, it)
|
||||||
}
|
}
|
||||||
@@ -480,7 +480,7 @@ class GUI(
|
|||||||
compartment.label,
|
compartment.label,
|
||||||
parameter.property as KMutableProperty1<Any, Double>,
|
parameter.property as KMutableProperty1<Any, Double>,
|
||||||
obj
|
obj
|
||||||
)?.let {
|
).let {
|
||||||
value = it
|
value = it
|
||||||
/* this is generally not needed, but when the persisted value is equal to the slider default
|
/* this is generally not needed, but when the persisted value is equal to the slider default
|
||||||
it will not emit the newly set value */
|
it will not emit the newly set value */
|
||||||
@@ -517,7 +517,7 @@ class GUI(
|
|||||||
compartment.label,
|
compartment.label,
|
||||||
parameter.property as KMutableProperty1<Any, Boolean>,
|
parameter.property as KMutableProperty1<Any, Boolean>,
|
||||||
obj
|
obj
|
||||||
)?.let {
|
).let {
|
||||||
value = it
|
value = it
|
||||||
setAndPersist(compartment.label, parameter.property as KMutableProperty1<Any, Boolean>, obj, it)
|
setAndPersist(compartment.label, parameter.property as KMutableProperty1<Any, Boolean>, obj, it)
|
||||||
}
|
}
|
||||||
@@ -540,7 +540,7 @@ class GUI(
|
|||||||
compartment.label,
|
compartment.label,
|
||||||
parameter.property as KMutableProperty1<Any, String>,
|
parameter.property as KMutableProperty1<Any, String>,
|
||||||
obj
|
obj
|
||||||
)?.let {
|
).let {
|
||||||
value = it
|
value = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -562,7 +562,7 @@ class GUI(
|
|||||||
compartment.label,
|
compartment.label,
|
||||||
parameter.property as KMutableProperty1<Any, ColorRGBa>,
|
parameter.property as KMutableProperty1<Any, ColorRGBa>,
|
||||||
obj
|
obj
|
||||||
)?.let {
|
).let {
|
||||||
color = it
|
color = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -598,7 +598,7 @@ class GUI(
|
|||||||
|
|
||||||
if (parameter.pathIsDirectory == false) {
|
if (parameter.pathIsDirectory == false) {
|
||||||
openFileDialog(
|
openFileDialog(
|
||||||
supportedExtensions = parameter.pathExtensions?.toList() ?: emptyList(),
|
supportedExtensions = parameter.pathExtensions?.let { listOf("supported extensions" to it.toList())} ?: emptyList(),
|
||||||
contextID = parameter.pathContext ?: "null"
|
contextID = parameter.pathContext ?: "null"
|
||||||
) {
|
) {
|
||||||
val resolvedPath = if (parameter.absolutePath == true) {
|
val resolvedPath = if (parameter.absolutePath == true) {
|
||||||
@@ -653,7 +653,7 @@ class GUI(
|
|||||||
compartment.label,
|
compartment.label,
|
||||||
parameter.property as KMutableProperty1<Any, MutableList<Double>>,
|
parameter.property as KMutableProperty1<Any, MutableList<Double>>,
|
||||||
obj
|
obj
|
||||||
)?.let {
|
).let {
|
||||||
value = it
|
value = it
|
||||||
setAndPersist(
|
setAndPersist(
|
||||||
compartment.label,
|
compartment.label,
|
||||||
@@ -685,7 +685,7 @@ class GUI(
|
|||||||
compartment.label,
|
compartment.label,
|
||||||
parameter.property as KMutableProperty1<Any, Vector2>,
|
parameter.property as KMutableProperty1<Any, Vector2>,
|
||||||
obj
|
obj
|
||||||
)?.let {
|
).let {
|
||||||
value = it
|
value = it
|
||||||
setAndPersist(compartment.label, parameter.property as KMutableProperty1<Any, Vector2>, obj, it)
|
setAndPersist(compartment.label, parameter.property as KMutableProperty1<Any, Vector2>, obj, it)
|
||||||
}
|
}
|
||||||
@@ -712,7 +712,7 @@ class GUI(
|
|||||||
compartment.label,
|
compartment.label,
|
||||||
parameter.property as KMutableProperty1<Any, Vector3>,
|
parameter.property as KMutableProperty1<Any, Vector3>,
|
||||||
obj
|
obj
|
||||||
)?.let {
|
).let {
|
||||||
value = it
|
value = it
|
||||||
setAndPersist(compartment.label, parameter.property as KMutableProperty1<Any, Vector3>, obj, it)
|
setAndPersist(compartment.label, parameter.property as KMutableProperty1<Any, Vector3>, obj, it)
|
||||||
}
|
}
|
||||||
@@ -739,7 +739,7 @@ class GUI(
|
|||||||
compartment.label,
|
compartment.label,
|
||||||
parameter.property as KMutableProperty1<Any, Vector4>,
|
parameter.property as KMutableProperty1<Any, Vector4>,
|
||||||
obj
|
obj
|
||||||
)?.let {
|
).let {
|
||||||
value = it
|
value = it
|
||||||
setAndPersist(compartment.label, parameter.property as KMutableProperty1<Any, Vector4>, obj, it)
|
setAndPersist(compartment.label, parameter.property as KMutableProperty1<Any, Vector4>, obj, it)
|
||||||
}
|
}
|
||||||
@@ -779,7 +779,7 @@ class GUI(
|
|||||||
compartment.label,
|
compartment.label,
|
||||||
parameter.property as KMutableProperty1<Any, Enum<*>>,
|
parameter.property as KMutableProperty1<Any, Enum<*>>,
|
||||||
obj
|
obj
|
||||||
)?.let { enum ->
|
).let { enum ->
|
||||||
(this@dropdownButton).value = items().find { item -> item.data == enum }
|
(this@dropdownButton).value = items().find { item -> item.data == enum }
|
||||||
?: error("no matching item found")
|
?: error("no matching item found")
|
||||||
setAndPersist(
|
setAndPersist(
|
||||||
@@ -985,7 +985,7 @@ class GUI(
|
|||||||
Gson().fromJson(json, typeToken.type)
|
Gson().fromJson(json, typeToken.type)
|
||||||
} catch (e: JsonSyntaxException) {
|
} catch (e: JsonSyntaxException) {
|
||||||
println("could not parse json: $json")
|
println("could not parse json: $json")
|
||||||
throw e;
|
throw e
|
||||||
}
|
}
|
||||||
|
|
||||||
fromObject(labeledValues)
|
fromObject(labeledValues)
|
||||||
|
|||||||
Reference in New Issue
Block a user