Add OptionParameter

Closes #78
This commit is contained in:
Edwin Jakobs
2020-04-14 20:43:26 +02:00
parent a0fd51c3c2
commit 591dccda63
6 changed files with 126 additions and 15 deletions

View File

@@ -22,6 +22,16 @@ import kotlin.reflect.full.memberProperties
@Retention(AnnotationRetention.RUNTIME)
annotation class Description(val title: String, val description: String = "")
/**
* OptionParameter annotation for a double precision parameter
* @property label a short description of the parameter
* @property order hint for where to place the parameter in user interfaces
*/
@Target(AnnotationTarget.PROPERTY)
@Retention(AnnotationRetention.RUNTIME)
annotation class OptionParameter(val label: String, val order: Int = Integer.MAX_VALUE)
/**
* DoubleParameter annotation for a double precision parameter
* @property label a short description of the parameter
@@ -167,7 +177,8 @@ enum class ParameterType(val annotationClass: KClass<out Annotation>) {
DoubleList(DoubleListParameter::class),
Vector2(Vector2Parameter::class),
Vector3(Vector3Parameter::class),
Vector4(Vector4Parameter::class)
Vector4(Vector4Parameter::class),
Option(OptionParameter::class)
;
companion object {
@@ -204,6 +215,7 @@ class Parameter(
val precision: Int?,
val invertY: Boolean?,
val showVector: Boolean?,
// val optionEnum: Enum<*>,
val order: Int)
//</editor-fold>
//<editor-fold desc="4. Add handling annotation code to listParameters" defaultstate="collapsed">
@@ -288,6 +300,10 @@ fun Any.listParameters(): List<Parameter> {
doubleRange = it.min..it.max
precision = it.precision
}
is OptionParameter -> {
label = it.label
order = it.order
}
}
}
Parameter(