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); 33 34 ~SelectOverlayModifier() override = default; 35 36 void onDraw(DrawingContext& drawingContext) override; 37 38 void SetOtherPointRadius(const Dimension& radius); 39 40 void SetHeadPointRadius(const Dimension& radius); 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); 50 SetHasExtensionMenu(bool hasExtensionMenu)51 void SetHasExtensionMenu(bool hasExtensionMenu) 52 { 53 hasExtensionMenu_ = hasExtensionMenu; 54 } 55 GetHasExtensionMenu()56 bool GetHasExtensionMenu() 57 { 58 return hasExtensionMenu_; 59 } 60 SetCirclesAndBackArrowOpacity(float circlesAndBackArrowOpacity)61 void SetCirclesAndBackArrowOpacity(float circlesAndBackArrowOpacity) 62 { 63 CHECK_NULL_VOID(circlesAndBackArrowOpacity_); 64 circlesAndBackArrowOpacity_->Set(circlesAndBackArrowOpacity); 65 } 66 SetFirstHandleIsShow(bool isShow)67 void SetFirstHandleIsShow(bool isShow) 68 { 69 CHECK_NULL_VOID(firstHandleIsShow_); 70 firstHandleIsShow_->Set(isShow); 71 } 72 SetSecondHandleIsShow(bool isShow)73 void SetSecondHandleIsShow(bool isShow) 74 { 75 CHECK_NULL_VOID(secondHandleIsShow_); 76 secondHandleIsShow_->Set(isShow); 77 } 78 SetIsNewAvoid(bool value)79 void SetIsNewAvoid(bool value) 80 { 81 isNewAvoid_ = value; 82 } 83 84 private: 85 void SetDefaultCircleAndLineEndOffset(); 86 87 void DrawbBackArrow(DrawingContext& context); 88 void DrawbCircles(DrawingContext& context); 89 90 RefPtr<PropertyBool> firstHandleIsShow_; 91 RefPtr<PropertyBool> secondHandleIsShow_; 92 RefPtr<PropertyOffsetF> menuOptionOffset_; 93 RefPtr<AnimatablePropertyFloat> pointRadius_; 94 RefPtr<AnimatablePropertyFloat> headPointRadius_; 95 RefPtr<AnimatablePropertyFloat> rotationAngle_; 96 RefPtr<AnimatablePropertyFloat> circlesAndBackArrowOpacity_; 97 std::vector<RefPtr<AnimatablePropertyOffsetF>> circleOffset_; 98 std::vector<RefPtr<AnimatablePropertyOffsetF>> lineEndOffset_; 99 100 Color iconColor_ = Color::BLACK; 101 bool hasExtensionMenu_ = false; 102 bool isNewAvoid_ = false; 103 104 ACE_DISALLOW_COPY_AND_MOVE(SelectOverlayModifier); 105 }; 106 } // namespace OHOS::Ace::NG 107 108 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_SELECT_OVERLAY_MODIFIER_H