• 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_RICH_EDITOR_RICH_EDITOR_OVERLAY_MODIFIER_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_RICH_EDITOR_RICH_EDITOR_OVERLAY_MODIFIER_H
18 
19 #include "core/components/common/properties/color.h"
20 #include "core/components_ng/pattern/scroll/inner/scroll_bar_overlay_modifier.h"
21 #include "core/components_ng/pattern/scroll/scroll_edge_effect.h"
22 #include "core/components_ng/pattern/text/text_overlay_modifier.h"
23 #include "core/components_ng/pattern/text_field/text_field_model.h"
24 
25 namespace OHOS::Ace::NG {
26 class RichEditorOverlayModifier : public TextOverlayModifier {
27     DECLARE_ACE_TYPE(RichEditorOverlayModifier, TextOverlayModifier);
28 
29 public:
30     RichEditorOverlayModifier(const WeakPtr<OHOS::Ace::NG::Pattern>& pattern,
31         const WeakPtr<ScrollBarOverlayModifier>& scrollbarOverlayModifier, WeakPtr<ScrollEdgeEffect>&& edgeEffect);
32     void SetCaretOffsetAndHeight(const OffsetF& cursorOffset, float height);
33     void SetFloatingCaretOffset(const OffsetF& cursorOffset);
34     void SetCaretColor(uint32_t caretColor);
35     void SetOriginCaretColor(uint32_t caretColor);
36     void SetCaretWidth(float width);
37     void SetCaretVisible(bool value);
38     void SetOriginCaretVisible(bool value);
39     void SetFloatingCaretVisible(bool value);
40     void SetFloatCaretLanding(bool caretLanding);
41     void SetScrollOffset(float value);
42     void SetScrollBarOpacityType(int32_t type);
43     void SetTextHeight(float value);
44     void SetFrameSize(const SizeF& value);
45     void SetPreviewTextDecorationColor(const Color& value);
46     void SetPreviewTextUnderlineWidth(float value);
47     void SetShowPreviewTextDecoration(bool value);
48     void SetPreviewTextStyle(const PreviewTextStyle& value);
49     float GetCaretHeight() const;
50     float GetCaretWidth() const;
51     OffsetF GetCaretOffset() const;
52     bool GetFloatCaretLanding() const;
53     void onDraw(DrawingContext& drawingContext) override;
54     void UpdateScrollBar(PaintWrapper* paintWrapper);
55     void StartFloatingCaretLand(const OffsetF& originCaretOffset);
56 private:
57     void PaintPreviewTextDecoration(DrawingContext& drawingContext) const;
58     void PaintCaret(DrawingContext& drawingContext) const;
59     void PaintFloatingCaret(DrawingContext& drawingContext) const;
60     void PaintScrollBar(DrawingContext& context);
61     void PaintEdgeEffect(const SizeF& frameSize, RSCanvas& canvas);
62 
63     RefPtr<PropertyBool> caretVisible_;
64     RefPtr<PropertyBool> originCaretVisible_;
65     RefPtr<PropertyBool> floatingCaretVisible_;
66     RefPtr<PropertyOffsetF> caretOffset_;
67     RefPtr<AnimatablePropertyOffsetF> floatingCaretOffset_;
68     RefPtr<PropertyFloat> caretHeight_;
69     RefPtr<PropertyFloat> caretWidth_;
70     RefPtr<PropertyInt> caretColor_;
71     RefPtr<PropertyInt> originCaretColor_;
72     RefPtr<PropertyFloat> scrollOffset_;
73     RefPtr<PropertyInt> scrollBarOpacityType_;
74     RefPtr<PropertyFloat> textHeight_;
75     WeakPtr<Pattern> pattern_;
76     WeakPtr<ScrollEdgeEffect> edgeEffect_;
77     WeakPtr<ScrollBarOverlayModifier> scrollBarOverlayModifier_;
78     RefPtr<PropertySizeF> frameSize_;
79     RefPtr<PropertyColor> previewTextDecorationColor_;
80     RefPtr<PropertyFloat> previewTextUnderlineWidth_;
81     RefPtr<PropertyBool> showPreviewTextDecoration_;
82     PreviewTextStyle previewTextStyle_;
83     bool caretLanding_ = false;
84     ACE_DISALLOW_COPY_AND_MOVE(RichEditorOverlayModifier);
85 };
86 } // namespace OHOS::Ace::NG
87 #endif
88