• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 WINDOW_IMPL_H
17 #define WINDOW_IMPL_H
18 
19 #include "ffi_remote_data.h"
20 #include "pixel_map.h"
21 #include "window.h"
22 #include "window_utils.h"
23 #include "window_register_manager.h"
24 
25 namespace OHOS {
26 namespace Rosen {
27 struct CAvoidArea {
28     bool visible;
29     Rect leftRect { 0, 0, 0, 0 };
30     Rect topRect { 0, 0, 0, 0 };
31     Rect rightRect { 0, 0, 0, 0 };
32     Rect bottomRect { 0, 0, 0, 0 };
33 };
34 
35 struct ResWindow {
36     int32_t ret;
37     sptr<Window> nativeWindow;
38 };
39 
40 struct CBarProperties {
41     std::string statusBarColor;
42     bool isStatusBarLightIcon;
43     std::string statusBarContentColor;
44     std::string navigationBarColor;
45     bool isNavigationBarLightIcon;
46     std::string navigationBarContentColor;
47     bool enableStatusBarAnimation;
48     bool enableNavigationBarAnimation;
49 };
50 
51 struct CTitleButtonRect {
52     int32_t right;
53     int32_t top;
54     uint32_t width;
55     uint32_t height;
56 };
57 
58 struct CWindowLimits {
59     uint32_t maxWidth = INT32_MAX;
60     uint32_t maxHeight = INT32_MAX;
61     uint32_t minWidth = 1;
62     uint32_t minHeight = 1;
63 };
64 
65 class CJWindowImpl : public OHOS::FFI::FFIData {
66 public:
67     explicit CJWindowImpl(sptr<Window> ptr);
68     sptr<Window> GetWindowToken();
69     int32_t Hide();
70     int32_t HideWithAnimation();
71     int32_t ShowWindow();
72     int32_t ShowWithAnimation();
73     int32_t DestroyWindow();
74     int32_t MoveWindowTo(int32_t x, int32_t y);
75     int32_t Resize(uint32_t width, uint32_t height);
76     int32_t SetWindowMode(uint32_t mode);
77     CWindowProperties GetWindowProperties(int32_t* errCode);
78     int32_t SetWindowLayoutFullScreen(bool isLayoutFullScreen);
79     int32_t SetWindowBackgroundColor(const char* color);
80     int32_t SetWindowBrightness(float brightness);
81     int32_t SetWindowFocusable(bool focusable);
82     int32_t SetWindowKeepScreenOn(bool keepScreenOn);
83     int32_t SetWindowPrivacyMode(bool isPrivacyMode);
84     int32_t SetWindowTouchable(bool touchable);
85     int32_t SetForbidSplitMove(bool isForbidSplitMove);
86     bool IsWindowSupportWideGamut(int32_t* errCode);
87     int32_t SetWindowColorSpace(uint32_t colorSpace);
88     bool IsWindowShowing(int32_t* errCode);
89     int32_t SetBackdropBlurStyle(uint32_t blurStyle);
90     int32_t SetPreferredOrientation(uint32_t orientation);
91     int32_t GetWindowAvoidArea(uint32_t areaType, CAvoidArea* retPtr);
92     int32_t SetShadowRadius(double radius);
93     int32_t SetShadowColor(std::string color);
94     int32_t SetShadowOffsetX(double offsetX);
95     int32_t SetShadowOffsetY(double offsetY);
96     int32_t SetBackdropBlur(double radius);
97     int32_t SetBlur(double radius);
98     int32_t SetWaterMarkFlag(bool enable);
99     int32_t SetAspectRatio(double ratio);
100     int32_t ResetAspectRatio();
101     int32_t Minimize();
102     int32_t SetCornerRadius(float radius);
103     int32_t SetResizeByDragEnabled(bool enable);
104     int32_t RaiseToAppTop();
105     int32_t SetSnapshotSkip(bool isSkip);
106     int32_t SetWakeUpScreen(bool wakeUp);
107 
108     int32_t SetRaiseByClickEnabled(bool enable);
109     uint32_t GetWindowColorSpace(int32_t* errCode);
110     int32_t RaiseAboveTarget(int32_t windowId);
111     int32_t Translate(double x, double y, double z);
112     int32_t Rotate(double x, double y, double z, double pivotX, double pivotY);
113     int32_t Scale(double x, double y, double pivotX, double pivotY);
114     int32_t Opacity(double opacity);
115     std::shared_ptr<Media::PixelMap> Snapshot(int32_t* errCode);
116     int32_t SetWindowSystemBarEnable(char** arr, uint32_t size);
117     int32_t OnRegisterWindowCallback(const std::string& type, int64_t funcId, int64_t parameter = 0);
118     int32_t UnregisterWindowCallback(const std::string& type, int64_t funcId);
119     int32_t SetWindowSystemBarProperties(const CBarProperties& cProperties);
120     ResWindow CheckWindow();
GetRuntimeType()121     OHOS::FFI::RuntimeType* GetRuntimeType() override { return GetClassType(); }
122     int32_t SetSubWindowModal(bool isModal);
123     int32_t SetWindowLimits(const CWindowLimits& cWindowLimits, CWindowLimits& rePtr);
124     int32_t GetWindowLimits(CWindowLimits& rePtr);
125     bool GetImmersiveModeEnabledState(int32_t& errCode);
126     int32_t SetImmersiveModeEnabledState(bool enabled);
127     int32_t KeepKeyboardOnFocus(bool keepKeyboardFlag);
128     int32_t GetWindowDecorHeight(int32_t& height);
129     int32_t SetWindowDecorHeight(int32_t height);
130     int32_t Recover();
131     int32_t SetWindowDecorVisible(bool isVisible);
132     int32_t GetTitleButtonRect(CTitleButtonRect& rePtr);
133     int32_t SetDialogBackGestureEnabled(bool enabled);
134     int32_t DisableLandscapeMultiWindow();
135     int32_t EnableLandscapeMultiWindow();
136     int32_t SetWindowGrayScale(float grayScale);
137     uint32_t GetPreferredOrientation(int32_t& errCode);
138     int32_t GetWindowStatus(int32_t& errCode);
139     int32_t GetWindowSystemBarProperties(CJBarProperties& rePtr);
140     int32_t SpecificSystemBarEnabled(int32_t name, bool enable, bool enableAnimation);
141     int32_t Maximize(int32_t presentation);
142     int32_t CreateSubWindowWithOptions(std::string name, int64_t &windowId,
143                                        CSubWindowOptions option);
144 private:
145     friend class OHOS::FFI::RuntimeType;
146     friend class OHOS::FFI::TypeBase;
GetClassType()147     static OHOS::FFI::RuntimeType* GetClassType()
148     {
149         static OHOS::FFI::RuntimeType runtimeType =
150             OHOS::FFI::RuntimeType::Create<OHOS::FFI::FFIData>("CJWindowImpl");
151         return &runtimeType;
152     }
153     sptr<Window> windowToken_;
154     std::unique_ptr<CjWindowRegisterManager> registerManager_ = nullptr;
155 };
156 
157 sptr<CJWindowImpl> CreateCjWindowObject(sptr<Window>& window);
158 sptr<CJWindowImpl> FindCjWindowObject(const std::string& windowName);
159 
160 }
161 }
162 
163 #endif
164