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 minY = parameter.vectorRange!!.first.y
maxX = parameter.vectorRange!!.second.x maxX = parameter.vectorRange!!.second.x
maxY = parameter.vectorRange!!.second.y maxY = parameter.vectorRange!!.second.y
keyboardIncrement = parameter.keyboardIncrement!!
precision = parameter.precision!! precision = parameter.precision!!
showAngle = parameter.showAngle!! showVector = parameter.showVector!!
invertY = parameter.invertY!!
events.valueChanged.subscribe { events.valueChanged.subscribe {
setAndPersist( setAndPersist(
@@ -539,9 +539,9 @@ class GUI : Extension {
(control as ColorpickerButton).color = (parameter.property as KMutableProperty1<Any, ColorRGBa>).get(labeledObject.obj) (control as ColorpickerButton).color = (parameter.property as KMutableProperty1<Any, ColorRGBa>).get(labeledObject.obj)
} }
// ParameterType.Vector2 -> { ParameterType.XY -> {
// (control as Vector2Control).value = (parameter.property as KMutableProperty1<Any, Vector2>).get(labeledObject.obj) (control as XYPad).value = (parameter.property as KMutableProperty1<Any, Vector2>).get(labeledObject.obj)
// } }
ParameterType.Boolean -> { ParameterType.Boolean -> {
(control as Toggle).value = (parameter.property as KMutableProperty1<Any, Boolean>).get(labeledObject.obj) (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( annotation class XYParameter(
val label: String, val label: String,
val minX: Double = -1.0, val minX: Double = -1.0,
val minY: Double = -1.0,
val maxX: Double = 1.0, val maxX: Double = 1.0,
val minY: Double = -1.0,
val maxY: Double = 1.0, val maxY: Double = 1.0,
val precision: Int = 1, val precision: Int = 1,
val keyboardIncrement: Double = 10.0, val showVector: Boolean = false,
val showAngle: Boolean = false, val invertY: Boolean = true,
val order: Int = Integer.MAX_VALUE 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 doubleRange a floating point based range in case [DoubleParameter] is used
* @property intRange an integer range in case [IntParameter] 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 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 * @property order a hint for where in the ui this parameter is placed, lower value means higher priority
*/ */
class Parameter( class Parameter(
@@ -142,8 +142,8 @@ class Parameter(
val vectorRange: Pair<Vector2, Vector2>?, val vectorRange: Pair<Vector2, Vector2>?,
val intRange: IntRange?, val intRange: IntRange?,
val precision: Int?, val precision: Int?,
val keyboardIncrement: Double?, val invertY: Boolean?,
val showAngle: Boolean?, val showVector: Boolean?,
val order: Int) val order: Int)
/** /**
@@ -164,8 +164,8 @@ fun Any.listParameters(): List<Parameter> {
var precision: Int? = null var precision: Int? = null
var type: ParameterType? = null var type: ParameterType? = null
var vectorRange = Pair(Vector2(-1.0, -1.0), Vector2(1.0, 1.0)) var vectorRange = Pair(Vector2(-1.0, -1.0), Vector2(1.0, 1.0))
var keyboardIncrement: Double? = null var invertY: Boolean? = null
var showAngle: Boolean? = null var showVector: Boolean? = null
annotations.forEach { annotations.forEach {
type = ParameterType.forParameterAnnotationClass(it) type = ParameterType.forParameterAnnotationClass(it)
@@ -197,9 +197,9 @@ fun Any.listParameters(): List<Parameter> {
label = it.label label = it.label
order = it.order order = it.order
vectorRange = Pair(Vector2(it.minX, it.minY), Vector2(it.maxX, it.maxY)) vectorRange = Pair(Vector2(it.minX, it.minY), Vector2(it.maxX, it.maxY))
keyboardIncrement = it.keyboardIncrement
precision = it.precision precision = it.precision
showAngle = it.showAngle invertY = it.invertY
showVector = it.showVector
} }
} }
} }
@@ -212,8 +212,8 @@ fun Any.listParameters(): List<Parameter> {
vectorRange = vectorRange, vectorRange = vectorRange,
intRange = intRange, intRange = intRange,
precision = precision, precision = precision,
keyboardIncrement = keyboardIncrement, showVector = showVector,
showAngle = showAngle, invertY = invertY,
order = order order = order
) )
} + this::class.declaredMemberFunctions.filter { } + this::class.declaredMemberFunctions.filter {
@@ -232,8 +232,8 @@ fun Any.listParameters(): List<Parameter> {
intRange = null, intRange = null,
vectorRange = null, vectorRange = null,
precision = null, precision = null,
keyboardIncrement = null, showVector = null,
showAngle = false, invertY = null,
order = order order = order
) )
}).sortedBy { it.order } }).sortedBy { it.order }