1 /*
2 * Copyright (c) 2023-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 #include "picture_in_picture_option.h"
17 #include "window_manager_hilog.h"
18
19 namespace OHOS {
20 namespace Rosen {
PipOption()21 PipOption::PipOption()
22 {
23 }
24
SetContext(void* contextPtr)25 void PipOption::SetContext(void* contextPtr)
26 {
27 contextPtr_ = contextPtr;
28 }
29
SetNavigationId(const std::string& navigationId)30 void PipOption::SetNavigationId(const std::string& navigationId)
31 {
32 navigationId_ = navigationId;
33 }
34
SetPipTemplate(uint32_t templateType)35 void PipOption::SetPipTemplate(uint32_t templateType)
36 {
37 templateType_ = templateType;
38 }
39
SetPiPControlStatus(PiPControlType controlType, PiPControlStatus status)40 void PipOption::SetPiPControlStatus(PiPControlType controlType, PiPControlStatus status)
41 {
42 for (auto& controlStatusInfo : pipControlStatusInfoList_) {
43 if (controlType == controlStatusInfo.controlType) {
44 controlStatusInfo.status = status;
45 return;
46 }
47 }
48 PiPControlStatusInfo newPiPControlStatusInfo {controlType, status};
49 pipControlStatusInfoList_.push_back(newPiPControlStatusInfo);
50 }
51
SetPiPControlEnabled(PiPControlType controlType, PiPControlStatus enabled)52 void PipOption::SetPiPControlEnabled(PiPControlType controlType, PiPControlStatus enabled)
53 {
54 for (auto& controlEnableInfo : pipControlEnableInfoList_) {
55 if (controlType == controlEnableInfo.controlType) {
56 controlEnableInfo.enabled = enabled;
57 return;
58 }
59 }
60 PiPControlEnableInfo newPiPControlEnableInfo {controlType, enabled};
61 pipControlEnableInfoList_.push_back(newPiPControlEnableInfo);
62 }
63
SetContentSize(uint32_t width, uint32_t height)64 void PipOption::SetContentSize(uint32_t width, uint32_t height)
65 {
66 contentWidth_ = width;
67 contentHeight_ = height;
68 }
69
SetControlGroup(std::vector<std::uint32_t> controlGroup)70 void PipOption::SetControlGroup(std::vector<std::uint32_t> controlGroup)
71 {
72 controlGroup_ = controlGroup;
73 }
74
SetNodeControllerRef(napi_ref ref)75 void PipOption::SetNodeControllerRef(napi_ref ref)
76 {
77 customNodeController_ = ref;
78 }
79
GetNodeControllerRef() const80 napi_ref PipOption::GetNodeControllerRef() const
81 {
82 return customNodeController_;
83 }
84
SetTypeNodeRef(napi_ref ref)85 void PipOption::SetTypeNodeRef(napi_ref ref)
86 {
87 typeNode_ = ref;
88 }
89
GetTypeNodeRef() const90 napi_ref PipOption::GetTypeNodeRef() const
91 {
92 return typeNode_;
93 }
94
GetContext() const95 void* PipOption::GetContext() const
96 {
97 return contextPtr_;
98 }
99
GetNavigationId() const100 std::string PipOption::GetNavigationId() const
101 {
102 return navigationId_;
103 }
104
GetPipTemplate()105 uint32_t PipOption::GetPipTemplate()
106 {
107 return templateType_;
108 }
109
GetContentSize(uint32_t& width, uint32_t& height)110 void PipOption::GetContentSize(uint32_t& width, uint32_t& height)
111 {
112 width = contentWidth_;
113 height = contentHeight_;
114 }
115
GetControlGroup()116 std::vector<std::uint32_t> PipOption::GetControlGroup()
117 {
118 return controlGroup_;
119 }
120
GetControlStatus()121 std::vector<PiPControlStatusInfo> PipOption::GetControlStatus()
122 {
123 return pipControlStatusInfoList_;
124 }
125
GetControlEnable()126 std::vector<PiPControlEnableInfo> PipOption::GetControlEnable()
127 {
128 return pipControlEnableInfoList_;
129 }
130
SetXComponentController(std::shared_ptr<XComponentController> xComponentController)131 void PipOption::SetXComponentController(std::shared_ptr<XComponentController> xComponentController)
132 {
133 xComponentController_ = xComponentController;
134 }
135
GetXComponentController()136 std::shared_ptr<XComponentController> PipOption::GetXComponentController()
137 {
138 return xComponentController_;
139 }
140
SetTypeNodeEnabled(bool enable)141 void PipOption::SetTypeNodeEnabled(bool enable)
142 {
143 useTypeNode_ = enable;
144 }
145
IsTypeNodeEnabled() const146 bool PipOption::IsTypeNodeEnabled() const
147 {
148 return useTypeNode_;
149 }
150 } // namespace Rosen
151 } // namespace OHOS