1 /* 2 * Copyright (c) 2021-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 OHOS_JS_WINDOW_H 17 #define OHOS_JS_WINDOW_H 18 19 #include "js_runtime_utils.h" 20 #include "js_window_register_manager.h" 21 #include "js_window_utils.h" 22 #include "native_engine/native_engine.h" 23 #include "native_engine/native_value.h" 24 #include "window.h" 25 26 namespace OHOS { 27 namespace Rosen { 28 NativeValue* CreateJsWindowObject(NativeEngine& engine, sptr<Window>& window); 29 std::shared_ptr<NativeReference> FindJsWindowObject(std::string windowName); 30 class JsWindow final { 31 public: 32 explicit JsWindow(const sptr<Window>& window); 33 ~JsWindow(); 34 static void Finalizer(NativeEngine* engine, void* data, void* hint); 35 static NativeValue* Show(NativeEngine* engine, NativeCallbackInfo* info); 36 static NativeValue* Destroy(NativeEngine* engine, NativeCallbackInfo* info); 37 static NativeValue* Hide(NativeEngine* engine, NativeCallbackInfo* info); 38 static NativeValue* MoveTo(NativeEngine* engine, NativeCallbackInfo* info); 39 static NativeValue* Resize(NativeEngine* engine, NativeCallbackInfo* info); 40 static NativeValue* SetWindowType(NativeEngine* engine, NativeCallbackInfo* info); 41 static NativeValue* SetWindowMode(NativeEngine* engine, NativeCallbackInfo* info); 42 static NativeValue* GetProperties(NativeEngine* engine, NativeCallbackInfo* info); 43 static NativeValue* RegisterWindowCallback(NativeEngine* engine, NativeCallbackInfo* info); 44 static NativeValue* UnregisterWindowCallback(NativeEngine* engine, NativeCallbackInfo* info); 45 static NativeValue* LoadContent(NativeEngine* engine, NativeCallbackInfo* info); 46 static NativeValue* SetFullScreen(NativeEngine* engine, NativeCallbackInfo* info); 47 static NativeValue* SetLayoutFullScreen(NativeEngine* engine, NativeCallbackInfo* info); 48 static NativeValue* SetSystemBarEnable(NativeEngine* engine, NativeCallbackInfo* info); 49 static NativeValue* SetSystemBarProperties(NativeEngine* engine, NativeCallbackInfo* info); 50 static NativeValue* GetAvoidArea(NativeEngine* engine, NativeCallbackInfo* info); 51 static NativeValue* IsShowing(NativeEngine* engine, NativeCallbackInfo* info); 52 static NativeValue* SetBackgroundColor(NativeEngine* engine, NativeCallbackInfo* info); 53 static NativeValue* SetBrightness(NativeEngine* engine, NativeCallbackInfo* info); 54 static NativeValue* SetDimBehind(NativeEngine* engine, NativeCallbackInfo* info); 55 static NativeValue* SetFocusable(NativeEngine* engine, NativeCallbackInfo* info); 56 static NativeValue* SetKeepScreenOn(NativeEngine* engine, NativeCallbackInfo* info); 57 static NativeValue* SetOutsideTouchable(NativeEngine* engine, NativeCallbackInfo* info); 58 static NativeValue* SetPrivacyMode(NativeEngine* engine, NativeCallbackInfo* info); 59 static NativeValue* SetTouchable(NativeEngine* engine, NativeCallbackInfo* info); 60 static NativeValue* SetCallingWindow(NativeEngine* engine, NativeCallbackInfo* info); 61 62 // colorspace, gamut 63 static NativeValue* IsSupportWideGamut(NativeEngine* engine, NativeCallbackInfo* info); 64 static NativeValue* SetColorSpace(NativeEngine* engine, NativeCallbackInfo* info); 65 static NativeValue* GetColorSpace(NativeEngine* engine, NativeCallbackInfo* info); 66 67 private: 68 std::string GetWindowName(); 69 NativeValue* OnShow(NativeEngine& engine, NativeCallbackInfo& info); 70 NativeValue* OnDestroy(NativeEngine& engine, NativeCallbackInfo& info); 71 NativeValue* OnHide(NativeEngine& engine, NativeCallbackInfo& info); 72 NativeValue* OnMoveTo(NativeEngine& engine, NativeCallbackInfo& info); 73 NativeValue* OnResize(NativeEngine& engine, NativeCallbackInfo& info); 74 NativeValue* OnSetWindowType(NativeEngine& engine, NativeCallbackInfo& info); 75 NativeValue* OnSetWindowMode(NativeEngine& engine, NativeCallbackInfo& info); 76 NativeValue* OnGetProperties(NativeEngine& engine, NativeCallbackInfo& info); 77 NativeValue* OnRegisterWindowCallback(NativeEngine& engine, NativeCallbackInfo& info); 78 NativeValue* OnUnregisterWindowCallback(NativeEngine& engine, NativeCallbackInfo& info); 79 NativeValue* OnSetFullScreen(NativeEngine& engine, NativeCallbackInfo& info); 80 NativeValue* OnSetLayoutFullScreen(NativeEngine& engine, NativeCallbackInfo& info); 81 NativeValue* OnSetSystemBarEnable(NativeEngine& engine, NativeCallbackInfo& info); 82 NativeValue* OnSetSystemBarProperties(NativeEngine& engine, NativeCallbackInfo& info); 83 NativeValue* OnLoadContent(NativeEngine& engine, NativeCallbackInfo& info); 84 NativeValue* OnGetAvoidArea(NativeEngine& engine, NativeCallbackInfo& info); 85 NativeValue* OnIsShowing(NativeEngine& engine, NativeCallbackInfo& info); 86 87 // colorspace, gamut 88 NativeValue* OnIsSupportWideGamut(NativeEngine& engine, NativeCallbackInfo& info); 89 NativeValue* OnSetColorSpace(NativeEngine& engine, NativeCallbackInfo& info); 90 NativeValue* OnGetColorSpace(NativeEngine& engine, NativeCallbackInfo& info); 91 NativeValue* OnSetBackgroundColor(NativeEngine& engine, NativeCallbackInfo& info); 92 NativeValue* OnSetBrightness(NativeEngine& engine, NativeCallbackInfo& info); 93 NativeValue* OnSetDimBehind(NativeEngine& engine, NativeCallbackInfo& info); 94 NativeValue* OnSetFocusable(NativeEngine& engine, NativeCallbackInfo& info); 95 NativeValue* OnSetKeepScreenOn(NativeEngine& engine, NativeCallbackInfo& info); 96 NativeValue* OnSetOutsideTouchable(NativeEngine& engine, NativeCallbackInfo& info); 97 NativeValue* OnSetPrivacyMode(NativeEngine& engine, NativeCallbackInfo& info); 98 NativeValue* OnSetTouchable(NativeEngine& engine, NativeCallbackInfo& info); 99 NativeValue* OnSetCallingWindow(NativeEngine& engine, NativeCallbackInfo& info); 100 101 sptr<Window> windowToken_ = nullptr; 102 std::unique_ptr<JsWindowRegisterManager> registerManager_ = nullptr; 103 }; 104 } // namespace Rosen 105 } // namespace OHOS 106 #endif