1/* 2 * Copyright (c) 2023 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/** 17 * @file 18 * @kit ArkUI 19 */ 20 21import { UIContext } from '../@ohos.arkui.UIContext'; 22import { FrameNode } from './FrameNode'; 23import { Size } from './Graphics'; 24 25/** 26 * Render type of the node using for indicating that 27 * if the node will be shown on the display or rendered to a texture 28 * 29 * @enum { number } Render type 30 * @syscap SystemCapability.ArkUI.ArkUI.Full 31 * @crossplatform 32 * @since 11 33 */ 34/** 35 * Render type of the node using for indicating that 36 * if the node will be shown on the display or rendered to a texture 37 * 38 * @enum { number } Render type 39 * @syscap SystemCapability.ArkUI.ArkUI.Full 40 * @crossplatform 41 * @atomicservice 42 * @since 12 43 */ 44declare enum NodeRenderType { 45 /** 46 * Display type.The node will be shown on the display. 47 * 48 * @syscap SystemCapability.ArkUI.ArkUI.Full 49 * @crossplatform 50 * @since 11 51 */ 52 /** 53 * Display type.The node will be shown on the display. 54 * 55 * @syscap SystemCapability.ArkUI.ArkUI.Full 56 * @crossplatform 57 * @atomicservice 58 * @since 12 59 */ 60 RENDER_TYPE_DISPLAY = 0, 61 62 /** 63 * Exporting texture type.The node will be render to a texture. 64 * 65 * @syscap SystemCapability.ArkUI.ArkUI.Full 66 * @since 11 67 */ 68 /** 69 * Exporting texture type.The node will be render to a texture. 70 * 71 * @syscap SystemCapability.ArkUI.ArkUI.Full 72 * @atomicservice 73 * @since 12 74 */ 75 RENDER_TYPE_TEXTURE = 1, 76} 77 78/** 79 * RenderOptions info. 80 * 81 * @interface RenderOptions 82 * @syscap SystemCapability.ArkUI.ArkUI.Full 83 * @crossplatform 84 * @since 11 85 */ 86/** 87 * RenderOptions info. 88 * 89 * @interface RenderOptions 90 * @syscap SystemCapability.ArkUI.ArkUI.Full 91 * @crossplatform 92 * @atomicservice 93 * @since 12 94 */ 95export interface RenderOptions { 96 /** 97 * The ideal size of the node. 98 * @type { ?Size } selfIdealSize - The ideal size of the node 99 * @syscap SystemCapability.ArkUI.ArkUI.Full 100 * @crossplatform 101 * @since 11 102 */ 103 /** 104 * The ideal size of the node. 105 * @type { ?Size } selfIdealSize - The ideal size of the node 106 * @syscap SystemCapability.ArkUI.ArkUI.Full 107 * @crossplatform 108 * @atomicservice 109 * @since 12 110 */ 111 selfIdealSize?: Size; 112 113 /** 114 * Render type of the node. 115 * @type { ?NodeRenderType } type - Render type of the node 116 * @syscap SystemCapability.ArkUI.ArkUI.Full 117 * @since 11 118 */ 119 /** 120 * Render type of the node. 121 * @type { ?NodeRenderType } type - Render type of the node 122 * @syscap SystemCapability.ArkUI.ArkUI.Full 123 * @atomicservice 124 * @since 12 125 */ 126 type?: NodeRenderType; 127 128 /** 129 * The surfaceId of a texture consumer 130 * @type { ?string } surfaceId - surfaceId of a consumer who can receive the texture of the Node 131 * @syscap SystemCapability.ArkUI.ArkUI.Full 132 * @since 11 133 */ 134 /** 135 * The surfaceId of a texture consumer 136 * @type { ?string } surfaceId - surfaceId of a consumer who can receive the texture of the Node 137 * @syscap SystemCapability.ArkUI.ArkUI.Full 138 * @atomicservice 139 * @since 12 140 */ 141 surfaceId?: string; 142} 143 144 145/** 146 * BuildOptions info. 147 * 148 * @interface BuildOptions 149 * @syscap SystemCapability.ArkUI.ArkUI.Full 150 * @crossplatform 151 * @atomicservice 152 * @since 12 153 */ 154export interface BuildOptions { 155 156 /** 157 * Build type of the Builder. 158 * @type { ?boolean } nestingBuilderSupported - Build type of the Builder. 159 * Indicates whether support the type that WrappedBuilder contains builder used different params. 160 * 161 * @syscap SystemCapability.ArkUI.ArkUI.Full 162 * @crossplatform 163 * @atomicservice 164 * @since 12 165 */ 166 nestingBuilderSupported?: boolean; 167 168} 169 170/** 171 * Defines BuilderNode. 172 * 173 * @syscap SystemCapability.ArkUI.ArkUI.Full 174 * @crossplatform 175 * @since 11 176 */ 177/** 178 * Defines BuilderNode. 179 * 180 * @syscap SystemCapability.ArkUI.ArkUI.Full 181 * @crossplatform 182 * @atomicservice 183 * @since 12 184 */ 185export class BuilderNode<Args extends Object[]> { 186 /** 187 * Constructor. 188 * 189 * @param { UIContext } uiContext - uiContext used to create the BuilderNode 190 * @param { RenderOptions } options - Render options of the Builder Node 191 * @syscap SystemCapability.ArkUI.ArkUI.Full 192 * @crossplatform 193 * @since 11 194 */ 195 /** 196 * Constructor. 197 * 198 * @param { UIContext } uiContext - uiContext used to create the BuilderNode 199 * @param { RenderOptions } options - Render options of the Builder Node 200 * @syscap SystemCapability.ArkUI.ArkUI.Full 201 * @crossplatform 202 * @atomicservice 203 * @since 12 204 */ 205 constructor(uiContext: UIContext, options?: RenderOptions); 206 207 /** 208 * Build the BuilderNode with the builder. 209 * 210 * @param { WrappedBuilder<Args> } builder - Defined the builder will be called to build the node. 211 * @param { Object } arg - Defined the args will be used in the builder. 212 * @syscap SystemCapability.ArkUI.ArkUI.Full 213 * @crossplatform 214 * @since 11 215 */ 216 /** 217 * Build the BuilderNode with the builder. 218 * 219 * @param { WrappedBuilder<Args> } builder - Defined the builder will be called to build the node. 220 * @param { Object } arg - Defined the args will be used in the builder. 221 * @syscap SystemCapability.ArkUI.ArkUI.Full 222 * @crossplatform 223 * @atomicservice 224 * @since 12 225 */ 226 build(builder: WrappedBuilder<Args>, arg?: Object): void; 227 228 /** 229 * Build the BuilderNode with the builder.Support the type that WrappedBuilder contains builder used different params. 230 * 231 * @param { WrappedBuilder<Args> } builder - Defined the builder will be called to build the node. 232 * @param { Object } arg - Defined the args will be used in the builder. 233 * @param { BuildOptions } options - Defined the options will be used when build. 234 * @syscap SystemCapability.ArkUI.ArkUI.Full 235 * @crossplatform 236 * @atomicservice 237 * @since 12 238 */ 239 build(builder: WrappedBuilder<Args>, arg: Object, options: BuildOptions): void; 240 241 /** 242 * Update the BuilderNode based on the provided parameters. 243 * 244 * @param { Object } arg - Parameters used to update the BuilderNode, which must match the types required by the builder bound to the BuilderNode. 245 * @syscap SystemCapability.ArkUI.ArkUI.Full 246 * @crossplatform 247 * @since 11 248 */ 249 /** 250 * Update the BuilderNode based on the provided parameters. 251 * 252 * @param { Object } arg - Parameters used to update the BuilderNode, which must match the types required by the builder bound to the BuilderNode. 253 * @syscap SystemCapability.ArkUI.ArkUI.Full 254 * @crossplatform 255 * @atomicservice 256 * @since 12 257 */ 258 update(arg: Object): void; 259 260 /** 261 * Get the FrameNode in BuilderNode. 262 * 263 * @returns { FrameNode | null } - Returns a FrameNode inside the BuilderNode, or null if not contained. 264 * @syscap SystemCapability.ArkUI.ArkUI.Full 265 * @crossplatform 266 * @since 11 267 */ 268 /** 269 * Get the FrameNode in BuilderNode. 270 * 271 * @returns { FrameNode | null } - Returns a FrameNode inside the BuilderNode, or null if not contained. 272 * @syscap SystemCapability.ArkUI.ArkUI.Full 273 * @crossplatform 274 * @atomicservice 275 * @since 12 276 */ 277 getFrameNode(): FrameNode | null; 278 279 /** 280 * Dispatch touchEvent to targetNode. 281 * 282 * @param { TouchEvent } event - The touchEvent which will be sent to the targetNode. 283 * @returns { boolean } - Returns true if the TouchEvent has been successfully posted to the targetNode, false otherwise. 284 * @syscap SystemCapability.ArkUI.ArkUI.Full 285 * @crossplatform 286 * @since 11 287 */ 288 /** 289 * Dispatch touchEvent to targetNode. 290 * 291 * @param { TouchEvent } event - The touchEvent which will be sent to the targetNode. 292 * @returns { boolean } - Returns true if the TouchEvent has been successfully posted to the targetNode, false otherwise. 293 * @syscap SystemCapability.ArkUI.ArkUI.Full 294 * @crossplatform 295 * @atomicservice 296 * @since 12 297 */ 298 postTouchEvent(event: TouchEvent): boolean; 299 300 /** 301 * Dispose the BuilderNode immediately. 302 * 303 * @syscap SystemCapability.ArkUI.ArkUI.Full 304 * @crossplatform 305 * @atomicservice 306 * @since 12 307 */ 308 dispose(): void; 309 310 /** 311 * Reuse the BuilderNode based on the provided parameters. 312 * 313 * @param { Object } [param] - Parameters for reusing BuilderNode. 314 * @syscap SystemCapability.ArkUI.ArkUI.Full 315 * @crossplatform 316 * @atomicservice 317 * @since 12 318 */ 319 reuse(param?: Object): void; 320 321 /** 322 * Recycle the BuilderNode. 323 * 324 * @syscap SystemCapability.ArkUI.ArkUI.Full 325 * @crossplatform 326 * @atomicservice 327 * @since 12 328 */ 329 recycle(): void; 330 331 /** 332 * Notify BuilderNode to update the configuration to trigger a reload of the BuilderNode. 333 * 334 * @syscap SystemCapability.ArkUI.ArkUI.Full 335 * @crossplatform 336 * @atomicservice 337 * @since 12 338 */ 339 updateConfiguration(): void; 340} 341