1/* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 17import { FrameNode, NodeController, RenderNode } from '@kit.ArkUI'; 18 19class MyNodeController extends NodeController { 20 private rootNode: FrameNode | null = null; 21 22 makeNode(uiContext: UIContext): FrameNode { 23 this.rootNode = new FrameNode(uiContext); 24 if (this.rootNode == null) { 25 return this.rootNode; 26 } 27 const renderNode = this.rootNode.getRenderNode() 28 if (renderNode != null) { 29 renderNode.frame = { 30 x: 0, 31 y: 0, 32 width: 10, 33 height: 500 34 } 35 renderNode.pivot = { x: 50, y: 50 } 36 } 37 return this.rootNode; 38 } 39 40 addNode(node: RenderNode): void { 41 if (this.rootNode == null) { 42 return; 43 } 44 const renderNode = this.rootNode.getRenderNode() 45 if (renderNode != null) { 46 renderNode.appendChild(node); 47 } 48 } 49 50 clearNodes(): void { 51 if (this.rootNode == null) { 52 return; 53 } 54 const renderNode = this.rootNode.getRenderNode() 55 if (renderNode != null) { 56 renderNode.clearChildren(); 57 } 58 } 59} 60 61export default MyNodeController; 62