• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16enum NodeRenderType {
17  RENDER_TYPE_DISPLAY = 0,
18  RENDER_TYPE_TEXTURE,
19}
20
21declare interface RenderOptions {
22  selfIdealSize?: Size,
23  type?: NodeRenderType,
24  surfaceId?: string
25}
26
27declare class DrawContext {}
28
29declare class __JSBaseNode__ {
30  constructor(options?: RenderOptions);
31  create(builder: (...args: Object[]) => void, params: Object): number | null;
32  createRenderNode(node: FrameNode | RenderNode): number | null;
33  finishUpdateFunc(): void;
34  postTouchEvent(touchEvent: TouchEvent): boolean;
35  dispose(): void;
36  updateStart(): void;
37  updateEnd(): void;
38  draw(drawContext: DrawContext): void;
39}
40
41class BaseNode extends __JSBaseNode__ {
42  protected instanceId_?: number;
43  protected nodePtr_: number | null;
44  constructor(uiContext: UIContext, options?: RenderOptions) {
45    super(options);
46    let instanceId: number = -1;
47    if (uiContext === undefined) {
48      throw Error('Node constructor error, param uiContext error');
49    } else {
50      if (!(typeof uiContext === "object") || !("instanceId_" in uiContext)) {
51        throw Error(
52          'Node constructor error, param uiContext is invalid'
53        );
54      }
55      instanceId = uiContext.instanceId_;
56    }
57    this.instanceId_ = instanceId;
58  }
59  public getInstanceId()
60  {
61    return this.instanceId_;
62  }
63}
64