1 /* 2 * Copyright 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.common.ui.compose.windowinsets 18 19 import android.view.DisplayCutout as ViewDisplayCutout 20 import androidx.compose.ui.unit.Dp 21 import androidx.compose.ui.unit.dp 22 import kotlin.math.abs 23 24 /** Represents the global position of the bounds for the display cutout for this display */ 25 data class DisplayCutout( 26 val left: Dp = 0.dp, 27 val top: Dp = 0.dp, 28 val right: Dp = 0.dp, 29 val bottom: Dp = 0.dp, 30 val location: CutoutLocation = CutoutLocation.NONE, 31 /** 32 * The original `DisplayCutout` for the `View` world; only use this when feeding it back to a 33 * `View`. 34 */ 35 val viewDisplayCutoutKeyguardStatusBarView: ViewDisplayCutout? = null, 36 ) { widthnull37 fun width() = abs(right.value - left.value).dp 38 fun height() = abs(bottom.value - top.value).dp 39 } 40 41 enum class CutoutLocation { 42 NONE, 43 CENTER, 44 LEFT, 45 RIGHT, 46 } 47