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 28 View::~View() = default; 29 GetNode() const30const RefPtr<FrameNode>& View::GetNode() const 31 { 32 return node_; 33 } 34 SetWidth(const CalcDimension & width)35void View::SetWidth(const CalcDimension& width) 36 { 37 if (width.Unit() == DimensionUnit::CALC) { 38 NG::ViewAbstract::SetWidth(reinterpret_cast<AceNode*>(node_->GetHandle()), NG::CalcLength(width.CalcValue())); 39 } else { 40 NG::ViewAbstract::SetWidth(reinterpret_cast<AceNode*>(node_->GetHandle()), NG::CalcLength(width)); 41 } 42 } 43 SetHeight(const CalcDimension & height)44void View::SetHeight(const CalcDimension& height) 45 { 46 if (height.Unit() == DimensionUnit::CALC) { 47 NG::ViewAbstract::SetHeight(reinterpret_cast<AceNode*>(node_->GetHandle()), NG::CalcLength(height.CalcValue())); 48 } else { 49 NG::ViewAbstract::SetHeight(reinterpret_cast<AceNode*>(node_->GetHandle()), NG::CalcLength(height)); 50 } 51 } 52 53 } // namespace OHOS::Ace::Kit 54