• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021 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_ACE_UI_CONTENT_H
17 #define FOUNDATION_ACE_INTERFACE_INNERKITS_ACE_UI_CONTENT_H
18 
19 #include <memory>
20 #include <string>
21 
22 #include "viewport_config.h"
23 
24 namespace OHOS {
25 
26 namespace AbilityRuntime {
27 class Context;
28 }
29 
30 namespace AppExecFwk {
31 class Configuration;
32 class Ability;
33 }
34 
35 namespace Rosen {
36 class Window;
37 enum class WindowSizeChangeReason : uint32_t;
38 enum class WindowMode : uint32_t;
39 }
40 
41 namespace MMI {
42 class PointerEvent;
43 class KeyEvent;
44 class AxisEvent;
45 } // namespace MMI
46 
47 } // namespace OHOS
48 
49 class NativeEngine;
50 class NativeValue;
51 
52 namespace OHOS::Ace {
53 
54 #define ACE_EXPORT __attribute__((visibility("default")))
55 
56 class ACE_EXPORT UIContent {
57 public:
58     static std::unique_ptr<UIContent> Create(OHOS::AbilityRuntime::Context* context, NativeEngine* runtime);
59     static std::unique_ptr<UIContent> Create(OHOS::AppExecFwk::Ability* ability);
60 
61     virtual ~UIContent() = default;
62 
63     // UI content life-cycles
64     virtual void Initialize(OHOS::Rosen::Window* window, const std::string& url, NativeValue* storage) = 0;
65     virtual void Foreground() = 0;
66     virtual void Background() = 0;
67     virtual void Focus() = 0;
68     virtual void UnFocus() = 0;
69     virtual void Destroy() = 0;
70 
71     // distribute
72     virtual void Restore(OHOS::Rosen::Window* window, const std::string& contentInfo, NativeValue* storage) = 0;
73     virtual std::string GetContentInfo() const = 0;
74 
75     // UI content event process
76     virtual bool ProcessBackPressed() = 0;
77     virtual bool ProcessPointerEvent(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent) = 0;
78     virtual bool ProcessKeyEvent(const std::shared_ptr<OHOS::MMI::KeyEvent>& keyEvent) = 0;
79     virtual bool ProcessAxisEvent(const std::shared_ptr<OHOS::MMI::AxisEvent>& axisEvent) = 0;
80     virtual bool ProcessVsyncEvent(uint64_t timeStampNanos) = 0;
81     virtual void UpdateConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config) = 0;
82     virtual void UpdateViewportConfig(const ViewportConfig& config, OHOS::Rosen::WindowSizeChangeReason reason) = 0;
83     virtual void UpdateWindowMode(OHOS::Rosen::WindowMode mode) = 0;
84 
85     // Window color
86     virtual uint32_t GetBackgroundColor() = 0;
87     virtual void SetBackgroundColor(uint32_t color) = 0;
88 
89     virtual void DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) = 0;
90 };
91 
92 } // namespace OHOS::Ace
93 
94 #endif // FOUNDATION_ACE_INTERFACE_INNERKITS_ACE_UI_CONTENT_H
95