123b3eb3cSopenharmony_ci/* 223b3eb3cSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd. 323b3eb3cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 423b3eb3cSopenharmony_ci * you may not use this file except in compliance with the License. 523b3eb3cSopenharmony_ci * You may obtain a copy of the License at 623b3eb3cSopenharmony_ci * 723b3eb3cSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 823b3eb3cSopenharmony_ci * 923b3eb3cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1023b3eb3cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1123b3eb3cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1223b3eb3cSopenharmony_ci * See the License for the specific language governing permissions and 1323b3eb3cSopenharmony_ci * limitations under the License. 1423b3eb3cSopenharmony_ci */ 1523b3eb3cSopenharmony_ci 1623b3eb3cSopenharmony_ci#ifndef FOUNDATION_ACE_FRAMEWORKS_BASE_SUBWINDOW_SUBWINDOW_H 1723b3eb3cSopenharmony_ci#define FOUNDATION_ACE_FRAMEWORKS_BASE_SUBWINDOW_SUBWINDOW_H 1823b3eb3cSopenharmony_ci 1923b3eb3cSopenharmony_ci#include <set> 2023b3eb3cSopenharmony_ci 2123b3eb3cSopenharmony_ci#include "base/geometry/ng/rect_t.h" 2223b3eb3cSopenharmony_ci#include "base/memory/ace_type.h" 2323b3eb3cSopenharmony_ci#include "base/memory/referenced.h" 2423b3eb3cSopenharmony_ci#include "core/components/dialog/dialog_properties.h" 2523b3eb3cSopenharmony_ci#include "core/components_ng/base/frame_node.h" 2623b3eb3cSopenharmony_ci#include "core/components_ng/pattern/overlay/overlay_manager.h" 2723b3eb3cSopenharmony_ci#include "core/components_ng/property/menu_property.h" 2823b3eb3cSopenharmony_ci#include "core/pipeline/base/component.h" 2923b3eb3cSopenharmony_ci 3023b3eb3cSopenharmony_cinamespace OHOS::Ace { 3123b3eb3cSopenharmony_ci 3223b3eb3cSopenharmony_cienum class ToastWindowType { 3323b3eb3cSopenharmony_ci TOAST_IN_TYPE_APP_SUB_WINDOW = 0, 3423b3eb3cSopenharmony_ci TOAST_IN_TYPE_SYSTEM_SUB_WINDOW, 3523b3eb3cSopenharmony_ci TOAST_IN_TYPE_TOAST, 3623b3eb3cSopenharmony_ci TOAST_IN_TYPE_SYSTEM_FLOAT, 3723b3eb3cSopenharmony_ci TOAST_WINDOW_COUNT 3823b3eb3cSopenharmony_ci}; 3923b3eb3cSopenharmony_ci 4023b3eb3cSopenharmony_ciclass ACE_EXPORT Subwindow : public AceType { 4123b3eb3cSopenharmony_ci DECLARE_ACE_TYPE(Subwindow, AceType) 4223b3eb3cSopenharmony_ci 4323b3eb3cSopenharmony_cipublic: 4423b3eb3cSopenharmony_ci static RefPtr<Subwindow> CreateSubwindow(int32_t instanceId); 4523b3eb3cSopenharmony_ci 4623b3eb3cSopenharmony_ci virtual bool InitContainer() = 0; 4723b3eb3cSopenharmony_ci virtual void ResizeWindow() = 0; 4823b3eb3cSopenharmony_ci virtual NG::RectF GetRect() = 0; 4923b3eb3cSopenharmony_ci virtual void SetRect(const NG::RectF& rect) = 0; 5023b3eb3cSopenharmony_ci virtual void ShowMenu(const RefPtr<Component>& newComponent) = 0; 5123b3eb3cSopenharmony_ci virtual void ShowMenuNG(const RefPtr<NG::FrameNode> menuNode, const NG::MenuParam& menuParam, 5223b3eb3cSopenharmony_ci const RefPtr<NG::FrameNode>& targetNode, const NG::OffsetF& offset) = 0; 5323b3eb3cSopenharmony_ci virtual void ShowMenuNG(std::function<void()>&& buildFunc, std::function<void()>&& previewBuildFunc, 5423b3eb3cSopenharmony_ci const NG::MenuParam& menuParam, const RefPtr<NG::FrameNode>& targetNode, const NG::OffsetF& offset) = 0; 5523b3eb3cSopenharmony_ci virtual bool ShowPreviewNG(bool isStartDraggingFromSubWindow) = 0; 5623b3eb3cSopenharmony_ci virtual void HidePreviewNG() = 0; 5723b3eb3cSopenharmony_ci virtual void HideMenuNG(const RefPtr<NG::FrameNode>& menu, int32_t targetId) = 0; 5823b3eb3cSopenharmony_ci virtual void HideMenuNG(bool showPreviewAnimation = true, bool startDrag = false) = 0; 5923b3eb3cSopenharmony_ci virtual void UpdateHideMenuOffsetNG(const NG::OffsetF& offset = NG::OffsetF(0.0f, 0.0f), 6023b3eb3cSopenharmony_ci float meunuScale = 1.0f, bool isRedragStart = false, int32_t menuWrapperId = -1) = 0; 6123b3eb3cSopenharmony_ci virtual void ContextMenuSwitchDragPreviewAnimationtNG(const RefPtr<NG::FrameNode>& dragPreviewNode, 6223b3eb3cSopenharmony_ci const NG::OffsetF& offset = NG::OffsetF(0.0f, 0.0f)) = 0; 6323b3eb3cSopenharmony_ci virtual void UpdatePreviewPosition() = 0; 6423b3eb3cSopenharmony_ci virtual bool GetMenuPreviewCenter(NG::OffsetF& offset) = 0; 6523b3eb3cSopenharmony_ci virtual void ShowPopup(const RefPtr<Component>& newComponent, bool disableTouchEvent = true) = 0; 6623b3eb3cSopenharmony_ci virtual void ShowPopupNG(int32_t targetId, const NG::PopupInfo& popupInfo, 6723b3eb3cSopenharmony_ci const std::function<void(int32_t)>&& onWillDismiss = nullptr, bool interactiveDismiss = true) = 0; 6823b3eb3cSopenharmony_ci virtual void HidePopupNG(int32_t targetId) = 0; 6923b3eb3cSopenharmony_ci virtual void GetPopupInfoNG(int32_t targetId, NG::PopupInfo& popupInfo) = 0; 7023b3eb3cSopenharmony_ci virtual bool CancelPopup(const std::string& id) = 0; 7123b3eb3cSopenharmony_ci virtual void CloseMenu() = 0; 7223b3eb3cSopenharmony_ci virtual void ClearMenu() {}; 7323b3eb3cSopenharmony_ci virtual void ClearMenuNG(int32_t targetId = -1, bool inWindow = true, bool showAnimation = false) = 0; 7423b3eb3cSopenharmony_ci virtual void ClearPopupNG() = 0; 7523b3eb3cSopenharmony_ci virtual RefPtr<NG::FrameNode> ShowDialogNG( 7623b3eb3cSopenharmony_ci const DialogProperties& dialogProps, std::function<void()>&& buildFunc) = 0; 7723b3eb3cSopenharmony_ci virtual RefPtr<NG::FrameNode> ShowDialogNGWithNode( 7823b3eb3cSopenharmony_ci const DialogProperties& dialogProps, const RefPtr<NG::UINode>& customNode) = 0; 7923b3eb3cSopenharmony_ci virtual void CloseDialogNG(const RefPtr<NG::FrameNode>& dialogNode) = 0; 8023b3eb3cSopenharmony_ci virtual void OpenCustomDialogNG(const DialogProperties& dialogProps, std::function<void(int32_t)>&& callback) = 0; 8123b3eb3cSopenharmony_ci virtual void CloseCustomDialogNG(int32_t dialogId) = 0; 8223b3eb3cSopenharmony_ci virtual void CloseCustomDialogNG(const WeakPtr<NG::UINode>& node, std::function<void(int32_t)>&& callback) = 0; 8323b3eb3cSopenharmony_ci virtual void UpdateCustomDialogNG(const WeakPtr<NG::UINode>& node, const DialogProperties& dialogProps, 8423b3eb3cSopenharmony_ci std::function<void(int32_t)>&& callback) = 0; 8523b3eb3cSopenharmony_ci virtual void HideSubWindowNG() = 0; 8623b3eb3cSopenharmony_ci virtual int32_t GetChildContainerId() const = 0; 8723b3eb3cSopenharmony_ci virtual bool GetShown() = 0; 8823b3eb3cSopenharmony_ci virtual void MarkDirtyDialogSafeArea() = 0; 8923b3eb3cSopenharmony_ci 9023b3eb3cSopenharmony_ci // Add interface for hot regions 9123b3eb3cSopenharmony_ci virtual void SetHotAreas(const std::vector<Rect>& rects, int32_t nodeId) {}; 9223b3eb3cSopenharmony_ci virtual void DeleteHotAreas(int32_t nodeId) {}; 9323b3eb3cSopenharmony_ci 9423b3eb3cSopenharmony_ci // Add interface to provide the size and offset of the parent window 9523b3eb3cSopenharmony_ci virtual Rect GetParentWindowRect() const = 0; 9623b3eb3cSopenharmony_ci virtual Rect GetUIExtensionHostWindowRect() const = 0; 9723b3eb3cSopenharmony_ci virtual NG::RectF GetWindowRect() const 9823b3eb3cSopenharmony_ci { 9923b3eb3cSopenharmony_ci return NG::RectF(); 10023b3eb3cSopenharmony_ci } 10123b3eb3cSopenharmony_ci virtual bool IsFreeMultiWindow() const = 0; 10223b3eb3cSopenharmony_ci virtual void OnFreeMultiWindowSwitch(bool enable) = 0; 10323b3eb3cSopenharmony_ci virtual int32_t RegisterFreeMultiWindowSwitchCallback(std::function<void(bool)>&& callback) = 0; 10423b3eb3cSopenharmony_ci virtual void UnRegisterFreeMultiWindowSwitchCallback(int32_t callbackId) = 0; 10523b3eb3cSopenharmony_ci 10623b3eb3cSopenharmony_ci int32_t GetSubwindowId() const 10723b3eb3cSopenharmony_ci { 10823b3eb3cSopenharmony_ci return subwindowId_; 10923b3eb3cSopenharmony_ci } 11023b3eb3cSopenharmony_ci 11123b3eb3cSopenharmony_ci void SetSubwindowId(int32_t id) 11223b3eb3cSopenharmony_ci { 11323b3eb3cSopenharmony_ci subwindowId_ = id; 11423b3eb3cSopenharmony_ci } 11523b3eb3cSopenharmony_ci 11623b3eb3cSopenharmony_ci int32_t GetUIExtensionHostWindowId() const 11723b3eb3cSopenharmony_ci { 11823b3eb3cSopenharmony_ci return uiExtensionHostWindowId_; 11923b3eb3cSopenharmony_ci } 12023b3eb3cSopenharmony_ci 12123b3eb3cSopenharmony_ci void SetUIExtensionHostWindowId(int32_t id) 12223b3eb3cSopenharmony_ci { 12323b3eb3cSopenharmony_ci uiExtensionHostWindowId_ = id; 12423b3eb3cSopenharmony_ci } 12523b3eb3cSopenharmony_ci 12623b3eb3cSopenharmony_ci void SetAboveApps(bool isAboveApps) 12723b3eb3cSopenharmony_ci { 12823b3eb3cSopenharmony_ci isAboveApps_ = isAboveApps; 12923b3eb3cSopenharmony_ci } 13023b3eb3cSopenharmony_ci 13123b3eb3cSopenharmony_ci bool GetAboveApps() const 13223b3eb3cSopenharmony_ci { 13323b3eb3cSopenharmony_ci return isAboveApps_; 13423b3eb3cSopenharmony_ci } 13523b3eb3cSopenharmony_ci 13623b3eb3cSopenharmony_ci void SetToastWindowType(const ToastWindowType& type) 13723b3eb3cSopenharmony_ci { 13823b3eb3cSopenharmony_ci toastWindowType_ = type; 13923b3eb3cSopenharmony_ci SetAboveApps(true); 14023b3eb3cSopenharmony_ci } 14123b3eb3cSopenharmony_ci 14223b3eb3cSopenharmony_ci void SetMainWindowId(uint32_t mainWindowId) 14323b3eb3cSopenharmony_ci { 14423b3eb3cSopenharmony_ci mainWindowId_ = mainWindowId; 14523b3eb3cSopenharmony_ci } 14623b3eb3cSopenharmony_ci 14723b3eb3cSopenharmony_ci uint32_t GetMainWindowId() const 14823b3eb3cSopenharmony_ci { 14923b3eb3cSopenharmony_ci return mainWindowId_; 15023b3eb3cSopenharmony_ci } 15123b3eb3cSopenharmony_ci 15223b3eb3cSopenharmony_ci ToastWindowType GetToastWindowType() const 15323b3eb3cSopenharmony_ci { 15423b3eb3cSopenharmony_ci return toastWindowType_; 15523b3eb3cSopenharmony_ci } 15623b3eb3cSopenharmony_ci 15723b3eb3cSopenharmony_ci void SetIsSystemTopMost(bool isSystemTopMost) 15823b3eb3cSopenharmony_ci { 15923b3eb3cSopenharmony_ci isSystemTopMost_ = isSystemTopMost; 16023b3eb3cSopenharmony_ci } 16123b3eb3cSopenharmony_ci 16223b3eb3cSopenharmony_ci bool IsSystemTopMost() const 16323b3eb3cSopenharmony_ci { 16423b3eb3cSopenharmony_ci return isSystemTopMost_; 16523b3eb3cSopenharmony_ci } 16623b3eb3cSopenharmony_ci 16723b3eb3cSopenharmony_ci virtual void ClearToast() = 0; 16823b3eb3cSopenharmony_ci virtual void ShowToast(const NG::ToastInfo& toastInfo, std::function<void(int32_t)>&& callback) = 0; 16923b3eb3cSopenharmony_ci virtual void CloseToast(const int32_t toastId, std::function<void(int32_t)>&& callback) = 0; 17023b3eb3cSopenharmony_ci virtual void ShowDialog(const std::string& title, const std::string& message, 17123b3eb3cSopenharmony_ci const std::vector<ButtonInfo>& buttons, bool autoCancel, std::function<void(int32_t, int32_t)>&& callback, 17223b3eb3cSopenharmony_ci const std::set<std::string>& callbacks) = 0; 17323b3eb3cSopenharmony_ci virtual void ShowDialog(const PromptDialogAttr& dialogAttr, const std::vector<ButtonInfo>& buttons, 17423b3eb3cSopenharmony_ci std::function<void(int32_t, int32_t)>&& callback, const std::set<std::string>& callbacks) = 0; 17523b3eb3cSopenharmony_ci virtual void ShowActionMenu(const std::string& title, const std::vector<ButtonInfo>& button, 17623b3eb3cSopenharmony_ci std::function<void(int32_t, int32_t)>&& callback) = 0; 17723b3eb3cSopenharmony_ci virtual void CloseDialog(int32_t instanceId) = 0; 17823b3eb3cSopenharmony_ci virtual void OpenCustomDialog(const PromptDialogAttr& dialogAttr, std::function<void(int32_t)>&& callback) = 0; 17923b3eb3cSopenharmony_ci virtual void CloseCustomDialog(const int32_t dialogId) = 0; 18023b3eb3cSopenharmony_ci virtual void CloseCustomDialog(const WeakPtr<NG::UINode>& node, std::function<void(int32_t)> &&callback) = 0; 18123b3eb3cSopenharmony_ci virtual const RefPtr<NG::OverlayManager> GetOverlayManager() = 0; 18223b3eb3cSopenharmony_ci virtual bool IsFocused() = 0; 18323b3eb3cSopenharmony_ci virtual void RequestFocus() = 0; 18423b3eb3cSopenharmony_ci virtual void ResizeWindowForFoldStatus() = 0; 18523b3eb3cSopenharmony_ci virtual void ResizeWindowForFoldStatus(int32_t parentContainerId) = 0; 18623b3eb3cSopenharmony_ci virtual bool Close() = 0; 18723b3eb3cSopenharmony_ci virtual bool IsToastSubWindow() = 0; 18823b3eb3cSopenharmony_ci virtual void DestroyWindow() = 0; 18923b3eb3cSopenharmony_ciprivate: 19023b3eb3cSopenharmony_ci int32_t subwindowId_ = 0; 19123b3eb3cSopenharmony_ci int32_t uiExtensionHostWindowId_ = 0; 19223b3eb3cSopenharmony_ci bool isAboveApps_ = false; 19323b3eb3cSopenharmony_ci bool isSystemTopMost_ = false; 19423b3eb3cSopenharmony_ci ToastWindowType toastWindowType_ = ToastWindowType::TOAST_IN_TYPE_TOAST; 19523b3eb3cSopenharmony_ci // toast main window ID 19623b3eb3cSopenharmony_ci uint32_t mainWindowId_ = 0; 19723b3eb3cSopenharmony_ci}; 19823b3eb3cSopenharmony_ci 19923b3eb3cSopenharmony_ci} // namespace OHOS::Ace 20023b3eb3cSopenharmony_ci 20123b3eb3cSopenharmony_ci#endif // FOUNDATION_ACE_FRAMEWORKS_BASE_SUBWINDOW_SUBWINDOW_H 202