• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CORE_COMPONENTS_NG_PATTERN_CIRCLE_PAINT_METHOD_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_CIRCLE_PAINT_METHOD_H
18 
19 #include "base/geometry/ng/size_t.h"
20 #include "core/components_ng/base/geometry_node.h"
21 #include "core/components_ng/pattern/select_overlay/select_overlay_content_modifier.h"
22 #include "core/components_ng/pattern/select_overlay/select_overlay_modifier.h"
23 #include "core/components_ng/pattern/select_overlay/select_overlay_property.h"
24 #include "core/components_ng/pattern/shape/shape_paint_property.h"
25 #include "core/components_ng/render/circle_painter.h"
26 #include "core/components_ng/render/node_paint_method.h"
27 
28 namespace OHOS::Ace::NG {
29 
30 class ACE_EXPORT SelectOverlayPaintMethod : public NodePaintMethod {
DECLARE_ACE_TYPE(SelectOverlayPaintMethod,NodePaintMethod)31     DECLARE_ACE_TYPE(SelectOverlayPaintMethod, NodePaintMethod)
32 public:
33     SelectOverlayPaintMethod(const RefPtr<SelectOverlayModifier>& selectOverlayModifier,
34         const RefPtr<SelectOverlayContentModifier>& selectOverlayContentModifier, SelectOverlayInfo info,
35         const OffsetF& offset, bool hasExtensionMenu, bool hasShowAnimation, bool isCreated, bool isHiddenHandle)
36         : selectOverlayModifier_(selectOverlayModifier), selectOverlayContentModifier_(selectOverlayContentModifier),
37           info_(std::move(info)), defaultMenuEndOffset_(offset), hasExtensionMenu_(hasExtensionMenu),
38           hasShowAnimation_(hasShowAnimation), isCreated_(isCreated), isHiddenHandle_(isHiddenHandle)
39     {}
40     ~SelectOverlayPaintMethod() override = default;
41 
GetOverlayModifier(PaintWrapper * paintWrapper)42     RefPtr<Modifier> GetOverlayModifier(PaintWrapper* paintWrapper) override
43     {
44         CHECK_NULL_RETURN(selectOverlayModifier_, nullptr);
45         // custom menu do not need to draw the overlay icon of default system menu
46         if (info_.menuInfo.menuBuilder) {
47             return nullptr;
48         }
49         return selectOverlayModifier_;
50     }
51 
GetContentModifier(PaintWrapper * paintWrapper)52     RefPtr<Modifier> GetContentModifier(PaintWrapper* paintWrapper) override
53     {
54         CHECK_NULL_RETURN(selectOverlayContentModifier_, nullptr);
55         return selectOverlayContentModifier_;
56     }
57 
58     void UpdateOverlayModifier(PaintWrapper* paintWrapper) override;
59 
60     void UpdateContentModifier(PaintWrapper* paintWrapper) override;
61 
62 private:
63     void CheckCirclesAndBackArrowIsShown();
64 
65     void CheckHasExtensionMenu();
66 
67     void CheckHandleIsShown();
68 
69     RefPtr<SelectOverlayModifier> selectOverlayModifier_;
70 
71     RefPtr<SelectOverlayContentModifier> selectOverlayContentModifier_;
72 
73     SelectOverlayInfo info_;
74 
75     OffsetF defaultMenuEndOffset_;
76 
77     bool hasExtensionMenu_ = false;
78 
79     bool hasShowAnimation_ = false;
80 
81     bool isCreated_ = false;
82 
83     bool handleIsShown_ = false;
84 
85     bool circlesAndBackArrowIsShown_ = false;
86     bool isHiddenHandle_ = false;
87 
88     ACE_DISALLOW_COPY_AND_MOVE(SelectOverlayPaintMethod);
89 };
90 
91 } // namespace OHOS::Ace::NG
92 
93 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_CIRCLE_PAINT_METHOD_H