diff --git a/frameworks/bridge/declarative_frontend/jsview/models/flex_model_impl.h b/frameworks/bridge/declarative_frontend/jsview/models/flex_model_impl.h index 3a00ff1a0b4f294b2c0a5c4b0156a03bc59200fa..93af83889437a9cc958e21178a84674e2358f348 100644 --- a/frameworks/bridge/declarative_frontend/jsview/models/flex_model_impl.h +++ b/frameworks/bridge/declarative_frontend/jsview/models/flex_model_impl.h @@ -48,8 +48,6 @@ public: void SetAlignContent(int32_t value) override; void SetMainSpace(const std::optional& space) override {}; void SetCrossSpace(const std::optional& space) override {}; - void SetWidthLayoutPolicy(uint8_t widthLayoutPolicy) override {}; - void SetHeightLayoutPolicy(uint8_t heightLayoutPolicy) override {}; }; } // namespace OHOS::Ace::Framework diff --git a/frameworks/core/components/common/layout/position_param.h b/frameworks/core/components/common/layout/position_param.h index e71d46920afa45c5db6f240d46ea711a9fa3839f..e413f5230bdb1bc03c1d07afce2a2ab82a3be4a7 100644 --- a/frameworks/core/components/common/layout/position_param.h +++ b/frameworks/core/components/common/layout/position_param.h @@ -216,6 +216,14 @@ struct BarrierInfo { (this->referencedId == right.referencedId)); } }; + +struct LocalizedBarrierInfo : public BarrierInfo { + LocalizedBarrierInfo() + { + direction = BarrierDirection::START; + } +}; + } // namespace OHOS::Ace #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_BASE_LAYOUT_POSITION_PARAM_H diff --git a/frameworks/core/components_ng/pattern/BUILD.gn b/frameworks/core/components_ng/pattern/BUILD.gn index f0e2e6bd91fcc3f7eb59aa337b833a7f2c9f36bd..741114b19f5a6eccd68162b6e0550b26881c4a47 100644 --- a/frameworks/core/components_ng/pattern/BUILD.gn +++ b/frameworks/core/components_ng/pattern/BUILD.gn @@ -118,12 +118,14 @@ build_component_ng("pattern_ng") { "dialog/dialog_view.cpp", "divider/divider_layout_algorithm.cpp", "divider/divider_model_ng.cpp", + "divider/divider_model_ng_static.cpp", "divider/divider_modifier.cpp", "divider/divider_pattern.cpp", "effect_component/effect_component_model_ng.cpp", "effect_component/effect_component_pattern.cpp", "flex/flex_layout_algorithm.cpp", "flex/flex_model_ng.cpp", + "flex/flex_model_ng_static.cpp", "flex/wrap_layout_algorithm.cpp", "form_link/form_link_model_ng.cpp", "form_link/form_link_pattern.cpp", @@ -161,12 +163,14 @@ build_component_ng("pattern_ng") { "grid_col/grid_col_layout_algorithm.cpp", "grid_col/grid_col_layout_property.cpp", "grid_col/grid_col_model_ng.cpp", + "grid_col/grid_col_model_ng_static.cpp", "grid_container/grid_container_layout_property.cpp", "grid_container/grid_container_model_ng.cpp", "grid_row/grid_row_layout_algorithm.cpp", "grid_row/grid_row_layout_pattern.cpp", "grid_row/grid_row_layout_property.cpp", "grid_row/grid_row_model_ng.cpp", + "grid_row/grid_row_model_ng_static.cpp", "hyperlink/hyperlink_model_ng.cpp", "hyperlink/hyperlink_model_static.cpp", "hyperlink/hyperlink_pattern.cpp", @@ -199,10 +203,13 @@ build_component_ng("pattern_ng") { "linear_indicator/linear_indicator_model_ng.cpp", "linear_indicator/linear_indicator_pattern.cpp", "linear_layout/column_model_ng.cpp", + "linear_layout/column_model_ng_static.cpp", "linear_layout/linear_layout_utils.cpp", "linear_layout/row_model_ng.cpp", + "linear_layout/row_model_ng_static.cpp", "linear_split/linear_split_layout_algorithm.cpp", "linear_split/linear_split_model_ng.cpp", + "linear_split/linear_split_model_ng_static.cpp", "linear_split/linear_split_paint_method.cpp", "linear_split/linear_split_pattern.cpp", "list/list_accessibility_property.cpp", @@ -646,6 +653,7 @@ build_component_ng("pattern_ng") { "folder_stack/folder_stack_group_node.cpp", "folder_stack/folder_stack_layout_algorithm.cpp", "folder_stack/folder_stack_model_ng.cpp", + "folder_stack/folder_stack_model_ng_static.cpp", "folder_stack/folder_stack_pattern.cpp", "folder_stack/hover_stack_node.cpp", "picker/datepicker_dialog_view.cpp", diff --git a/frameworks/core/components_ng/pattern/divider/divider_model_ng.cpp b/frameworks/core/components_ng/pattern/divider/divider_model_ng.cpp index 2609c8280d0527175612d55e7f5e1e6d025d52ca..aab4f83134571f06578c364f0712e2b9c8e87c77 100644 --- a/frameworks/core/components_ng/pattern/divider/divider_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/divider/divider_model_ng.cpp @@ -15,7 +15,6 @@ #include "core/components_ng/pattern/divider/divider_model_ng.h" -#include "core/common/resource/resource_parse_utils.h" #include "core/components_ng/pattern/divider/divider_pattern.h" namespace OHOS::Ace::NG { @@ -48,33 +47,6 @@ void DividerModelNG::DividerColor(const Color& value) ACE_UPDATE_PAINT_PROPERTY(DividerRenderProperty, DividerColor, value); } -void DividerModelNG::DividerColor(const RefPtr& resObj) -{ - auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); - CHECK_NULL_VOID(frameNode); - - auto dividerPattern = frameNode->GetPattern(); - CHECK_NULL_VOID(dividerPattern); - auto&& updateFunc = [weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { - auto frameNode = weak.Upgrade(); - CHECK_NULL_VOID(frameNode); - auto dividerPattern = frameNode->GetPattern(); - CHECK_NULL_VOID(dividerPattern); - std::string dividerColor = dividerPattern->GetResCacheMapByKey("divider.Color"); - Color result; - if (dividerColor.empty()) { - ResourceParseUtils::ParseResColor(resObj, result); - dividerPattern->AddResCache("divider.Color", result.ColorToString()); - } else { - result = Color::ColorFromString(dividerColor); - } - ACE_UPDATE_NODE_PAINT_PROPERTY(DividerRenderProperty, DividerColor, result, frameNode); - frameNode->MarkDirtyNode(PROPERTY_UPDATE_RENDER); - }; - updateFunc(resObj); - dividerPattern->AddResObj("divider.Color", resObj, std::move(updateFunc)); -} - void DividerModelNG::StrokeWidth(const Dimension& value) { ACE_UPDATE_LAYOUT_PROPERTY(DividerLayoutProperty, StrokeWidth, value); @@ -85,31 +57,19 @@ void DividerModelNG::LineCap(const Ace::LineCap& value) ACE_UPDATE_PAINT_PROPERTY(DividerRenderProperty, LineCap, value); } -void DividerModelNG::StrokeWidth(FrameNode* frameNode, std::optional valueOpt) +void DividerModelNG::StrokeWidth(FrameNode* frameNode, const Dimension& value) { - if (valueOpt) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(DividerLayoutProperty, StrokeWidth, valueOpt.value(), frameNode); - } else { - ACE_RESET_NODE_LAYOUT_PROPERTY(DividerLayoutProperty, StrokeWidth, frameNode); - } + ACE_UPDATE_NODE_LAYOUT_PROPERTY(DividerLayoutProperty, StrokeWidth, value, frameNode); } -void DividerModelNG::LineCap(FrameNode* frameNode, const std::optional valueOpt) +void DividerModelNG::LineCap(FrameNode* frameNode, const Ace::LineCap& value) { - if (valueOpt) { - ACE_UPDATE_NODE_PAINT_PROPERTY(DividerRenderProperty, LineCap, valueOpt.value(), frameNode); - } else { - ACE_RESET_NODE_PAINT_PROPERTY(DividerRenderProperty, LineCap, frameNode); - } + ACE_UPDATE_NODE_PAINT_PROPERTY(DividerRenderProperty, LineCap, value, frameNode); } -void DividerModelNG::SetDividerColor(FrameNode* frameNode, std::optional colorOpt) +void DividerModelNG::SetDividerColor(FrameNode* frameNode, const Color& color) { - if (colorOpt) { - ACE_UPDATE_NODE_PAINT_PROPERTY(DividerRenderProperty, DividerColor, colorOpt.value(), frameNode); - } else { - ACE_RESET_NODE_PAINT_PROPERTY(DividerRenderProperty, DividerColor, frameNode); - } + ACE_UPDATE_NODE_PAINT_PROPERTY(DividerRenderProperty, DividerColor, color, frameNode); } void DividerModelNG::SetVertical(FrameNode* frameNode, const bool& value) diff --git a/frameworks/core/components_ng/pattern/divider/divider_model_ng.h b/frameworks/core/components_ng/pattern/divider/divider_model_ng.h index d7f8b55419d531c0b80d71d2ecd62c1284d35707..e0f1db1f59f1cae4baa674c25434e1a98c299307 100644 --- a/frameworks/core/components_ng/pattern/divider/divider_model_ng.h +++ b/frameworks/core/components_ng/pattern/divider/divider_model_ng.h @@ -26,14 +26,13 @@ public: void Create() override; void Vertical(bool value) override; void DividerColor(const Color& value) override; - void DividerColor(const RefPtr& resobj) override; void StrokeWidth(const Dimension& value) override; void LineCap(const enum LineCap& value) override; void ResetDividerColor() override; static RefPtr CreateFrameNode(int32_t nodeId); - static void StrokeWidth(FrameNode* frameNode, std::optional valueOpt); - static void LineCap(FrameNode* frameNode, std::optional valueOpt); - static void SetDividerColor(FrameNode* frameNode, std::optional colorOpt); + static void StrokeWidth(FrameNode* frameNode, const Dimension& value); + static void LineCap(FrameNode* frameNode, const enum LineCap& value); + static void SetDividerColor(FrameNode* frameNode, const Color& color); static void SetVertical(FrameNode* frameNode, const bool& value); }; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/divider/divider_model_ng_static.cpp b/frameworks/core/components_ng/pattern/divider/divider_model_ng_static.cpp new file mode 100644 index 0000000000000000000000000000000000000000..68596ee2261b07a5059df175208d0ed7ebdcf124 --- /dev/null +++ b/frameworks/core/components_ng/pattern/divider/divider_model_ng_static.cpp @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "core/components_ng/pattern/divider/divider_model_ng_static.h" +#include "core/components_ng/pattern/divider/divider_pattern.h" + +namespace OHOS::Ace::NG { + +void DividerModelNGStatic::StrokeWidth(FrameNode* frameNode, std::optional valueOpt) +{ + if (valueOpt) { + ACE_UPDATE_NODE_LAYOUT_PROPERTY(DividerLayoutProperty, StrokeWidth, valueOpt.value(), frameNode); + } else { + ACE_RESET_NODE_LAYOUT_PROPERTY(DividerLayoutProperty, StrokeWidth, frameNode); + } +} + +void DividerModelNGStatic::LineCap(FrameNode* frameNode, const std::optional valueOpt) +{ + if (valueOpt) { + ACE_UPDATE_NODE_PAINT_PROPERTY(DividerRenderProperty, LineCap, valueOpt.value(), frameNode); + } else { + ACE_RESET_NODE_PAINT_PROPERTY(DividerRenderProperty, LineCap, frameNode); + } +} + +void DividerModelNGStatic::SetDividerColor(FrameNode* frameNode, std::optional colorOpt) +{ + if (colorOpt) { + ACE_UPDATE_NODE_PAINT_PROPERTY(DividerRenderProperty, DividerColor, colorOpt.value(), frameNode); + } else { + ACE_RESET_NODE_PAINT_PROPERTY(DividerRenderProperty, DividerColor, frameNode); + } +} +} \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/divider/divider_model_ng_static.h b/frameworks/core/components_ng/pattern/divider/divider_model_ng_static.h new file mode 100644 index 0000000000000000000000000000000000000000..1196148fbc33632105e3bbd14207d7cf748aa6ba --- /dev/null +++ b/frameworks/core/components_ng/pattern/divider/divider_model_ng_static.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_DIVIDER_DIVIDER_MODEL_NG_STATIC_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_DIVIDER_DIVIDER_MODEL_NG_STATIC_H + +#include "core/components_ng/base/frame_node.h" +#include "core/components_ng/pattern/divider/divider_model.h" + +namespace OHOS::Ace::NG { + +class ACE_EXPORT DividerModelNGStatic : public DividerModel { +public: + static void StrokeWidth(FrameNode* frameNode, std::optional valueOpt); + static void LineCap(FrameNode* frameNode, std::optional valueOpt); + static void SetDividerColor(FrameNode* frameNode, std::optional colorOpt); +}; +} // namespace OHOS::Ace::NG + +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_DIVIDER_DIVIDER_MODEL_NG_STATIC_H \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/flex/flex_layout_property.h b/frameworks/core/components_ng/pattern/flex/flex_layout_property.h index ae1282cd60ab74107cf9a514f0dca23fde33d5d6..6586b4df2392ced95313caf544812cb1518148a6 100644 --- a/frameworks/core/components_ng/pattern/flex/flex_layout_property.h +++ b/frameworks/core/components_ng/pattern/flex/flex_layout_property.h @@ -78,9 +78,6 @@ public: ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(FlexLayoutAttribute, CrossAxisAlign, FlexAlign, PROPERTY_UPDATE_MEASURE); ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(FlexLayoutAttribute, Space, Dimension, PROPERTY_UPDATE_MEASURE); ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(FlexLayoutAttribute, IsReverse, bool, PROPERTY_UPDATE_MEASURE); - ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(FlexLayoutAttribute, WidthLayoutPolicy, uint8_t, PROPERTY_UPDATE_MEASURE); - ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP( - FlexLayoutAttribute, HeightLayoutPolicy, uint8_t, PROPERTY_UPDATE_MEASURE); ACE_DEFINE_PROPERTY_GROUP(WrapLayoutAttribute, WrapLayoutAttribute); ACE_DEFINE_PROPERTY_ITEM_WITH_GROUP(WrapLayoutAttribute, WrapDirection, WrapDirection, PROPERTY_UPDATE_MEASURE); diff --git a/frameworks/core/components_ng/pattern/flex/flex_layout_styles.h b/frameworks/core/components_ng/pattern/flex/flex_layout_styles.h index caf992b6cb5666c56ddd0a5e8b5d9d3e8842cda8..aac3549cd9f28d1e6456c8354589a20921749895 100644 --- a/frameworks/core/components_ng/pattern/flex/flex_layout_styles.h +++ b/frameworks/core/components_ng/pattern/flex/flex_layout_styles.h @@ -26,8 +26,6 @@ struct FlexLayoutAttribute { ACE_DEFINE_PROPERTY_GROUP_ITEM(CrossAxisAlign, FlexAlign); ACE_DEFINE_PROPERTY_GROUP_ITEM(Space, Dimension); ACE_DEFINE_PROPERTY_GROUP_ITEM(IsReverse, bool); - ACE_DEFINE_PROPERTY_GROUP_ITEM(WidthLayoutPolicy, uint8_t); - ACE_DEFINE_PROPERTY_GROUP_ITEM(HeightLayoutPolicy, uint8_t); }; struct WrapLayoutAttribute { diff --git a/frameworks/core/components_ng/pattern/flex/flex_model.h b/frameworks/core/components_ng/pattern/flex/flex_model.h index c58eed5c743d5fea44ffbf61bc1a8fb433e514f0..207067d19560fc4751508f718ee0aae08f72a6d2 100644 --- a/frameworks/core/components_ng/pattern/flex/flex_model.h +++ b/frameworks/core/components_ng/pattern/flex/flex_model.h @@ -73,8 +73,6 @@ public: virtual void SetAlignContent(int32_t value) = 0; virtual void SetMainSpace(const std::optional& space) = 0; virtual void SetCrossSpace(const std::optional& space) = 0; - virtual void SetWidthLayoutPolicy(uint8_t widthLayoutPolicy) = 0; - virtual void SetHeightLayoutPolicy(uint8_t heightLayoutPolicy) = 0; }; } // namespace OHOS::Ace #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FLEX_FLEX_MODEL_H diff --git a/frameworks/core/components_ng/pattern/flex/flex_model_ng.cpp b/frameworks/core/components_ng/pattern/flex/flex_model_ng.cpp index 498f3ede52d59f8853128dda279ce1d42cb814d2..9f20c2c139bf4daba849a3e571f09f7618241ee0 100644 --- a/frameworks/core/components_ng/pattern/flex/flex_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/flex/flex_model_ng.cpp @@ -102,46 +102,16 @@ void FlexModelNG::SetMainAxisAlign(FlexAlign align) ACE_UPDATE_LAYOUT_PROPERTY(FlexLayoutProperty, MainAxisAlign, align); } -void FlexModelNG::SetMainAxisAlign(FrameNode* frameNode, std::optional& align) -{ - CHECK_NULL_VOID(frameNode); - if (align.has_value()) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, MainAxisAlign, align.value(), frameNode); - } else { - ACE_RESET_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, MainAxisAlign, frameNode); - } -} - void FlexModelNG::SetWrapMainAlignment(WrapAlignment value) { ACE_UPDATE_LAYOUT_PROPERTY(FlexLayoutProperty, MainAlignment, value); } -void FlexModelNG::SetWrapMainAlignment(FrameNode* frameNode, std::optional& align) -{ - CHECK_NULL_VOID(frameNode); - if (align.has_value()) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, MainAlignment, align.value(), frameNode); - } else { - ACE_RESET_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, MainAlignment, frameNode); - } -} - void FlexModelNG::SetCrossAxisAlign(FlexAlign align) { ACE_UPDATE_LAYOUT_PROPERTY(FlexLayoutProperty, CrossAxisAlign, align); } -void FlexModelNG::SetWrapCrossAlignment(FrameNode* frameNode, std::optional& align) -{ - CHECK_NULL_VOID(frameNode); - if (align.has_value()) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, CrossAlignment, align.value(), frameNode); - } else { - ACE_RESET_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, CrossAlignment, frameNode); - } -} - void FlexModelNG::SetWrapCrossAlignment(WrapAlignment value) { ACE_UPDATE_LAYOUT_PROPERTY(FlexLayoutProperty, CrossAlignment, value); @@ -189,7 +159,6 @@ void FlexModelNG::SetAlignContent(int32_t value) void FlexModelNG::SetFlexRow(FrameNode* frameNode) { - CHECK_NULL_VOID(frameNode); ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, FlexDirection, FlexDirection::ROW, frameNode); ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, MainAxisAlign, FlexAlign::FLEX_START, frameNode); ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, CrossAxisAlign, FlexAlign::FLEX_START, frameNode); @@ -200,7 +169,6 @@ void FlexModelNG::SetFlexRow(FrameNode* frameNode) void FlexModelNG::SetFlexWrap(FrameNode* frameNode) { - CHECK_NULL_VOID(frameNode); ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, WrapDirection, WrapDirection::HORIZONTAL, frameNode); ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, Alignment, WrapAlignment::START, frameNode); ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, MainAlignment, WrapAlignment::START, frameNode); @@ -212,29 +180,16 @@ void FlexModelNG::SetFlexWrap(FrameNode* frameNode) void FlexModelNG::SetFlexDirection(FrameNode* frameNode, FlexDirection value) { - CHECK_NULL_VOID(frameNode); ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, FlexDirection, value, frameNode); } -void FlexModelNG::SetFlexDirection(FrameNode* frameNode, std::optional& layoutDirection) -{ - CHECK_NULL_VOID(frameNode); - if (layoutDirection) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, FlexDirection, layoutDirection.value(), frameNode); - } else { - ACE_RESET_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, FlexDirection, frameNode); - } -} - void FlexModelNG::SetFlexWrapDirection(FrameNode* frameNode, WrapDirection value) { - CHECK_NULL_VOID(frameNode); ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, WrapDirection, value, frameNode); } void FlexModelNG::SetFlexJustifyContent(FrameNode* frameNode, int32_t value) { - CHECK_NULL_VOID(frameNode); auto pattern = frameNode->GetPattern(); if (!pattern->GetIsWrap()) { ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, MainAxisAlign, static_cast(value), frameNode); @@ -243,19 +198,8 @@ void FlexModelNG::SetFlexJustifyContent(FrameNode* frameNode, int32_t value) ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, MainAlignment, static_cast(value), frameNode); } -void FlexModelNG::SetCrossAxisAlign(FrameNode* frameNode, std::optional& align) -{ - CHECK_NULL_VOID(frameNode); - if (align.has_value()) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, CrossAxisAlign, align.value(), frameNode); - } else { - ACE_RESET_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, CrossAxisAlign, frameNode); - } -} - void FlexModelNG::SetFlexAlignItems(FrameNode* frameNode, int32_t value) { - CHECK_NULL_VOID(frameNode); auto pattern = frameNode->GetPattern(); if (!pattern->GetIsWrap()) { ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, CrossAxisAlign, static_cast(value), frameNode); @@ -266,7 +210,6 @@ void FlexModelNG::SetFlexAlignItems(FrameNode* frameNode, int32_t value) void FlexModelNG::SetFlexAlignContent(FrameNode* frameNode, int32_t value) { - CHECK_NULL_VOID(frameNode); auto pattern = frameNode->GetPattern(); if (!pattern->GetIsWrap()) { return; @@ -274,16 +217,6 @@ void FlexModelNG::SetFlexAlignContent(FrameNode* frameNode, int32_t value) ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, Alignment, static_cast(value), frameNode); } -void FlexModelNG::SetFlexAlignContent(FrameNode* frameNode, std::optional& align) -{ - CHECK_NULL_VOID(frameNode); - if (align.has_value()) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, Alignment, align.value(), frameNode); - } else { - ACE_RESET_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, Alignment, frameNode); - } -} - void FlexModelNG::SetWidthLayoutPolicy(uint8_t widthLayoutPolicy) { ACE_UPDATE_LAYOUT_PROPERTY(FlexLayoutProperty, WidthLayoutPolicy, widthLayoutPolicy); @@ -386,7 +319,6 @@ void FlexModelNG::SetCrossSpace(const std::optional& space) void FlexModelNG::SetMainSpace(FrameNode* frameNode, const std::optional& space) { - CHECK_NULL_VOID(frameNode); CHECK_NULL_VOID(space); if (GreatOrEqual(space->Value(), 0.0)) { ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, Space, space.value(), frameNode); @@ -395,7 +327,6 @@ void FlexModelNG::SetMainSpace(FrameNode* frameNode, const std::optional& space) { - CHECK_NULL_VOID(frameNode); CHECK_NULL_VOID(space); if (GreatOrEqual(space->Value(), 0.0)) { ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, CrossSpace, space.value(), frameNode); diff --git a/frameworks/core/components_ng/pattern/flex/flex_model_ng.h b/frameworks/core/components_ng/pattern/flex/flex_model_ng.h index 247e60a2d453bd806171d5b81969796e035b2fe0..3a2b7e811db5c13d33d332ecd37df06d4663f666 100644 --- a/frameworks/core/components_ng/pattern/flex/flex_model_ng.h +++ b/frameworks/core/components_ng/pattern/flex/flex_model_ng.h @@ -56,16 +56,10 @@ public: static void SetFlexRow(FrameNode* frameNode); static void SetFlexWrap(FrameNode* frameNode); static void SetFlexDirection(FrameNode* frameNode, FlexDirection value); - static void SetFlexDirection(FrameNode* frameNode, std::optional& value); static void SetFlexWrapDirection(FrameNode* frameNode, WrapDirection value); - static void SetCrossAxisAlign(FrameNode* frameNode, std::optional& align); - static void SetMainAxisAlign(FrameNode* frameNode, std::optional&); static void SetFlexJustifyContent(FrameNode* frameNode, int32_t value); - static void SetWrapMainAlignment(FrameNode* frameNode, std::optional&); - static void SetWrapCrossAlignment(FrameNode* frameNode, std::optional&); static void SetFlexAlignItems(FrameNode* frameNode, int32_t value); static void SetFlexAlignContent(FrameNode* frameNode, int32_t value); - static void SetFlexAlignContent(FrameNode* frameNode, std::optional& alignContent); static void SetWidthLayoutPolicy(FrameNode* frameNode, uint8_t widthLayoutPolicy); static void SetHeightLayoutPolicy(FrameNode* frameNode, uint8_t heightLayoutPolicy); diff --git a/frameworks/core/components_ng/pattern/flex/flex_model_ng_static.cpp b/frameworks/core/components_ng/pattern/flex/flex_model_ng_static.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d662b6baa6f93502f88d48dbb460c6aa7bdb0b0f --- /dev/null +++ b/frameworks/core/components_ng/pattern/flex/flex_model_ng_static.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "core/components_ng/pattern/flex/flex_model_ng_static.h" +#include "core/components_ng/pattern/flex/flex_layout_pattern.h" + +namespace OHOS::Ace::NG { + +void FlexModelNGStatic::SetMainAxisAlign(FrameNode* frameNode, std::optional& align) +{ + CHECK_NULL_VOID(frameNode); + if (align.has_value()) { + ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, MainAxisAlign, align.value(), frameNode); + } else { + ACE_RESET_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, MainAxisAlign, frameNode); + } +} + +void FlexModelNGStatic::SetWrapMainAlignment(FrameNode* frameNode, std::optional& align) +{ + CHECK_NULL_VOID(frameNode); + if (align.has_value()) { + ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, MainAlignment, align.value(), frameNode); + } else { + ACE_RESET_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, MainAlignment, frameNode); + } +} + +void FlexModelNGStatic::SetWrapCrossAlignment(FrameNode* frameNode, std::optional& align) +{ + CHECK_NULL_VOID(frameNode); + if (align.has_value()) { + ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, CrossAlignment, align.value(), frameNode); + } else { + ACE_RESET_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, CrossAlignment, frameNode); + } +} + +void FlexModelNGStatic::SetFlexDirection(FrameNode* frameNode, std::optional& layoutDirection) +{ + CHECK_NULL_VOID(frameNode); + if (layoutDirection) { + ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, FlexDirection, layoutDirection.value(), frameNode); + } else { + ACE_RESET_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, FlexDirection, frameNode); + } +} + +void FlexModelNGStatic::SetCrossAxisAlign(FrameNode* frameNode, std::optional& align) +{ + CHECK_NULL_VOID(frameNode); + if (align.has_value()) { + ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, CrossAxisAlign, align.value(), frameNode); + } else { + ACE_RESET_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, CrossAxisAlign, frameNode); + } +} + +void FlexModelNGStatic::SetFlexAlignContent(FrameNode* frameNode, std::optional& align) +{ + CHECK_NULL_VOID(frameNode); + if (align.has_value()) { + ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, Alignment, align.value(), frameNode); + } else { + ACE_RESET_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, Alignment, frameNode); + } +} + +} // namespace OHOS::Ace::NG \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/flex/flex_model_ng_static.h b/frameworks/core/components_ng/pattern/flex/flex_model_ng_static.h new file mode 100644 index 0000000000000000000000000000000000000000..0589bec7aa0cd6869cf4aa3cc39d5215886680b1 --- /dev/null +++ b/frameworks/core/components_ng/pattern/flex/flex_model_ng_static.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FLEX_FLEX_MODEL_NG_STATIC_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FLEX_FLEX_MODEL_NG_STATIC_H + +#include "core/components_ng/pattern/flex/flex_model.h" +#include "core/components_ng/base/frame_node.h" + +namespace OHOS::Ace::NG { + +class ACE_EXPORT FlexModelNGStatic : public FlexModel { +public: + static void SetCrossAxisAlign(FrameNode* frameNode, std::optional& align); + static void SetMainAxisAlign(FrameNode* frameNode, std::optional&); + static void SetWrapMainAlignment(FrameNode* frameNode, std::optional&); + static void SetWrapCrossAlignment(FrameNode* frameNode, std::optional&); + static void SetFlexAlignContent(FrameNode* frameNode, std::optional& alignContent); + static void SetFlexDirection(FrameNode* frameNode, std::optional& layoutDirection); +}; +} + +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FLEX_FLEX_MODEL_NG_STATIC_H diff --git a/frameworks/core/components_ng/pattern/folder_stack/folder_stack_model_ng.cpp b/frameworks/core/components_ng/pattern/folder_stack/folder_stack_model_ng.cpp index ef6e73dbafdbc2e6754976e3fdff3694728fab2e..2f21a92d7088da916227e395de87c105b72e2dcf 100644 --- a/frameworks/core/components_ng/pattern/folder_stack/folder_stack_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/folder_stack/folder_stack_model_ng.cpp @@ -18,7 +18,6 @@ #include "core/components_ng/pattern/folder_stack/control_parts_stack_node.h" #include "core/components_ng/pattern/folder_stack/folder_stack_pattern.h" #include "core/components_ng/pattern/folder_stack/hover_stack_node.h" -#include "folder_stack_model_ng.h" namespace OHOS::Ace::NG { void FolderStackModelNG::Create() @@ -51,41 +50,6 @@ void FolderStackModelNG::Create(const std::vector& itemId) ACE_UPDATE_LAYOUT_PROPERTY(FolderStackLayoutProperty, UpperItems, itemId); } -RefPtr FolderStackModelNG::CreateFrameNode(int32_t nodeId) -{ - auto folderStackGroupNode = FolderStackGroupNode::GetOrCreateGroupNode( - V2::FOLDER_STACK_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr(); }); - if (!folderStackGroupNode->GetHoverNode()) { - int32_t hoverId = ElementRegister::GetInstance()->MakeUniqueId(); - auto hoverStackNode = HoverStackNode::GetOrCreateHoverStackNode( - V2::HOVER_STACK_ETS_TAG, hoverId, []() { return AceType::MakeRefPtr(); }); - folderStackGroupNode->AddChild(hoverStackNode); - folderStackGroupNode->SetHoverNode(hoverStackNode); - } - if (!folderStackGroupNode->GetControlPartsStackNode()) { - int32_t controlPartsId = ElementRegister::GetInstance()->MakeUniqueId(); - auto controlPartsNode = ControlPartsStackNode::GetOrCreateControlPartsStackNode(V2::CONTROL_PARTS_STACK_ETS_TAG, - controlPartsId, []() { return AceType::MakeRefPtr(); }); - folderStackGroupNode->AddChild(controlPartsNode); - folderStackGroupNode->SetControlPartsStackNode(controlPartsNode); - } - std::vector itemId; - SetUpdateUpperItems(folderStackGroupNode.GetRawPtr(), itemId); - return folderStackGroupNode; -} - -void FolderStackModelNG::SetUpdateUpperItems(FrameNode* frameNode, const std::vector& itemId) -{ - auto folderStackGroupNode = AceType::DynamicCast(frameNode); - folderStackGroupNode->SetItemId(itemId); - ACE_UPDATE_NODE_LAYOUT_PROPERTY(FolderStackLayoutProperty, UpperItems, itemId, frameNode); -} - -void FolderStackModelNG::SetAlignment(FrameNode* frameNode, const std::optional& valueOpt) -{ - ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Alignment, valueOpt.value_or(Alignment::CENTER), frameNode); -} - void FolderStackModelNG::SetAlignment(Alignment alignment) { ACE_UPDATE_LAYOUT_PROPERTY(LayoutProperty, Alignment, alignment); @@ -112,8 +76,9 @@ void FolderStackModelNG::SetAutoHalfFold(bool IsAutoHalfFold) } void FolderStackModelNG::SetOnFolderStateChange( - FrameNode* frameNode, std::function&& onChange) + std::function&& onChange) { + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); CHECK_NULL_VOID(frameNode); auto eventHub = frameNode->GetEventHub(); CHECK_NULL_VOID(eventHub); @@ -121,18 +86,18 @@ void FolderStackModelNG::SetOnFolderStateChange( } void FolderStackModelNG::SetOnFolderStateChange( - std::function&& onChange) + FrameNode* frameNode, std::function&& onChange) { - auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); CHECK_NULL_VOID(frameNode); - auto eventHub = frameNode->GetOrCreateEventHub(); + auto eventHub = frameNode->GetEventHub(); CHECK_NULL_VOID(eventHub); eventHub->SetOnFolderStateChange(std::move(onChange)); } void FolderStackModelNG::SetOnHoverStatusChange( - FrameNode* frameNode, std::function&& onChange) + std::function&& onChange) { + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); CHECK_NULL_VOID(frameNode); auto eventHub = frameNode->GetEventHub(); CHECK_NULL_VOID(eventHub); @@ -140,12 +105,12 @@ void FolderStackModelNG::SetOnHoverStatusChange( } void FolderStackModelNG::SetOnHoverStatusChange( - std::function&& onChange) + FrameNode* frameNode, std::function&& onChange) { - auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); CHECK_NULL_VOID(frameNode); - auto eventHub = frameNode->GetOrCreateEventHub(); + auto eventHub = frameNode->GetEventHub(); CHECK_NULL_VOID(eventHub); eventHub->SetOnHoverStatusChange(std::move(onChange)); } + } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/folder_stack/folder_stack_model_ng.h b/frameworks/core/components_ng/pattern/folder_stack/folder_stack_model_ng.h index e37b05b992c446ea2359136e1c3ff74a8c11d1d8..d0eb5e46052908795b69068006d5ec79315cdee4 100644 --- a/frameworks/core/components_ng/pattern/folder_stack/folder_stack_model_ng.h +++ b/frameworks/core/components_ng/pattern/folder_stack/folder_stack_model_ng.h @@ -24,9 +24,6 @@ namespace OHOS::Ace::NG { class ACE_EXPORT FolderStackModelNG : public FolderStackModel { public: void Create(const std::vector& itemId) override; - static RefPtr CreateFrameNode(int32_t nodeId); - static void SetUpdateUpperItems(FrameNode* frameNode, const std::vector& itemId); - static void SetAlignment(FrameNode* frameNode, const std::optional& valueOpt); void SetAlignment(Alignment alignment) override; static void SetOnFolderStateChange( FrameNode* frameNode, std::function&& onChange); diff --git a/frameworks/core/components_ng/pattern/folder_stack/folder_stack_model_ng_static.cpp b/frameworks/core/components_ng/pattern/folder_stack/folder_stack_model_ng_static.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d186fc9cd84545edf10fa398d645a33d4a12cab7 --- /dev/null +++ b/frameworks/core/components_ng/pattern/folder_stack/folder_stack_model_ng_static.cpp @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "core/components_ng/pattern/folder_stack/folder_stack_model_ng_static.h" + +#include "core/components_ng/base/view_stack_processor.h" +#include "core/components_ng/pattern/folder_stack/control_parts_stack_node.h" +#include "core/components_ng/pattern/folder_stack/folder_stack_pattern.h" +#include "core/components_ng/pattern/folder_stack/hover_stack_node.h" +#include "folder_stack_model_ng.h" + + +namespace OHOS::Ace::NG { + +RefPtr FolderStackModelNGStatic::CreateFrameNode(int32_t nodeId) +{ + auto folderStackGroupNode = FolderStackGroupNode::GetOrCreateGroupNode( + V2::FOLDER_STACK_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr(); }); + if (!folderStackGroupNode->GetHoverNode()) { + int32_t hoverId = ElementRegister::GetInstance()->MakeUniqueId(); + auto hoverStackNode = HoverStackNode::GetOrCreateHoverStackNode( + V2::HOVER_STACK_ETS_TAG, hoverId, []() { return AceType::MakeRefPtr(); }); + folderStackGroupNode->AddChild(hoverStackNode); + folderStackGroupNode->SetHoverNode(hoverStackNode); + } + if (!folderStackGroupNode->GetControlPartsStackNode()) { + int32_t controlPartsId = ElementRegister::GetInstance()->MakeUniqueId(); + auto controlPartsNode = ControlPartsStackNode::GetOrCreateControlPartsStackNode(V2::CONTROL_PARTS_STACK_ETS_TAG, + controlPartsId, []() { return AceType::MakeRefPtr(); }); + folderStackGroupNode->AddChild(controlPartsNode); + folderStackGroupNode->SetControlPartsStackNode(controlPartsNode); + } + std::vector itemId; + SetUpdateUpperItems(folderStackGroupNode.GetRawPtr(), itemId); + return folderStackGroupNode; +} + +void FolderStackModelNGStatic::SetUpdateUpperItems(FrameNode* frameNode, const std::vector& itemId) +{ + auto folderStackGroupNode = AceType::DynamicCast(frameNode); + folderStackGroupNode->SetItemId(itemId); + ACE_UPDATE_NODE_LAYOUT_PROPERTY(FolderStackLayoutProperty, UpperItems, itemId, frameNode); +} + +void FolderStackModelNGStatic::SetAlignment(FrameNode* frameNode, const std::optional& valueOpt) +{ + ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, Alignment, valueOpt.value_or(Alignment::CENTER), frameNode); +} + +} diff --git a/frameworks/core/components_ng/pattern/folder_stack/folder_stack_model_ng_static.h b/frameworks/core/components_ng/pattern/folder_stack/folder_stack_model_ng_static.h new file mode 100644 index 0000000000000000000000000000000000000000..b8c8712c6c11d2cc57248726e0bd38ebb92d5df8 --- /dev/null +++ b/frameworks/core/components_ng/pattern/folder_stack/folder_stack_model_ng_static.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FOLDER_STACK_MODEL_NG_STATIC_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FOLDER_STACK_MODEL_NG_STATIC_H + +#include "base/utils/macros.h" +#include "core/components_ng/base/frame_node.h" +#include "core/components_ng/pattern/folder_stack/folder_stack_model.h" + +namespace OHOS::Ace::NG { +class ACE_EXPORT FolderStackModelNGStatic : public FolderStackModel { +public: + static RefPtr CreateFrameNode(int32_t nodeId); + static void SetUpdateUpperItems(FrameNode* frameNode, const std::vector& itemId); + static void SetAlignment(FrameNode* frameNode, const std::optional& valueOpt); +}; +} + +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_FOLDER_STACK_MODEL_NG_STATIC_H diff --git a/frameworks/core/components_ng/pattern/grid_col/grid_col_model_ng_static.cpp b/frameworks/core/components_ng/pattern/grid_col/grid_col_model_ng_static.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1ea0608819ce4f3b5a0ebaea007211b884bf39aa --- /dev/null +++ b/frameworks/core/components_ng/pattern/grid_col/grid_col_model_ng_static.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "core/components_ng/pattern/grid_col/grid_col_model_ng_static.h" + +#include "core/components_ng/base/view_stack_processor.h" +#include "core/components_ng/pattern/grid_col/grid_col_layout_pattern.h" + +namespace OHOS::Ace::NG { + +void GridColModelNGStatic::SetSpan(FrameNode *frameNode, const std::optional& span) +{ + int32_t defaultValue {1}; + V2::GridContainerSize gcSizeValue = (span.has_value()) ? span.value() : V2::GridContainerSize(defaultValue); + ACE_UPDATE_NODE_LAYOUT_PROPERTY(GridColLayoutProperty, Span, gcSizeValue, frameNode); +} + +void GridColModelNGStatic::SetOffset(FrameNode *frameNode, const std::optional& offset) +{ + int32_t defaultValue {0}; + V2::GridContainerSize gcSizeValue = (offset.has_value()) ? offset.value() : V2::GridContainerSize(defaultValue); + ACE_UPDATE_NODE_LAYOUT_PROPERTY(GridColLayoutProperty, Offset, gcSizeValue, frameNode); +} + +void GridColModelNGStatic::SetOrder(FrameNode *frameNode, const std::optional& order) +{ + int32_t defaultValue {0}; + V2::GridContainerSize gcSizeValue = (order.has_value()) ? order.value() : V2::GridContainerSize(defaultValue); + ACE_UPDATE_NODE_LAYOUT_PROPERTY(GridColLayoutProperty, Order, gcSizeValue, frameNode); +} +} \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/grid_col/grid_col_model_ng_static.h b/frameworks/core/components_ng/pattern/grid_col/grid_col_model_ng_static.h new file mode 100644 index 0000000000000000000000000000000000000000..4db7b306a5305f8945408ec72529b100bf00e760 --- /dev/null +++ b/frameworks/core/components_ng/pattern/grid_col/grid_col_model_ng_static.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_GRID_COL_MODEL_NG_STATIC_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_GRID_COL_MODEL_NG_STATIC_H + +#include "core/components_ng/pattern/grid_col/grid_col_model.h" +#include "core/components_ng/base/frame_node.h" + +namespace OHOS::Ace::NG { + +class ACE_EXPORT GridColModelNGStatic : public GridColModel { +public: + static void SetSpan(FrameNode* frameNode, const std::optional& span); + static void SetOffset(FrameNode* frameNode, const std::optional& offset); + static void SetOrder(FrameNode* frameNode, const std::optional& order); +}; +} // namespace OHOS::Ace::NG + +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_GRID_COL_MODEL_NG_STATIC_H \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/grid_row/grid_row_model_ng_static.cpp b/frameworks/core/components_ng/pattern/grid_row/grid_row_model_ng_static.cpp new file mode 100644 index 0000000000000000000000000000000000000000..67d671db9cf546df0517428a7a0417557a74974d --- /dev/null +++ b/frameworks/core/components_ng/pattern/grid_row/grid_row_model_ng_static.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "grid_row_model_ng_static.h" + +#include "grid_row_layout_pattern.h" + +namespace OHOS::Ace::NG { + +void GridRowModelNGStatic::SetAlignItems(FrameNode* frameNode, const std::optional& alignItem) +{ + CHECK_NULL_VOID(frameNode); + if (alignItem.has_value()) { + auto layoutProperty = frameNode->GetLayoutProperty(); + CHECK_NULL_VOID(layoutProperty); + layoutProperty->UpdateAlignItems(alignItem.value()); + ACE_UPDATE_NODE_LAYOUT_PROPERTY(GridRowLayoutProperty, AlignItems, alignItem.value(), frameNode); + } else { + ACE_RESET_NODE_LAYOUT_PROPERTY(GridRowLayoutProperty, AlignItems, frameNode); + } +} + +void GridRowModelNGStatic::SetDirection(FrameNode* frameNode, const std::optional& direction) +{ + CHECK_NULL_VOID(frameNode); + ACE_UPDATE_NODE_LAYOUT_PROPERTY(GridRowLayoutProperty, Direction, + direction.has_value()? direction.value(): V2::GridRowDirection::Row, frameNode); +} +} \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/grid_row/grid_row_model_ng_static.h b/frameworks/core/components_ng/pattern/grid_row/grid_row_model_ng_static.h new file mode 100644 index 0000000000000000000000000000000000000000..eea3b9125d54096dd8c9a20d86c4c5ef51474f9b --- /dev/null +++ b/frameworks/core/components_ng/pattern/grid_row/grid_row_model_ng_static.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_GRID_ROW_MODEL_NG_STATIC_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_GRID_ROW_MODEL_NG_STATIC_H + +#include "core/components_ng/pattern/grid_row/grid_row_model.h" +#include "core/components_ng/base/frame_node.h" + +namespace OHOS::Ace::NG { + +class ACE_EXPORT GridRowModelNGStatic : public GridRowModel { +public: + static void SetAlignItems(FrameNode* frameNode, const std::optional& alignItem); + static void SetDirection(FrameNode* frameNode, const std::optional& direction); +}; +} // namespace OHOS::Ace::NG + +#endif \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/linear_layout/column_model_ng.cpp b/frameworks/core/components_ng/pattern/linear_layout/column_model_ng.cpp index 1ce6125db6e28cc7dd4f3f89b223f2d4027868d4..0f87f0b467102a913801a5caa72874f199aff0da 100644 --- a/frameworks/core/components_ng/pattern/linear_layout/column_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/linear_layout/column_model_ng.cpp @@ -15,7 +15,6 @@ #include "core/components_ng/pattern/linear_layout/column_model_ng.h" -#include "core/common/resource/resource_parse_utils.h" #include "core/components_ng/base/view_stack_processor.h" #include "core/components_ng/pattern/linear_layout/linear_layout_pattern.h" @@ -37,52 +36,13 @@ void ColumnModelNG::Create(const std::optional& space, AlignDeclarati } } -void ColumnModelNG::Create(const RefPtr& spaceResObj, AlignDeclaration*, const std::string&) -{ - auto* stack = ViewStackProcessor::GetInstance(); - auto nodeId = stack->ClaimNodeId(); - ACE_LAYOUT_SCOPED_TRACE("Create[%s][self:%d]", V2::COLUMN_ETS_TAG, nodeId); - auto frameNode = FrameNode::GetOrCreateFrameNode( - V2::COLUMN_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr(true); }); - stack->Push(frameNode); - ACE_UPDATE_LAYOUT_PROPERTY(LinearLayoutProperty, FlexDirection, FlexDirection::COLUMN); - - CHECK_NULL_VOID(spaceResObj); - auto pattern = frameNode->GetPattern(); - CHECK_NULL_VOID(pattern); - auto&& updateFunc = [weak = AceType::WeakClaim(AceType::RawPtr(frameNode))]( - const RefPtr& resObj) { - auto frameNode = weak.Upgrade(); - CHECK_NULL_VOID(frameNode); - auto pattern = frameNode->GetPattern(); - CHECK_NULL_VOID(pattern); - std::string columnString = pattern->GetResCacheMapByKey("column.space"); - CalcDimension value; - if (columnString.empty()) { - ResourceParseUtils::ParseResDimensionVp(resObj, value); - pattern->AddResCache("column.space", value.ToString()); - } else { - value = StringUtils::StringToCalcDimension(columnString); - } - if (GreatOrEqual(value.Value(), 0.0)) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, Space, value, frameNode); - frameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE); - } - }; - pattern->AddResObj("column.space", spaceResObj, std::move(updateFunc)); - CalcDimension value; - ResourceParseUtils::ParseResDimensionVp(spaceResObj, value); - if (GreatOrEqual(value.Value(), 0.0)) { - ACE_UPDATE_LAYOUT_PROPERTY(LinearLayoutProperty, Space, value); - } -} - void ColumnModelNG::SetSpace(FrameNode* frameNode, const std::optional& space) { - if (space && GreatOrEqual(space->Value(), 0.0)) { + CHECK_NULL_VOID(space); + if (GreatOrEqual(space->Value(), 0.0)) { ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, Space, space.value(), frameNode); } else { - ACE_RESET_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, Space, frameNode); + LOGE("Column: the space value is illegal due to space is less than zero"); } } @@ -117,22 +77,14 @@ void ColumnModelNG::SetIsReverse(FrameNode* frameNode, bool isReverse) ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, IsReverse, isReverse, frameNode); } -void ColumnModelNG::SetJustifyContent(FrameNode* frameNode, const std::optional& valueOpt) +void ColumnModelNG::SetJustifyContent(FrameNode* frameNode, FlexAlign flexAlign) { - if (valueOpt) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, MainAxisAlign, valueOpt.value(), frameNode); - } else { - ACE_RESET_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, MainAxisAlign, frameNode); - } + ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, MainAxisAlign, flexAlign, frameNode); } -void ColumnModelNG::SetAlignItems(FrameNode* frameNode, const std::optional& valueOpt) +void ColumnModelNG::SetAlignItems(FrameNode* frameNode, FlexAlign flexAlign) { - if (valueOpt) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, CrossAxisAlign, valueOpt.value(), frameNode); - } else { - ACE_RESET_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, CrossAxisAlign, frameNode); - } + ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, CrossAxisAlign, flexAlign, frameNode); } FlexAlign ColumnModelNG::GetJustifyContent(FrameNode* frameNode) diff --git a/frameworks/core/components_ng/pattern/linear_layout/column_model_ng.h b/frameworks/core/components_ng/pattern/linear_layout/column_model_ng.h index 389974bd84af4b57536794f2b48386ceac8c8fad..8afd2d3f9b08586eae5e52458ad86220c20a4017 100644 --- a/frameworks/core/components_ng/pattern/linear_layout/column_model_ng.h +++ b/frameworks/core/components_ng/pattern/linear_layout/column_model_ng.h @@ -25,15 +25,13 @@ namespace OHOS::Ace::NG { class ACE_EXPORT ColumnModelNG : public ColumnModel { public: void Create(const std::optional& space, AlignDeclaration*, const std::string& tag) override; - void Create( - const RefPtr& spaceResObj, AlignDeclaration* declaration, const std::string& tag) override; void SetAlignItems(FlexAlign flexAlign) override; void SetJustifyContent(FlexAlign flexAlign) override; void SetIsReverse(bool isReverse) override; void CreateWithWrap() override {} static void SetSpace(FrameNode* frameNode, const std::optional& space); - static void SetJustifyContent(FrameNode* frameNode, const std::optional& valueOpt); - static void SetAlignItems(FrameNode* frameNode, const std::optional& valueOpt); + static void SetJustifyContent(FrameNode* frameNode, FlexAlign flexAlign); + static void SetAlignItems(FrameNode* frameNode, FlexAlign flexAlign); static void SetIsReverse(FrameNode* frameNode, bool isReverse); static RefPtr CreateFrameNode(int32_t nodeId); static FlexAlign GetJustifyContent(FrameNode* frameNode); diff --git a/frameworks/core/components_ng/pattern/linear_layout/column_model_ng_static.cpp b/frameworks/core/components_ng/pattern/linear_layout/column_model_ng_static.cpp new file mode 100644 index 0000000000000000000000000000000000000000..21556805552a99156da7bdd0448b76cee1cf3700 --- /dev/null +++ b/frameworks/core/components_ng/pattern/linear_layout/column_model_ng_static.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "core/components_ng/pattern/linear_layout/column_model_ng_static.h" + +#include "core/components_ng/base/view_stack_processor.h" +#include "core/components_ng/pattern/linear_layout/linear_layout_pattern.h" + +namespace OHOS::Ace::NG { + +void ColumnModelNGStatic::SetSpace(FrameNode* frameNode, const std::optional& space) +{ + if (space && GreatOrEqual(space->Value(), 0.0)) { + ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, Space, space.value(), frameNode); + } else { + ACE_RESET_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, Space, frameNode); + } +} + +void ColumnModelNGStatic::SetJustifyContent(FrameNode* frameNode, const std::optional& valueOpt) +{ + if (valueOpt) { + ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, MainAxisAlign, valueOpt.value(), frameNode); + } else { + ACE_RESET_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, MainAxisAlign, frameNode); + } +} + +void ColumnModelNGStatic::SetAlignItems(FrameNode* frameNode, const std::optional& valueOpt) +{ + if (valueOpt) { + ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, CrossAxisAlign, valueOpt.value(), frameNode); + } else { + ACE_RESET_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, CrossAxisAlign, frameNode); + } +} +} // namespace OHOS::AceL::NG diff --git a/frameworks/core/components_ng/pattern/linear_layout/column_model_ng_static.h b/frameworks/core/components_ng/pattern/linear_layout/column_model_ng_static.h new file mode 100644 index 0000000000000000000000000000000000000000..4653e152c321f5595c6092d8fd3d50c033af3dc2 --- /dev/null +++ b/frameworks/core/components_ng/pattern/linear_layout/column_model_ng_static.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_LINEAR_LAYOUT_COLUMN_MODEL_NG_STATIC_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_LINEAR_LAYOUT_COLUMN_MODEL_NG_STATIC_H + +#include "base/utils/macros.h" +#include "core/components_ng/base/frame_node.h" +#include "core/components_ng/pattern/linear_layout/column_model.h" + +namespace OHOS::Ace::NG { + +class ACE_EXPORT ColumnModelNGStatic : public ColumnModel { +public: + static void SetSpace(FrameNode* frameNode, const std::optional& space); + static void SetJustifyContent(FrameNode* frameNode, const std::optional& valueOpt); + static void SetAlignItems(FrameNode* frameNode, const std::optional& valueOpt); +}; + +} // namespace OHOS::Ace::NG +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_LINEAR_LAYOUT_COLUMN_MODEL_NG_H diff --git a/frameworks/core/components_ng/pattern/linear_layout/row_model_ng.cpp b/frameworks/core/components_ng/pattern/linear_layout/row_model_ng.cpp index 1699dfbd8924aba46c61adb243a994229c0219a7..179ef1b899592aae3ef7f888d6dbb169c6592841 100644 --- a/frameworks/core/components_ng/pattern/linear_layout/row_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/linear_layout/row_model_ng.cpp @@ -15,7 +15,6 @@ #include "core/components_ng/pattern/linear_layout/row_model_ng.h" -#include "core/common/resource/resource_parse_utils.h" #include "core/components_ng/base/view_stack_processor.h" #include "core/components_ng/pattern/linear_layout/linear_layout_pattern.h" @@ -37,50 +36,8 @@ void RowModelNG::Create(const std::optional& space, AlignDeclaration* } } -void RowModelNG::Create(const RefPtr& spaceResObj, AlignDeclaration*, const std::string&) -{ - auto* stack = ViewStackProcessor::GetInstance(); - auto nodeId = stack->ClaimNodeId(); - ACE_LAYOUT_SCOPED_TRACE("Create[%s][self:%d]", V2::ROW_ETS_TAG, nodeId); - auto frameNode = FrameNode::GetOrCreateFrameNode( - V2::ROW_ETS_TAG, nodeId, []() { return AceType::MakeRefPtr(false); }); - stack->Push(frameNode); - ACE_UPDATE_LAYOUT_PROPERTY(LinearLayoutProperty, FlexDirection, FlexDirection::ROW); - - CHECK_NULL_VOID(spaceResObj); - auto pattern = frameNode->GetPattern(); - CHECK_NULL_VOID(pattern); - auto&& updateFunc = [weak = AceType::WeakClaim(AceType::RawPtr(frameNode))]( - const RefPtr& resObj) { - auto frameNode = weak.Upgrade(); - CHECK_NULL_VOID(frameNode); - auto pattern = frameNode->GetPattern(); - CHECK_NULL_VOID(pattern); - std::string columnString = pattern->GetResCacheMapByKey("row.space"); - CalcDimension value; - if (columnString.empty()) { - ResourceParseUtils::ParseResDimensionVp(resObj, value); - pattern->AddResCache("row.space", value.ToString()); - } else { - value = StringUtils::StringToCalcDimension(columnString); - } - if (GreatOrEqual(value.Value(), 0.0)) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, Space, value, frameNode); - frameNode->MarkDirtyNode(PROPERTY_UPDATE_MEASURE); - } - }; - updateFunc(spaceResObj); - pattern->AddResObj("row.space", spaceResObj, std::move(updateFunc)); - CalcDimension value; - ResourceParseUtils::ParseResDimensionVp(spaceResObj, value); - if (GreatOrEqual(value.Value(), 0.0)) { - ACE_UPDATE_LAYOUT_PROPERTY(LinearLayoutProperty, Space, value); - } -} - void RowModelNG::SetSpace(FrameNode* frameNode, const std::optional& space) { - CHECK_NULL_VOID(frameNode); CHECK_NULL_VOID(space); if (GreatOrEqual(space->Value(), 0.0)) { ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, Space, space.value(), frameNode); @@ -115,34 +72,21 @@ void RowModelNG::SetIsReverse(bool isReverse) ACE_UPDATE_LAYOUT_PROPERTY(FlexLayoutProperty, IsReverse, isReverse); } -void RowModelNG::SetIsReverse(FrameNode* frameNode, const std::optional isReverse) +void RowModelNG::SetIsReverse(FrameNode* frameNode, bool isReverse) { - CHECK_NULL_VOID(frameNode); - if (isReverse.has_value()) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, IsReverse, isReverse.value(), frameNode); - } else { - ACE_RESET_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, IsReverse, frameNode); - } + ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, IsReverse, isReverse, frameNode); } -void RowModelNG::SetJustifyContent(FrameNode* frameNode, const std::optional& flexAlign) +void RowModelNG::SetJustifyContent(FrameNode* frameNode, FlexAlign flexAlign) { CHECK_NULL_VOID(frameNode); - if (flexAlign.has_value()) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, MainAxisAlign, flexAlign.value(), frameNode); - } else { - ACE_RESET_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, MainAxisAlign, frameNode); - } + ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, MainAxisAlign, flexAlign, frameNode); } -void RowModelNG::SetAlignItems(FrameNode* frameNode, const std::optional& flexAlign) +void RowModelNG::SetAlignItems(FrameNode* frameNode, FlexAlign flexAlign) { CHECK_NULL_VOID(frameNode); - if (flexAlign.has_value()) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, CrossAxisAlign, flexAlign.value(), frameNode); - } else { - ACE_RESET_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, CrossAxisAlign, frameNode); - } + ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, CrossAxisAlign, flexAlign, frameNode); } FlexAlign RowModelNG::GetJustifyContent(FrameNode* frameNode) diff --git a/frameworks/core/components_ng/pattern/linear_layout/row_model_ng.h b/frameworks/core/components_ng/pattern/linear_layout/row_model_ng.h index 31f59e4362056e73bdf7d55d2eda526fc1fb7c33..5bcc5ebb9174b6440373447533168550fa24a4fe 100644 --- a/frameworks/core/components_ng/pattern/linear_layout/row_model_ng.h +++ b/frameworks/core/components_ng/pattern/linear_layout/row_model_ng.h @@ -25,16 +25,14 @@ namespace OHOS::Ace::NG { class ACE_EXPORT RowModelNG : public RowModel { public: void Create(const std::optional& space, AlignDeclaration*, const std::string& tag) override; - void Create( - const RefPtr& spaceResObj, AlignDeclaration* declaration, const std::string& tag) override; void SetAlignItems(FlexAlign flexAlign) override; void SetJustifyContent(FlexAlign flexAlign) override; void SetIsReverse(bool isReverse) override; void CreateWithWrap() override {} static void SetSpace(FrameNode* frameNode, const std::optional& space); - static void SetJustifyContent(FrameNode* frameNode, const std::optional& flexAlign); - static void SetAlignItems(FrameNode* frameNode, const std::optional& flexAlign); - static void SetIsReverse(FrameNode* frameNode, const std::optional isReverse); + static void SetJustifyContent(FrameNode* frameNode, FlexAlign flexAlign); + static void SetAlignItems(FrameNode* frameNode, FlexAlign flexAlign); + static void SetIsReverse(FrameNode* frameNode, bool isReverse); static RefPtr CreateFrameNode(int32_t nodeId); static FlexAlign GetJustifyContent(FrameNode* frameNode); static FlexAlign GetAlignItems(FrameNode* frameNode); diff --git a/frameworks/core/components_ng/pattern/linear_layout/row_model_ng_static.cpp b/frameworks/core/components_ng/pattern/linear_layout/row_model_ng_static.cpp new file mode 100644 index 0000000000000000000000000000000000000000..08ab7b076c6ca1aad21522cd2a38e544b2dc8ff5 --- /dev/null +++ b/frameworks/core/components_ng/pattern/linear_layout/row_model_ng_static.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "core/components_ng/pattern/linear_layout/row_model_ng_static.h" + +#include "core/components_ng/base/view_stack_processor.h" +#include "core/components_ng/pattern/linear_layout/linear_layout_pattern.h" + +namespace OHOS::Ace::NG { + +void RowModelNGStatic::SetIsReverse(FrameNode* frameNode, const std::optional isReverse) +{ + CHECK_NULL_VOID(frameNode); + if (isReverse.has_value()) { + ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, IsReverse, isReverse.value(), frameNode); + } else { + ACE_RESET_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, IsReverse, frameNode); + } +} + +void RowModelNGStatic::SetJustifyContent(FrameNode* frameNode, const std::optional& flexAlign) +{ + CHECK_NULL_VOID(frameNode); + if (flexAlign.has_value()) { + ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, MainAxisAlign, flexAlign.value(), frameNode); + } else { + ACE_RESET_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, MainAxisAlign, frameNode); + } +} + +void RowModelNGStatic::SetAlignItems(FrameNode* frameNode, const std::optional& flexAlign) +{ + CHECK_NULL_VOID(frameNode); + if (flexAlign.has_value()) { + ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, CrossAxisAlign, flexAlign.value(), frameNode); + } else { + ACE_RESET_NODE_LAYOUT_PROPERTY(LinearLayoutProperty, CrossAxisAlign, frameNode); + } +} +} \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/linear_layout/row_model_ng_static.h b/frameworks/core/components_ng/pattern/linear_layout/row_model_ng_static.h new file mode 100644 index 0000000000000000000000000000000000000000..8c079e66dd49baf64687da71b4f5397c23d188a2 --- /dev/null +++ b/frameworks/core/components_ng/pattern/linear_layout/row_model_ng_static.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_LINEAR_LAYOUT_ROW_MODEL_NG_STATIC_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_LINEAR_LAYOUT_ROW_MODEL_NG_STATIC_H + +#include "base/utils/macros.h" +#include "core/components_ng/base/frame_node.h" +#include "core/components_ng/pattern/linear_layout/row_model.h" + +namespace OHOS::Ace::NG { + +class ACE_EXPORT RowModelNGStatic : public RowModel { +public: + static void SetJustifyContent(FrameNode* frameNode, const std::optional& flexAlign); + static void SetAlignItems(FrameNode* frameNode, const std::optional& flexAlign); + static void SetIsReverse(FrameNode* frameNode, const std::optional isReverse); +}; +} // namespace OHOS::Ace::NG +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_LINEAR_LAYOUT_ROW_MODEL_NG_STATIC_H \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/linear_split/linear_split_model_ng_static.cpp b/frameworks/core/components_ng/pattern/linear_split/linear_split_model_ng_static.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3baa5d8c6e7a68e82792eff1094a4a2505e9021c --- /dev/null +++ b/frameworks/core/components_ng/pattern/linear_split/linear_split_model_ng_static.cpp @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "core/components_ng/pattern/linear_split/linear_split_model_ng_static.h" + +#include "core/components_ng/base/view_stack_processor.h" +#include "core/components_ng/pattern/linear_split/linear_split_pattern.h" + +namespace OHOS::Ace::NG { + +RefPtr LinearSplitModelNGStatic::CreateFrameNode(int32_t nodeId, SplitType splitType) +{ + std::string tag = splitType == SplitType::ROW_SPLIT ? V2::ROW_SPLIT_ETS_TAG : V2::COLUMN_SPLIT_ETS_TAG; + auto frameNode = FrameNode::GetOrCreateFrameNode( + tag, nodeId, [splitType]() { return AceType::MakeRefPtr(splitType); }); + return frameNode; +} + +void LinearSplitModelNGStatic::SetDivider(FrameNode* frameNode, NG::SplitType splitType, + const std::optional& optDivider) +{ + CHECK_NULL_VOID(frameNode); + if (optDivider) { + ACE_UPDATE_NODE_LAYOUT_PROPERTY(LinearSplitLayoutProperty, Divider, optDivider.value(), frameNode); + } else { + ACE_RESET_NODE_LAYOUT_PROPERTY(LinearSplitLayoutProperty, Divider, frameNode); + } +} +} \ No newline at end of file diff --git a/frameworks/core/components_ng/pattern/linear_split/linear_split_model_ng_static.h b/frameworks/core/components_ng/pattern/linear_split/linear_split_model_ng_static.h new file mode 100644 index 0000000000000000000000000000000000000000..2b2a43658ed6873814ed645f330bc0c2afeabd49 --- /dev/null +++ b/frameworks/core/components_ng/pattern/linear_split/linear_split_model_ng_static.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_LINEAR_SPLIT_LINEAR_SPLIT_MODEL_NG_STATIC_H +#define FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_LINEAR_SPLIT_LINEAR_SPLIT_MODEL_NG_STATIC_H + +#include "core/components_ng/base/frame_node.h" +#include "core/components_ng/pattern/linear_split/linear_split_model.h" + +namespace OHOS::Ace::NG { + +class ACE_EXPORT LinearSplitModelNGStatic : public OHOS::Ace::LinearSplitModel { +public: + static RefPtr CreateFrameNode(int32_t nodeId, SplitType splitType); + static void SetDivider(FrameNode* frameNode, NG::SplitType splitType, + const std::optional& optDivider); +}; +} // namespace OHOS::Ace::NG + +#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_LINEAR_SPLIT_LINEAR_SPLIT_MODEL_NG_STATIC_H + diff --git a/frameworks/core/components_ng/pattern/relative_container/relative_container_layout_property.h b/frameworks/core/components_ng/pattern/relative_container/relative_container_layout_property.h index a60e8858de4d014b7672e2778887737f84a8b1ed..e9de10b093136067800c7f6f1441d13cb4a638f7 100644 --- a/frameworks/core/components_ng/pattern/relative_container/relative_container_layout_property.h +++ b/frameworks/core/components_ng/pattern/relative_container/relative_container_layout_property.h @@ -49,90 +49,6 @@ public: ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(Barrier, std::vector, PROPERTY_UPDATE_MEASURE); ACE_DEFINE_PROPERTY_ITEM_WITHOUT_GROUP(Guideline, std::vector, PROPERTY_UPDATE_MEASURE); - - std::unique_ptr GuidelineInfoToJsonObject(GuidelineInfo& info) const - { - auto json = JsonUtil::Create(true); - json->Put("id", info.id.c_str()); - std::string direction; - if (info.direction == LineDirection::VERTICAL) { - direction = "Axis.Vertical"; - } - if (info.direction == LineDirection::HORIZONTAL) { - direction = "Axis.Horizontal"; - } - json->Put("direction", direction.c_str()); - auto jsonPos = JsonUtil::Create(true); - jsonPos->Put("start", info.start->ToString().c_str()); - jsonPos->Put("end", info.end->ToString().c_str()); - json->Put("position", jsonPos); - - return json; - } - - std::unique_ptr GuidelineToJsonObject() const - { - auto array = JsonUtil::CreateArray(); - if (!HasGuideline()) { - return array; - } - auto value = GetGuidelineValue(); - for (int i = 0; i < value.size(); i++) - { - array->Put(GuidelineInfoToJsonObject(value[i])); - } - return array; - } - - std::string BarrierDirectionToString(BarrierDirection value) const - { - switch (value) - { - case BarrierDirection::LEFT: return "BarrierDirection.LEFT"; - case BarrierDirection::RIGHT: return "BarrierDirection.RIGHT"; - case BarrierDirection::TOP: return "BarrierDirection.TOP"; - case BarrierDirection::BOTTOM: return "BarrierDirection.BOTTOM"; - case BarrierDirection::START: return "BarrierDirection.START"; - case BarrierDirection::END: return "BarrierDirection.END"; - } - } - - std::unique_ptr BarrierInfoToJsonObject(const BarrierInfo& info) const - { - auto json = JsonUtil::Create(true); - json->Put("id", info.id.c_str()); - json->Put("direction", BarrierDirectionToString(info.direction).c_str()); - auto array = JsonUtil::CreateArray(); - for (int i = 0; i < info.referencedId.size(); i++) { - array->Put(std::to_string(i).c_str(), info.referencedId[i].c_str()); - } - json->Put("referencedId", array); - return json; - } - - std::unique_ptr BarrierToJsonObject() const - { - auto array = JsonUtil::CreateArray(); - if (!HasBarrier()) { - return array; - } - auto value = GetBarrierValue(); - for (int i = 0; i < value.size(); i++) { - array->Put(BarrierInfoToJsonObject(value[i])); - } - return array; - } - - void ToJsonValue(std::unique_ptr& json, const InspectorFilter& filter) const override - { - LayoutProperty::ToJsonValue(json, filter); - /* no fixed attr below, just return */ - if (filter.IsFastFilter()) { - return; - } - json->Put("barrier", BarrierToJsonObject()); - json->Put("guideLine", GuidelineToJsonObject()); - } }; } // namespace OHOS::Ace::NG