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_PATTERN_TEXT_DRAG_TEXT_DRAG_BASE_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_DRAG_TEXT_DRAG_BASE_H 18 19 #include "base/memory/ace_type.h" 20 #include "core/components_ng/manager/select_overlay/selection_host.h" 21 #include "core/components_ng/render/drawing.h" 22 #include "core/components_ng/render/paragraph.h" 23 24 constexpr uint32_t DRAGGED_TEXT_OPACITY = 0x66; 25 constexpr uint32_t DRAGGED_TEXT_TRANSPARENCY = 0x40; 26 27 namespace OHOS::Ace::NG { 28 using ParagraphT = std::variant<std::shared_ptr<RSParagraph>, RefPtr<Paragraph>>; 29 30 // inherited by TextPattern and TextFieldPattern 31 // Text Drag polymorphism 32 class TextDragBase : public virtual AceType { 33 DECLARE_ACE_TYPE(TextDragBase, AceType); 34 35 public: 36 TextDragBase() = default; 37 ~TextDragBase() override = default; 38 39 virtual bool IsTextArea() const = 0; 40 41 virtual const RectF& GetTextRect() = 0; 42 virtual const RectF& GetTextContentRect() const = 0; 43 virtual float GetLineHeight() const = 0; 44 45 virtual std::vector<RectF> GetTextBoxes() = 0; 46 virtual OffsetF GetParentGlobalOffset() const = 0; 47 48 virtual const RefPtr<FrameNode>& MoveDragNode() = 0; 49 50 virtual ParagraphT GetDragParagraph() const = 0; 51 52 virtual void CloseSelectOverlay() = 0; CloseHandleAndSelect()53 virtual void CloseHandleAndSelect() 54 { 55 CloseSelectOverlay(); 56 } CreateHandles()57 virtual void CreateHandles() {}; 58 virtual bool CloseKeyboard(bool forceClose) = 0; 59 virtual OffsetF GetDragUpperLeftCoordinates() = 0; 60 InitSpanImageLayout(const std::vector<int32_t> & placeholderIndex,const std::vector<RectF> & rectsForPlaceholders,OffsetF contentOffset)61 virtual void InitSpanImageLayout(const std::vector<int32_t>& placeholderIndex, 62 const std::vector<RectF>& rectsForPlaceholders, OffsetF contentOffset) {} 63 GetContentOffset()64 virtual OffsetF GetContentOffset() 65 { 66 return OffsetF(0, 0); 67 } 68 69 ACE_DISALLOW_COPY_AND_MOVE(TextDragBase); 70 }; 71 } // namespace OHOS::Ace::NG 72 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_DRAG_TEXT_DRAG_BASE_H 73