1 /* 2 * Copyright (C) 2024 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.statusbar.notification.stack.shared.model 18 19 import androidx.compose.ui.geometry.Rect 20 21 /** Models the bounds of the notification stack. */ 22 data class ShadeScrimBounds( 23 /** The position of the left of the stack in its window coordinate system, in pixels. */ 24 val left: Float = 0f, 25 /** The position of the top of the stack in its window coordinate system, in pixels. */ 26 val top: Float = 0f, 27 /** The position of the right of the stack in its window coordinate system, in pixels. */ 28 val right: Float = 0f, 29 /** The position of the bottom of the stack in its window coordinate system, in pixels. */ 30 val bottom: Float = 0f, 31 ) { 32 constructor( 33 bounds: Rect 34 ) : this(left = bounds.left, top = bounds.top, right = bounds.right, bottom = bounds.bottom) 35 36 /** The current height of the notification container. */ 37 val height: Float = bottom - top 38 minusnull39 fun minus(leftOffset: Int = 0, topOffset: Int = 0) = 40 if (leftOffset == 0 && topOffset == 0) { 41 this 42 } else { 43 ShadeScrimBounds( 44 left = this.left - leftOffset, 45 top = this.top - topOffset, 46 right = this.right - leftOffset, 47 bottom = this.bottom - topOffset, 48 ) 49 } 50 } 51