1 /* 2 * Copyright (c) 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 FOUNDATION_ACE_FRAMEWORKS_BASE_SUBWINDOW_SUBWINDOW_H 17 #define FOUNDATION_ACE_FRAMEWORKS_BASE_SUBWINDOW_SUBWINDOW_H 18 19 #include <set> 20 21 #include "base/memory/ace_type.h" 22 #include "base/memory/referenced.h" 23 #include "core/components/dialog/dialog_properties.h" 24 #include "core/components_ng/base/frame_node.h" 25 #include "core/components_ng/pattern/overlay/overlay_manager.h" 26 #include "core/pipeline/base/component.h" 27 28 namespace OHOS::Ace { 29 30 class ACE_EXPORT Subwindow : public AceType { 31 DECLARE_ACE_TYPE(Subwindow, AceType) 32 33 public: 34 static RefPtr<Subwindow> CreateSubwindow(int32_t instanceId); 35 36 virtual void InitContainer() = 0; 37 virtual void ResizeWindow() = 0; 38 virtual void ShowMenu(const RefPtr<Component>& newComponent) = 0; 39 virtual void ShowMenuNG(const RefPtr<NG::FrameNode> menuNode, int32_t targetId, const NG::OffsetF& offset) = 0; 40 virtual void HideMenuNG(int32_t targetId) = 0; 41 virtual void HideMenuNG() = 0; 42 virtual void ShowPopup(const RefPtr<Component>& newComponent, bool disableTouchEvent = true) = 0; 43 virtual void ShowPopupNG(int32_t targetId, const NG::PopupInfo& popupInfo) = 0; 44 virtual void HidePopupNG(int32_t targetId) = 0; 45 virtual void HidePopupNG() = 0; 46 virtual bool CancelPopup(const std::string& id) = 0; 47 virtual void CloseMenu() = 0; ClearMenu()48 virtual void ClearMenu() {}; 49 virtual void ClearMenuNG() = 0; 50 virtual RefPtr<NG::FrameNode> ShowDialogNG( 51 const DialogProperties& dialogProps, const RefPtr<NG::UINode>& customNode) = 0; 52 virtual void HideSubWindowNG() = 0; 53 54 // Add interface for hot regions SetHotAreas(const std::vector<Rect> & rects)55 virtual void SetHotAreas(const std::vector<Rect>& rects) {}; 56 GetSubwindowId()57 int32_t GetSubwindowId() const 58 { 59 return subwindowId_; 60 } 61 SetSubwindowId(int32_t id)62 void SetSubwindowId(int32_t id) 63 { 64 subwindowId_ = id; 65 } 66 67 virtual void ShowToast(const std::string& message, int32_t duration, const std::string& bottom) = 0; 68 virtual void ShowDialog(const std::string& title, const std::string& message, 69 const std::vector<ButtonInfo>& buttons, bool autoCancel, std::function<void(int32_t, int32_t)>&& callback, 70 const std::set<std::string>& callbacks) = 0; 71 virtual void ShowActionMenu(const std::string& title, const std::vector<ButtonInfo>& button, 72 std::function<void(int32_t, int32_t)>&& callback) = 0; 73 virtual void CloseDialog(int32_t instanceId) = 0; 74 75 private: 76 int32_t subwindowId_ = 0; 77 }; 78 79 } // namespace OHOS::Ace 80 81 #endif // FOUNDATION_ACE_FRAMEWORKS_BASE_SUBWINDOW_SUBWINDOW_H 82