1 /* 2 * Copyright (c) 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 #ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FOLDER_STACK_LAYOUT_ALGORITHM_H 17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FOLDER_STACK_LAYOUT_ALGORITHM_H 18 19 #include "base/memory/referenced.h" 20 #include "core/components_ng/base/frame_node.h" 21 #include "core/components_ng/base/group_node.h" 22 #include "core/components_ng/layout/box_layout_algorithm.h" 23 #include "core/components_ng/layout/layout_wrapper.h" 24 #include "core/components_ng/pattern/folder_stack/folder_stack_group_node.h" 25 #include "core/components_ng/pattern/folder_stack/folder_stack_layout_property.h" 26 #include "core/components_ng/pattern/stack/stack_layout_algorithm.h" 27 28 namespace OHOS::Ace::NG { 29 class ACE_EXPORT FolderStackLayoutAlgorithm : public StackLayoutAlgorithm { 30 DECLARE_ACE_TYPE(FolderStackLayoutAlgorithm, StackLayoutAlgorithm); 31 32 public: 33 FolderStackLayoutAlgorithm(); 34 ~FolderStackLayoutAlgorithm() override = default; 35 void Layout(LayoutWrapper* layoutWrapper) override; 36 void Measure(LayoutWrapper* layoutWrapper) override; GetControlPartsStackRect()37 const OffsetF& GetControlPartsStackRect() const 38 { 39 return controlPartsStackRect_; 40 } 41 GetIsIntoFolderStack()42 bool GetIsIntoFolderStack() const 43 { 44 return isIntoFolderStack_; 45 } 46 47 private: 48 void LayoutHoverStack(LayoutWrapper* layoutWrapper, const RefPtr<FolderStackGroupNode>& hostNode, 49 const RefPtr<FolderStackLayoutProperty>& folderStackLayoutProperty); 50 void LayoutControlPartsStack(LayoutWrapper* layoutWrapper, const RefPtr<FolderStackGroupNode>& hostNode, 51 const RefPtr<FolderStackLayoutProperty>& folderStackLayoutProperty); 52 void MeasureHoverStack(LayoutWrapper* layoutWrapper, const RefPtr<FolderStackGroupNode>& hostNode, 53 const RefPtr<FolderStackLayoutProperty>& folderStackLayoutProperty, const SizeF& size); 54 void MeasureControlPartsStack(LayoutWrapper* layoutWrapper, const RefPtr<FolderStackGroupNode>& hostNode, 55 const RefPtr<FolderStackLayoutProperty>& folderStackLayoutProperty, const SizeF& size); 56 void RangeCalculation(const RefPtr<FolderStackGroupNode>& hostNode, 57 const RefPtr<FolderStackLayoutProperty>& folderStackLayoutProperty, const SizeF& size); 58 bool IsFullWindow(SizeF& frameSize, const RefPtr<FolderStackLayoutProperty>& folderStackLayoutProperty, 59 LayoutWrapper* layoutWrapper); 60 static NG::OffsetF CalculateStackAlignment( 61 const NG::SizeF& parentSize, const NG::SizeF& childSize, const Alignment& alignment); 62 void AdjustNodeTree(const RefPtr<FolderStackGroupNode>& hostNode); 63 bool IsIntoFolderStack(SizeF& frameSize, const RefPtr<FolderStackLayoutProperty>& folderStackLayoutProperty, 64 LayoutWrapper* layoutWrapper); 65 void OnHoverStatusChange(LayoutWrapper* layoutWrapper); 66 void MeasureByStack(const RefPtr<FolderStackGroupNode>& hostNode, LayoutWrapper* layoutWrapper); 67 ACE_DISALLOW_COPY_AND_MOVE(FolderStackLayoutAlgorithm); 68 float preHoverStackHeight_ = 0.0f; 69 float preControlPartsStackHeight_ = 0.0f; 70 OffsetF controlPartsStackRect_; 71 bool isIntoFolderStack_ = false; 72 }; 73 } // namespace OHOS::Ace::NG 74 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FOLDER_STACK_FOLDER_STACK_LAYOUT_ALGORITHM_H 75