• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 namespace OHOS {
23 namespace AbilityRuntime {
24 class Context;
25 }
26 
27 namespace AppExecFwk {
28 class Configuration;
29 class Ability;
30 }
31 
32 namespace Rosen {
33 class Window;
34 enum class WindowMode : uint32_t;
35 class RSSurfaceNode;
36 }
37 
38 namespace AAFwk {
39 class Want;
40 }
41 
42 namespace MMI {
43 class PointerEvent;
44 class KeyEvent;
45 class AxisEvent;
46 } // namespace MMI
47 
48 namespace Media {
49     class PixelMap;
50 }
51 } // namespace OHOS
52 
53 class NativeEngine;
54 class NativeValue;
55 
56 namespace OHOS::Ace {
57 #define ACE_EXPORT __attribute__((visibility("default")))
58 class ACE_EXPORT UIContent {
59 public:
60     static std::unique_ptr<UIContent> Create(OHOS::AbilityRuntime::Context* context, NativeEngine* runtime);
61     static std::unique_ptr<UIContent> Create(OHOS::AppExecFwk::Ability* ability);
62     static void ShowDumpHelp(std::vector<std::string>& info);
63 
64     virtual ~UIContent() = default;
65 
66     // UI content life-cycles
67     virtual void Initialize(OHOS::Rosen::Window* window, const std::string& url, NativeValue* storage) = 0;
68     virtual void Foreground() = 0;
69     virtual void Background() = 0;
70     virtual void Focus() = 0;
71     virtual void UnFocus() = 0;
72     virtual void Destroy() = 0;
73     virtual void OnNewWant(const OHOS::AAFwk::Want& want) = 0;
74 
75     // distribute
76     virtual void Restore(OHOS::Rosen::Window* window, const std::string& contentInfo, NativeValue* storage) = 0;
77     virtual std::string GetContentInfo() const = 0;
78     virtual void DestroyUIDirector() = 0;
79 
80     // UI content event process
81     virtual bool ProcessBackPressed() = 0;
82     virtual bool ProcessPointerEvent(const std::shared_ptr<OHOS::MMI::PointerEvent>& pointerEvent) = 0;
83     virtual bool ProcessKeyEvent(const std::shared_ptr<OHOS::MMI::KeyEvent>& keyEvent) = 0;
84     virtual bool ProcessAxisEvent(const std::shared_ptr<OHOS::MMI::AxisEvent>& axisEvent) = 0;
85     virtual bool ProcessVsyncEvent(uint64_t timeStampNanos) = 0;
86     virtual void UpdateConfiguration(const std::shared_ptr<OHOS::AppExecFwk::Configuration>& config) = 0;
87     virtual void UpdateWindowMode(OHOS::Rosen::WindowMode mode) = 0;
88     virtual void HideWindowTitleButton(bool hideSplit, bool hideMaximize, bool hideMinimize) = 0;
89 
90     // Window color
91     virtual uint32_t GetBackgroundColor() = 0;
92     virtual void SetBackgroundColor(uint32_t color) = 0;
93 
94     virtual void DumpInfo(const std::vector<std::string>& params, std::vector<std::string>& info) = 0;
95 
96     // Set UIContent callback for custom window animation
97     virtual void SetNextFrameLayoutCallback(std::function<void()>&& callback) = 0;
98 
99     // Receive memory level notification
100     virtual void NotifyMemoryLevel(int32_t level) = 0;
101 
102     // receive label and icon
103     virtual void SetAppWindowTitle(const std::string& title) = 0;
104     virtual void SetAppWindowIcon(const std::shared_ptr<OHOS::Media::PixelMap>& pixelMap) = 0;
105 
106     // ArkTS Form
107     virtual std::shared_ptr<Rosen::RSSurfaceNode> GetFormRootNode() = 0;
108 
109     virtual void UpdateFormData(const std::string& data) = 0;
110 
111     virtual void SetFormWidth(const float width) = 0;
112     virtual void SetFormHeight(const float height) = 0;
113     virtual float GetFormWidth() = 0;
114     virtual float GetFormHeight() = 0;
115 
116     virtual void SetActionEventHandler(
117         std::function<void(const std::string&)>&& actionCallback) = 0;
118     virtual void SetErrorEventHandler(
119         std::function<void(const std::string&, const std::string&)>&& errorCallback) = 0;
120 };
121 } // namespace OHOS::Ace
122 
123 #endif // FOUNDATION_ACE_INTERFACE_INNERKITS_ACE_UI_CONTENT_H
124