1 /* 2 * Copyright (c) 2024 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_FIELD_PATTERN_MAGNIFIER_CONTROLLER_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_FIELD_PATTERN_MAGNIFIER_CONTROLLER_H 18 19 #include "base/geometry/ng/offset_t.h" 20 #include "base/geometry/ng/size_t.h" 21 #include "base/image/pixel_map.h" 22 #include "base/memory/ace_type.h" 23 #include "base/memory/referenced.h" 24 #include "core/components_ng/pattern/pattern.h" 25 #include "core/components_ng/render/drawing.h" 26 #include "frameworks/base/memory/referenced.h" 27 28 namespace OHOS::Ace::NG { 29 struct MagnifierRect { 30 bool isChildNode = false; 31 int32_t childNodeId = 0; 32 float startX = 0.0f; 33 float startY = 0.0f; 34 float endX = 0.0f; 35 float endY = 0.0f; 36 OffsetF localOffset; 37 OffsetF cursorOffset; 38 SizeF contentSize; 39 OffsetF contentOffset; 40 RefPtr<PixelMap> pixelMap = nullptr; 41 WeakPtr<Pattern> parent = nullptr; 42 }; 43 44 class MagnifierController : public virtual AceType { 45 DECLARE_ACE_TYPE(MagnifierController, AceType); 46 47 public: MagnifierController(const WeakPtr<Pattern> & pattern)48 explicit MagnifierController(const WeakPtr<Pattern>& pattern) : pattern_(pattern) {} 49 ~MagnifierController() override = default; 50 51 void OpenMagnifier(); 52 void CloseMagnifier(); 53 54 private: 55 void CreateMagnifierChildNode(); 56 void SetMagnifierRect(const RefPtr<Pattern>& childPattern); 57 58 WeakPtr<Pattern> pattern_; 59 RefPtr<FrameNode> magnifierFrameNode_ = nullptr; 60 }; 61 } // namespace OHOS::Ace::NG 62 63 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_TEXT_FIELD_PATTERN_MAGNIFIER_CONTROLLER_H 64