• 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 SetSelectedColor(uint32_t selectedColor);
39 
40     void SetSelectedRects(const std::vector<RectF>& 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     void SetShowSelect(bool value);
54 
55     std::vector<RectF> GetSelectedRects() const;
56 protected:
57     std::optional<RectF> contentRect_;
58     RefPtr<PropertyBool> showSelect_;
59 
60 private:
61     bool IsSelectedRectsChanged(const std::vector<RectF>& selectedRects);
62 
63     RefPtr<PropertyOffsetF> paintOffset_;
64     RefPtr<PropertyInt> selectedColor_;
65     RefPtr<PropertyBool> changeSelectedRects_;
66     RefPtr<PropertyBool> isClip_;;
67     std::vector<RectF> selectedRects_;
68 
69     ACE_DISALLOW_COPY_AND_MOVE(TextOverlayModifier);
70 };
71 } // namespace OHOS::Ace::NG
72 
73 #endif