Add invertY to annotation, remove keyboardIncrement, rename showAngle to showVector, reorder min-max arguments

This commit is contained in:
Edwin Jakobs
2020-03-20 00:10:11 +01:00
parent 963038d74e
commit 686583b7b5
2 changed files with 19 additions and 19 deletions

View File

@@ -419,9 +419,9 @@ class GUI : Extension {
minY = parameter.vectorRange!!.first.y
maxX = parameter.vectorRange!!.second.x
maxY = parameter.vectorRange!!.second.y
keyboardIncrement = parameter.keyboardIncrement!!
precision = parameter.precision!!
showAngle = parameter.showAngle!!
showVector = parameter.showVector!!
invertY = parameter.invertY!!
events.valueChanged.subscribe {
setAndPersist(
@@ -539,9 +539,9 @@ class GUI : Extension {
(control as ColorpickerButton).color = (parameter.property as KMutableProperty1<Any, ColorRGBa>).get(labeledObject.obj)
}
// ParameterType.Vector2 -> {
// (control as Vector2Control).value = (parameter.property as KMutableProperty1<Any, Vector2>).get(labeledObject.obj)
// }
ParameterType.XY -> {
(control as XYPad).value = (parameter.property as KMutableProperty1<Any, Vector2>).get(labeledObject.obj)
}
ParameterType.Boolean -> {
(control as Toggle).value = (parameter.property as KMutableProperty1<Any, Boolean>).get(labeledObject.obj)

View File

@@ -82,12 +82,12 @@ annotation class ColorParameter(val label: String, val order: Int = Integer.MAX_
annotation class XYParameter(
val label: String,
val minX: Double = -1.0,
val minY: Double = -1.0,
val maxX: Double = 1.0,
val minY: Double = -1.0,
val maxY: Double = 1.0,
val precision: Int = 1,
val keyboardIncrement: Double = 10.0,
val showAngle: Boolean = false,
val showVector: Boolean = false,
val invertY: Boolean = true,
val order: Int = Integer.MAX_VALUE
)
@@ -130,7 +130,7 @@ enum class ParameterType(val annotationClass: KClass<out Annotation>) {
* @property doubleRange a floating point based range in case [DoubleParameter] is used
* @property intRange an integer range in case [IntParameter] is used
* @property precision a precision hint in case a [DoubleParameter] annotation is used
* @property keyboardIncrement how much change the keyboard makes in case a [XYParameter] annotation is used
* @property invertY should the y-axis of [XYParameter] be inverted?
* @property order a hint for where in the ui this parameter is placed, lower value means higher priority
*/
class Parameter(
@@ -142,8 +142,8 @@ class Parameter(
val vectorRange: Pair<Vector2, Vector2>?,
val intRange: IntRange?,
val precision: Int?,
val keyboardIncrement: Double?,
val showAngle: Boolean?,
val invertY: Boolean?,
val showVector: Boolean?,
val order: Int)
/**
@@ -164,8 +164,8 @@ fun Any.listParameters(): List<Parameter> {
var precision: Int? = null
var type: ParameterType? = null
var vectorRange = Pair(Vector2(-1.0, -1.0), Vector2(1.0, 1.0))
var keyboardIncrement: Double? = null
var showAngle: Boolean? = null
var invertY: Boolean? = null
var showVector: Boolean? = null
annotations.forEach {
type = ParameterType.forParameterAnnotationClass(it)
@@ -197,9 +197,9 @@ fun Any.listParameters(): List<Parameter> {
label = it.label
order = it.order
vectorRange = Pair(Vector2(it.minX, it.minY), Vector2(it.maxX, it.maxY))
keyboardIncrement = it.keyboardIncrement
precision = it.precision
showAngle = it.showAngle
invertY = it.invertY
showVector = it.showVector
}
}
}
@@ -212,8 +212,8 @@ fun Any.listParameters(): List<Parameter> {
vectorRange = vectorRange,
intRange = intRange,
precision = precision,
keyboardIncrement = keyboardIncrement,
showAngle = showAngle,
showVector = showVector,
invertY = invertY,
order = order
)
} + this::class.declaredMemberFunctions.filter {
@@ -232,8 +232,8 @@ fun Any.listParameters(): List<Parameter> {
intRange = null,
vectorRange = null,
precision = null,
keyboardIncrement = null,
showAngle = false,
showVector = null,
invertY = null,
order = order
)
}).sortedBy { it.order }