• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
16 #ifndef INTERFACES_INNERKITS_WINDOW_MODEL_H
17 #define INTERFACES_INNERKITS_WINDOW_MODEL_H
18 
19 #include "window.h"
20 
21 namespace OHOS {
22 namespace Previewer {
23 enum class Orientation : int32_t {
24     PORTRAIT,
25     LANDSCAPE,
26     ORIENTATION_UNDEFINED,
27 };
28 
29 enum class DeviceType {
30     PHONE,
31     TV,
32     WATCH,
33     CAR,
34     TABLET,
35     TWO_IN_ONE,
36     UNKNOWN,
37 };
38 
39 enum class ColorMode : int32_t {
40     LIGHT = 0,
41     DARK,
42     COLOR_MODE_UNDEFINED,
43 };
44 
45 struct PreviewerWindowModel {
46     bool isRound = false; // shape rect(false) circle(true)
47     int32_t originWidth = 0; // or width
48     int32_t originHeight = 0; // or height
49     int32_t compressWidth = 0; // cr width
50     int32_t compressHeight = 0; // cr height
51     Orientation orientation = Orientation::PORTRAIT; // orientation
52     double density = 1.0; // dpi with calculate
53     DeviceType deviceType = DeviceType::PHONE; // device type
54     ColorMode colorMode = ColorMode::LIGHT; // color mode
55 };
56 
57 class WINDOW_EXPORT PreviewerWindow {
58 public:
59     PreviewerWindow(const PreviewerWindow&) = delete;
60     PreviewerWindow& operator=(const PreviewerWindow&) = delete;
61     ~PreviewerWindow() = default;
62 
63     static PreviewerWindow& GetInstance();
64     static Rosen::Orientation TransOrientation(Previewer::Orientation orientation);
65     void SetWindowParams(const PreviewerWindowModel& windowModel);
66     PreviewerWindowModel& GetWindowParams();
67 
68     void SetWindowObject(const Rosen::Window* window);
69     Rosen::Window* GetWindowObject();
70 
71 private:
72     PreviewerWindow();
73     PreviewerWindowModel windowModel_;
74     Rosen::Window* window_ = nullptr;
75 };
76 } // namespace Previewer
77 } // namespace OHOS
78 #endif // INTERFACES_INNERKITS_WINDOW_MODEL_H
79