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_SELECT_OVERLAY_PAINT_METHOD_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SELECT_OVERLAY_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 { 31 DECLARE_ACE_TYPE(SelectOverlayPaintMethod, NodePaintMethod); 32 public: SelectOverlayPaintMethod(const RefPtr<SelectOverlayModifier> & selectOverlayModifier,const RefPtr<SelectOverlayContentModifier> & selectOverlayContentModifier,SelectOverlayInfo info,const OffsetF & endOffset,float selectMenuHeight,bool hasExtensionMenu,bool hasShowAnimation,bool isCreated,bool isHiddenHandle,const OffsetF & startOffset,bool isReverse,const WeakPtr<Pattern> & pattern)33 SelectOverlayPaintMethod(const RefPtr<SelectOverlayModifier>& selectOverlayModifier, 34 const RefPtr<SelectOverlayContentModifier>& selectOverlayContentModifier, SelectOverlayInfo info, 35 const OffsetF& endOffset, float selectMenuHeight, bool hasExtensionMenu, bool hasShowAnimation, bool isCreated, 36 bool isHiddenHandle, const OffsetF& startOffset, bool isReverse, const WeakPtr<Pattern>& pattern) 37 : selectOverlayModifier_(selectOverlayModifier), selectOverlayContentModifier_(selectOverlayContentModifier), 38 info_(std::move(info)), defaultMenuEndOffset_(endOffset), selectMenuHeight_(selectMenuHeight), 39 hasExtensionMenu_(hasExtensionMenu), hasShowAnimation_(hasShowAnimation), isCreated_(isCreated), 40 isHiddenHandle_(isHiddenHandle), defaultMenuStartOffset_(startOffset), isReversePaint_(isReverse), 41 pattern_(pattern) 42 {} 43 ~SelectOverlayPaintMethod() override = default; 44 GetOverlayModifier(PaintWrapper * paintWrapper)45 RefPtr<Modifier> GetOverlayModifier(PaintWrapper* paintWrapper) override 46 { 47 CHECK_NULL_RETURN(selectOverlayModifier_, nullptr); 48 // custom menu do not need to draw the overlay icon of default system menu 49 if (info_.menuInfo.menuBuilder) { 50 return nullptr; 51 } 52 return selectOverlayModifier_; 53 } 54 GetContentModifier(PaintWrapper * paintWrapper)55 RefPtr<Modifier> GetContentModifier(PaintWrapper* paintWrapper) override 56 { 57 CHECK_NULL_RETURN(selectOverlayContentModifier_, nullptr); 58 return selectOverlayContentModifier_; 59 } 60 61 void UpdateOverlayModifier(PaintWrapper* paintWrapper) override; 62 63 void UpdateContentModifier(PaintWrapper* paintWrapper) override; 64 65 private: 66 void CheckCirclesAndBackArrowIsShown(); 67 68 void CheckHasExtensionMenu(); 69 70 void CheckHandleIsShown(); 71 72 bool IsModeSwitchComplete() const; 73 74 RefPtr<SelectOverlayModifier> selectOverlayModifier_; 75 76 RefPtr<SelectOverlayContentModifier> selectOverlayContentModifier_; 77 78 SelectOverlayInfo info_; 79 80 OffsetF defaultMenuEndOffset_; 81 82 float selectMenuHeight_ = 0.0f; 83 84 bool hasExtensionMenu_ = false; 85 86 bool hasShowAnimation_ = false; 87 88 bool isCreated_ = false; 89 90 bool handleIsShown_ = false; 91 92 bool circlesAndBackArrowIsShown_ = false; 93 bool isHiddenHandle_ = false; 94 95 OffsetF defaultMenuStartOffset_; 96 97 bool isReversePaint_ = false; 98 WeakPtr<Pattern> pattern_; 99 100 ACE_DISALLOW_COPY_AND_MOVE(SelectOverlayPaintMethod); 101 }; 102 103 } // namespace OHOS::Ace::NG 104 105 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SELECT_OVERLAY_PAINT_METHOD_H