@@ -8,11 +8,7 @@ import androidx.compose.ui.graphics.Outline
88import androidx.compose.ui.graphics.Shape
99import androidx.compose.ui.layout.Placeable
1010import androidx.compose.ui.layout.SubcomposeMeasureScope
11- import androidx.compose.ui.unit.Constraints
12- import androidx.compose.ui.unit.Density
13- import androidx.compose.ui.unit.IntOffset
14- import androidx.compose.ui.unit.IntSize
15- import androidx.compose.ui.unit.LayoutDirection
11+ import androidx.compose.ui.unit.*
1612
1713class DataTableMeasuredRow (
1814 val placeables : Array <Placeable ?>,
@@ -59,7 +55,8 @@ class DataTableMeasuredRow(
5955 }
6056
6157 override fun place (
62- subcomposeScope : SubcomposeMeasureScope , placementBlock : Placeable .PlacementScope ,
58+ subcomposeScope : SubcomposeMeasureScope ,
59+ placementBlock : Placeable .PlacementScope ,
6360 upperBound : Int ,
6461 lowerBound : Int ,
6562 ) {
@@ -74,21 +71,20 @@ class DataTableMeasuredRow(
7471 maxWidth = tableWidth,
7572 )
7673 )
77- .place(0 , backgroundOffset)
78- // .placeWithLayer(0, backgroundOffset) {
79- // shape = object : Shape {
80- // override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
81- // val sizeRect = size.toRect()
82- // return Outline.Rectangle(
83- // sizeRect.copy(
84- // top = maxOf(sizeRect.top, sizeRect.top + upperBound.toFloat() - backgroundOffset),
85- // bottom = minOf(sizeRect.bottom, sizeRect.bottom - backgroundOffset - height + lowerBound.toFloat()),
86- // )
87- // )
88- // }
89- // }
90- // clip = true
91- // }
74+ .placeWithLayer(0 , backgroundOffset) {
75+ shape = object : Shape {
76+ override fun createOutline (size : Size , layoutDirection : LayoutDirection , density : Density ): Outline {
77+ val sizeRect = size.toRect()
78+ return Outline .Rectangle (
79+ sizeRect.copy(
80+ top = maxOf(sizeRect.top, sizeRect.top + upperBound.toFloat() - backgroundOffset),
81+ bottom = minOf(sizeRect.bottom, sizeRect.bottom - backgroundOffset - height + lowerBound.toFloat()),
82+ )
83+ )
84+ }
85+ }
86+ clip = true
87+ }
9288 }
9389 }
9490 placeables.forEachIndexed { index, placeable ->
@@ -147,40 +143,59 @@ class DataTableMeasuredSimple(
147143 with (placementBlock) {
148144 with (subcomposeScope) {
149145 subcompose(key, background).map {
150- it.measure(
146+ val placeable = it.measure(
151147 Constraints (
152148 minHeight = height,
153149 maxHeight = height,
154150 minWidth = tableWidth,
155151 maxWidth = tableWidth,
156152 )
157153 )
158- .place(offset)
154+ placeable.placeWithLayer(offset) {
155+ shape = object : Shape {
156+ override fun createOutline (
157+ size : Size ,
158+ layoutDirection : LayoutDirection ,
159+ density : Density
160+ ): Outline {
161+ val sizeRect = size.toRect()
162+ return Outline .Rectangle (
163+ sizeRect.copy(
164+ top = maxOf(sizeRect.top, sizeRect.top + upperBound.toFloat() - offset.y),
165+ bottom = minOf(
166+ sizeRect.bottom,
167+ sizeRect.bottom - offset.y - placeable.height.toFloat() + lowerBound.toFloat()
168+ ),
169+ )
170+ )
171+ }
172+ }
173+ clip = true
174+ }
159175 }
160176 }
161177 placeables.forEach { placeable ->
162- placeable.place(offset)
163- // placeable.placeWithLayer(offset) {
164- // shape = object : Shape {
165- // override fun createOutline(
166- // size: Size,
167- // layoutDirection: LayoutDirection,
168- // density: Density
169- // ): Outline {
170- // val sizeRect = size.toRect()
171- // return Outline.Rectangle(
172- // sizeRect.copy(
173- // top = maxOf(sizeRect.top, sizeRect.top + upperBound.toFloat() - offset.y),
174- // bottom = minOf(
175- // sizeRect.bottom,
176- // sizeRect.bottom - offset.y - placeable.height.toFloat() + lowerBound.toFloat()
177- // ),
178- // )
179- // )
180- // }
181- // }
182- // clip = true
183- // }
178+ placeable.placeWithLayer(offset) {
179+ shape = object : Shape {
180+ override fun createOutline (
181+ size : Size ,
182+ layoutDirection : LayoutDirection ,
183+ density : Density
184+ ): Outline {
185+ val sizeRect = size.toRect()
186+ return Outline .Rectangle (
187+ sizeRect.copy(
188+ top = maxOf(sizeRect.top, sizeRect.top + upperBound.toFloat() - offset.y),
189+ bottom = minOf(
190+ sizeRect.bottom,
191+ sizeRect.bottom - offset.y - placeable.height.toFloat() + lowerBound.toFloat()
192+ ),
193+ )
194+ )
195+ }
196+ }
197+ clip = true
198+ }
184199 }
185200 }
186201 }
0 commit comments