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 6abe246273c5f3961edee3463ccca1356a1ed8d6..a07d2a5e7e037348c5660be6cbad30ee28dcf737 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", @@ -647,6 +654,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 c3cafa7b13f5ca915c74f1ff5e5869248f473051..572c045eb2c7c58683582f646fcc7a8d7f4b2c89 100644 --- a/frameworks/core/components_ng/pattern/divider/divider_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/divider/divider_model_ng.cpp @@ -101,31 +101,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, bool isSetByTheme) +void DividerModelNG::SetDividerColor(FrameNode* frameNode, const Color& color, bool isSetByTheme) { - 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); if (SystemProperties::ConfigChangePerform()) { ACE_UPDATE_NODE_PAINT_PROPERTY(DividerRenderProperty, DividerColorSetByTheme, isSetByTheme, frameNode); } 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 00372bab4bd5b7a6f16309fbc304ed46a8179ee9..45aedebd5d7afe3aa4196475569a56a4aa15ce52 100644 --- a/frameworks/core/components_ng/pattern/divider/divider_model_ng.h +++ b/frameworks/core/components_ng/pattern/divider/divider_model_ng.h @@ -32,9 +32,9 @@ public: void ResetDividerColor() override; void ResetResObj(const std::string& key) 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, bool isSetByUser); + 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, bool isSetByUser); static void SetDividerColor(FrameNode* frameNode, const RefPtr& resObj, bool isSetByUser); static void SetVertical(FrameNode* frameNode, const bool& value); static void ResetResObj(FrameNode* frameNode, const std::string& key); 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..2fb0eca101ab99aac40ad19868c9656baffabf5a 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,36 +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); -} - -void FlexModelNG::SetWidthLayoutPolicy(FrameNode* frameNode, uint8_t widthLayoutPolicy) -{ - ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, WidthLayoutPolicy, widthLayoutPolicy, frameNode); -} - -void FlexModelNG::SetHeightLayoutPolicy(uint8_t heightLayoutPolicy) -{ - ACE_UPDATE_LAYOUT_PROPERTY(FlexLayoutProperty, HeightLayoutPolicy, heightLayoutPolicy); -} - -void FlexModelNG::SetHeightLayoutPolicy(FrameNode* frameNode, uint8_t heightLayoutPolicy) -{ - ACE_UPDATE_NODE_LAYOUT_PROPERTY(FlexLayoutProperty, HeightLayoutPolicy, heightLayoutPolicy, frameNode); -} - int FlexModelNG::GetFlexWrap(FrameNode* frameNode) { int value = 0; @@ -386,7 +299,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 +307,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..13277f4079ed84f4c62950f28d102d8713d0566e 100644 --- a/frameworks/core/components_ng/pattern/flex/flex_model_ng.h +++ b/frameworks/core/components_ng/pattern/flex/flex_model_ng.h @@ -49,25 +49,15 @@ public: void SetJustifyContent(int32_t value) override; void SetAlignContent(int32_t value) override; - void SetWidthLayoutPolicy(uint8_t widthLayoutPolicy) override; - void SetHeightLayoutPolicy(uint8_t heightLayoutPolicy) override; static RefPtr CreateFrameNode(int32_t nodeId); 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); static int GetFlexWrap(FrameNode* frameNode); static int GetFlexDirection(FrameNode* frameNode); 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..adcb4554f897d9b7bb9fa21b56e27f993aeaf45a --- /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..86f1cae6b636d864dddf050867c791df1bc24cf0 --- /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..44aba02c6e68c04af205fb13c19528d3f6bbe89f --- /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 4ba10fa296c8f201a4aca940be7e73f67db6e5e2..152d9921cc25ec83be40df51b03ad33d18150999 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 @@ -37,52 +37,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"); } } @@ -161,22 +122,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 c351c4f541e96a7342e5562fcae5816229c33317..d391aa33d4e0a65137be49aa998ae324001f6994 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,16 +25,14 @@ 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 SetSpace(FrameNode* frameNode, const RefPtr& spaceResObj); - 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..bb45c7d214a18480d929976d090544ee2ee6b1aa --- /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 defee5ccb717c9bc7f1eff87e77b3c80e2297a22..79ef3603676e7445af2c46625407718d3e29d0df 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 @@ -37,50 +37,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); @@ -160,34 +118,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 822d4b1687f47a0c8e8b164c3adbe96af11bae43..64e309f6f3c3c7a1e4d8c7c0a71c145d38aaa494 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,17 +25,15 @@ 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 SetSpace(FrameNode* frameNode, const RefPtr& spaceResObj); - 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