• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, uint32_t selectedUrlColor);
49     void ClearSelectedForegroundColorAndRects();
SetIsClip(bool isClip)50     void SetIsClip(bool isClip)
51     {
52         CHECK_NULL_VOID(isClip_);
53         isClip_->Set(isClip);
54     }
55 
56     void SetShowSelect(bool value);
57 
58     std::vector<RectF> GetSelectedRects() const;
59 protected:
60     std::optional<RectF> contentRect_;
61     RefPtr<PropertyBool> showSelect_;
62 
63 private:
64     bool IsSelectedRectsChanged(const std::vector<RectF>& selectedRects);
65 
66     RefPtr<PropertyOffsetF> paintOffset_;
67     RefPtr<PropertyInt> cursorColor_;
68     RefPtr<PropertyInt> selectedColor_;
69     RefPtr<PropertyBool> changeSelectedRects_;
70     RefPtr<PropertyBool> isClip_;;
71     std::vector<RectF> selectedRects_;
72     std::vector<RectF> selectedUrlRects_;
73     RefPtr<PropertyInt> selectedUrlColor_;
74     ACE_DISALLOW_COPY_AND_MOVE(TextOverlayModifier);
75 };
76 } // namespace OHOS::Ace::NG
77 
78 #endif