1 /*
2  * Copyright 2022 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.node
18 
19 import androidx.compose.ui.layout.LayoutCoordinates
20 import androidx.compose.ui.layout.onGloballyPositioned
21 
22 /**
23  * A [androidx.compose.ui.Modifier.Node] whose [onGloballyPositioned] is called with the final
24  * LayoutCoordinates of the Layout when the global position of the content may have changed. Note
25  * that it will be called after a composition when the coordinates are finalized.
26  *
27  * This is the [androidx.compose.ui.Modifier.Node] equivalent of
28  * [androidx.compose.ui.layout.OnGloballyPositionedModifier]
29  *
30  * Usage example:
31  *
32  * @sample androidx.compose.ui.samples.OnGloballyPositioned
33  * @sample androidx.compose.ui.samples.GlobalPositionAwareModifierNodeSample
34  * @see LayoutCoordinates
35  */
36 interface GlobalPositionAwareModifierNode : DelegatableNode {
37     /**
38      * Called with the final LayoutCoordinates of the Layout after measuring. Note that it will be
39      * called after a composition when the coordinates are finalized. The position in the modifier
40      * chain makes no difference in either the [LayoutCoordinates] argument or when the
41      * [onGloballyPositioned] is called.
42      */
onGloballyPositionednull43     fun onGloballyPositioned(coordinates: LayoutCoordinates)
44 }
45