org.marid.fx.extensions.EnumExtensions.kt Maven / Gradle / Ivy
package org.marid.fx.extensions
import kotlin.math.max
inline val > E.progress: Double get() = ordinal.toDouble() / enumValues().size.toDouble()
inline fun > E.progress(subProgress: Double): Double {
val step = 1.0 / enumValues().size.toDouble()
val value = max(step * subProgress, step)
return progress + value
}
inline fun , reified P : Enum> E.progress(subItem: P): Double = progress(subItem.progress)