Skip to content

Commit

Permalink
LayoutDSL: Fix inconsistent rounding in arrangement position calculat…
Browse files Browse the repository at this point in the history
…ions

Source-Commit: ade472fdc50a18f98a0b5a84ba3e97404b593b08
  • Loading branch information
Johni0702 committed Feb 29, 2024
1 parent 430372f commit 84bee44
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import gg.essential.elementa.utils.ObservableAddEvent
import gg.essential.elementa.utils.ObservableClearEvent
import gg.essential.elementa.utils.ObservableListEvent
import gg.essential.elementa.utils.ObservableRemoveEvent
import gg.essential.elementa.utils.roundToRealPixels

abstract class Arrangement {
internal lateinit var mainAxis: Axis
Expand Down Expand Up @@ -112,16 +113,16 @@ private open class SpacedArrangement(
}

override fun layoutPositions() {
val spacing = getSpacing(boundComponent)
var nextStart = boundComponent.getMainAxisStart() + getStartOffset(boundComponent, spacing)
val spacing = getSpacing(boundComponent).roundToRealPixels()
var nextStart = boundComponent.getMainAxisStart() + getStartOffset(boundComponent, spacing).roundToRealPixels()
boundComponent.children.forEach {
lastPosValues[it] = nextStart
nextStart += it.getMainAxisSize() + spacing
}
}

override fun getPadding(child: UIComponent): Float {
return if (child === boundComponent.children.last()) 0f else getSpacing(boundComponent)
return if (child === boundComponent.children.last()) 0f else getSpacing(boundComponent).roundToRealPixels()
}
}

Expand Down

0 comments on commit 84bee44

Please sign in to comment.