Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a35135a authored by Xiaoqian (Daisy) Dai's avatar Xiaoqian (Daisy) Dai Committed by Android (Google) Code Review
Browse files

Merge "screen capture: hide the dimension pill after resizing" into main

parents a58c58f8 ccc1ae42
Loading
Loading
Loading
Loading
+48 −41
Original line number Diff line number Diff line
@@ -461,7 +461,7 @@ fun RegionBox(
                // button [RegionDimensionsPill]'s size, which is only known after measurement.
                SubcomposeLayout { constraints ->
                    // First, measure the pill [RegionDimensionsPill] to get its actual height.
                    val dimensionPillPlaceable =
                    val dimensionPillMeasurables =
                        subcompose("dimensionPill") {
                            val pillVerticalSpacingDp = 16.dp
                            RegionDimensionsPill(
@@ -469,8 +469,7 @@ fun RegionBox(
                                heightPx = currentRect.height.roundToInt(),
                                modifier =
                                    Modifier.layout { measurable, _ ->
                                            val pillInnerPlaceable =
                                                measurable.measure(Constraints())
                                        val pillInnerPlaceable = measurable.measure(Constraints())
                                        val pillVerticalSpacingPx =
                                            with(density) { pillVerticalSpacingDp.toPx() }
                                        // Center the pill horizontally relative to the region
@@ -500,11 +499,19 @@ fun RegionBox(
                                    },
                            )
                        }
                            .first()
                            .measure(constraints)

                    val dimensionPillPlaceable =
                        if (
                            state.dragMode == DragMode.RESIZING ||
                                state.dragMode == DragMode.DRAWING
                        ) {
                            dimensionPillMeasurables.first().measure(constraints)
                        } else {
                            null
                        }

                    val dimensionPillHeightDp =
                        with(density) { dimensionPillPlaceable.height.toDp() }
                        dimensionPillPlaceable?.let { with(density) { it.height.toDp() } } ?: 0.dp

                    // To determine the button's placement, we first need to know its size. We
                    // subcompose the button once just to measure it.
@@ -676,7 +683,7 @@ fun RegionBox(
                        // SubcomposeLayout to the correct on-screen position, ensuring all
                        // elements move as a single, synchronized unit.
                        selectionBoxPlaceable.placeRelative(0, 0)
                        dimensionPillPlaceable.placeRelative(0, 0)
                        dimensionPillPlaceable?.placeRelative(0, 0)
                        captureButtonPlaceable.placeRelative(0, 0)
                    }
                }