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