1 /* 2 * Copyright (c) 2022 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 "bridge/declarative_frontend/jsview/models/linear_split_model_impl.h" 17 18 #include "bridge/declarative_frontend/view_stack_processor.h" 19 #include "core/components/split_container/column_split_component.h" 20 #include "core/components/split_container/row_split_component.h" 21 22 namespace OHOS::Ace::Framework { 23 Create(NG::SplitType splitType)24void LinearSplitModelImpl::Create(NG::SplitType splitType) 25 { 26 if (splitType == NG::SplitType::ROW_SPLIT) { 27 std::list<RefPtr<OHOS::Ace::Component>> componentChildren; 28 auto rowSplit = AceType::MakeRefPtr<RowSplitComponent>(componentChildren); 29 ViewStackProcessor::GetInstance()->Push(rowSplit); 30 auto box = ViewStackProcessor::GetInstance()->GetBoxComponent(); 31 box->SetBoxClipFlag(true); 32 } else if (splitType == NG::SplitType::COLUMN_SPLIT) { 33 std::list<RefPtr<OHOS::Ace::Component>> componentChildren; 34 auto columnSplit = AceType::MakeRefPtr<ColumnSplitComponent>(componentChildren); 35 ViewStackProcessor::GetInstance()->ClaimElementId(columnSplit); 36 ViewStackProcessor::GetInstance()->Push(columnSplit); 37 auto box = ViewStackProcessor::GetInstance()->GetBoxComponent(); 38 box->SetBoxClipFlag(true); 39 } 40 } 41 SetResizable(NG::SplitType splitType,bool resizable)42void LinearSplitModelImpl::SetResizable(NG::SplitType splitType, bool resizable) 43 { 44 if (splitType == NG::SplitType::ROW_SPLIT) { 45 auto rowSplit = AceType::DynamicCast<RowSplitComponent>(ViewStackProcessor::GetInstance()->GetMainComponent()); 46 if (rowSplit) { 47 rowSplit->SetResizable(resizable); 48 } 49 } else if (splitType == NG::SplitType::COLUMN_SPLIT) { 50 auto columnSplit = 51 AceType::DynamicCast<ColumnSplitComponent>(ViewStackProcessor::GetInstance()->GetMainComponent()); 52 if (columnSplit) { 53 columnSplit->SetResizable(resizable); 54 } 55 } 56 } 57 SetDivider(NG::SplitType splitType,const NG::ItemDivider & divider)58void LinearSplitModelImpl::SetDivider(NG::SplitType splitType, const NG::ItemDivider& divider) 59 { 60 } 61 62 63 } // namespace OHOS::Ace::Framework