• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 MAGNIFICATION_MENU_H
17 #define MAGNIFICATION_MENU_H
18 
19 #include "hilog_wrapper.h"
20 #include "wm/window.h"
21 #include "window_option.h"
22 #include <ui/rs_canvas_node.h>
23 #include <ui/rs_surface_node.h>
24 #include <transaction/rs_transaction.h>
25 #include "ui/rs_ui_context.h"
26 #include "ui/rs_ui_director.h"
27 #include "ui/rs_root_node.h"
28 #include "recording/recording_canvas.h"
29 #include "image_source.h"
30 #include "pixel_map.h"
31 #include "magnification_def.h"
32 #include "display_manager.h"
33 #include "ext_utils.h"
34 
35 namespace OHOS {
36 namespace Accessibility {
37 
38 class MagnificationMenu {
39 public:
40     // magnification menu
41     void ShowMenuWindow(uint32_t mode);
42     void DisableMenuWindow();
43     bool IsTapOnMenu(int32_t posX, int32_t posY);
44     void MoveMenuWindow(int32_t deltaX, int32_t deltaY);
45     void SetCurrentType(uint32_t type);
46     void AttachToEdge();
47     void RefreshWindowParam();
48     uint32_t ChangeMode();
49     bool IsMenuShown();
50 
51 private:
52     void GetWindowParam();
53     void CreateMenuWindow();
54     void LoadMenuBgImage(uint32_t mode);
55     void AdjustMenuPosition();
56     void FlushImplicitTransaction();
57     std::shared_ptr<Media::PixelMap> DecodePixelMap(const std::string& pathName,
58         const Media::AllocatorType& allocatorType);
59     //menu window
60     sptr<Rosen::Window> menuWindow_ = nullptr;
61     std::shared_ptr<Rosen::RSSurfaceNode> surfaceNode_ = nullptr;
62     std::shared_ptr<Rosen::RSCanvasNode> canvasNode_ = nullptr;
63     std::shared_ptr<Rosen::RSUIContext> rsUIContext_ = nullptr;
64     Media::AllocatorType allocatorType_ = Media::AllocatorType::DMA_ALLOC;
65     std::shared_ptr<Media::PixelMap> bgpixelmap_ = nullptr;
66     std::shared_ptr<Rosen::RSImage> rosenImage_ = nullptr;
67 
68     Rosen::Rect menuRect_ = {0, 0, 0, 0};
69     Rosen::Rect screenRect_ = {0, 0, 0, 0};
70 
71     uint32_t menuSize_ = 150;
72     int32_t margin_ = 50;
73     uint64_t screenId_ = 0;
74     uint32_t screenWidth_ = 0;
75     uint32_t screenHeight_ = 0;
76 
77     uint32_t menuMode_ = 0;
78     uint32_t currentType_ = 0;
79     bool isMenuShown_ = false;
80 };
81 
82 } // namespace Accessibility
83 } // namespace OHOS
84 #endif // MAGNIFICATION_MENU_H