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 #ifndef WINDOW_IMPL_H 16 #define WINDOW_IMPL_H 17 18 #include "ffi_remote_data.h" 19 #include "pixel_map.h" 20 #include "window.h" 21 #include "window_utils.h" 22 #include "window_register_manager.h" 23 24 namespace OHOS { 25 namespace Rosen { 26 struct CAvoidArea { 27 bool visible; 28 Rect leftRect { 0, 0, 0, 0 }; 29 Rect topRect { 0, 0, 0, 0 }; 30 Rect rightRect { 0, 0, 0, 0 }; 31 Rect bottomRect { 0, 0, 0, 0 }; 32 }; 33 34 struct ResWindow { 35 int32_t ret; 36 sptr<Window> nativeWindow; 37 }; 38 39 struct CBarProperties { 40 std::string statusBarColor; 41 bool isStatusBarLightIcon; 42 std::string statusBarContentColor; 43 std::string navigationBarColor; 44 bool isNavigationBarLightIcon; 45 std::string navigationBarContentColor; 46 }; 47 48 class CJWindowImpl : public OHOS::FFI::FFIData { 49 public: 50 explicit CJWindowImpl(sptr<Window> ptr); 51 sptr<Window> GetWindowToken(); 52 int32_t Hide(); 53 int32_t HideWithAnimation(); 54 int32_t ShowWindow(); 55 int32_t ShowWithAnimation(); 56 int32_t DestroyWindow(); 57 int32_t MoveWindowTo(int32_t x, int32_t y); 58 int32_t Resize(uint32_t width, uint32_t height); 59 int32_t SetWindowMode(uint32_t mode); 60 CWindowProperties GetWindowProperties(int32_t* errCode); 61 int32_t SetWindowLayoutFullScreen(bool isLayoutFullScreen); 62 int32_t SetWindowBackgroundColor(const char* color); 63 int32_t SetWindowBrightness(float brightness); 64 int32_t SetWindowFocusable(bool focusable); 65 int32_t SetWindowKeepScreenOn(bool keepScreenOn); 66 int32_t SetWindowPrivacyMode(bool isPrivacyMode); 67 int32_t SetWindowTouchable(bool touchable); 68 int32_t SetForbidSplitMove(bool isForbidSplitMove); 69 bool IsWindowSupportWideGamut(int32_t* errCode); 70 int32_t SetWindowColorSpace(uint32_t colorSpace); 71 bool IsWindowShowing(int32_t* errCode); 72 int32_t SetBackdropBlurStyle(uint32_t blurStyle); 73 int32_t SetPreferredOrientation(uint32_t orientation); 74 int32_t GetWindowAvoidArea(uint32_t areaType, CAvoidArea* retPtr); 75 int32_t SetShadowRadius(double radius); 76 int32_t SetShadowColor(std::string color); 77 int32_t SetShadowOffsetX(double offsetX); 78 int32_t SetShadowOffsetY(double offsetY); 79 int32_t SetBackdropBlur(double radius); 80 int32_t SetBlur(double radius); 81 int32_t SetWaterMarkFlag(bool enable); 82 int32_t SetAspectRatio(double ratio); 83 int32_t ResetAspectRatio(); 84 int32_t Minimize(); 85 int32_t SetCornerRadius(float radius); 86 int32_t SetResizeByDragEnabled(bool enable); 87 int32_t RaiseToAppTop(); 88 int32_t SetSnapshotSkip(bool isSkip); 89 int32_t SetWakeUpScreen(bool wakeUp); 90 91 int32_t SetRaiseByClickEnabled(bool enable); 92 uint32_t GetWindowColorSpace(int32_t* errCode); 93 int32_t RaiseAboveTarget(int32_t windowId); 94 int32_t Translate(double x, double y, double z); 95 int32_t Rotate(double x, double y, double z, double pivotX, double pivotY); 96 int32_t Scale(double x, double y, double pivotX, double pivotY); 97 int32_t Opacity(double opacity); 98 std::shared_ptr<Media::PixelMap> Snapshot(int32_t* errCode); 99 int32_t SetWindowSystemBarEnable(char** arr, uint32_t size); 100 int32_t OnRegisterWindowCallback(const std::string& type, int64_t funcId); 101 int32_t UnregisterWindowCallback(const std::string& type, int64_t funcId); 102 int32_t SetWindowSystemBarProperties(const CBarProperties& cProperties); 103 ResWindow CheckWindow(); GetRuntimeType()104 OHOS::FFI::RuntimeType* GetRuntimeType() override { return GetClassType(); } 105 private: 106 friend class OHOS::FFI::RuntimeType; 107 friend class OHOS::FFI::TypeBase; GetClassType()108 static OHOS::FFI::RuntimeType* GetClassType() 109 { 110 static OHOS::FFI::RuntimeType runtimeType = 111 OHOS::FFI::RuntimeType::Create<OHOS::FFI::FFIData>("CJWindowImpl"); 112 return &runtimeType; 113 } 114 sptr<Window> windowToken_; 115 std::unique_ptr<CjWindowRegisterManager> registerManager_ = nullptr; 116 }; 117 118 sptr<CJWindowImpl> CreateCjWindowObject(sptr<Window>& window); 119 sptr<CJWindowImpl> FindCjWindowObject(const std::string& windowName); 120 121 } 122 } 123 124 #endif 125