• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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_SEARCH_SEARCH_LAYOUT_ALGORITHM_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SEARCH_SEARCH_LAYOUT_ALGORITHM_H
18 
19 #include "core/components_ng/layout/layout_algorithm.h"
20 #include "core/components_ng/layout/layout_wrapper.h"
21 
22 namespace OHOS::Ace::NG {
23 
24 class ACE_EXPORT SearchLayoutAlgorithm : public LayoutAlgorithm {
25     DECLARE_ACE_TYPE(SearchLayoutAlgorithm, LayoutAlgorithm);
26 
27 public:
28     SearchLayoutAlgorithm() = default;
29 
30     ~SearchLayoutAlgorithm() override = default;
31 
OnReset()32     void OnReset() override {}
33 
34     void Measure(LayoutWrapper* layoutWrapper) override;
35     void Layout(LayoutWrapper* layoutWrapper) override;
36 
37 private:
38     void CancelImageMeasure(LayoutWrapper* layoutWrapper);
39     void CancelButtonMeasure(LayoutWrapper* layoutWrapper);
40     void TextFieldMeasure(LayoutWrapper* layoutWrapper);
41     void ImageMeasure(LayoutWrapper* layoutWrapper);
42     void SearchButtonMeasure(LayoutWrapper* layoutWrapper);
43     void SelfMeasure(LayoutWrapper* layoutWrapper);
44     bool IsFixedHeightMode(LayoutWrapper* layoutWrapper);
45     double CalcSearchAdaptHeight(LayoutWrapper* layoutWrapper);
46     void CalcChildrenHotZone(LayoutWrapper* layoutWrapper);
47     double CalcSearchWidth(const LayoutConstraintF& contentConstraint, LayoutWrapper* layoutWrapper);
48     double CalcSearchHeight(const LayoutConstraintF& contentConstraint, LayoutWrapper* layoutWrapper);
49 
50     // children frame size
51     SizeF searchIconSizeMeasure_;
52     SizeF cancelIconSizeMeasure_;
53     SizeF searchButtonSizeMeasure_;
54     SizeF cancelBtnSizeMeasure_;
55     SizeF textFieldSizeMeasure_;
56 
57     ACE_DISALLOW_COPY_AND_MOVE(SearchLayoutAlgorithm);
58 };
59 
60 } // namespace OHOS::Ace::NG
61 
62 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SEARCH_SEARCH_LAYOUT_ALGORITHM_H
63