From 1499b4841e0f6d8d63729a4f821465f0a7e56d8d Mon Sep 17 00:00:00 2001 From: fupengfei001 Date: Sat, 27 May 2023 12:00:32 +0800 Subject: [PATCH 1/2] fupengfei6@huawei.com Signed-off-by: fupengfei001 --- previewer/BUILD.gn | 1 + previewer/include/window_model.h | 79 ++++++++++++++++++++++++++++++++ previewer/src/window_model.cpp | 52 +++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100644 previewer/include/window_model.h create mode 100644 previewer/src/window_model.cpp diff --git a/previewer/BUILD.gn b/previewer/BUILD.gn index ef2e21fedb..665fe85237 100644 --- a/previewer/BUILD.gn +++ b/previewer/BUILD.gn @@ -41,6 +41,7 @@ ohos_shared_library("previewer_window") { "src/window.cpp", "src/window_impl.cpp", "src/window_scene.cpp", + "src/window_model.cpp" ] include_dirs = [ diff --git a/previewer/include/window_model.h b/previewer/include/window_model.h new file mode 100644 index 0000000000..675dfb392c --- /dev/null +++ b/previewer/include/window_model.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef INTERFACES_INNERKITS_WINDOW_MODEL_H +#define INTERFACES_INNERKITS_WINDOW_MODEL_H + +#include "window_impl.h" +#include "device_type.h" +#include "device_config.h" + +namespace OHOS { +namespace Previewer { +enum class Orientation : int32_t { + PORTRAIT, + LANDSCAPE, + ORIENTATION_UNDEFINED, +}; + +enum class DeviceType { + PHONE, + TV, + WATCH, + CAR, + TABLET, + UNKNOWN, +}; + +enum class ColorMode : int32_t { + LIGHT = 0, + DARK, + COLOR_MODE_UNDEFINED, +}; + +struct PreviewerWindowModel { + bool isRound = false; // shape rect(false) circle(true) + int32_t originWidth = 0; // or width + int32_t originHeight = 0; // or height + int32_t compressWidth = 0; // cr width + int32_t compressHeight = 0; // cr height + Orientation orientation = Orientation::PORTRAIT; // orientation + double density = 1.0; // dpi with calculate + DeviceType deviceType = DeviceType::PHONE; // device type + ColorMode colorMode = ColorMode::LIGHT; // color mode +}; + +class PreviewerWindow { +public: + PreviewerWindow(const PreviewerWindow&) = delete; + PreviewerWindow& operator=(const PreviewerWindow&) = delete; + ~PreviewerWindow() = default; + + static PreviewerWindow& GetInstance(); + + void SetWindowParams(const PreviewerWindowModel& windowModel); + PreviewerWindowModel& GetWindowParams(); + + void SetWindowObject(const Rosen::WindowImpl *window); + Rosen::WindowImpl* GetWindowObject(); + +private: + PreviewerWindow(); + PreviewerWindowModel windowModel; + Rosen::WindowImpl *window; +}; +} // namespace Previewer +} // namespace OHOS +#endif // INTERFACES_INNERKITS_WINDOW_MODEL_H diff --git a/previewer/src/window_model.cpp b/previewer/src/window_model.cpp new file mode 100644 index 0000000000..b6244a2ea9 --- /dev/null +++ b/previewer/src/window_model.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "window_model.h" + +namespace OHOS { +namespace Previewer { + +PreviewerWindow::PreviewerWindow() +{ +} + +PreviewerWindow& PreviewerWindow::GetInstance() +{ + static PreviewerWindow instance; + return instance; +} + +void PreviewerWindow::SetWindowParams(const PreviewerWindowModel& windowModel) +{ + this->windowModel = windowModel; +} + +PreviewerWindowModel& PreviewerWindow::GetWindowParams() +{ + return this->windowModel; +} + +void PreviewerWindow::SetWindowObject(const Rosen::WindowImpl *window) +{ + this->window = const_cast(window); +} + +Rosen::WindowImpl* PreviewerWindow::GetWindowObject() +{ + return this->window; +} + +} // namespace Previewer +} // namespace OHOS \ No newline at end of file -- Gitee From 2972ae157f78737613481aea4b533b3c0ae70f78 Mon Sep 17 00:00:00 2001 From: fupengfei001 Date: Sat, 27 May 2023 12:47:56 +0800 Subject: [PATCH 2/2] fupengfei6@huawei.com Signed-off-by: fupengfei001 --- previewer/include/window_model.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/previewer/include/window_model.h b/previewer/include/window_model.h index 675dfb392c..ce2adc91a6 100644 --- a/previewer/include/window_model.h +++ b/previewer/include/window_model.h @@ -17,8 +17,6 @@ #define INTERFACES_INNERKITS_WINDOW_MODEL_H #include "window_impl.h" -#include "device_type.h" -#include "device_config.h" namespace OHOS { namespace Previewer { -- Gitee