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