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 SetCursorColor(uint32_t cursorColor); 39 40 void SetSelectedColor(uint32_t selectedColor); 41 42 void SetSelectedRects(const std::vector<RectF>& selectedRects); 43 SetContentRect(const RectF & contentRect)44 void SetContentRect(const RectF& contentRect) 45 { 46 contentRect_ = contentRect; 47 } 48 void SetSelectedForegroundColorAndRects(const std::vector<RectF>& selectedUrlRects, 49 uint32_t selectedUrlColor); 50 void ClearSelectedForegroundColorAndRects(); SetIsClip(bool isClip)51 void SetIsClip(bool isClip) 52 { 53 CHECK_NULL_VOID(isClip_); 54 isClip_->Set(isClip); 55 } 56 57 void SetShowSelect(bool value); 58 59 std::vector<RectF> GetSelectedRects() const; 60 protected: 61 std::optional<RectF> contentRect_; 62 RefPtr<PropertyBool> showSelect_; 63 64 private: 65 bool IsSelectedRectsChanged(const std::vector<RectF>& selectedRects); 66 67 RefPtr<PropertyOffsetF> paintOffset_; 68 RefPtr<PropertyInt> cursorColor_; 69 RefPtr<PropertyInt> selectedColor_; 70 RefPtr<PropertyBool> changeSelectedRects_; 71 RefPtr<PropertyBool> isClip_;; 72 std::vector<RectF> selectedRects_; 73 std::vector<RectF> selectedUrlRects_; 74 RefPtr<PropertyInt> selectedUrlColor_; 75 ACE_DISALLOW_COPY_AND_MOVE(TextOverlayModifier); 76 }; 77 } // namespace OHOS::Ace::NG 78 79 #endif