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/paragraph.h" 22 23 constexpr uint32_t DRAGGED_TEXT_OPACITY = 0x66; 24 constexpr uint32_t DRAGGED_TEXT_TRANSPARENCY = 0x40; 25 26 namespace OHOS::Ace::NG { 27 28 // inherited by TextPattern and TextFieldPattern 29 // Text Drag polymorphism 30 class TextDragBase : public virtual AceType { 31 DECLARE_ACE_TYPE(TextDragBase, AceType); 32 33 public: 34 TextDragBase() = default; 35 ~TextDragBase() override = default; 36 37 virtual bool IsTextArea() const = 0; 38 39 virtual const RectF& GetTextRect() = 0; 40 virtual RectF GetTextContentRect(bool isActualText = false) const = 0; 41 virtual float GetLineHeight() const = 0; 42 43 virtual std::vector<RectF> GetTextBoxes() = 0; 44 virtual OffsetF GetParentGlobalOffset() const = 0; 45 46 virtual const RefPtr<FrameNode>& MoveDragNode() = 0; 47 48 virtual const RefPtr<Paragraph>& GetDragParagraph() const = 0; 49 50 virtual void CloseSelectOverlay() = 0; CloseHandleAndSelect()51 virtual void CloseHandleAndSelect() 52 { 53 CloseSelectOverlay(); 54 } 55 ShowHandles(const bool isNeedShowHandles)56 virtual void ShowHandles(const bool isNeedShowHandles) 57 { 58 ShowHandles(); 59 } 60 ShowHandles()61 virtual void ShowHandles() 62 { 63 CreateHandles(); 64 } 65 IsHandlesShow()66 virtual bool IsHandlesShow() 67 { 68 return true; 69 } 70 CreateHandles()71 virtual void CreateHandles() {}; 72 virtual bool CloseKeyboard(bool forceClose) = 0; 73 virtual OffsetF GetDragUpperLeftCoordinates() = 0; 74 InitSpanImageLayout(const std::vector<int32_t> & placeholderIndex,const std::vector<RectF> & rectsForPlaceholders,OffsetF contentOffset)75 virtual void InitSpanImageLayout(const std::vector<int32_t>& placeholderIndex, 76 const std::vector<RectF>& rectsForPlaceholders, OffsetF contentOffset) {} 77 GetContentOffset()78 virtual OffsetF GetContentOffset() 79 { 80 return OffsetF(0, 0); 81 } 82 83 ACE_DISALLOW_COPY_AND_MOVE(TextDragBase); 84 }; 85 } // namespace OHOS::Ace::NG 86 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_DRAG_TEXT_DRAG_BASE_H 87