From 686583b7b51d724b90f67c5c01a1de340221dd25 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Fri, 20 Mar 2020 00:10:11 +0100 Subject: [PATCH] Add invertY to annotation, remove keyboardIncrement, rename showAngle to showVector, reorder min-max arguments --- orx-gui/src/main/kotlin/Gui.kt | 10 +++---- orx-parameters/src/main/kotlin/Annotations.kt | 28 +++++++++---------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/orx-gui/src/main/kotlin/Gui.kt b/orx-gui/src/main/kotlin/Gui.kt index f2f60c86..3ecda134 100644 --- a/orx-gui/src/main/kotlin/Gui.kt +++ b/orx-gui/src/main/kotlin/Gui.kt @@ -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).get(labeledObject.obj) } -// ParameterType.Vector2 -> { -// (control as Vector2Control).value = (parameter.property as KMutableProperty1).get(labeledObject.obj) -// } + ParameterType.XY -> { + (control as XYPad).value = (parameter.property as KMutableProperty1).get(labeledObject.obj) + } ParameterType.Boolean -> { (control as Toggle).value = (parameter.property as KMutableProperty1).get(labeledObject.obj) diff --git a/orx-parameters/src/main/kotlin/Annotations.kt b/orx-parameters/src/main/kotlin/Annotations.kt index 5442a6cf..b20cc680 100644 --- a/orx-parameters/src/main/kotlin/Annotations.kt +++ b/orx-parameters/src/main/kotlin/Annotations.kt @@ -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) { * @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?, 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 { 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 { 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 { 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 { intRange = null, vectorRange = null, precision = null, - keyboardIncrement = null, - showAngle = false, + showVector = null, + invertY = null, order = order ) }).sortedBy { it.order }