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 SetCaretColor(uint32_t caretColor); 34 void SetSelectedBackgroundColor(uint32_t selectedBackgroundColor); 35 void SetCaretWidth(float width); 36 void SetCaretVisible(bool value); 37 void SetScrollOffset(float value); 38 void SetScrollBarOpacityType(int32_t type); 39 void SetTextHeight(float value); 40 void SetFrameSize(const SizeF& value); 41 void SetPreviewTextDecorationColor(const Color& value); 42 void SetPreviewTextUnderlineWidth(float value); 43 void SetShowPreviewTextDecoration(bool value); 44 void SetPreviewTextStyle(const PreviewTextStyle& value); 45 float GetCaretHeight() const; 46 float GetCaretWidth() const; 47 OffsetF GetCaretOffset() const; 48 void onDraw(DrawingContext& drawingContext) override; 49 void UpdateScrollBar(PaintWrapper* paintWrapper); 50 private: 51 void PaintPreviewTextDecoration(DrawingContext& drawingContext) const; 52 void PaintCaret(DrawingContext& drawingContext) const; 53 void PaintScrollBar(DrawingContext& context); 54 void PaintEdgeEffect(const SizeF& frameSize, RSCanvas& canvas); 55 56 RefPtr<PropertyBool> caretVisible_; 57 RefPtr<PropertyOffsetF> caretOffset_; 58 RefPtr<PropertyFloat> caretHeight_; 59 RefPtr<PropertyFloat> caretWidth_; 60 RefPtr<PropertyInt> caretColor_; 61 RefPtr<PropertyInt> selectedBackgroundColor_; 62 RefPtr<PropertyFloat> scrollOffset_; 63 RefPtr<PropertyInt> scrollBarOpacityType_; 64 RefPtr<PropertyFloat> textHeight_; 65 WeakPtr<Pattern> pattern_; 66 WeakPtr<ScrollEdgeEffect> edgeEffect_; 67 WeakPtr<ScrollBarOverlayModifier> scrollBarOverlayModifier_; 68 RefPtr<PropertySizeF> frameSize_; 69 RefPtr<PropertyColor> previewTextDecorationColor_; 70 RefPtr<PropertyFloat> previewTextUnderlineWidth_; 71 RefPtr<PropertyBool> showPreviewTextDecoration_; 72 PreviewTextStyle previewTextStyle_; 73 ACE_DISALLOW_COPY_AND_MOVE(RichEditorOverlayModifier); 74 }; 75 } // namespace OHOS::Ace::NG 76 #endif 77