• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-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 OHOS_ROSEN_WINDOW_OPTION_H
17 #define OHOS_ROSEN_WINDOW_OPTION_H
18 #include <refbase.h>
19 #include <string>
20 #include <unordered_map>
21 
22 #include "../dm/dm_common.h"
23 #include "wm_common.h"
24 
25 namespace OHOS {
26 namespace Rosen {
27 class WindowOption : public RefBase {
28 public:
29     WindowOption();
30     virtual ~WindowOption() = default;
31 
32     void SetWindowRect(const struct Rect& rect);
33     void SetWindowType(WindowType type);
34     void SetWindowMode(WindowMode mode);
35     void SetFocusable(bool isFocusable);
36     void SetTouchable(bool isTouchable);
37     void SetDisplayId(DisplayId displayId);
38     void SetParentId(uint32_t parentId);
39     void SetWindowName(const std::string& windowName);
40     void AddWindowFlag(WindowFlag flag);
41     void RemoveWindowFlag(WindowFlag flag);
42     void SetWindowFlags(uint32_t flags);
43     void SetSystemBarProperty(WindowType type, const SystemBarProperty& property);
44     void SetHitOffset(int32_t x, int32_t y);
45     void SetWindowTag(WindowTag windowTag);
46     void SetKeepScreenOn(bool keepScreenOn);
47     bool IsKeepScreenOn() const;
48     void SetTurnScreenOn(bool turnScreenOn);
49     bool IsTurnScreenOn() const;
50     void SetBrightness(float brightness);
51     void SetRequestedOrientation(Orientation orientation);
52     void SetCallingWindow(uint32_t windowId);
53     void SetMainHandlerAvailable(bool isMainHandlerAvailable);
54 
55     Rect GetWindowRect() const;
56     WindowType GetWindowType() const;
57     WindowMode GetWindowMode() const;
58     bool GetFocusable() const;
59     bool GetTouchable() const;
60     DisplayId GetDisplayId() const;
61     uint32_t GetParentId() const;
62     const std::string& GetWindowName() const;
63     uint32_t GetWindowFlags() const;
64     const std::unordered_map<WindowType, SystemBarProperty>& GetSystemBarProperty() const;
65     const PointInfo& GetHitOffset() const;
66     WindowTag GetWindowTag() const;
67     float GetBrightness() const;
68     Orientation GetRequestedOrientation() const;
69     uint32_t GetCallingWindow() const;
70     bool GetMainHandlerAvailable() const;
71 
72 private:
73     Rect windowRect_ { 0, 0, 0, 0 };
74     WindowType type_ { WindowType::WINDOW_TYPE_APP_MAIN_WINDOW };
75     WindowMode mode_ { WindowMode::WINDOW_MODE_UNDEFINED };
76     bool focusable_ { true };
77     bool touchable_ { true };
78     DisplayId displayId_ { 0 };
79     uint32_t parentId_ = INVALID_WINDOW_ID;
80     std::string windowName_ { "" };
81     uint32_t flags_ { 0 };
82     PointInfo hitOffset_ { 0, 0 };
83     WindowTag windowTag_;
84     bool keepScreenOn_ = false;
85     bool turnScreenOn_ = false;
86     bool isMainHandlerAvailable_ = true;
87     float brightness_ = UNDEFINED_BRIGHTNESS;
88     uint32_t callingWindow_ = INVALID_WINDOW_ID;
89     std::unordered_map<WindowType, SystemBarProperty> sysBarPropMap_ {
90         { WindowType::WINDOW_TYPE_STATUS_BAR,     SystemBarProperty() },
91         { WindowType::WINDOW_TYPE_NAVIGATION_BAR, SystemBarProperty() },
92     };
93     Orientation requestedOrientation_ { Orientation::UNSPECIFIED };
94 };
95 } // namespace Rosen
96 } // namespace OHOS
97 #endif // OHOS_ROSEN_WINDOW_OPTION_H
98