• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SELECT_OVERLAY_MODIFIER_H
16 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SELECT_OVERLAY_MODIFIER_H
17 
18 #include <optional>
19 #include <vector>
20 
21 #include "base/geometry/dimension.h"
22 #include "base/memory/ace_type.h"
23 #include "core/components/common/properties/color.h"
24 #include "core/components_ng/base/modifier.h"
25 #include "core/components_ng/pattern/pattern.h"
26 #include "core/components_ng/render/node_paint_method.h"
27 
28 namespace OHOS::Ace::NG {
29 class SelectOverlayModifier : public OverlayModifier {
30     DECLARE_ACE_TYPE(SelectOverlayModifier, OverlayModifier);
31 
32 public:
33     SelectOverlayModifier(const OffsetF& menuOptionOffset, bool isReverse, const WeakPtr<Pattern>& pattern);
34 
35     ~SelectOverlayModifier() override = default;
36 
37     void onDraw(DrawingContext& drawingContext) override;
38 
39     void SetOtherPointRadius(const Dimension& radius, bool noAnimation = false);
40 
41     void SetHeadPointRadius(const Dimension& radius, bool noAnimation = false);
42 
SetMenuOptionOffset(const OffsetF & offset)43     void SetMenuOptionOffset(const OffsetF& offset)
44     {
45         if (menuOptionOffset_) {
46             menuOptionOffset_->Set(offset);
47         }
48     }
49 
50     void SetLineEndOffset(bool isMore, bool noAnimation = false);
51 
SetHasExtensionMenu(bool hasExtensionMenu)52     void SetHasExtensionMenu(bool hasExtensionMenu)
53     {
54         CHECK_NULL_VOID(hasExtensionMenu_);
55         hasExtensionMenu_->Set(hasExtensionMenu);
56     }
57 
GetHasExtensionMenu()58     bool GetHasExtensionMenu()
59     {
60         return hasExtensionMenu_;
61     }
62 
SetCirclesAndBackArrowOpacity(float circlesAndBackArrowOpacity)63     void SetCirclesAndBackArrowOpacity(float circlesAndBackArrowOpacity)
64     {
65         CHECK_NULL_VOID(circlesAndBackArrowOpacity_);
66         circlesAndBackArrowOpacity_->Set(circlesAndBackArrowOpacity);
67     }
68 
SetFirstHandleIsShow(bool isShow)69     void SetFirstHandleIsShow(bool isShow)
70     {
71         CHECK_NULL_VOID(firstHandleIsShow_);
72         firstHandleIsShow_->Set(isShow);
73     }
74 
SetSecondHandleIsShow(bool isShow)75     void SetSecondHandleIsShow(bool isShow)
76     {
77         CHECK_NULL_VOID(secondHandleIsShow_);
78         secondHandleIsShow_->Set(isShow);
79     }
80 
SetIsNewAvoid(bool value)81     void SetIsNewAvoid(bool value)
82     {
83         isNewAvoid_ = value;
84     }
85 
SetIsReverse(bool isReverse)86     void SetIsReverse(bool isReverse)
87     {
88         isReverse_ = isReverse;
89     }
90 
91 private:
92     void SetDefaultCircleAndLineEndOffset();
93 
94     void DrawbBackArrow(DrawingContext& context);
95     void DrawbCircles(DrawingContext& context);
96     void LineEndOffsetWithAnimation(bool isMore, bool noAnimation);
97     void BackArrowTransitionAnimation(bool noAnimation);
98     void ChangeCircle();
99     void BackArrowTransitionChange(const OffsetF& coordinate, int32_t i);
100 
101     RefPtr<PropertyBool> firstHandleIsShow_;
102     RefPtr<PropertyBool> secondHandleIsShow_;
103     RefPtr<PropertyBool> hasExtensionMenu_;
104     RefPtr<PropertyOffsetF> menuOptionOffset_;
105     RefPtr<AnimatablePropertyFloat> pointRadius_;
106     RefPtr<AnimatablePropertyFloat> headPointRadius_;
107     RefPtr<AnimatablePropertyFloat> rotationAngle_;
108     RefPtr<AnimatablePropertyFloat> circlesAndBackArrowOpacity_;
109     std::vector<RefPtr<AnimatablePropertyOffsetF>> circleOffset_;
110     std::vector<RefPtr<AnimatablePropertyOffsetF>> lineEndOffset_;
111 
112     Color iconColor_ = Color::BLACK;
113     bool isNewAvoid_ = false;
114     bool isReverse_ = false;
115     WeakPtr<Pattern> pattern_;
116 
117     ACE_DISALLOW_COPY_AND_MOVE(SelectOverlayModifier);
118 };
119 } // namespace OHOS::Ace::NG
120 
121 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SELECT_OVERLAY_MODIFIER_H