1 /*
2 * Copyright (c) 2023 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_DISPLAY_INFO_H
16 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_DISPLAY_INFO_H
17
18 #include "base/geometry/rect.h"
19 #include "base/memory/ace_type.h"
20
21 namespace OHOS::Ace {
22 /**
23 * souce is Rosen::FoldDisplayMode
24 */
25 enum class FoldDisplayMode: uint32_t {
26 UNKNOWN = 0,
27 FULL = 1, // EXPAND
28 MAIN = 2, // FOLDED
29 SUB = 3,
30 COORDINATION = 4,
31 };
32
33 /**
34 * souce is Rosen::FoldStatus
35 */
36 enum class FoldStatus : uint32_t {
37 UNKNOWN = 0,
38 EXPAND = 1,
39 FOLDED = 2,
40 HALF_FOLD = 3,
41 };
42
43 /**
44 * souce is Rosen::Rotation
45 */
46 enum class Rotation : uint32_t {
47 ROTATION_0,
48 ROTATION_90,
49 ROTATION_180,
50 ROTATION_270,
51 };
52
53 /**
54 * source is Rosen::DisplayOrientation
55 */
56 enum class DisplayOrientation : uint32_t {
57 PORTRAIT = 0,
58 LANDSCAPE,
59 PORTRAIT_INVERTED,
60 LANDSCAPE_INVERTED,
61 };
62
IsValidDisplayOrientation(DisplayOrientation ori)63 inline bool IsValidDisplayOrientation(DisplayOrientation ori)
64 {
65 return static_cast<int32_t>(DisplayOrientation::PORTRAIT) <= static_cast<int32_t>(ori) &&
66 static_cast<int32_t>(DisplayOrientation::LANDSCAPE_INVERTED) >= static_cast<int32_t>(ori);
67 }
68
69 /**
70 * souce is Rosen::WindowStatus
71 */
72 enum class WindowStatus : uint32_t {
73 WINDOW_STATUS_UNDEFINED = 0,
74 WINDOW_STATUS_FULLSCREEN = 1,
75 WINDOW_STATUS_MAXMIZE,
76 WINDOW_STATUS_MINIMIZE,
77 WINDOW_STATUS_FLOATING,
78 WINDOW_STATUS_SPLITSCREEN
79 };
80
81 class ACE_EXPORT DisplayInfo : public AceType {
82 DECLARE_ACE_TYPE(DisplayInfo, AceType);
83
84 public:
85 DisplayInfo() = default;
86 ~DisplayInfo() override = default;
87
GetIsFoldable()88 bool GetIsFoldable()
89 {
90 return isFoldable_;
91 }
92
SetIsFoldable(bool isFoldable)93 void SetIsFoldable(bool isFoldable)
94 {
95 isFoldable_ = isFoldable;
96 }
97
GetFoldStatus()98 FoldStatus GetFoldStatus()
99 {
100 return foldStatus_;
101 }
102
SetFoldStatus(FoldStatus foldStatus)103 void SetFoldStatus(FoldStatus foldStatus)
104 {
105 foldStatus_ = foldStatus;
106 }
107
GetRotation()108 Rotation GetRotation()
109 {
110 return rotation_;
111 }
112
SetRotation(Rotation rotation)113 void SetRotation(Rotation rotation)
114 {
115 rotation_ = rotation;
116 }
117
GetCurrentFoldCreaseRegion()118 std::vector<Rect> GetCurrentFoldCreaseRegion()
119 {
120 return currentFoldCreaseRegion_;
121 }
122
SetCurrentFoldCreaseRegion(std::vector<Rect> currentFoldCreaseRegion)123 void SetCurrentFoldCreaseRegion(std::vector<Rect> currentFoldCreaseRegion)
124 {
125 currentFoldCreaseRegion_ = currentFoldCreaseRegion;
126 }
127
GetDisplayId()128 uint64_t GetDisplayId() const
129 {
130 return displayId_;
131 }
132
SetDisplayId(uint64_t displayId)133 void SetDisplayId(uint64_t displayId)
134 {
135 displayId_ = displayId;
136 }
137
GetWidth()138 int32_t GetWidth() const
139 {
140 return width_;
141 }
142
SetWidth(int32_t width)143 void SetWidth(int32_t width)
144 {
145 width_ = width;
146 }
147
GetHeight()148 int32_t GetHeight() const
149 {
150 return height_;
151 }
152
SetHeight(int32_t height)153 void SetHeight(int32_t height)
154 {
155 height_ = height;
156 }
157
158 private:
159 FoldStatus foldStatus_ = FoldStatus::UNKNOWN;
160 bool isFoldable_ = false;
161 Rotation rotation_ = Rotation::ROTATION_0;
162 std::vector<Rect> currentFoldCreaseRegion_;
163 uint64_t displayId_ = 0;
164 int32_t width_ = 0;
165 int32_t height_ = 0;
166 };
167 } // namespace OHOS::Ace
168 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMMON_DISPLAY_INFO_H
169