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 24 namespace OHOS::Ace::NG { 25 class RichEditorOverlayModifier : public TextOverlayModifier { 26 DECLARE_ACE_TYPE(RichEditorOverlayModifier, TextOverlayModifier) 27 28 public: 29 RichEditorOverlayModifier(const WeakPtr<OHOS::Ace::NG::Pattern>& pattern, 30 const WeakPtr<ScrollBarOverlayModifier>& scrollbarOverlayModifier, WeakPtr<ScrollEdgeEffect>&& edgeEffect); 31 void SetCaretOffsetAndHeight(const OffsetF& cursorOffset, float height); 32 void SetCaretColor(uint32_t caretColor); 33 void SetCaretWidth(float width); 34 void SetCaretVisible(bool value); 35 void SetScrollOffset(float value); 36 void SetScrollBarOpacityType(int32_t type); 37 void SetTextHeight(float value); 38 void SetFrameSize(const SizeF& value); 39 float GetCaretHeight() const; 40 float GetCaretWidth() const; 41 OffsetF GetCaretOffset() const; 42 void onDraw(DrawingContext& drawingContext) override; 43 void UpdateScrollBar(PaintWrapper* paintWrapper); 44 private: 45 void PaintCaret(DrawingContext& drawingContext) const; 46 void PaintScrollBar(DrawingContext& context); 47 void PaintEdgeEffect(const SizeF& frameSize, RSCanvas& canvas); 48 49 RefPtr<PropertyBool> caretVisible_; 50 RefPtr<PropertyOffsetF> caretOffset_; 51 RefPtr<PropertyFloat> caretHeight_; 52 RefPtr<PropertyFloat> caretWidth_; 53 RefPtr<PropertyInt> caretColor_; 54 RefPtr<PropertyFloat> scrollOffset_; 55 RefPtr<PropertyInt> scrollBarOpacityType_; 56 RefPtr<PropertyFloat> textHeight_; 57 WeakPtr<Pattern> pattern_; 58 WeakPtr<ScrollEdgeEffect> edgeEffect_; 59 WeakPtr<ScrollBarOverlayModifier> scrollBarOverlayModifier_; 60 RefPtr<PropertySizeF> frameSize_; 61 ACE_DISALLOW_COPY_AND_MOVE(RichEditorOverlayModifier); 62 }; 63 } // namespace OHOS::Ace::NG 64 #endif 65