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 16 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_TEXT_OVERLAY_MODIFIER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_TEXT_TEXT_OVERLAY_MODIFIER_H 18 19 #include <optional> 20 #include <vector> 21 22 #include "base/memory/ace_type.h" 23 #include "core/components_ng/base/modifier.h" 24 25 namespace OHOS::Ace::NG { 26 class Pattern; 27 28 class TextOverlayModifier : public OverlayModifier { 29 DECLARE_ACE_TYPE(TextOverlayModifier, OverlayModifier) 30 31 public: 32 TextOverlayModifier(); 33 34 void onDraw(DrawingContext& drawingContext) override; 35 36 void SetPrintOffset(const OffsetF& paintOffset); 37 38 void SetSelectedColor(uint32_t selectedColor); 39 40 void SetSelectedRects(const std::vector<Rect>& selectedRects); 41 SetContentRect(const RectF & contentRect)42 void SetContentRect(const RectF& contentRect) 43 { 44 contentRect_ = contentRect; 45 } 46 SetIsClip(bool isClip)47 void SetIsClip(bool isClip) 48 { 49 CHECK_NULL_VOID(isClip_); 50 isClip_->Set(isClip); 51 } 52 53 protected: 54 std::optional<RectF> contentRect_; 55 56 private: 57 bool IsSelectedRectsChanged(const std::vector<Rect>& selectedRects); 58 59 RefPtr<PropertyOffsetF> paintOffset_; 60 RefPtr<PropertyInt> selectedColor_; 61 RefPtr<PropertyBool> changeSelectedRects_; 62 RefPtr<PropertyBool> isClip_;; 63 std::vector<Rect> selectedRects_; 64 65 ACE_DISALLOW_COPY_AND_MOVE(TextOverlayModifier); 66 }; 67 } // namespace OHOS::Ace::NG 68 69 #endif