Skip to content

Commit

Permalink
Merge branch 'main' into av/kotlinx-coroutines-1.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
alexvanyo authored Dec 28, 2024
2 parents 7c87e42 + aa55e99 commit acf96ef
Show file tree
Hide file tree
Showing 23 changed files with 1,741 additions and 790 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import androidx.compose.ui.unit.IntSize
/**
* A finite rectangular region of a cell universe.
*
* This is represented by an [IntRect], with the [IntRect.topLeft] being the top-left most point (inclusive), and
* [IntRect.bottomRight] being the bottom-right most point (exclusive).
* This is represented by an [IntRect] [intRect], with the [IntRect.topLeft] being the top-left most point (inclusive),
* and [IntRect.bottomRight] being the bottom-right most point (exclusive).
*/
@JvmInline
value class CellWindow(private val intRect: IntRect) {
value class CellWindow(val intRect: IntRect) {

init {
require(intRect.top <= intRect.bottom)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.IntRect
import androidx.compose.ui.unit.LayoutDirection

operator fun Rect.times(scale: Float): Rect =
Rect(
topLeft = topLeft * scale,
bottomRight = bottomRight * scale,
)

operator fun Rect.div(scale: Float): Rect =
Rect(
topLeft = topLeft / scale,
bottomRight = bottomRight / scale,
)

fun Rect.topStart(layoutDirection: LayoutDirection): Offset = when (layoutDirection) {
LayoutDirection.Ltr -> topLeft
LayoutDirection.Rtl -> topRight
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import com.alexvanyo.composelife.ui.app.createComponent
import com.alexvanyo.composelife.ui.cells.CellWindowInjectEntryPoint
import com.alexvanyo.composelife.ui.cells.CellWindowLocalEntryPoint
import com.alexvanyo.composelife.ui.cells.cellStateDragAndDropTarget
import com.alexvanyo.composelife.ui.cells.rememberMutableCellStateDropStateHolder
import kotlinx.coroutines.test.runCurrent
import org.junit.runner.RunWith
import kotlin.test.Test
Expand Down Expand Up @@ -97,9 +98,11 @@ class LoadedCellStatePreviewTests : BaseUiInjectTest<TestComposeLifeApplicationC
Spacer(
modifier = Modifier
.testTag("TestDropTarget")
.cellStateDragAndDropTarget {
droppedCellState = it
}
.cellStateDragAndDropTarget(
rememberMutableCellStateDropStateHolder { _, cellState ->
droppedCellState = cellState
},
)
.size(100.dp)
.background(Color.Blue),
)
Expand All @@ -125,8 +128,8 @@ class LoadedCellStatePreviewTests : BaseUiInjectTest<TestComposeLifeApplicationC
downTime,
downTime,
MotionEvent.ACTION_DOWN,
loadedCellStatePreviewCenter.x.toFloat(),
loadedCellStatePreviewCenter.y.toFloat(),
loadedCellStatePreviewCenter.x,
loadedCellStatePreviewCenter.y,
0,
).apply {
source = InputDevice.SOURCE_TOUCHSCREEN
Expand All @@ -141,8 +144,8 @@ class LoadedCellStatePreviewTests : BaseUiInjectTest<TestComposeLifeApplicationC
downTime,
SystemClock.uptimeMillis(),
MotionEvent.ACTION_MOVE,
testDropTargetCenter.x.toFloat(),
testDropTargetCenter.y.toFloat(),
testDropTargetCenter.x,
testDropTargetCenter.y,
0,
).apply {
source = InputDevice.SOURCE_TOUCHSCREEN
Expand All @@ -154,8 +157,8 @@ class LoadedCellStatePreviewTests : BaseUiInjectTest<TestComposeLifeApplicationC
downTime,
SystemClock.uptimeMillis(),
MotionEvent.ACTION_UP,
testDropTargetCenter.x.toFloat(),
testDropTargetCenter.y.toFloat(),
testDropTargetCenter.x,
testDropTargetCenter.y,
0,
).apply {
source = InputDevice.SOURCE_TOUCHSCREEN
Expand Down
Loading

0 comments on commit acf96ef

Please sign in to comment.