• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_STACK_STACK_LAYOUT_PROPERTY_H
17 #define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_STACK_STACK_LAYOUT_PROPERTY_H
18 
19 #include "core/components_ng/base/inspector_filter.h"
20 #include "core/components_ng/layout/layout_property.h"
21 #include "core/components_ng/property/position_property.h"
22 
23 namespace OHOS::Ace::NG {
24 class ACE_EXPORT StackLayoutProperty : public LayoutProperty {
25     DECLARE_ACE_TYPE(StackLayoutProperty, LayoutProperty);
26 
27 public:
28     StackLayoutProperty() = default;
29 
30     ~StackLayoutProperty() override = default;
31 
Clone()32     RefPtr<LayoutProperty> Clone() const override
33     {
34         auto layoutProperty = MakeRefPtr<StackLayoutProperty>();
35         layoutProperty->UpdateLayoutProperty(this);
36         return layoutProperty;
37     }
38 
Reset()39     void Reset() override
40     {
41         LayoutProperty::Reset();
42     }
43 
ToJsonValue(std::unique_ptr<JsonValue> & json,const InspectorFilter & filter)44     void ToJsonValue(std::unique_ptr<JsonValue>& json, const InspectorFilter& filter) const override
45     {
46         LayoutProperty::ToJsonValue(json, filter);
47         /* no fixed attr below, just return */
48         if (filter.IsFastFilter()) {
49             return;
50         }
51         auto align = Alignment::CENTER;
52         if (GetPositionProperty()) {
53             align = GetPositionProperty()->GetAlignment().value_or(Alignment::CENTER);
54         }
55         json->PutExtAttr("alignContent", align.GetAlignmentStr(TextDirection::LTR).c_str(), filter);
56     }
57 
FromJson(const std::unique_ptr<JsonValue> & json)58     void FromJson(const std::unique_ptr<JsonValue>& json) override
59     {
60         UpdateAlignment(Alignment::GetAlignment(TextDirection::LTR, json->GetString("alignContent")));
61         LayoutProperty::FromJson(json);
62     }
63 
64 private:
65     ACE_DISALLOW_COPY_AND_MOVE(StackLayoutProperty);
66 };
67 } // namespace OHOS::Ace::NG
68 #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_STACK_STACK_LAYOUT_PROPERTY_H
69