Skip to content

Commit c3e6609

Browse files
committed
disable clipping momentarily
1 parent 3fe3235 commit c3e6609

2 files changed

Lines changed: 48 additions & 38 deletions

File tree

  • data-table/src/commonMain/kotlin/com/seanproctor/datatable
  • demo-common/src/commonMain/kotlin/com/seanproctor/datatable/demo

data-table/src/commonMain/kotlin/com/seanproctor/datatable/DataTableMeasuredRow.kt

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ class DataTableMeasuredRow(
4747
space = IntSize(columnWidth, height),
4848
layoutDirection = layoutDirection
4949
)
50-
placeableOffsets[index * 2] =
51-
x + alignmentOffset.x
50+
placeableOffsets[index * 2] = x + alignmentOffset.x
5251
placeableOffsets[index * 2 + 1] = offset.y + alignmentOffset.y
5352
x += columnWidth
5453
}
@@ -67,45 +66,48 @@ class DataTableMeasuredRow(
6766
with(placementBlock) {
6867
with(subcomposeScope) {
6968
subcompose(key, background).map {
70-
val placeable = it.measure(
69+
it.measure(
7170
Constraints(
7271
minHeight = height,
7372
maxHeight = height,
7473
minWidth = tableWidth,
7574
maxWidth = tableWidth,
7675
)
7776
)
78-
// .place(0, backgroundOffset)
79-
// if (upperBound >= backgroundOffset && lowerBound < backgroundOffset) {
80-
// placeable.place(0, backgroundOffset)
81-
// } else {
82-
placeable.placeWithLayer(0, backgroundOffset) {
83-
shape = object : Shape {
84-
override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
85-
val sizeRect = size.toRect()
86-
return Outline.Rectangle(
87-
sizeRect.copy(
88-
top = maxOf(sizeRect.top, sizeRect.top + upperBound.toFloat() - backgroundOffset),
89-
bottom = minOf(sizeRect.bottom, sizeRect.bottom - backgroundOffset - height + lowerBound.toFloat()),
90-
)
91-
)
92-
}
93-
}
94-
clip = true
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
9591
// }
96-
}
9792
}
9893
}
9994
placeables.forEachIndexed { index, placeable ->
10095
val offset = getOffset(index)
10196
placeable?.placeWithLayer(offset) {
10297
shape = object : Shape {
103-
override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
98+
override fun createOutline(
99+
size: Size,
100+
layoutDirection: LayoutDirection,
101+
density: Density
102+
): Outline {
104103
val sizeRect = size.toRect()
105104
return Outline.Rectangle(
106105
sizeRect.copy(
107106
top = maxOf(sizeRect.top, sizeRect.top + upperBound.toFloat() - offset.y),
108-
bottom = minOf(sizeRect.bottom, sizeRect.bottom - offset.y - placeable.height.toFloat() + lowerBound.toFloat()),
107+
bottom = minOf(
108+
sizeRect.bottom,
109+
sizeRect.bottom - offset.y - placeable.height.toFloat() + lowerBound.toFloat()
110+
),
109111
)
110112
)
111113
}
@@ -157,20 +159,28 @@ class DataTableMeasuredSimple(
157159
}
158160
}
159161
placeables.forEach { placeable ->
160-
placeable.placeWithLayer(offset) {
161-
shape = object : Shape {
162-
override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
163-
val sizeRect = size.toRect()
164-
return Outline.Rectangle(
165-
sizeRect.copy(
166-
top = maxOf(sizeRect.top, sizeRect.top + upperBound.toFloat() - offset.y),
167-
bottom = minOf(sizeRect.bottom, sizeRect.bottom - offset.y - placeable.height.toFloat() + lowerBound.toFloat()),
168-
)
169-
)
170-
}
171-
}
172-
clip = true
173-
}
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+
// }
174184
}
175185
}
176186
}

demo-common/src/commonMain/kotlin/com/seanproctor/datatable/demo/App.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ fun DataTableScope.generateTable(
186186
) {
187187
data.forEachIndexed { index, rowData ->
188188
row {
189-
backgroundColor = if (index % 2 == 0) colorEven else colorOdd
189+
// backgroundColor = if (index % 2 == 0) colorEven else colorOdd
190190
onClick = { onRowClick(index) }
191191
cell { }
192192
cell {

0 commit comments

Comments
 (0)