1 /* 2 * Copyright (c) 2021 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_BUBBLE_BUBBLE_COMPONENT_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BUBBLE_BUBBLE_COMPONENT_H 18 19 #include "core/components/common/properties/color.h" 20 #include "core/components/common/properties/edge.h" 21 #include "core/components/popup/popup_component.h" 22 #include "core/pipeline/base/component.h" 23 #include "core/pipeline/base/sole_child_component.h" 24 25 namespace OHOS::Ace { 26 27 class BubbleComponent : public SoleChildComponent { 28 DECLARE_ACE_TYPE(BubbleComponent, SoleChildComponent); 29 30 public: 31 using StateChangeEvent = std::function<void(bool)>; 32 BubbleComponent(const RefPtr<Component> & child)33 explicit BubbleComponent(const RefPtr<Component>& child) : SoleChildComponent(child) {} 34 ~BubbleComponent() override = default; 35 36 RefPtr<Element> CreateElement() override; 37 RefPtr<RenderNode> CreateRenderNode() override; 38 SetPopupParam(const RefPtr<PopupParam> & popupParam)39 void SetPopupParam(const RefPtr<PopupParam>& popupParam) 40 { 41 popupParam_ = popupParam; 42 } 43 GetPopupParam()44 const RefPtr<PopupParam>& GetPopupParam() const 45 { 46 return popupParam_; 47 } 48 SetId(const ComposeId & id)49 void SetId(const ComposeId& id) 50 { 51 id_ = id; 52 } 53 GetId()54 const ComposeId& GetId() const 55 { 56 return id_; 57 } 58 SetWeakStack(const WeakPtr<StackElement> & weakStack)59 void SetWeakStack(const WeakPtr<StackElement>& weakStack) 60 { 61 weakStack_ = weakStack; 62 } 63 GetWeakStack()64 const WeakPtr<StackElement>& GetWeakStack() const 65 { 66 return weakStack_; 67 } 68 GetStateChangeEvent()69 const StateChangeEvent& GetStateChangeEvent() const 70 { 71 return stateChangeEvent_; 72 } 73 SetStateChangeEvent(StateChangeEvent && stateChangeEvent)74 void SetStateChangeEvent(StateChangeEvent&& stateChangeEvent) 75 { 76 stateChangeEvent_ = std::move(stateChangeEvent); 77 } 78 79 private: 80 ComposeId id_; 81 RefPtr<PopupParam> popupParam_; 82 WeakPtr<StackElement> weakStack_; 83 StateChangeEvent stateChangeEvent_; 84 }; 85 86 } // namespace OHOS::Ace 87 88 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BUBBLE_BUBBLE_COMPONENT_H 89