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