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_TIP_RENDER_TIP_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TIP_RENDER_TIP_H 18 19 #include "core/components/arc/arc_component.h" 20 #include "core/components/common/properties/border.h" 21 #include "core/components/common/properties/edge.h" 22 #include "core/pipeline/base/render_node.h" 23 24 namespace OHOS::Ace { 25 26 constexpr Dimension TIP_SPACING = 8.0_vp; 27 28 class RenderTip : public RenderNode { 29 DECLARE_ACE_TYPE(RenderTip, RenderNode); 30 31 public: 32 static RefPtr<RenderNode> Create(); 33 void Update(const RefPtr<Component>& component) override; 34 void PerformLayout() override; 35 GetChildSize()36 const Size& GetChildSize() const 37 { 38 return childSize_; 39 } 40 SetPadding(const Edge & padding)41 void SetPadding(const Edge& padding) 42 { 43 padding_ = padding; 44 } 45 46 protected: 47 Color bgColor_; 48 Dimension arrowOffset_; 49 Size childSize_; 50 Edge padding_; 51 Border border_; 52 Axis direction_ = Axis::HORIZONTAL; 53 54 private: 55 void AdaptChildPadding(const Size& childSize, const Size& selfSize); 56 }; 57 58 } // namespace OHOS::Ace 59 60 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_TIP_RENDER_TIP_H 61