1 /* 2 * Copyright (C) 2022 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 ACCESSIBILITY_ZOOM_PROXY_H 17 #define ACCESSIBILITY_ZOOM_PROXY_H 18 19 #include <vector> 20 #include "refbase.h" 21 22 namespace OHOS { 23 namespace Accessibility { 24 /** 25 * @brief Magnification callback function, including zone change, rotation, user change. 26 * 27 * @since 1.0 28 * @version 1.0 29 */ 30 class AccessibilityDisplayResizeListener { 31 public: 32 /** 33 * @brief 34 */ AccessibilityDisplayResizeListener()35 AccessibilityDisplayResizeListener() {} 36 37 /** 38 * @brief 39 */ ~AccessibilityDisplayResizeListener()40 virtual ~AccessibilityDisplayResizeListener() {} 41 42 /** 43 * @brief Callback function when zone change. 44 * 45 * @param aams AccessibilityAbilityManagerServicethe reference. 46 * @since 1.0 47 * @version 1.0 48 */ OnDisplayResized(Rect & outRegion)49 virtual void OnDisplayResized(Rect &outRegion) {} 50 51 /** 52 * @brief Callback function when rotation. 53 * 54 * @since 1.0 55 * @version 1.0 56 */ OnRotationChanged()57 virtual void OnRotationChanged() {} 58 59 /** 60 * @brief Callback function when user changed. 61 * 62 * @since 1.0 63 * @version 1.0 64 */ OnUserContextChanged()65 virtual void OnUserContextChanged() {} 66 }; 67 68 class AccessibilityZoomProxy : public RefBase { 69 public: 70 /** 71 * @brief AccessibilityZoomProxy instance. 72 * 73 * @since 1.0 74 * @version 1.0 75 */ GetInstance()76 static AccessibilityZoomProxy &GetInstance() 77 { 78 static AccessibilityZoomProxy instance_; 79 return instance_; 80 } 81 82 /** 83 * @brief A constructor used to create a magnification controller instance. 84 * 85 * @since 1.0 86 * @version 1.0 87 */ AccessibilityZoomProxy()88 AccessibilityZoomProxy() {} 89 90 /** 91 * @brief A destructor used to delete the magnification controller instance. 92 * 93 * @since 1.0 94 * @version 1.0 95 */ ~AccessibilityZoomProxy()96 virtual ~AccessibilityZoomProxy() {} 97 98 /** 99 * @brief Register the listener of magnification. 100 * 101 * @param listener Reference to the magnification listener. 102 * @since 1.0 103 * @version 1.0 104 */ AddListener(AccessibilityDisplayResizeListener & listener)105 void AddListener(AccessibilityDisplayResizeListener &listener) {} 106 107 /** 108 * @brief Unregister the listener of magnification. 109 * 110 * @param listener Reference to the magnification listener. 111 * @since 1.0 112 * @version 1.0 113 */ DeleteListener(AccessibilityDisplayResizeListener & listener)114 void DeleteListener(AccessibilityDisplayResizeListener &listener) {} 115 Register(int displayId)116 void Register(int displayId) {} 117 Unregister(int displayId)118 void Unregister(int displayId) {} 119 IsRegistered(int displayId)120 bool IsRegistered(int displayId) 121 { 122 return false; 123 } 124 IsRunning(int displayId)125 bool IsRunning(int displayId) 126 { 127 return false; 128 } 129 130 /** 131 * @brief Gets the scale. 132 * 133 * @param displayId The logical display id. 134 * @return Returns scale value. 135 * @since 1.0 136 * @version 1.0 137 */ GetScale(int displayId)138 float GetScale(int displayId) 139 { 140 return 0.0; 141 } 142 143 /** 144 * @brief Gets the screen-relative X coordinate that is centered. 145 * 146 * @param displayId The logical display id. 147 * @return Returns the X coordinate of focus. 148 * @since 1.0 149 * @version 1.0 150 */ GetCenterX(int displayId)151 float GetCenterX(int displayId) 152 { 153 return 0.0; 154 } 155 156 /** 157 * @brief Gets the screen-relative Y coordinate that is centered. 158 * 159 * @param displayId The logical display id. 160 * @return Returns the Y coordinate of focus. 161 * @since 1.0 162 * @version 1.0 163 */ GetCenterY(int displayId)164 float GetCenterY(int displayId) 165 { 166 return 0.0; 167 } 168 169 /** 170 * @brief Gets the current magnification area. 171 * 172 * @param displayId The logical display id. 173 * @return Returns the region of magnification. 174 * @since 1.0 175 * @version 1.0 176 */ GetDisplayResizeRect(int displayId)177 Rect GetDisplayResizeRect(int displayId) 178 { 179 Rect rc {}; 180 return rc; 181 } 182 183 /** 184 * @brief Reset magnification. 185 * 186 * @param displayId The logical display id. 187 * @return Returns the region of . 188 * @since 1.0 189 * @version 1.0 190 */ Reset(int displayId)191 bool Reset(int displayId) 192 { 193 return false; 194 } 195 196 /** 197 * @brief Set the magnification center and scale. 198 * 199 * @param displayId The logical display id. 200 * @param scale the target scale. 201 * @param centerX The screen-relative X coordinate that is centered and scaled. 202 * @param centerY The screen-relative Y coordinate that is centered and scaled. 203 * @since 1.0 204 * @version 1.0 205 */ SetScaleAndCenter(int displayId,float scale,float centerX,float centerY)206 bool SetScaleAndCenter(int displayId, float scale, float centerX, float centerY) 207 { 208 return false; 209 } 210 211 private: 212 std::vector<AccessibilityDisplayResizeListener> mListeners_; 213 214 /** 215 * @brief Set the magnification scale. 216 * 217 * @param displayId The logical display id. 218 * @param scale the target scale. 219 * @return Returns the region of . 220 * @since 1.0 221 * @version 1.0 222 */ SetScale(int displayId,float scale,float pivotX,float pivotY,bool animate,int id)223 bool SetScale(int displayId, float scale, float pivotX, float pivotY, bool animate, int id) 224 { 225 return false; 226 } 227 228 /** 229 * @brief Set the magnification center. 230 * 231 * @param displayId The logical display id. 232 * @param centerX The screen-relative X coordinate that is centered and scaled. 233 * @param centerY The screen-relative Y coordinate that is centered and scaled. 234 * @since 1.0 235 * @version 1.0 236 */ SetCenter(int displayId,float centerX,float centerY,bool animate,int id)237 bool SetCenter(int displayId, float centerX, float centerY, bool animate, int id) 238 { 239 return false; 240 } 241 242 /** 243 * @brief Set the magnifying offset. 244 * 245 * @param displayId corresponds to one screen. 246 * @param offsetX Offset the distance in the X direction, in current 247 * screen pixels. 248 * @param offsetY Offset the distance in the Y direction, in current 249 * screen pixels. 250 * @since 1.0 251 * @version 1.0 252 */ SetDisplayResizeOffset(int displayId,float offsetX,float offsetY)253 void SetDisplayResizeOffset(int displayId, float offsetX, float offsetY) {} 254 }; 255 } // namespace Accessibility 256 } // namespace OHOS 257 #endif // ACCESSIBILITY_ZOOM_PROXY_H 258