1 /* 2 * Copyright (c) 2022-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 FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OVERLAY_OVERLAY_MANAGER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OVERLAY_OVERLAY_MANAGER_H 18 19 #include <cstdint> 20 #include <functional> 21 #include <stack> 22 #include <unordered_map> 23 #include <utility> 24 25 #include "base/memory/ace_type.h" 26 #include "base/memory/referenced.h" 27 #include "base/utils/noncopyable.h" 28 #include "base/want/want_wrap.h" 29 #include "base/utils/utils.h" 30 #include "core/components/common/properties/placement.h" 31 #include "core/components/dialog/dialog_properties.h" 32 #include "core/components/picker/picker_data.h" 33 #include "core/components_ng/animation/geometry_transition.h" 34 #include "core/components_ng/base/frame_node.h" 35 #include "core/components_ng/base/ui_node.h" 36 #include "core/components_ng/pattern/calendar_picker/calendar_type_define.h" 37 #include "core/components_ng/pattern/overlay/content_cover_param.h" 38 #include "core/components_ng/pattern/overlay/modal_presentation_pattern.h" 39 #include "core/components_ng/pattern/overlay/modal_style.h" 40 #include "core/components_ng/pattern/overlay/sheet_style.h" 41 #include "core/components_ng/pattern/overlay/group_manager.h" 42 #include "core/components_ng/pattern/picker/datepicker_event_hub.h" 43 #include "core/components_ng/pattern/picker/picker_type_define.h" 44 #include "core/components_ng/pattern/text_picker/textpicker_event_hub.h" 45 #include "core/components_ng/pattern/toast/toast_layout_property.h" 46 #include "core/components_ng/pattern/toast/toast_view.h" 47 #include "core/components_ng/property/safe_area_insets.h" 48 #include "core/pipeline_ng/ui_task_scheduler.h" 49 #include "interfaces/inner_api/ace/modal_ui_extension_config.h" 50 51 namespace OHOS::Ace::NG { 52 enum class HideMenuType : int32_t { 53 NORMAL = 0, 54 IS_SHOW, 55 OPEN_MENU, 56 CLOSE_MENU, 57 WRAPPER_LOSE_FOCUS, 58 WRAPPER_TOUCH_DOWN, 59 TOUCH_OUT_SIDE, 60 OPEN_OTHER_MENU, 61 MENU_TOUCH_UP, 62 SCROLL_DRAG_END, 63 ITEM_SELECT_PROCESS, 64 SELECT_SELECTED, 65 ITEM_CLOSE_MENU, 66 PREVIEW_DRAG_END, 67 MENU_DRAG_END, 68 VIEW_DRAG_END, 69 CLOSE_AI_MENU, 70 REMOVE_MENU, 71 }; 72 struct PopupInfo { 73 int32_t popupId = -1; 74 WeakPtr<FrameNode> target; 75 RefPtr<FrameNode> popupNode; 76 bool markNeedUpdate = false; 77 bool isCurrentOnShow = false; 78 bool isBlockEvent = true; 79 SizeF targetSize; 80 OffsetF targetOffset; 81 bool focusable = false; 82 bool isAvoidKeyboard = false; 83 bool isTips = false; 84 int32_t disappearingTimeWithContinuousOperation = 700; 85 }; 86 87 struct GatherNodeChildInfo { 88 WeakPtr<FrameNode> imageNode; 89 OffsetF offset; 90 float width = 0.0f; 91 float height = 0.0f; 92 float halfWidth = 0.0f; 93 float halfHeight = 0.0f; 94 WeakPtr<FrameNode> preImageNode; 95 }; 96 97 struct DismissTarget { DismissTargetDismissTarget98 DismissTarget() {} DismissTargetDismissTarget99 explicit DismissTarget(int32_t inputTargetId) : targetIdOfModal(inputTargetId) {} DismissTargetDismissTarget100 explicit DismissTarget(const SheetKey& index) : sheetKey(index) 101 { 102 targetIsSheet = true; 103 } 104 GetTargetIdDismissTarget105 int32_t GetTargetId() 106 { 107 return targetIsSheet ? sheetKey.targetId : targetIdOfModal; 108 } 109 110 int32_t targetIdOfModal = -1; 111 SheetKey sheetKey; 112 bool targetIsSheet = false; 113 }; 114 115 struct CustomKeyboardOffsetInfo { 116 float finalOffset = 0.0f; 117 float inAniStartOffset = 0.0f; 118 float outAniEndOffset = 0.0f; 119 }; 120 121 struct OverlayManagerInfo { 122 bool renderRootOverlay = true; 123 bool enableBackPressedEvent = false; 124 }; 125 126 // StageManager is the base class for root render node to perform page switch. 127 class ACE_FORCE_EXPORT OverlayManager : public virtual AceType { 128 DECLARE_ACE_TYPE(OverlayManager, AceType); 129 130 public: 131 explicit OverlayManager(const RefPtr<FrameNode>& rootNode); 132 ~OverlayManager() override; 133 void ShowIndexerPopup(int32_t targetId, RefPtr<FrameNode>& customNode); 134 void RemoveIndexerPopupById(int32_t targetId); 135 void RemoveIndexerPopup(); 136 void HidePopup(int32_t targetId, const PopupInfo& popupInfo, bool isEraseFromMap = false); 137 RefPtr<FrameNode> HidePopupWithoutAnimation(int32_t targetId, const PopupInfo& popupInfo, 138 bool isForceClear = false); 139 void ShowPopup(int32_t targetId, const PopupInfo& popupInfo, 140 const std::function<void(int32_t)>&& onWillDismiss = nullptr, bool interactiveDismiss = true); 141 void HideTips(int32_t targetId, const PopupInfo& tipsInfo, int32_t disappearingTime); 142 void ShowTips(int32_t targetId, const PopupInfo& tipsInfo, int32_t appearingTime, 143 int32_t appearingTimeWithContinuousOperation, bool isSubwindow); 144 void ErasePopup(int32_t targetId); 145 void EraseTipsInfo(int32_t targetId); 146 PopupInfo GetTipsInfo(int32_t targetId); 147 void HideAllPopups(); 148 void HideCustomPopups(); 149 void HideAllPopupsWithoutAnimation(); 150 void HideAllMenusWithoutAnimation(bool showInSubwindow = false); 151 void SetPopupHotAreas(RefPtr<FrameNode> popupNode); 152 void ShowPopupAnimation(const RefPtr<FrameNode>& popupNode); 153 void ShowPopupAnimationNG(const RefPtr<FrameNode>& popupNode); 154 void HidePopupAnimation(const RefPtr<FrameNode>& popupNode, const std::function<void()>& finish); 155 PopupInfo GetPopupInfoWithExistContent(const RefPtr<UINode>& node); 156 void UpdateTipsEnterAndLeaveInfo(int32_t targetId); 157 void UpdateTipsEnterAndLeaveInfoBool(int32_t targetId); 158 bool GetBoolFromTipsEnterAndLeaveInfo(int32_t targetId, int32_t times); 159 int32_t GetTipsEnterAndLeaveInfo(int32_t targetId); 160 void EraseTipsEnterAndLeaveInfo(int32_t targetId, int32_t times); 161 void UpdateTipsInfo(int32_t targetId, const PopupInfo& popupInfo); 162 void UpdateTipsStatus(int32_t targetId, bool isInContinus); 163 void EraseTipsStatus(int32_t targetId); 164 bool GetTipsStatus(int32_t targetId); 165 bool TipsInfoListIsEmpty(int32_t targetId); 166 GetPopupInfo(int32_t targetId)167 PopupInfo GetPopupInfo(int32_t targetId) const 168 { 169 auto it = popupMap_.find(targetId); 170 if (it == popupMap_.end()) { 171 return {}; 172 } 173 return it->second; 174 } 175 HasPopupInfo(int32_t targetId)176 bool HasPopupInfo(int32_t targetId) const 177 { 178 return popupMap_.find(targetId) != popupMap_.end(); 179 } 180 ErasePopupInfo(int32_t targetId)181 void ErasePopupInfo(int32_t targetId) 182 { 183 if (popupMap_.find(targetId) != popupMap_.end()) { 184 popupMap_.erase(targetId); 185 } 186 } 187 SetDismissDialogId(int32_t id)188 void SetDismissDialogId(int32_t id) 189 { 190 dismissDialogId_ = id; 191 } 192 GetDismissDialogId()193 int32_t GetDismissDialogId() const 194 { 195 return dismissDialogId_; 196 } 197 198 void RemoveDialogFromMapForcefully(const RefPtr<FrameNode>& node); 199 void ShowMenu(int32_t targetId, const NG::OffsetF& offset, RefPtr<FrameNode> menu = nullptr); 200 void HideMenu(const RefPtr<FrameNode>& menu, int32_t targetId, bool isMenuOnTouch = false, 201 const HideMenuType& reason = HideMenuType::NORMAL); 202 void DeleteMenu(int32_t targetId); 203 void ShowMenuInSubWindow(int32_t targetId, const NG::OffsetF& offset, RefPtr<FrameNode> menu = nullptr); 204 void HideMenuInSubWindow(const RefPtr<FrameNode>& menu, int32_t targetId); 205 RefPtr<FrameNode> GetMenuNodeWithExistContent(const RefPtr<UINode>& node); 206 RefPtr<FrameNode> GetMenuNode(int32_t targetId); 207 void HideMenuInSubWindow(bool showPreviewAnimation = true, bool startDrag = false); 208 void CleanMenuInSubWindow(int32_t targetId); 209 void CleanPreviewInSubWindow(); 210 void CleanHoverImagePreviewInSubWindow(const RefPtr<FrameNode>& flexNode); 211 void CleanPopupInSubWindow(bool isForceClear = false); 212 void CleanMenuInSubWindowWithAnimation(); 213 void HideAllMenus(); 214 void UpdatePreviousDisappearingTime(int32_t targetId); 215 216 void ClearToastInSubwindow(); 217 void ClearToast(); 218 void ShowToast(const NG::ToastInfo& toastInfo, const std::function<void(int32_t)>& callback); 219 void CloseToast(int32_t toastId, const std::function<void(int32_t)>& callback); 220 221 void FireAutoSave(const RefPtr<FrameNode>& containerNode); 222 GetDialogMap()223 std::unordered_map<int32_t, RefPtr<FrameNode>> GetDialogMap() 224 { 225 return dialogMap_; 226 }; 227 RefPtr<FrameNode> GetDialog(int32_t dialogId); 228 RefPtr<FrameNode> SetDialogMask(const DialogProperties& dialogProps); 229 // customNode only used by customDialog, pass in nullptr if not customDialog 230 RefPtr<FrameNode> ShowDialog( 231 const DialogProperties& dialogProps, std::function<void()>&& buildFunc, bool isRightToLeft = false); 232 RefPtr<FrameNode> ShowDialogWithNode( 233 const DialogProperties& dialogProps, const RefPtr<NG::UINode>& customNode, bool isRightToLeft = false); 234 void ShowCustomDialog(const RefPtr<FrameNode>& customNode); 235 void ShowDateDialog(const DialogProperties& dialogProps, const DatePickerSettingData& settingData, 236 std::map<std::string, NG::DialogEvent> dialogEvent, 237 std::map<std::string, NG::DialogGestureEvent> dialogCancelEvent, 238 std::map<std::string, NG::DialogCancelEvent> dialogLifeCycleEvent = {}, 239 const std::vector<ButtonInfo>& buttonInfos = std::vector<ButtonInfo>({})); 240 void ShowTimeDialog(const DialogProperties& dialogProps, const TimePickerSettingData& settingData, 241 std::map<std::string, PickerTime> timePickerProperty, std::map<std::string, NG::DialogEvent> dialogEvent, 242 std::map<std::string, NG::DialogGestureEvent> dialogCancelEvent, 243 std::map<std::string, NG::DialogCancelEvent> dialogLifeCycleEvent = {}, 244 const std::vector<ButtonInfo>& buttonInfos = std::vector<ButtonInfo>({})); 245 void ShowTextDialog(const DialogProperties& dialogProps, const TextPickerSettingData& settingData, 246 std::map<std::string, NG::DialogTextEvent> dialogEvent, 247 std::map<std::string, NG::DialogGestureEvent> dialogCancelEvent, 248 std::map<std::string, NG::DialogCancelEvent> dialogLifeCycleEvent = {}, 249 const std::vector<ButtonInfo>& buttonInfos = std::vector<ButtonInfo>({})); 250 void ShowCalendarDialog(const DialogProperties& dialogProps, const CalendarSettingData& settingData, 251 std::map<std::string, NG::DialogEvent> dialogEvent, 252 std::map<std::string, NG::DialogGestureEvent> dialogCancelEvent, 253 std::map<std::string, NG::DialogCancelEvent> dialogLifeCycleEvent = {}, 254 const std::vector<ButtonInfo>& buttonInfos = std::vector<ButtonInfo>({})); 255 void PopModalDialog(int32_t maskId); 256 257 void CloseDialog(const RefPtr<FrameNode>& dialogNode); 258 void DeleteDialogHotAreas(const RefPtr<FrameNode>& dialogNode); 259 260 RefPtr<FrameNode> OpenCustomDialog(const DialogProperties& dialogProps, std::function<void(int32_t)> &&callback); 261 void CloseCustomDialog(const int32_t dialogId); 262 void CloseCustomDialog(const WeakPtr<NG::UINode>& node, std::function<void(int32_t)> &&callback); 263 void UpdateCustomDialog(const WeakPtr<NG::UINode>& node, const DialogProperties& dialogProps, 264 std::function<void(int32_t)> &&callback); 265 void UpdateCustomDialogWithNode( 266 const WeakPtr<NG::UINode>& node, const DialogProperties& dialogProps, std::function<void(int32_t)>&& callback); 267 std::optional<double> GetTopOrder(); 268 std::optional<double> GetBottomOrder(); 269 SetSubWindowId(int32_t subWindowId)270 void SetSubWindowId(int32_t subWindowId) 271 { 272 subWindowId_ = subWindowId; 273 } GetSubwindowId()274 int32_t GetSubwindowId() 275 { 276 return subWindowId_; 277 } SetMaskNodeId(int32_t dialogId,int32_t maskId)278 void SetMaskNodeId(int32_t dialogId, int32_t maskId) 279 { 280 maskNodeIdMap_[dialogId] = maskId; 281 } 282 bool isMaskNode(int32_t maskId); 283 int32_t GetMaskNodeIdWithDialogId(int32_t dialogId); 284 285 /** pop overlays (if any) on back press 286 * 287 * @return true if popup was removed, false if no overlay exists 288 */ 289 bool RemoveOverlay(bool isBackPressed, bool isPageRouter = false); 290 bool RemoveDialog(const RefPtr<FrameNode>& overlay, bool isBackPressed, bool isPageRouter = false); 291 bool RemoveDialogWithContent( 292 const RefPtr<FrameNode>& overlay, const DialogProperties& props, bool isBackPressed, bool isPageRouter = false); 293 bool RemoveBubble(const RefPtr<FrameNode>& overlay); 294 bool RemoveMenu(const RefPtr<FrameNode>& overlay); 295 bool RemoveDragPreview(const RefPtr<FrameNode>& overlay); 296 bool RemoveModalInOverlay(); 297 bool RemoveAllModalInOverlay(bool isRouterTransition = true); 298 bool RemoveAllModalInOverlayByStack(); 299 bool RemoveAllModalInOverlayByList(); 300 bool OnRemoveAllModalInOverlayByList(); 301 void AfterRemoveAllModalInOverlayByList(); 302 bool IsModalUiextensionNode(const RefPtr<FrameNode>& topModalNode); 303 bool IsProhibitedRemoveByRouter(const RefPtr<FrameNode>& topModalNode); 304 bool IsProhibitedRemoveByNavigation(const RefPtr<FrameNode>& topModalNode); 305 bool RemoveOverlayInSubwindow(); 306 bool RemoveNonKeyboardOverlay(const RefPtr<FrameNode>& overlay); 307 bool RemoveMenuInSubWindow(const RefPtr<FrameNode>& menuWrapper); 308 RegisterOnHideDialog(std::function<void ()> callback)309 void RegisterOnHideDialog(std::function<void()> callback) 310 { 311 onHideDialogCallback_ = callback; 312 } 313 CallOnHideDialogCallback()314 void CallOnHideDialogCallback() 315 { 316 if (onHideDialogCallback_) { 317 onHideDialogCallback_(); 318 } 319 } 320 SetBackPressEvent(std::function<bool ()> event)321 void SetBackPressEvent(std::function<bool()> event) 322 { 323 backPressEvent_ = event; 324 } 325 FireBackPressEvent()326 bool FireBackPressEvent() const 327 { 328 if (backPressEvent_) { 329 return backPressEvent_(); 330 } 331 return false; 332 } 333 GetHasPixelMap()334 bool GetHasPixelMap() 335 { 336 return hasPixelMap_; 337 } 338 SetHasPixelMap(bool hasPixelMap)339 void SetHasPixelMap(bool hasPixelMap) 340 { 341 hasPixelMap_ = hasPixelMap; 342 } 343 GetHasDragPixelMap()344 bool GetHasDragPixelMap() const 345 { 346 return hasDragPixelMap_; 347 } 348 SetHasDragPixelMap(bool hasDragPixelMap)349 void SetHasDragPixelMap(bool hasDragPixelMap) 350 { 351 hasDragPixelMap_ = hasDragPixelMap; 352 } 353 GetHasGatherNode()354 bool GetHasGatherNode() 355 { 356 return hasGatherNode_; 357 } 358 GetPixelMapNode()359 RefPtr<FrameNode> GetPixelMapNode() 360 { 361 return pixmapColumnNodeWeak_.Upgrade(); 362 } 363 364 RefPtr<FrameNode> GetPixelMapContentNode(bool isSubwindowOverlay = false) const; 365 366 RefPtr<FrameNode> GetPixelMapContentNodeForSubwindow() const; 367 368 RefPtr<FrameNode> GetDragPixelMapContentNode() const; 369 370 RefPtr<FrameNode> GetPixelMapBadgeNode() const; 371 372 RefPtr<FrameNode> GetDragPixelMapBadgeNode() const; 373 374 bool GetHasFilterWithCheck(); 375 GetHasFilter()376 bool GetHasFilter() 377 { 378 return hasFilter_; 379 } 380 SetHasFilter(bool hasFilter)381 void SetHasFilter(bool hasFilter) 382 { 383 hasFilter_ = hasFilter; 384 } 385 GetHasEvent()386 bool GetHasEvent() 387 { 388 return hasEvent_; 389 } 390 SetHasEvent(bool hasEvent)391 void SetHasEvent(bool hasEvent) 392 { 393 hasEvent_ = hasEvent; 394 } 395 GetIsOnAnimation()396 bool GetIsOnAnimation() 397 { 398 return isOnAnimation_; 399 } 400 SetIsOnAnimation(bool isOnAnimation)401 void SetIsOnAnimation(bool isOnAnimation) 402 { 403 isOnAnimation_ = isOnAnimation; 404 } 405 SetFilterColumnNode(const RefPtr<FrameNode> & columnNode)406 void SetFilterColumnNode(const RefPtr<FrameNode>& columnNode) 407 { 408 filterColumnNodeWeak_ = columnNode; 409 } GetFilterColumnNode()410 RefPtr<FrameNode> GetFilterColumnNode() const 411 { 412 return filterColumnNodeWeak_.Upgrade(); 413 } 414 void MountFilterToWindowScene(const RefPtr<FrameNode>& columnNode, const RefPtr<UINode>& windowScene); 415 void MountPixelMapToWindowScene( 416 const RefPtr<FrameNode>& columnNode, const RefPtr<UINode>& windowScene, bool isDragPixelMap = false); 417 void MountEventToWindowScene(const RefPtr<FrameNode>& columnNode, const RefPtr<UINode>& windowScene); 418 void MountPixelMapToRootNode(const RefPtr<FrameNode>& columnNode, bool isDragPixelMap = false); 419 void MountEventToRootNode(const RefPtr<FrameNode>& columnNode); 420 void RemovePixelMap(); 421 void RemovePixelMapAnimation(bool startDrag, double x, double y, bool isSubwindowOverlay = false); 422 void RemoveDragPixelMap(); 423 void UpdatePixelMapScale(float& scale); 424 void RemoveFilter(); 425 void RemoveFilterWithNode(const RefPtr<FrameNode>& filterNode); 426 void RemoveFilterAnimation(); 427 void RemoveMenuFilter(const RefPtr<FrameNode>& menuWrapper, bool hasAnimation = true); 428 void ShowFilterDisappearAnimation(const RefPtr<FrameNode>& filterNode); 429 void AddFilterOnDisappear(int32_t filterId); 430 void RemoveFilterOnDisappear(int32_t filterId); 431 bool IsFilterOnDisappear(int32_t filterId) const; 432 void RemoveEventColumn(); 433 void UpdatePixelMapPosition(bool isSubwindowOverlay = false); 434 void UpdateContextMenuDisappearPosition(const NG::OffsetF& offset, float menuScale = 1.0f, 435 bool isRedragStart = false, int32_t menuWrapperId = -1); 436 void ContextMenuSwitchDragPreviewAnimation(const RefPtr<NG::FrameNode>& dragPreviewNode, 437 const NG::OffsetF& offset); 438 bool GetMenuPreviewCenter(NG::OffsetF& offset); 439 ResetContextMenuDragHideFinished()440 void ResetContextMenuDragHideFinished() 441 { 442 isContextMenuDragHideFinished_ = false; 443 dragMoveVector_ = OffsetF(0.0f, 0.0f); 444 lastDragMoveVector_ = OffsetF(0.0f, 0.0f); 445 } 446 ResetContextMenuRestartDragVector()447 void ResetContextMenuRestartDragVector() 448 { 449 dragMoveVector_ = OffsetF(0.0f, 0.0f); 450 lastDragMoveVector_ = OffsetF(0.0f, 0.0f); 451 } 452 SetContextMenuDragHideFinished(bool isContextMenuDragHideFinished)453 void SetContextMenuDragHideFinished(bool isContextMenuDragHideFinished) 454 { 455 isContextMenuDragHideFinished_ = isContextMenuDragHideFinished; 456 } 457 IsContextMenuDragHideFinished()458 bool IsContextMenuDragHideFinished() const 459 { 460 return isContextMenuDragHideFinished_ == true; 461 } 462 IsOriginDragMoveVector()463 bool IsOriginDragMoveVector() const 464 { 465 return dragMoveVector_.NonOffset() && lastDragMoveVector_.NonOffset(); 466 } 467 IsUpdateDragMoveVector()468 bool IsUpdateDragMoveVector() const 469 { 470 return !GetUpdateDragMoveVector().NonOffset() && !lastDragMoveVector_.NonOffset(); 471 } 472 UpdateDragMoveVector(const NG::OffsetF & offset)473 void UpdateDragMoveVector(const NG::OffsetF& offset) 474 { 475 lastDragMoveVector_ = dragMoveVector_; 476 dragMoveVector_ = offset; 477 } 478 GetUpdateDragMoveVector()479 OffsetF GetUpdateDragMoveVector() const 480 { 481 return dragMoveVector_ - lastDragMoveVector_; 482 } 483 484 void BindContentCover(bool isShow, std::function<void(const std::string&)>&& callback, 485 std::function<RefPtr<UINode>()>&& buildNodeFunc, NG::ModalStyle& modalStyle, std::function<void()>&& onAppear, 486 std::function<void()>&& onDisappear, std::function<void()>&& onWillAppear, 487 std::function<void()>&& onWillDisappear, const NG::ContentCoverParam& contentCoverParam, 488 const RefPtr<FrameNode>& targetNode, int32_t sessionId = 0); 489 void OnBindContentCover(bool isShow, std::function<void(const std::string&)>&& callback, 490 std::function<RefPtr<UINode>()>&& buildNodeFunc, NG::ModalStyle& modalStyle, std::function<void()>&& onAppear, 491 std::function<void()>&& onDisappear, std::function<void()>&& onWillAppear, 492 std::function<void()>&& onWillDisappear, const NG::ContentCoverParam& contentCoverParam, 493 const RefPtr<FrameNode>& targetNode, int32_t sessionId = 0); 494 void BindSheet(bool isShow, std::function<void(const std::string&)>&& callback, 495 std::function<RefPtr<UINode>()>&& buildNodeFunc, std::function<RefPtr<UINode>()>&& buildTitleNodeFunc, 496 NG::SheetStyle& sheetStyle, std::function<void()>&& onAppear, std::function<void()>&& onDisappear, 497 std::function<void()>&& shouldDismiss, std::function<void(const int32_t info)>&& onWillDismiss, 498 std::function<void()>&& onWillAppear, std::function<void()>&& onWillDisappear, 499 std::function<void(const float)>&& onHeightDidChange, 500 std::function<void(const float)>&& onDetentsDidChange, std::function<void(const float)>&& onWidthDidChange, 501 std::function<void(const float)>&& onTypeDidChange, std::function<void()>&& sheetSpringBack, 502 const RefPtr<FrameNode>& targetNode); 503 void OnBindSheet(bool isShow, std::function<void(const std::string&)>&& callback, 504 std::function<RefPtr<UINode>()>&& buildNodeFunc, std::function<RefPtr<UINode>()>&& buildtitleNodeFunc, 505 NG::SheetStyle& sheetStyle, std::function<void()>&& onAppear, std::function<void()>&& onDisappear, 506 std::function<void()>&& shouldDismiss, std::function<void(const int32_t info)>&& onWillDismiss, 507 std::function<void()>&& onWillAppear, std::function<void()>&& onWillDisappear, 508 std::function<void(const float)>&& onHeightDidChange, 509 std::function<void(const float)>&& onDetentsDidChange, std::function<void(const float)>&& onWidthDidChange, 510 std::function<void(const float)>&& onTypeDidChange, std::function<void()>&& sheetSpringBack, 511 const RefPtr<FrameNode>& targetNode); 512 void CloseSheet(const SheetKey& sheetKey); 513 void InitSheetMask( 514 const RefPtr<FrameNode>& maskNode, const RefPtr<FrameNode>& sheetNode, const SheetStyle& sheetStyle); IsModalEmpty()515 bool IsModalEmpty() const 516 { 517 return modalStack_.empty(); 518 } 519 bool HasModalPage(); 520 void DismissSheet(); 521 void DismissContentCover(); 522 void SheetSpringBack(); 523 524 void OpenBindSheetByUIContext( 525 const RefPtr<FrameNode>& sheetContentNode, std::function<RefPtr<UINode>()>&& buildtitleNodeFunc, 526 NG::SheetStyle& sheetStyle, std::function<void()>&& onAppear, std::function<void()>&& onDisappear, 527 std::function<void()>&& shouldDismiss, std::function<void(const int32_t)>&& onWillDismiss, 528 std::function<void()>&& onWillAppear, std::function<void()>&& onWillDisappear, 529 std::function<void(const float)>&& onHeightDidChange, 530 std::function<void(const float)>&& onDetentsDidChange, 531 std::function<void(const float)>&& onWidthDidChange, 532 std::function<void(const float)>&& onTypeDidChange, 533 std::function<void()>&& sheetSpringBack, 534 std::function<void(const int32_t, const int32_t)> cleanViewContextMapCallback, 535 const RefPtr<FrameNode>& targetNode); 536 void UpdateBindSheetByUIContext(const RefPtr<NG::FrameNode>& sheetContentNode, 537 const NG::SheetStyle& sheetStyle, int32_t targetId, bool isPartialUpdate); 538 void CloseBindSheetByUIContext(const RefPtr<NG::FrameNode>& sheetContentNode, int32_t targetId); SetDismissTarget(const DismissTarget & dismissTarget)539 void SetDismissTarget(const DismissTarget& dismissTarget) 540 { 541 dismissTarget_ = dismissTarget; 542 } SetDismissSheet(int32_t sheetId)543 void SetDismissSheet(int32_t sheetId) 544 { 545 dismissSheetId_ = sheetId; 546 } GetDismissSheet()547 int32_t GetDismissSheet() const 548 { 549 return dismissSheetId_; 550 } 551 RefPtr<FrameNode> GetModalStackTop(); 552 void RemoveSheetNode(const RefPtr<FrameNode>& sheetNode); 553 void CreateSheetWapperNode(const RefPtr<FrameNode>& sheetPageNode, 554 const RefPtr<FrameNode>& targetNode, NG::SheetStyle& sheetStyle); 555 void CreateMaskNode(const RefPtr<FrameNode>& sheetPageNode, 556 const RefPtr<FrameNode>& targetNode, NG::SheetStyle& sheetStyle); 557 void RemoveSheet(RefPtr<FrameNode> sheetNode); 558 void InitSheetWrapperAction(const RefPtr<FrameNode>& sheetNode, 559 const RefPtr<FrameNode>& targetNode, NG::SheetStyle& sheetStyle); 560 RefPtr<FrameNode> MountSheetWrapperAndChildren(const RefPtr<FrameNode>& sheetNode, 561 const RefPtr<FrameNode>& targetNode, NG::SheetStyle& sheetStyle); GetSheetMap()562 std::unordered_map<SheetKey, WeakPtr<FrameNode>, SheetKeyHash> GetSheetMap() 563 { 564 return sheetMap_; 565 } 566 void MountToParentWithService(const RefPtr<UINode>& rootNode, const RefPtr<FrameNode>& node, 567 std::optional<double> levelOrder = std::nullopt); 568 void MountToParentWithOrder(const RefPtr<UINode>& rootNode, const RefPtr<FrameNode>& node, 569 std::optional<double> levelOrder = std::nullopt); 570 void OnMainWindowSizeChange(int32_t instanceId, WindowSizeChangeReason reason); 571 572 void CleanSheet(const RefPtr<FrameNode>& sheetNode, const SheetKey& sheetKey); 573 574 RefPtr<FrameNode> GetSheetMask(const RefPtr<FrameNode>& sheetNode); 575 576 RefPtr<FrameNode> GetModal(int32_t targetId); 577 void RemoveModal(int32_t targetId); 578 void DeleteModal(int32_t targetId, bool needOnWillDisappear = true); 579 void PopTopModalNode(); 580 581 void DeleteModalNode(int32_t targetId, RefPtr<FrameNode>& modalNode, bool isModal, bool needOnWillDisappear); 582 583 void BindKeyboard(const std::function<void()>& keyboardBuilder, int32_t targetId); 584 void BindKeyboardWithNode(const RefPtr<UINode>& keyboard, int32_t targetId); 585 void CloseKeyboard(int32_t targetId); 586 void UpdateCustomKeyboardPosition(); 587 588 RefPtr<UINode> FindWindowScene(RefPtr<FrameNode> targetNode); 589 590 // ui extension 591 bool HandleUIExtNodeSize(const AAFwk::Want& want, RefPtr<FrameNode> uiExtNode); 592 bool HandleUIExtNodeAngle(int32_t uiExtNodeAngle, RefPtr<FrameNode> uiExtNode); 593 bool HandleUIExtNodeTransform(const AAFwk::Want& want, RefPtr<FrameNode> uiExtNode); 594 bool UIExtNodeAngleValid(int32_t uiExtNodeAngle); 595 int32_t CreateModalUIExtension(const RefPtr<WantWrap>& want, const ModalUIExtensionCallbacks& callbacks, 596 const ModalUIExtensionConfig& config); 597 int32_t CreateModalUIExtension(const AAFwk::Want& want, const ModalUIExtensionCallbacks& callbacks, 598 const ModalUIExtensionConfig& config); 599 void CloseModalUIExtension(int32_t sessionId); 600 void UpdateModalUIExtensionConfig( 601 int32_t sessionId, const ModalUIExtensionAllowedUpdateConfig& config); 602 static ModalStyle SetUIExtensionModalStyleAndGet(bool prohibitedRemoveByRouter, 603 bool isAllowAddChildBelowModalUec, bool prohibitedRemoveByNavigation, bool isModalRequestFocus); 604 605 RefPtr<FrameNode> BuildAIEntityMenu(const std::vector<std::pair<std::string, std::function<void()>>>& menuOptions); 606 RefPtr<FrameNode> CreateAIEntityMenu(const std::vector<std::pair<std::string, std::function<void()>>>& menuOptions, 607 const RefPtr<FrameNode>& targetNode); 608 bool ShowAIEntityMenu(const std::vector<std::pair<std::string, std::function<void()>>>& menuOptions, 609 const RectF& aiRect, const RefPtr<FrameNode>& targetNode); 610 void CloseAIEntityMenu(int32_t targetId); 611 612 void MarkDirty(PropertyChangeFlag flag); 613 void MarkDirtyOverlay(); 614 float GetRootHeight() const; 615 float GetRootWidth() const; 616 617 void PlaySheetMaskTransition(RefPtr<FrameNode> maskNode, RefPtr<FrameNode> sheetNode, bool isTransitionIn); 618 619 void PlaySheetTransition(RefPtr<FrameNode> sheetNode, bool isTransitionIn, bool isFirstTransition = true); 620 621 void ComputeSheetOffset(const NG::SheetStyle& sheetStyle, RefPtr<FrameNode> sheetNode); 622 623 void ComputeSingleGearSheetOffset(const NG::SheetStyle& sheetStyle, RefPtr<FrameNode> sheetNode); 624 625 void ComputeDetentsSheetOffset(const NG::SheetStyle& sheetStyle, RefPtr<FrameNode> sheetNode); 626 627 void CheckDeviceInLandscape(NG::SheetStyle& sheetStyle, RefPtr<FrameNode> sheetNode, float& sheetTopSafeArea); 628 SetSheetHeight(float height)629 void SetSheetHeight(float height) 630 { 631 sheetHeight_ = height; 632 } 633 GetSheetHeight()634 float GetSheetHeight() const 635 { 636 return sheetHeight_; 637 } 638 639 const WeakPtr<UINode>& GetRootNode() const; 640 const RefPtr<GroupManager>& GetGroupManager() const; 641 642 void ModalPageLostFocus(const RefPtr<FrameNode>& node); 643 644 void SetCustomKeyboardOption(bool supportAvoidance); 645 SetFilterActive(bool actived)646 void SetFilterActive(bool actived) 647 { 648 hasFilterActived = actived; 649 } 650 SetDismissPopupId(int32_t targetId)651 void SetDismissPopupId(int32_t targetId) 652 { 653 dismissPopupId_ = targetId; 654 } 655 656 void DismissPopup(); 657 658 void MountGatherNodeToRootNode(const RefPtr<FrameNode>& frameNode, 659 const std::vector<GatherNodeChildInfo>& gatherNodeChildrenInfo); 660 void MountGatherNodeToWindowScene(const RefPtr<FrameNode>& frameNode, 661 const std::vector<GatherNodeChildInfo>& gatherNodeChildrenInfo, 662 const RefPtr<UINode>& windowScene); 663 void RemoveGatherNode(); 664 void RemoveGatherNodeWithAnimation(); 665 void UpdateGatherNodeToTop(); GetGatherNode()666 RefPtr<FrameNode> GetGatherNode() const 667 { 668 return gatherNodeWeak_.Upgrade(); 669 } SetDragNodeCopy(const RefPtr<FrameNode> & dragNodeCopy)670 void SetDragNodeCopy(const RefPtr<FrameNode>& dragNodeCopy) 671 { 672 dragNodeCopyWeak_ = dragNodeCopy; 673 } GetDragNodeCopy()674 RefPtr<FrameNode> GetDragNodeCopy() 675 { 676 return dragNodeCopyWeak_.Upgrade(); 677 } GetGatherNodeChildrenInfo()678 const std::vector<GatherNodeChildInfo>& GetGatherNodeChildrenInfo() 679 { 680 return gatherNodeChildrenInfo_; 681 } IsGatherWithMenu()682 bool IsGatherWithMenu() const 683 { 684 return isGatherWithMenu_; 685 } SetIsGatherWithMenu(bool isGatherWithMenu)686 void SetIsGatherWithMenu(bool isGatherWithMenu) 687 { 688 isGatherWithMenu_ = isGatherWithMenu; 689 } 690 void RemoveMenuBadgeNode(const RefPtr<FrameNode>& menuWrapperNode); 691 void RemovePreviewBadgeNode(); 692 void CreateOverlayNode(); 693 void AddFrameNodeToOverlay(const RefPtr<NG::FrameNode>& node, std::optional<int32_t> index = std::nullopt); 694 RefPtr<FrameNode> CreateOverlayNodeWithOrder(std::optional<double> levelOrder); 695 void AddFrameNodeWithOrder(const RefPtr<FrameNode>& node, std::optional<double> levelOrder); 696 void RemoveFrameNodeOnOverlay(const RefPtr<NG::FrameNode>& node); 697 void RemoveFrameNodeWithOrder(const RefPtr<NG::FrameNode>& node); 698 void ShowNodeOnOverlay(const RefPtr<NG::FrameNode>& node); 699 void HideNodeOnOverlay(const RefPtr<NG::FrameNode>& node); 700 void ShowAllNodesOnOverlay(); 701 void HideAllNodesOnOverlay(); GetOverlayNode()702 RefPtr<FrameNode> GetOverlayNode() 703 { 704 return overlayNode_; 705 } 706 bool CheckPageNeedAvoidKeyboard() const; 707 void TriggerCustomKeyboardAvoid(int32_t targetId, float safeHeight); 708 void AvoidCustomKeyboard(int32_t targetId, float safeHeight); 709 void ShowFilterAnimation(const RefPtr<FrameNode>& columnNode, const RefPtr<FrameNode>& menuWrapperNode); 710 void ExecuteFilterAnimation(const RefPtr<FrameNode>& columnNode, const RefPtr<FrameNode>& menuWrapperNode); EraseMenuInfo(int32_t targetId)711 void EraseMenuInfo(int32_t targetId) 712 { 713 if (menuMap_.find(targetId) != menuMap_.end()) { 714 menuMap_.erase(targetId); 715 } 716 } 717 bool IsRootExpansive() const; 718 void DumpOverlayInfo() const; 719 void ReloadBuilderNodeConfig(); 720 IsMenuShow()721 bool IsMenuShow() const 722 { 723 return isMenuShow_; 724 } 725 726 void SetIsMenuShow(bool isMenuShow, const RefPtr<FrameNode>& menuNode = nullptr); 727 SetIsAttachToCustomNode(bool isAttachToCustomNode)728 void SetIsAttachToCustomNode(bool isAttachToCustomNode) 729 { 730 isAttachToCustomNode_ = isAttachToCustomNode; 731 } 732 733 void SetIsAllowedBeCovered(bool isAllowedBeCovered = true); 734 void ClearUIExtensionNode(); 735 void DeleteUIExtensionNode(int32_t sessionId); 736 bool AddCurSessionId(int32_t curSessionId); 737 void ResetRootNode(int32_t sessionId); 738 void OnUIExtensionWindowSizeChange(); SetOverlayManagerOptions(const OverlayManagerInfo & overlayInfo)739 bool SetOverlayManagerOptions(const OverlayManagerInfo& overlayInfo) 740 { 741 if (overlayInfo_.has_value()) { 742 return false; 743 } 744 overlayInfo_ = overlayInfo; 745 return true; 746 } GetOverlayManagerOptions()747 std::optional<OverlayManagerInfo> GetOverlayManagerOptions() 748 { 749 return overlayInfo_; 750 } 751 752 void UpdateSheetPage(const RefPtr<FrameNode>& sheetNode, const NG::SheetStyle& sheetStyle); 753 754 RefPtr<FrameNode> GetDialogNodeWithExistContent(const RefPtr<UINode>& node); 755 OffsetF CalculateMenuPosition(const RefPtr<FrameNode>& menuWrapperNode, const OffsetF& offset); 756 BorderRadiusProperty GetPrepareDragFrameNodeBorderRadius() const; 757 static SafeAreaInsets GetSafeAreaInsets(const RefPtr<FrameNode>& frameNode, bool useCurrentWindow = false); 758 RefPtr<FrameNode> GetLastChildNotRemoving(const RefPtr<UINode>& rootNode); 759 bool IsCurrentNodeProcessRemoveOverlay(const RefPtr<FrameNode>& currentNode, bool skipModal); 760 static Rect GetDisplayAvailableRect(const RefPtr<FrameNode>& frameNode, int32_t type); 761 static int32_t GetSubwindowKeyNodeId(const RefPtr<FrameNode>& frameNode); 762 static bool IsNeedAvoidFoldCrease(const RefPtr<FrameNode>& frameNode, bool checkSenboard, bool expandDisplay, 763 std::optional<bool> enableHoverMode); 764 static bool IsSceneBoardWindow(); 765 void SkipMenuShow(int32_t targetId); 766 void ResumeMenuShow(int32_t targetId); 767 bool CheckSkipMenuShow(int32_t targetId); 768 bool IsTopOrder(std::optional<double> levelOrder); 769 std::optional<double> GetLevelOrder(const RefPtr<FrameNode>& node, std::optional<double> levelOrder = std::nullopt); 770 void PopToast(int32_t targetId); 771 772 private: 773 RefPtr<PipelineContext> GetPipelineContext() const; 774 void OnBindSheetInner(std::function<void(const std::string&)>&& callback, 775 const RefPtr<UINode>& sheetContentNode, std::function<RefPtr<UINode>()>&& buildtitleNodeFunc, 776 NG::SheetStyle& sheetStyle, std::function<void()>&& onAppear, std::function<void()>&& onDisappear, 777 std::function<void()>&& shouldDismiss, std::function<void(const int32_t)>&& onWillDismiss, 778 std::function<void()>&& onWillAppear, std::function<void()>&& onWillDisappear, 779 std::function<void(const float)>&& onHeightDidChange, std::function<void(const float)>&& onDetentsDidChange, 780 std::function<void(const float)>&& onWidthDidChange, 781 std::function<void(const float)>&& onTypeDidChange, 782 std::function<void()>&& sheetSpringBack, const RefPtr<FrameNode>& targetNode, bool isStartByUIContext = false); 783 void SetSheetProperty( 784 const RefPtr<FrameNode>& sheetPageNode, 785 NG::SheetStyle& sheetStyle, std::function<void()>&& onAppear, std::function<void()>&& onDisappear, 786 std::function<void()>&& shouldDismiss, std::function<void(const int32_t)>&& onWillDismiss, 787 std::function<void()>&& onWillAppear, std::function<void()>&& onWillDisappear, 788 std::function<void(const float)>&& onHeightDidChange, std::function<void(const float)>&& onDetentsDidChange, 789 std::function<void(const float)>&& onWidthDidChange, 790 std::function<void(const float)>&& onTypeDidChange, 791 std::function<void()>&& sheetSpringBack); 792 void SaveSheetPageNode( 793 const RefPtr<FrameNode>& sheetPageNode, const RefPtr<UINode>& sheetContentNode, 794 const RefPtr<FrameNode>& targetNode, bool isStartByUIContext); 795 bool CheckTargetIdIsValid(int32_t targetId); 796 void UpdateSheetRender( 797 const RefPtr<FrameNode>& sheetPageNode, const NG::SheetStyle& sheetStyle, bool isPartialUpdate); 798 void UpdateSheetPage(const RefPtr<FrameNode>& sheetNode, const NG::SheetStyle& sheetStyle, 799 int32_t targetId, bool isStartByUIContext = false, bool isPartialUpdate = false, 800 std::function<void()>&& onAppear = nullptr, std::function<void()>&& onDisappear = nullptr, 801 std::function<void()>&& shouldDismiss = nullptr, std::function<void(const int32_t)>&& onWillDismiss = nullptr, 802 std::function<void()>&& onWillAppear = nullptr, std::function<void()>&& onWillDisappear = nullptr, 803 std::function<void(const float)>&& onHeightDidChange = nullptr, 804 std::function<void(const float)>&& onDetentsDidChange = nullptr, 805 std::function<void(const float)>&& onWidthDidChange = nullptr, 806 std::function<void(const float)>&& onTypeDidChange = nullptr, 807 std::function<void()>&& sheetSpringBack = nullptr); 808 SheetStyle UpdateSheetStyle( 809 const RefPtr<FrameNode>& sheetNode, const SheetStyle& sheetStyle, bool isPartialUpdate); 810 void UpdateSheetRenderProperty( 811 const RefPtr<FrameNode>& sheetNode, const NG::SheetStyle& currentStyle, bool isPartialUpdate); 812 void UpdateSheetMaskBackgroundColor(const RefPtr<FrameNode>& maskNode, 813 const RefPtr<RenderContext>& maskRenderContext, const SheetStyle& sheetStyle); 814 void UpdateSheetMask(const RefPtr<FrameNode>& maskNode, 815 const RefPtr<FrameNode>& sheetNode, const SheetStyle& sheetStyle, bool isPartialUpdate = false); CleanViewContextMap(int32_t instanceId,int32_t sheetContentId)816 void CleanViewContextMap(int32_t instanceId, int32_t sheetContentId) 817 { 818 if (cleanViewContextMapCallback_) { 819 cleanViewContextMapCallback_(instanceId, sheetContentId); 820 } 821 } 822 void CleanInvalidModalNode(const WeakPtr<FrameNode>& invalidNode); 823 824 // toast should contain id to avoid multiple delete. 825 std::unordered_map<int32_t, WeakPtr<FrameNode>> toastMap_; 826 827 /** find/register menu node and update menu's display position 828 * 829 * @return true if process is successful 830 */ 831 bool ShowMenuHelper(RefPtr<FrameNode>& menu, int32_t targetId, const NG::OffsetF& offset); 832 void ResetMenuWrapperVisibility(const RefPtr<FrameNode>& menuWrapper); 833 // The focus logic of overlay node (menu and dialog): 834 // 1. before start show animation: lower level node set unfocusabel and lost focus; 835 // 2. end show animation: overlay node get focus; 836 // 3. before start hide animation: lower level node set focusable; 837 // 4. end hide animation: overlay node lost focus, lower level node get focus. 838 void FocusOverlayNode(const RefPtr<FrameNode>& overlayNode, bool isInSubWindow = false); 839 void BlurOverlayNode(const RefPtr<FrameNode>& currentOverlay, bool isInSubWindow = false); 840 void BlurLowerNode(const RefPtr<FrameNode>& currentOverlay); 841 void ResetLowerNodeFocusable(const RefPtr<FrameNode>& currentOverlay); 842 void PostDialogFinishEvent(const WeakPtr<FrameNode>& nodeWk); 843 void OnDialogCloseEvent(const RefPtr<FrameNode>& node); 844 845 void CloseDialogInner(const RefPtr<FrameNode>& dialogNode); 846 RefPtr<PipelineContext> GetMainPipelineContext(int32_t containerId); 847 RefPtr<PipelineContext> GetMainPipelineContext(const RefPtr<FrameNode>& node); 848 849 void SetPreviewFirstShow(const RefPtr<FrameNode>& menu); 850 void ShowMenuAnimation(const RefPtr<FrameNode>& menu); 851 void SetPatternFirstShow(const RefPtr<FrameNode>& menu); 852 void PopMenuAnimation(const RefPtr<FrameNode>& menu, bool showPreviewAnimation = true, bool startDrag = false); 853 void ShowMenuDisappearTransition(const RefPtr<FrameNode>& menu); 854 void ShowMenuClearAnimation(const RefPtr<FrameNode>& menuWrapper, AnimationOption& option, 855 bool showPreviewAnimation, bool startDrag); 856 bool IsContextMenuBindedOnOrigNode(); 857 void OpenDialogAnimationInner(const RefPtr<FrameNode>& node, const DialogProperties& dialogProps, 858 bool isReadFirstNode = true); 859 void OpenDialogAnimation(const RefPtr<FrameNode>& node, const DialogProperties& dialogProps, 860 bool isReadFirstNode = true); 861 void CloseDialogAnimation(const RefPtr<FrameNode>& node); 862 void UpdateChildVisible(const RefPtr<FrameNode>& node, const RefPtr<FrameNode>& childNode); 863 void SetTransitionCallbacks(const RefPtr<FrameNode>& node, const RefPtr<FrameNode>& contentNode, 864 const RefPtr<FrameNode>& maskNode, const DialogProperties& dialogProps); 865 void SetDialogTransitionEffect(const RefPtr<FrameNode>& node, const DialogProperties& dialogProps); 866 void SendDialogAccessibilityEvent(const RefPtr<FrameNode>& node, AccessibilityEventType eventType); 867 void UpdateChildInvisible(const RefPtr<FrameNode>& node, const RefPtr<FrameNode>& child); 868 void CloseMaskAndContentMatchTransition(const RefPtr<FrameNode>& node); 869 void CloseDialogMatchTransition(const RefPtr<FrameNode>& node); 870 void SetContainerButtonEnable(bool isEnabled); 871 872 void SaveLastModalNode(); 873 void PlayTransitionEffectIn(const RefPtr<FrameNode>& topModalNode); 874 void PlayTransitionEffectOut(const RefPtr<FrameNode>& topModalNode); 875 void PlayDefaultModalTransition(const RefPtr<FrameNode>& modalNode, bool isTransitionIn); 876 void DefaultModalTransition(bool isTransitionIn); 877 void PlayAlphaModalTransition(const RefPtr<FrameNode>& modalNode, bool isTransitionIn); 878 void FireModalPageShow(); 879 void FireModalPageHide(); 880 void ShowTipsInSubwindow(int32_t targetId, const PopupInfo& popupInfo, int32_t times); 881 882 void SetSheetBackgroundBlurStyle(const RefPtr<FrameNode>& sheetNode, const BlurStyleOption& bgBlurStyle); 883 void SetSheetBackgroundColor(const RefPtr<FrameNode>& sheetNode, const RefPtr<SheetTheme>& sheetTheme, 884 const NG::SheetStyle& sheetStyle, bool isPartialUpdate = false); 885 886 bool ModalExitProcess(const RefPtr<FrameNode>& topModalNode); 887 bool ModalPageExitProcess(const RefPtr<FrameNode>& topModalNode); 888 bool SheetPageExitProcess(const RefPtr<FrameNode>& topModalNode); 889 890 void BeforeShowDialog(const RefPtr<FrameNode>& dialogNode); 891 void PutLevelOrder(const RefPtr<FrameNode>& node, std::optional<double> levelOrder); 892 void PopLevelOrder(int32_t nodeId); 893 RefPtr<FrameNode> GetNextNodeWithOrder(const std::optional<double>& levelOrder); 894 RefPtr<FrameNode> GetTopOrderNode(); 895 bool GetNodeFocusable(const RefPtr<FrameNode>& node); 896 RefPtr<FrameNode> GetTopFocusableNode(); 897 void FocusNextOrderNode(const RefPtr<FrameNode>& topNode); 898 void SendAccessibilityEventToNextOrderNode(const RefPtr<FrameNode>& topNode); 899 void RemoveDialogFromMap(const RefPtr<FrameNode>& node); 900 void RemoveMaskFromMap(const RefPtr<FrameNode>& dialogNode); 901 bool DialogInMapHoldingFocus(); 902 void PlayKeyboardTransition(const RefPtr<FrameNode>& customKeyboard, bool isTransitionIn); 903 void FireNavigationStateChange(bool show, const RefPtr<UINode>& node = nullptr); 904 RefPtr<FrameNode> GetModalNodeInStack(std::stack<WeakPtr<FrameNode>>& stack); 905 void PlayBubbleStyleSheetTransition(RefPtr<FrameNode> sheetNode, bool isTransitionIn); 906 void CheckReturnFocus(RefPtr<FrameNode> node); 907 void MountPopup(int32_t targetId, const PopupInfo& popupInfo, 908 const std::function<void(int32_t)>&& onWillDismiss = nullptr, bool interactiveDismiss = true); 909 bool IsContentUpdatePopup(const RefPtr<Pattern>& pattern); 910 911 int32_t GetPopupIdByNode(const RefPtr<FrameNode>& overlay); 912 bool PopupInteractiveDismiss(const RefPtr<FrameNode>& overlay); 913 bool PopupCallBackOnWillDismiss(const RefPtr<FrameNode>& overlay); 914 bool RemovePopupInSubwindow(const RefPtr<Pattern>& pattern, const RefPtr<FrameNode>& overlay, 915 const RefPtr<UINode>& rootNode); 916 bool UpdatePopupMap(int32_t targetId, const PopupInfo& popupInfo); 917 void PlayDefaultModalIn(const RefPtr<FrameNode>& modalNode, const RefPtr<RenderContext>& context, 918 AnimationOption option, float showHeight); 919 void PlayDefaultModalOut(const RefPtr<FrameNode>& modalNode, const RefPtr<RenderContext>& context, 920 AnimationOption option, float showHeight); 921 void OpenToastAnimation(const RefPtr<FrameNode>& toastNode, int32_t duration); 922 void OnShowMenuAnimationFinished(const WeakPtr<FrameNode> menuWK, const WeakPtr<OverlayManager> weak, 923 int32_t instanceId); 924 void HandleMenuDisappearCallback(const RefPtr<FrameNode>& menu); 925 bool CheckSelectSubWindowToClose( 926 const RefPtr<FrameNode>& menu, const RefPtr<OverlayManager>& overlayManager, bool expandDisplay); 927 void OnPopMenuAnimationFinished(const WeakPtr<FrameNode> menuWK, const WeakPtr<UINode> rootWeak, 928 const WeakPtr<OverlayManager> weak, int32_t instanceId); 929 void UpdateMenuVisibility(const RefPtr<FrameNode>& menu); 930 void RemoveMenuNotInSubWindow( 931 const WeakPtr<FrameNode>& menuWK, const WeakPtr<UINode>& rootWeak, const WeakPtr<OverlayManager>& overlayWeak); 932 bool CreateSheetKey(const RefPtr<NG::FrameNode>& sheetContentNode, int32_t targetId, 933 SheetKey& sheetKey); 934 935 bool CheckTopModalNode(const RefPtr<FrameNode>& topModalNode, int32_t targetId); 936 void HandleModalShow(std::function<void(const std::string&)>&& callback, 937 std::function<RefPtr<UINode>()>&& buildNodeFunc, NG::ModalStyle& modalStyle, std::function<void()>&& onAppear, 938 std::function<void()>&& onDisappear, std::function<void()>&& onWillDisappear, const RefPtr<UINode> rootNode, 939 const NG::ContentCoverParam& contentCoverParam, int32_t targetId, 940 std::optional<ModalTransition> modalTransition); 941 void HandleModalPop(std::function<void()>&& onWillDisappear, const RefPtr<UINode> rootNode, int32_t targetId); 942 943 int32_t ExceptComponent(const RefPtr<NG::UINode>& rootNode, RefPtr<NG::FrameNode>& overlay, 944 bool isBackPressed, bool isPageRouter); 945 void OverlayDoDismiss(RefPtr<NG::FrameNode>& overlay, RefPtr<Pattern>& pattern); 946 int32_t RemoveOverlayCommon(const RefPtr<NG::UINode>& rootNode, RefPtr<NG::FrameNode>& overlay, 947 RefPtr<Pattern>& pattern, bool isBackPressed, bool isPageRouter); 948 int32_t WebBackward(RefPtr<NG::FrameNode>& overlay); 949 void FindWebNode(const RefPtr<NG::UINode>& node, RefPtr<NG::FrameNode>& webNode, bool& isNavDestination); 950 951 void RegisterDialogLifeCycleCallback(const RefPtr<FrameNode>& dialog, const DialogProperties& dialogProps); 952 void CustomDialogRecordEvent(const DialogProperties& dialogProps); 953 RefPtr<UINode> RebuildCustomBuilder(RefPtr<UINode>& contentNode); 954 void OpenCustomDialogInner(const DialogProperties& dialogProps, std::function<void(int32_t)> &&callback, 955 const RefPtr<FrameNode> dialog, bool showComponentContent); 956 RefPtr<FrameNode> UpdateCustomDialogInner(const WeakPtr<NG::UINode>& node, const DialogProperties& dialogProps, 957 const std::function<void(int32_t)>& callback); 958 959 void DumpPopupMapInfo() const; 960 void DumpMapInfo( 961 std::unordered_map<int32_t, RefPtr<FrameNode>> map, const std::string mapName, bool hasTarget = true) const; 962 void DumpMapInfo( 963 std::unordered_map<int32_t, WeakPtr<FrameNode>> map, const std::string mapName, bool hasTarget = true) const; 964 void DumpSheetMapInfo(const std::unordered_map<SheetKey, WeakPtr<FrameNode>, SheetKeyHash>& map, 965 const std::string mapName) const; 966 void DumpMaskNodeIdMapInfo() const; 967 void DumpModalListInfo() const; 968 void DumpEntry(const RefPtr<FrameNode>& targetNode, int32_t targetId, const RefPtr<FrameNode>& node) const; 969 std::string GetMapNodeLog(const RefPtr<FrameNode>& node, bool hasTarget = true) const; 970 RefPtr<UINode> FindChildNodeByKey(const RefPtr<NG::UINode>& parentNode, const std::string& key); 971 bool SetNodeBeforeAppbar(const RefPtr<NG::UINode>& rootNode, const RefPtr<FrameNode>& node, 972 std::optional<double> levelOrder = std::nullopt); 973 RefPtr<FrameNode> GetOverlayFrameNode(); 974 void RemoveChildWithService(const RefPtr<UINode>& rootNode, const RefPtr<FrameNode>& node); 975 CustomKeyboardOffsetInfo CalcCustomKeyboardOffset(const RefPtr<FrameNode>& customKeyboard); 976 void SendToAccessibility(const WeakPtr<FrameNode> node, bool isShow); 977 void RemoveMenuWrapperNode(const RefPtr<UINode>& rootNode, const RefPtr<PipelineContext>& pipeline); 978 void CallMenuDisappearWithStatus(const RefPtr<FrameNode>& menuWrapperNode); 979 void CallMenuDisappearOnlyNewLifeCycle(const RefPtr<FrameNode>& menuWrapperNode); 980 void EraseMenuInfoFromWrapper(const RefPtr<FrameNode>& menuWrapperNode); 981 void SetDragNodeNeedClean(); 982 void MountCustomKeyboard(const RefPtr<FrameNode>& customKeyboard, int32_t targetId); 983 void FireNavigationLifecycle(const RefPtr<UINode>& uiNode, int32_t lifecycleId, bool isLowerOnly, int32_t reason); 984 int32_t RemoveOverlayManagerNode(); 985 void UpdateMenuAnimationOptions(const RefPtr<FrameNode>& menu, AnimationOption& option); 986 RefPtr<FrameNode> GetLastChildNotRemovingForAtm(const RefPtr<UINode>& atomicNode); 987 RefPtr<FrameNode> overlayNode_; 988 // Key: frameNode Id, Value: index 989 std::unordered_map<int32_t, int32_t> frameNodeMapOnOverlay_; 990 std::unordered_map<int32_t, int32_t> orderOverlayMap_; 991 // Key: target Id, Value: PopupInfo 992 std::unordered_map<int32_t, NG::PopupInfo> popupMap_; 993 std::unordered_map<int32_t, std::list<std::pair<int32_t, bool>>> tipsEnterAndLeaveInfoMap_; 994 std::list<std::pair<int32_t, NG::PopupInfo>> tipsInfoList_; 995 std::list<std::pair<int32_t, bool>> tipsStatusList_; 996 // K: target frameNode ID, V: menuNode 997 std::unordered_map<int32_t, RefPtr<FrameNode>> menuMap_; 998 std::unordered_map<int32_t, RefPtr<FrameNode>> dialogMap_; 999 std::unordered_map<int32_t, double> nodeIdOrderMap_; 1000 std::map<double, std::vector<RefPtr<FrameNode>>> orderNodesMap_; 1001 std::unordered_map<int32_t, RefPtr<FrameNode>> customPopupMap_; 1002 std::unordered_map<int32_t, RefPtr<FrameNode>> customKeyboardMap_; 1003 std::stack<WeakPtr<FrameNode>> modalStack_; 1004 std::list<WeakPtr<FrameNode>> modalList_; 1005 std::unordered_map<SheetKey, WeakPtr<FrameNode>, SheetKeyHash> sheetMap_; 1006 std::function<void(const int32_t, const int32_t)> cleanViewContextMapCallback_ = nullptr; 1007 std::unordered_map<int32_t, RefPtr<NG::ClickEvent>> sheetMaskClickEventMap_; // Key: maskNodeId 1008 WeakPtr<FrameNode> lastModalNode_; // Previous Modal Node 1009 float sheetHeight_ { 0.0 }; 1010 WeakPtr<UINode> rootNodeWeak_; 1011 WeakPtr<PipelineContext> context_; 1012 int32_t dialogCount_ = 0; 1013 DismissTarget dismissTarget_; 1014 int32_t dismissSheetId_ = 0; 1015 int32_t dismissDialogId_ = 0; 1016 std::unordered_map<int32_t, int32_t> maskNodeIdMap_; 1017 int32_t subWindowId_ = -1; 1018 bool hasPixelMap_ { false }; 1019 bool hasDragPixelMap_ { false }; 1020 bool hasFilter_ { false }; 1021 bool hasEvent_ { false }; 1022 bool isOnAnimation_ { false }; 1023 WeakPtr<FrameNode> pixmapColumnNodeWeak_; 1024 WeakPtr<FrameNode> dragPixmapColumnNodeWeak_; 1025 WeakPtr<FrameNode> filterColumnNodeWeak_; 1026 WeakPtr<FrameNode> eventColumnNodeWeak_; 1027 bool isContextMenuDragHideFinished_ = false; 1028 OffsetF dragMoveVector_ = OffsetF(0.0f, 0.0f); 1029 OffsetF lastDragMoveVector_ = OffsetF(0.0f, 0.0f); 1030 1031 std::function<void()> onHideDialogCallback_ = nullptr; 1032 CancelableCallback<void()> continuousTask_; 1033 CancelableCallback<void()> previewFilterTask_; 1034 std::function<bool()> backPressEvent_ = nullptr; 1035 1036 std::set<WeakPtr<UINode>> windowSceneSet_; 1037 1038 RefPtr<NG::ClickEvent> sheetMaskClickEvent_; 1039 RefPtr<GroupManager> groupManager_ = MakeRefPtr<GroupManager>(); 1040 1041 // native modal ui extension 1042 bool isProhibitBack_ = false; 1043 1044 std::unordered_map<int32_t, WeakPtr<FrameNode>> uiExtNodes_; 1045 bool keyboardAvoidance_ = false; 1046 ACE_DISALLOW_COPY_AND_MOVE(OverlayManager); 1047 1048 bool hasFilterActived {false}; 1049 1050 int32_t dismissPopupId_ = 0; 1051 1052 bool hasGatherNode_ { false }; 1053 bool isGatherWithMenu_ { false }; 1054 WeakPtr<FrameNode> gatherNodeWeak_; 1055 WeakPtr<FrameNode> dragNodeCopyWeak_; 1056 std::vector<GatherNodeChildInfo> gatherNodeChildrenInfo_; 1057 bool isMenuShow_ = false; 1058 bool isAttachToCustomNode_ = false; 1059 1060 // Only used when CreateModalUIExtension 1061 // No thread safety issue due to they are all run in UI thread 1062 bool isAllowedBeCovered_ = true; 1063 // Only hasValue when isAllowedBeCovered is false 1064 std::set<int32_t> curSessionIds_; 1065 std::set<int32_t> skipTargetIds_; 1066 std::optional<OverlayManagerInfo> overlayInfo_; 1067 std::unordered_set<int32_t> onDisappearFilterIds_; 1068 }; 1069 } // namespace OHOS::Ace::NG 1070 1071 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_OVERLAY_OVERLAY_MANAGER_H 1072