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