1 /* 2 * Copyright (C) 2025-2025 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 WINDOW_MAGNIFICATION_MANAGER_H 17 #define WINDOW_MAGNIFICATION_MANAGER_H 18 19 #include "hilog_wrapper.h" 20 #include "magnification_def.h" 21 #include "ffrt.h" 22 #include "magnification_window_proxy.h" 23 24 namespace OHOS { 25 namespace Accessibility { 26 27 struct RectBound { 28 uint32_t width; 29 uint32_t height; 30 }; 31 32 class WindowMagnificationManager { 33 public: 34 WindowMagnificationManager(); 35 explicit WindowMagnificationManager(std::shared_ptr<MagnificationWindowProxy> proxy); 36 ~WindowMagnificationManager() = default; 37 38 bool IsMagnificationWindowShow(); 39 float GetScale(); 40 void EnableWindowMagnification(int32_t centerX, int32_t centerY); 41 void ShowWindowMagnification(); 42 void ShowWindowMagnificationWithPosition(PointerPos pos); 43 void DisableWindowMagnification(bool needClear = false); 44 void SetScale(float deltaSpan); 45 void MoveMagnificationWindow(int32_t deltaX, int32_t deltaY); 46 bool IsTapOnHotArea(int32_t posX, int32_t posY); 47 bool IsTapOnMagnificationWindow(int32_t posX, int32_t posY); 48 PointerPos ConvertCoordinates(int32_t posX, int32_t posY); 49 void FixSourceCenter(bool needFix); 50 void PersistScale(); 51 void RefreshWindowParam(RotationType type); 52 void FollowFocuseElement(int32_t centerX, int32_t centerY); 53 PointerPos GetSourceCenter(); 54 55 private: 56 ffrt::mutex mutex_; 57 std::shared_ptr<MagnificationWindowProxy> windowProxy_ = nullptr; 58 }; 59 } // namespace Accessibility 60 } // namespace OHOS 61 #endif // WINDOW_MAGNIFICATION_MANAGER_H