1 /* 2 * Copyright 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 androidx.xr.compose.subspace.node 18 19 import androidx.compose.runtime.AbstractApplier 20 21 /** 22 * Node applier for subspace compositions. 23 * 24 * See [androidx.compose.ui.node.UiApplier] 25 */ 26 internal class SubspaceNodeApplier(private val owner: SubspaceOwner) : 27 AbstractApplier<SubspaceLayoutNode>(owner.root) { 28 29 init { 30 owner.root.measurePolicy = SubspaceLayoutNode.RootMeasurePolicy 31 } 32 insertTopDownnull33 override fun insertTopDown(index: Int, instance: SubspaceLayoutNode) { 34 // Ignored. Insert is performed in [insertBottomUp] to build the tree bottom-up to avoid 35 // duplicate notification when the child nodes enter the tree. 36 } 37 insertBottomUpnull38 override fun insertBottomUp(index: Int, instance: SubspaceLayoutNode) { 39 current.insertAt(index, instance) 40 } 41 removenull42 override fun remove(index: Int, count: Int) { 43 current.removeAt(index, count) 44 } 45 movenull46 override fun move(from: Int, to: Int, count: Int) { 47 current.move(from, to, count) 48 } 49 onClearnull50 override fun onClear() { 51 owner.root.removeAll() 52 } 53 onEndChangesnull54 override fun onEndChanges() { 55 owner.requestRelayout() 56 } 57 } 58