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