• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 INPUTMETHOD_IMF_PANEL_COMMON_H
17 #define INPUTMETHOD_IMF_PANEL_COMMON_H
18 
19 #include <cstdint>
20 
21 #include "wm_common.h"
22 
23 namespace OHOS {
24 namespace MiscServices {
25 struct WindowSize {
26     uint32_t width = 0;
27     uint32_t height = 0;
28 };
29 
30 struct ChangeY {
31     uint32_t portrait = 0;
32     uint32_t landscape = 0;
33 };
34 
35 struct LayoutParams {
36     Rosen::Rect landscapeRect{ 0, 0, 0, 0 };
37     Rosen::Rect portraitRect{ 0, 0, 0, 0 };
38 };
39 
40 struct HotArea {
41     std::vector<Rosen::Rect> keyboardHotArea;
42     std::vector<Rosen::Rect> panelHotArea;
ToStringHotArea43     static std::string ToString(const std::vector<Rosen::Rect> &areas)
44     {
45         std::string areasStr = "[";
46         for (const auto area : areas) {
47             areasStr.append(area.ToString());
48         }
49         areasStr.append("]");
50         return areasStr;
51     }
52 };
53 
54 struct HotAreas {
55     HotArea landscape;
56     HotArea portrait;
57     bool isSet{ false };
58 };
59 
60 struct EnhancedLayoutParam {
61     Rosen::Rect rect{ 0, 0, 0, 0 };      // rect of keyboard panel
62     Rosen::Rect panelRect{ 0, 0, 0, 0 }; // rect of system panel
63     int32_t avoidY{ 0 };
64     uint32_t avoidHeight{ 0 };
ToStringEnhancedLayoutParam65     inline std::string ToString() const
66     {
67         std::stringstream ss;
68         ss << "rect" << rect.ToString() << " avoidY " << avoidY << " avoidHeight " << avoidHeight;
69         return ss.str();
70     }
71 };
72 
73 struct EnhancedLayoutParams {
74     bool isFullScreen{ false };
75     EnhancedLayoutParam portrait;
76     EnhancedLayoutParam landscape;
77 };
78 
79 struct DisplaySize {
80     WindowSize portrait;
81     WindowSize landscape;
82 };
83 
84 struct PanelAdjustInfo {
85     int32_t top{ 0 };
86     int32_t left{ 0 };
87     int32_t right{ 0 };
88     int32_t bottom{ 0 };
89     bool operator==(const PanelAdjustInfo &panelAdjust) const
90     {
91         return (top == panelAdjust.top && left == panelAdjust.left && right == panelAdjust.right &&
92                 bottom == panelAdjust.bottom);
93     }
ToStringPanelAdjustInfo94     inline std::string ToString() const
95     {
96         std::stringstream ss;
97         ss << "[top=" << top << ", left=" << left << ", right=" << right << ", bottom=" << bottom << "]";
98         return ss.str();
99     }
100 };
101 
102 struct FullPanelAdjustInfo {
103     PanelAdjustInfo portrait;
104     PanelAdjustInfo landscape;
ToStringFullPanelAdjustInfo105     inline std::string ToString() const
106     {
107         std::stringstream ss;
108         ss << " portrait: " << portrait.ToString()
109            << ", landscape: " << landscape.ToString();
110         return ss.str();
111     }
112 };
113 } // namespace MiscServices
114 } // namespace OHOS
115 #endif //INPUTMETHOD_IMF_PANEL_COMMON_H
116