1 /* 2 * Copyright (c) 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_PATTERN_MENU_MENU_WRAPPER_PAINT_METHOD_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MENU_MENU_WRAPPER_PAINT_METHOD_H 18 19 #include "base/geometry/ng/size_t.h" 20 #include "base/memory/ace_type.h" 21 #include "base/memory/referenced.h" 22 #include "base/utils/macros.h" 23 #include "base/utils/utils.h" 24 #include "core/components/common/properties/placement.h" 25 #include "core/components_ng/render/node_paint_method.h" 26 #include "core/components_v2/list/list_component.h" 27 28 // @deprecated 29 namespace OHOS::Ace::NG { 30 struct MenuParam; 31 struct MenuPathParams { 32 float radiusTopLeftPx = 0.0f; 33 float radiusTopRightPx = 0.0f; 34 float radiusBottomLeftPx = 0.0f; 35 float radiusBottomRightPx = 0.0f; 36 OffsetF childOffset = OffsetF(); 37 SizeF frameSize = SizeF(); 38 OffsetF arrowPosition = OffsetF(); 39 Placement arrowPlacement = Placement::NONE; 40 bool didNeedArrow = false; 41 }; 42 43 struct ArrowOutlineOffset { 44 float top = 0.0f; 45 float bottom = 0.0f; 46 float left = 0.0f; 47 float right = 0.0f; ResetArrowOutlineOffset48 void Reset() 49 { 50 top = 0.0f; 51 bottom = 0.0f; 52 left = 0.0f; 53 right = 0.0f; 54 } 55 }; 56 57 class ACE_EXPORT MenuWrapperPaintMethod : public NodePaintMethod { 58 DECLARE_ACE_TYPE(MenuWrapperPaintMethod, NodePaintMethod); 59 public: 60 MenuWrapperPaintMethod() = default; 61 ~MenuWrapperPaintMethod() override = default; 62 63 CanvasDrawFunction GetOverlayDrawFunction(PaintWrapper* paintWrapper) override; 64 65 private: 66 void PaintDoubleBorder(RSCanvas& canvas, PaintWrapper* paintWrapper); 67 void PaintInnerBorderAndClipSinglePath(RSCanvas& canvas, PaintWrapper* paintWrapper, const MenuPathParams& path); 68 void PaintOuterBorderAndClipSinglePath(RSCanvas& canvas, PaintWrapper* paintWrapper, const MenuPathParams& path); 69 void BuildCompletePath(RSPath& rsPath, const MenuPathParams& params); 70 void BuildTopLinePath(RSPath& rsPath, const MenuPathParams& params); 71 void BuildRightLinePath(RSPath& rsPath, const MenuPathParams& params); 72 void BuildBottomLinePath(RSPath& rsPath, const MenuPathParams& params); 73 void BuildLeftLinePath(RSPath& rsPath, const MenuPathParams& params); 74 void BuildBottomArrowPath(RSPath& rsPath, float arrowX, float arrowY); 75 void BuildTopArrowPath(RSPath& rsPath, float arrowX, float arrowY); 76 void BuildRightArrowPath(RSPath& rsPath, float arrowX, float arrowY); 77 void BuildLeftArrowPath(RSPath& rsPath, float arrowX, float arrowY); 78 void PaintEdgeOuterBorder(const MenuPathParams& params, RSCanvas& canvas, const MenuParam& menuParam); 79 RSPath BuildOutlinePath(const MenuPathParams& params, const MenuParam& menuParam); 80 ACE_DISALLOW_COPY_AND_MOVE(MenuWrapperPaintMethod); 81 82 ArrowOutlineOffset arrowOutlineOffset_; 83 }; 84 } // namespace OHOS::Ace::NG 85 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_MENU_MENU_PAINT_METHOD_H