1 /* 2 * Copyright 2020 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 androidx.compose.ui.layout 18 19 import androidx.compose.ui.Modifier 20 import androidx.compose.ui.platform.ViewConfiguration 21 import androidx.compose.ui.unit.Density 22 import androidx.compose.ui.unit.LayoutDirection 23 24 /** 25 * The public information about the layouts used internally as nodes in the Compose UI hierarchy. 26 */ 27 interface LayoutInfo { 28 29 /** 30 * This returns a new List of [Modifier]s and the coordinates and any extra information that may 31 * be useful. This is used for tooling to retrieve layout modifier and layer information. 32 */ getModifierInfonull33 fun getModifierInfo(): List<ModifierInfo> 34 35 /** The measured width of this layout and all of its modifiers. */ 36 val width: Int 37 38 /** The measured height of this layout and all of its modifiers. */ 39 val height: Int 40 41 /** Coordinates of just the contents of the layout, after being affected by all modifiers. */ 42 val coordinates: LayoutCoordinates 43 44 /** Whether or not this layout and all of its parents have been placed in the hierarchy. */ 45 val isPlaced: Boolean 46 47 /** Parent of this layout. */ 48 val parentInfo: LayoutInfo? 49 50 /** The density in use for this layout. */ 51 val density: Density 52 53 /** The layout direction in use for this layout. */ 54 val layoutDirection: LayoutDirection 55 56 /** The [ViewConfiguration] in use for this layout. */ 57 val viewConfiguration: ViewConfiguration 58 59 /** Returns true if this layout is currently a part of the layout tree. */ 60 val isAttached: Boolean 61 62 /** Unique and stable id representing this node to the semantics system. */ 63 val semanticsId: Int 64 65 /** 66 * True if the node is deactivated. For example, the children of 67 * [androidx.compose.ui.layout.SubcomposeLayout] which are retained to be reused in future are 68 * considered deactivated. 69 */ 70 val isDeactivated: Boolean 71 get() = false 72 } 73 74 /** Used by tooling to examine the modifiers on a [LayoutInfo]. */ 75 class ModifierInfo( 76 val modifier: Modifier, 77 val coordinates: LayoutCoordinates, 78 val extra: Any? = null 79 ) { 80 override fun toString(): String { 81 return "ModifierInfo($modifier, $coordinates, $extra)" 82 } 83 } 84