• 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 
16 #ifndef FOUNDATION_ACE_INTERFACE_INNERKITS_XCOMPONENT_CONTROLLER_INTERFACE_H
17 #define FOUNDATION_ACE_INTERFACE_INNERKITS_XCOMPONENT_CONTROLLER_INTERFACE_H
18 
19 #include <memory>
20 
21 typedef struct napi_value__* napi_value;
22 typedef struct napi_env__* napi_env;
23 
24 namespace OHOS::Ace {
25 #ifndef ACE_EXPORT
26 #define ACE_EXPORT __attribute__((visibility("default")))
27 #endif
28 
29 enum XComponentControllerErrorCode {
30     XCOMPONENT_CONTROLLER_NO_ERROR = 0,
31     XCOMPONENT_CONTROLLER_BAD_PARAMETER,
32     XCOMPONENT_CONTROLLER_TYPE_ERROR,
33     XCOMPONENT_CONTROLLER_REPEAT_SET,
34     XCOMPONENT_CONTROLLER_RESET_ERROR,
35 };
36 
37 /**
38  * @class XComponentController
39  * XComponentController interface is used to control xcomponent.
40  * Xcomponent:XComponentController = 1:1
41  */
42 class ACE_EXPORT XComponentController {
43 public:
44     /**
45      * @brief Get xcomponentController from napiValue converted by jsXComponentController
46      *
47      */
48     static std::shared_ptr<XComponentController> GetXComponentControllerFromNapiValue(napi_env env,
49         napi_value napiValue);
50     XComponentController() = default;
51     virtual ~XComponentController() = default;
52 
53     /**
54      * @brief Get xcomponent's position releated to the window in which xcomponent is located
55      *
56      */
57     virtual XComponentControllerErrorCode GetGlobalPosition(float& offsetX, float& offsetY) = 0;
58 
59     /**
60      * @brief Get xcomponent's size
61      *
62      */
63     virtual XComponentControllerErrorCode GetSize(float& width, float& height) = 0;
64 
65     /**
66      * @brief move the controling right of showing & setting size and posiotion to the other xcomponentController,
67      * which cannot be repeated set more than once, unless calling reset before
68      * @param xcomponentController the other xcomponentController
69      */
70     virtual XComponentControllerErrorCode SetExtController(
71         std::shared_ptr<XComponentController> xcomponentController) = 0;
72 
73     /**
74      * @brief restore the controling right of showing & setting size and posiotion from the other xcomponentController
75      * which must be same as the controller set before
76      * @param xcomponentController the other xcomponentController
77      */
78     virtual XComponentControllerErrorCode ResetExtController(
79         std::shared_ptr<XComponentController> xcomponentController) = 0;
80 };
81 } // namespace OHOS::Ace
82 #endif // FOUNDATION_ACE_INTERFACE_INNERKITS_XCOMPONENT_CONTROLLER_INTERFACE_H
83