1 /*
2 * Copyright (c) 2025 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 "ui/view/view.h"
17
18 #include "interfaces/inner_api/ace_kit/src/view/frame_node_impl.h"
19 #include "ui/base/referenced.h"
20 #include "ui/view_stack/view_stack_processor.h"
21
22 #include "core/components_ng/base/view_abstract.h"
23
24 namespace OHOS::Ace::Kit {
25
26 View::View() = default;
27
View(const RefPtr<FrameNode> & node)28 View::View(const RefPtr<FrameNode>& node) : node_(node) {}
29
30 View::~View() = default;
31
GetNode() const32 const RefPtr<FrameNode>& View::GetNode() const
33 {
34 return node_;
35 }
36
SetWidth(const CalcDimension & width)37 void View::SetWidth(const CalcDimension& width)
38 {
39 if (width.Unit() == DimensionUnit::CALC) {
40 NG::ViewAbstract::SetWidth(reinterpret_cast<AceNode*>(node_->GetHandle()), NG::CalcLength(width.CalcValue()));
41 } else {
42 NG::ViewAbstract::SetWidth(reinterpret_cast<AceNode*>(node_->GetHandle()), NG::CalcLength(width));
43 }
44 }
45
SetHeight(const CalcDimension & height)46 void View::SetHeight(const CalcDimension& height)
47 {
48 if (height.Unit() == DimensionUnit::CALC) {
49 NG::ViewAbstract::SetHeight(reinterpret_cast<AceNode*>(node_->GetHandle()), NG::CalcLength(height.CalcValue()));
50 } else {
51 NG::ViewAbstract::SetHeight(reinterpret_cast<AceNode*>(node_->GetHandle()), NG::CalcLength(height));
52 }
53 }
54
SetLinearGradientBlur(const NG::LinearGradientBlurPara & blurPara)55 void View::SetLinearGradientBlur(const NG::LinearGradientBlurPara& blurPara)
56 {
57 NG::ViewAbstract::SetLinearGradientBlur(reinterpret_cast<AceNode*>(node_->GetHandle()), blurPara);
58 }
59 } // namespace OHOS::Ace::Kit
60