• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_UI_CONTEXT_H
17 #define FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_UI_CONTEXT_H
18 
19 #include <functional>
20 
21 #include "ui/base/ace_type.h"
22 #include "ui/base/geometry/ng/offset_t.h"
23 #include "ui/base/utils/system_param.h"
24 #include "ui/view/frame_node.h"
25 #include "ui/view/overlay/overlay_manager.h"
26 
27 namespace OHOS {
28 class IRemoteObject;
29 template<typename T>
30 class sptr;
31 } // namespace OHOS
32 namespace OHOS::Ace {
33 class DisplayInfo;
34 enum class FoldStatus : uint32_t;
35 enum class WindowMode : uint32_t;
36 enum class WindowSizeChangeReason : uint32_t;
37 }; // namespace OHOS::Ace
38 
39 namespace OHOS::Ace::Kit {
40 
41 using Task = std::function<void()>;
42 using ArkUIObjectLifecycleCallback = std::function<void(void*)>;
43 class OverlayManager;
44 
45 class ACE_FORCE_EXPORT UIContext : public AceType {
46     DECLARE_ACE_TYPE(UIContext, AceType);
47 public:
48     static RefPtr<UIContext> Current();
49 
50     // task schedule
51     virtual void RunScopeUITaskSync(Task&& task, const std::string& name) = 0;
52     virtual void RunScopeUITask(Task&& task, const std::string& name) = 0;
53     virtual void RunScopeUIDelayedTask(Task&& task, const std::string& name, uint32_t delayTime) = 0;
54 
55     // page operation
56     virtual void OnBackPressed() = 0;
57 
58     // ui infos
59     virtual ColorMode GetLocalColorMode() = 0;
60     virtual ColorMode GetColorMode() = 0;
61     virtual float GetFontScale() = 0;
62 
63     // overlay manager
64     virtual RefPtr<OverlayManager> GetOverlayManager() = 0;
65 
66     // pipeline tasks
67     virtual void AddAfterLayoutTask(Task&& task, bool isFlushInImplicitAnimationTask = false) = 0;
68     virtual void RequestFrame() = 0;
69 
70     // API version
71     virtual int32_t GetApiTargetVersion() = 0;
72     virtual bool GreatOrEqualTargetAPIVersion(int32_t version) = 0;
73     virtual int32_t GetContainerModalTitleHeight() = 0;
74     virtual int32_t GetContainerModalButtonsWidth() = 0;
75     virtual NG::OffsetF GetContainerModalButtonsOffset() = 0;
76     virtual void RegisterArkUIObjectLifecycleCallback(ArkUIObjectLifecycleCallback&& callback) = 0;
77     virtual void UnregisterArkUIObjectLifecycleCallback() = 0;
78 
79     virtual sptr<IRemoteObject> GetToken() = 0;
80 
81     // Display Info
82     virtual RefPtr<DisplayInfo> GetDisplayInfo() = 0;
83     virtual WindowMode GetWindowMode() = 0;
84     virtual bool GetIsMidScene() = 0;
85     virtual bool IsAccessibilityEnabled() = 0;
86 
87     virtual int32_t RegisterSurfaceChangedCallback(
88         std::function<void(int32_t, int32_t, int32_t, int32_t, WindowSizeChangeReason)>&& callback) = 0;
89     virtual void UnregisterSurfaceChangedCallback(int32_t callbackId) = 0;
90     virtual int32_t RegisterFoldStatusChangedCallback(std::function<void(FoldStatus)>&& callback) = 0;
91     virtual void UnRegisterFoldStatusChangedCallback(int32_t callbackId) = 0;
92     virtual int32_t RegisterRotationEndCallback(std::function<void()>&& callback) = 0;
93     virtual void UnregisterRotationEndCallback(int32_t callbackId) = 0;
94     virtual void AddWindowSizeChangeCallback(int32_t nodeId) = 0;
95 };
96 
97 }
98 #endif // FOUNDATION_ACE_INTERFACES_INNER_API_ACE_KIT_INCLUDE_VIEW_UI_CONTEXT_H
99