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