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_PATTERNS_IMAGE_OVERLAY_MODIFIER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_IMAGE_OVERLAY_MODIFIER_H 18 19 #include <optional> 20 #include <vector> 21 22 #include "base/geometry/ng/offset_t.h" 23 #include "base/memory/ace_type.h" 24 #include "core/components_ng/base/modifier.h" 25 26 namespace OHOS::Ace::NG { 27 28 class ImageOverlayModifier : public OverlayModifier { 29 DECLARE_ACE_TYPE(ImageOverlayModifier, OverlayModifier) 30 31 public: 32 ImageOverlayModifier(const Color& selectedColor); 33 34 void onDraw(DrawingContext& drawingContext) override; 35 SetIsSelected(bool isSelected)36 void SetIsSelected(bool isSelected) 37 { 38 CHECK_NULL_VOID(isSelected_); 39 isSelected_->Set(isSelected); 40 } 41 SetSize(const SizeF & size)42 void SetSize(const SizeF& size) 43 { 44 CHECK_NULL_VOID(size_); 45 size_->Set(size); 46 } 47 SetOffset(const OffsetF & offset)48 void SetOffset(const OffsetF& offset) 49 { 50 CHECK_NULL_VOID(offset_); 51 offset_->Set(offset); 52 } 53 54 private: 55 RefPtr<PropertyBool> isSelected_; 56 RefPtr<PropertySizeF> size_; 57 RefPtr<PropertyOffsetF> offset_; 58 const Color& selectedColor_; 59 60 ACE_DISALLOW_COPY_AND_MOVE(ImageOverlayModifier); 61 }; 62 } // namespace OHOS::Ace::NG 63 64 #endif