• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_OVERLAY_SHEET_WRAPPER_PAINT_METHOD_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_OVERLAY_SHEET_WRAPPER_PAINT_METHOD_H
18 
19 #include "core/components_ng/pattern/overlay/sheet_style.h"
20 #include "core/components_ng/pattern/pattern.h"
21 #include "core/components_ng/render/node_paint_method.h"
22 
23 namespace OHOS::Ace::NG {
24 
25 class ACE_EXPORT SheetWrapperPaintMethod : public NodePaintMethod {
DECLARE_ACE_TYPE(SheetWrapperPaintMethod,NodePaintMethod)26     DECLARE_ACE_TYPE(SheetWrapperPaintMethod, NodePaintMethod)
27 public:
28     SheetWrapperPaintMethod() {}
29     ~SheetWrapperPaintMethod() override = default;
30 
GetOverlayDrawFunction(PaintWrapper * paintWrapper)31     CanvasDrawFunction GetOverlayDrawFunction(PaintWrapper* paintWrapper) override
32     {
33         return [weak = WeakClaim(this), paintWrapper](RSCanvas& canvas) {
34             auto sheet = weak.Upgrade();
35             if (sheet) {
36                 sheet->PaintInnerBorder(canvas, paintWrapper);
37                 sheet->PaintOuterBorder(canvas, paintWrapper);
38             }
39         };
40     }
41 
42     void PaintOuterBorder(RSCanvas& canvas, PaintWrapper* paintWrapper);
43     void PaintInnerBorder(RSCanvas& canvas, PaintWrapper* paintWrapper);
44 
45 private:
46     RefPtr<FrameNode> GetSheetNode(PaintWrapper* paintWrapper);
47     void SetBorderPenStyle(RSPen& pen, const Dimension& borderWidth, const Color& borderColor);
48     void GetBorderDrawPath(RSPath& path, const RefPtr<FrameNode> sheetNode, const RefPtr<SheetTheme>& sheetTheme,
49         float borderWidth, const BorderRadiusProperty& sheetRadius);
50     void GetBorderDrawPathNew(RSPath& path, const RefPtr<FrameNode> sheetNode,
51         float borderWidth, const BorderRadiusProperty& sheetRadius);
52     void DrawClipPathBottom(
53         RSPath&, const RefPtr<FrameNode>, const BorderRadiusProperty&, float, const SheetPopupInfo&);
54     void DrawClipPathTop(RSPath&, const RefPtr<FrameNode>, const BorderRadiusProperty&, float, const SheetPopupInfo&);
55     void DrawClipPathLeft(RSPath&, const RefPtr<FrameNode>, const BorderRadiusProperty&, float, const SheetPopupInfo&);
56     void DrawClipPathRight(RSPath&, const RefPtr<FrameNode>, const BorderRadiusProperty&, float, const SheetPopupInfo&);
57     void DrawClipPathWithoutArrow(RSPath&, const RefPtr<FrameNode>, const BorderRadiusProperty&, float);
58     bool IsDrawBorder(PaintWrapper* paintWrapper);
59 
60     ACE_DISALLOW_COPY_AND_MOVE(SheetWrapperPaintMethod);
61 };
62 
63 } // namespace OHOS::Ace::NG
64 
65 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_OVERLAY_SHEET_WRAPPER_PAINT_METHOD_H
66