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.internal.JvmDefaultWithCompatibility
21 
22 /**
23  * A [Modifier.Element] that provides a [Remeasurement] object associated with the layout node the
24  * modifier is applied to.
25  */
26 @JvmDefaultWithCompatibility
27 interface RemeasurementModifier : Modifier.Element {
28     /**
29      * This method is executed when the modifier is attached to the layout node.
30      *
31      * @param remeasurement [Remeasurement] object associated with the layout node the modifier is
32      *   applied to.
33      */
onRemeasurementAvailablenull34     fun onRemeasurementAvailable(remeasurement: Remeasurement)
35 }
36 
37 /**
38  * This object is associated with a layout node and allows to execute some extra measure/layout
39  * actions which are needed for some complex layouts. In most cases you don't need it as measuring
40  * and layout should be correctly working automatically for most cases.
41  */
42 interface Remeasurement {
43     /**
44      * Performs the node remeasuring synchronously even if the node was not marked as needs
45      * remeasure before. Useful for cases like when during scrolling you need to re-execute the
46      * measure block to consume the scroll offset and remeasure your children in a blocking way.
47      */
48     fun forceRemeasure()
49 }
50