diff --git a/frameworks/core/components_ng/base/view_abstract_model_static.cpp b/frameworks/core/components_ng/base/view_abstract_model_static.cpp index 4520d0e50d62803d696fc9725cd68333549d4c02..15c9774e41d1ab6e964b46af4aa02e06b0d27742 100644 --- a/frameworks/core/components_ng/base/view_abstract_model_static.cpp +++ b/frameworks/core/components_ng/base/view_abstract_model_static.cpp @@ -1402,13 +1402,13 @@ void ViewAbstractModelStatic::SetFocusScopeId(FrameNode* frameNode, const std::s } void ViewAbstractModelStatic::SetFocusScopePriority( - FrameNode* frameNode, const std::string& focusScopeId, const std::optional& focusPriority) + FrameNode* frameNode, const std::optional& focusScopeId, const std::optional& focusPriority) { CHECK_NULL_VOID(frameNode); auto focusHub = frameNode->GetOrCreateFocusHub(); CHECK_NULL_VOID(focusHub); auto proirity = focusPriority.value_or(static_cast(FocusPriority::AUTO)); - focusHub->SetFocusScopePriority(focusScopeId, proirity); + focusHub->SetFocusScopePriority(focusScopeId.value_or(""), proirity); } void ViewAbstractModelStatic::SetGrayScale(FrameNode* frameNode, const std::optional& grayScale) diff --git a/frameworks/core/components_ng/base/view_abstract_model_static.h b/frameworks/core/components_ng/base/view_abstract_model_static.h index aec9865d6f85a5083c5c25b2667ad1e94000fe81..c52891edd6973611aaa5852afc764231cd47afbd 100644 --- a/frameworks/core/components_ng/base/view_abstract_model_static.h +++ b/frameworks/core/components_ng/base/view_abstract_model_static.h @@ -298,8 +298,8 @@ public: static void SetFocusBoxStyle(FrameNode* frameNode, const std::optional& style); static void SetFocusScopeId(FrameNode* frameNode, const std::string& focusScopeId, const std::optional& isGroup, const std::optional& arrowKeyStepOut); - static void SetFocusScopePriority( - FrameNode* frameNode, const std::string& focusScopeId, const std::optional& focusPriority); + static void SetFocusScopePriority(FrameNode* frameNode, const std::optional& focusScopeId, + const std::optional& focusPriority); static void SetGrayScale(FrameNode* frameNode, const std::optional& grayScale); static void SetColorBlend(FrameNode* frameNode, const std::optional& colorBlend); static void SetUseShadowBatching(FrameNode* frameNode, std::optional useShadowBatching); diff --git a/frameworks/core/components_ng/pattern/button/button_model_static.cpp b/frameworks/core/components_ng/pattern/button/button_model_static.cpp index 69fc4964f680b518a5a989f0199eac9814191c0f..65af0acfbb87b21d49c2973c7507fa296ac36066 100644 --- a/frameworks/core/components_ng/pattern/button/button_model_static.cpp +++ b/frameworks/core/components_ng/pattern/button/button_model_static.cpp @@ -263,7 +263,7 @@ void ButtonModelStatic::SetStateEffect(FrameNode* frameNode, const std::optional if (stateEffect) { buttonEventHub->SetStateEffect(stateEffect.value()); } else { - buttonEventHub->SetStateEffect(false); + buttonEventHub->SetStateEffect(true); } } diff --git a/frameworks/core/components_ng/pattern/image/image_model_static.cpp b/frameworks/core/components_ng/pattern/image/image_model_static.cpp index 02030706827fd2162bb062eaa67a9de96ada5f06..dc23bda22c523f3e5fd20a834db59aed52dc6d08 100644 --- a/frameworks/core/components_ng/pattern/image/image_model_static.cpp +++ b/frameworks/core/components_ng/pattern/image/image_model_static.cpp @@ -161,7 +161,7 @@ void ImageModelStatic::SetImageInterpolation( void ImageModelStatic::SetOrientation(FrameNode* frameNode, const std::optional& orientation) { - const auto orientationValue = orientation.value_or(ImageRotateOrientation::AUTO); + const auto orientationValue = orientation.value_or(ImageRotateOrientation::UP); ACE_UPDATE_NODE_LAYOUT_PROPERTY(ImageLayoutProperty, ImageRotateOrientation, orientationValue, frameNode); auto pattern = frameNode->GetPattern(); CHECK_NULL_VOID(pattern); diff --git a/frameworks/core/components_ng/pattern/indexer/indexer_model_static.cpp b/frameworks/core/components_ng/pattern/indexer/indexer_model_static.cpp index 3b4e8a804f0a58081e38dad8259f2b15c8e81dca..3a9fb149258950da22bfe09d408a30c262e9025d 100644 --- a/frameworks/core/components_ng/pattern/indexer/indexer_model_static.cpp +++ b/frameworks/core/components_ng/pattern/indexer/indexer_model_static.cpp @@ -198,14 +198,16 @@ void IndexerModelStatic::SetFontWeight(FrameNode* frameNode, const FontWeight we ACE_UPDATE_NODE_LAYOUT_PROPERTY(IndexerLayoutProperty, FontWeight, weight, frameNode); } -void IndexerModelStatic::SetItemSize(FrameNode* frameNode, const Dimension& itemSize) +void IndexerModelStatic::SetItemSize(FrameNode* frameNode, const std::optional& itemSize) { - auto itemSizeValue = itemSize.Value(); + const auto defaultValue = Dimension(INDEXER_ITEM_SIZE, DimensionUnit::VP); + auto value = itemSize.value_or(defaultValue); + auto itemSizeValue = value.Value(); if (itemSizeValue > 0) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(IndexerLayoutProperty, ItemSize, itemSize, frameNode); + ACE_UPDATE_NODE_LAYOUT_PROPERTY(IndexerLayoutProperty, ItemSize, value, frameNode); } else { ACE_UPDATE_NODE_LAYOUT_PROPERTY( - IndexerLayoutProperty, ItemSize, Dimension(INDEXER_ITEM_SIZE, DimensionUnit::VP), frameNode); + IndexerLayoutProperty, ItemSize, defaultValue, frameNode); } } @@ -229,9 +231,9 @@ void IndexerModelStatic::SetPopupPositionY(FrameNode* frameNode, const std::opti } } -void IndexerModelStatic::SetAutoCollapse(FrameNode* frameNode, bool autoCollapse) +void IndexerModelStatic::SetAutoCollapse(FrameNode* frameNode, const std::optional& autoCollapse) { - ACE_UPDATE_NODE_LAYOUT_PROPERTY(IndexerLayoutProperty, AutoCollapse, autoCollapse, frameNode); + ACE_UPDATE_NODE_LAYOUT_PROPERTY(IndexerLayoutProperty, AutoCollapse, autoCollapse.value_or(true), frameNode); } void IndexerModelStatic::SetEnableHapticFeedback(FrameNode* frameNode, const std::optional& state) diff --git a/frameworks/core/components_ng/pattern/indexer/indexer_model_static.h b/frameworks/core/components_ng/pattern/indexer/indexer_model_static.h index 9b20180e57595e3b26b40958478a8bc757f3a4f0..61d9fee1abe29b062f03d8c60354e582842d1a88 100644 --- a/frameworks/core/components_ng/pattern/indexer/indexer_model_static.h +++ b/frameworks/core/components_ng/pattern/indexer/indexer_model_static.h @@ -44,7 +44,7 @@ public: const std::optional& fontStyle); static void SetFontSize(FrameNode* frameNode, const Dimension& fontSize); static void SetFontWeight(FrameNode* frameNode, const FontWeight weight); - static void SetItemSize(FrameNode* frameNode, const Dimension& value); + static void SetItemSize(FrameNode* frameNode, const std::optional& value); static void SetFont(FrameNode* frameNode, const std::optional& fontSize, const std::optional& fontWeight, const std::optional>& fontFamily, const std::optional& fontStyle); @@ -54,7 +54,7 @@ public: static void SetOnPopupSelected(FrameNode* frameNode, std::function&& onPopupSelected); static void SetPopupPositionX(FrameNode* frameNode, const std::optional& popupPositionXOpt); static void SetPopupPositionY(FrameNode* frameNode, const std::optional& popupPositionYOpt); - static void SetAutoCollapse(FrameNode* frameNode, bool autoCollapse); + static void SetAutoCollapse(FrameNode* frameNode, const std::optional& autoCollapse); static void SetPopupItemBorderRadius(FrameNode* frameNode, const std::optional& radius); static void SetPopupBorderRadius(FrameNode* frameNode, const std::optional& radius); static void SetItemBorderRadius(FrameNode* frameNode, const std::optional& radius); diff --git a/frameworks/core/components_ng/pattern/radio/radio_model_static.cpp b/frameworks/core/components_ng/pattern/radio/radio_model_static.cpp index c7c48f4a954842d9fe7464a3fc3ae9ae55e9edea..810ea8fe4d133006dbff159afa71bd27c6651984 100644 --- a/frameworks/core/components_ng/pattern/radio/radio_model_static.cpp +++ b/frameworks/core/components_ng/pattern/radio/radio_model_static.cpp @@ -23,7 +23,7 @@ namespace OHOS::Ace::NG { void RadioModelStatic::SetChecked(FrameNode* frameNode, const std::optional isChecked) { CHECK_NULL_VOID(frameNode); - auto eventHub = frameNode->GetEventHub(); + auto eventHub = frameNode->GetOrCreateEventHub(); CHECK_NULL_VOID(eventHub); eventHub->SetCurrentUIState(UI_STATE_SELECTED, isChecked.value_or(false)); if (isChecked) { @@ -72,7 +72,7 @@ void RadioModelStatic::SetBuilder(FrameNode* frameNode, std::function&& void RadioModelStatic::SetOnChangeEvent(FrameNode* frameNode, ChangeEvent&& onChangeEvent) { CHECK_NULL_VOID(frameNode); - auto eventHub = frameNode->GetEventHub(); + auto eventHub = frameNode->GetOrCreateEventHub(); CHECK_NULL_VOID(eventHub); eventHub->SetOnChangeEvent(std::move(onChangeEvent)); } diff --git a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model_static.cpp b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model_static.cpp index 4f322b3452aa2540deee2fa0504c36a115ba668e..074796c087e32c12f33812b66e70ce883b972cff 100644 --- a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model_static.cpp +++ b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model_static.cpp @@ -184,6 +184,16 @@ void RichEditorModelStatic::BindSelectionMenu(FrameNode* frameNode, TextSpanType } } +void RichEditorModelStatic::SetSelectionMenuOptions(FrameNode* frameNode, + const OnCreateMenuCallback&& onCreateMenuCallback, const OnMenuItemClickCallback&& onMenuItemClick) +{ + CHECK_NULL_VOID(frameNode); + auto richEditorPattern = frameNode->GetPattern(); + CHECK_NULL_VOID(richEditorPattern); + richEditorPattern->OnSelectionMenuOptionsUpdate(std::move(onCreateMenuCallback), std::move(onMenuItemClick), + nullptr); +} + void RichEditorModelStatic::SetMaxLength(FrameNode* frameNode, std::optional value) { CHECK_NULL_VOID(frameNode); diff --git a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model_static.h b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model_static.h index b6f42260fcf50cc742da540912f7d99fa147a9ff..7e18a2113328e7e0f1ff8bb9342ce8cca1266dc1 100644 --- a/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model_static.h +++ b/frameworks/core/components_ng/pattern/rich_editor/rich_editor_model_static.h @@ -43,6 +43,8 @@ public: static void SetMaxLength(FrameNode* frameNode, std::optional value); static void SetMaxLines(FrameNode* frameNode, uint32_t value); void SetDraggable(bool draggable); + static void SetSelectionMenuOptions(FrameNode* frameNode, const OnCreateMenuCallback&& onCreateMenuCallback, + const OnMenuItemClickCallback&& onMenuItemClick); }; } // namespace OHOS::Ace::NG #endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERNS_RICH_EDITOR_RICH_EDITOR_STATIC_H diff --git a/frameworks/core/components_ng/pattern/text_picker/textpicker_model_static.cpp b/frameworks/core/components_ng/pattern/text_picker/textpicker_model_static.cpp index 3ec1e76b069b4f0e3d8ae5a7ba049caa10b8525f..c4f09796ff28b1b39a119987f2a64d85875769af 100644 --- a/frameworks/core/components_ng/pattern/text_picker/textpicker_model_static.cpp +++ b/frameworks/core/components_ng/pattern/text_picker/textpicker_model_static.cpp @@ -326,19 +326,7 @@ int32_t TextPickerModelStatic::GetCanLoop(FrameNode* frameNode) return textPickerPattern->GetCanLoop(); } -void TextPickerModelStatic::SetDigitalCrownSensitivity(FrameNode* frameNode, int32_t crownSensitivity) -{ - if (crownSensitivity < CROWN_SENSITIVITY_MIN || crownSensitivity > CROWN_SENSITIVITY_MAX) { - return; - } - CHECK_NULL_VOID(frameNode); - auto textPickerPattern = frameNode->GetPattern(); - CHECK_NULL_VOID(textPickerPattern); - textPickerPattern->SetDigitalCrownSensitivity(crownSensitivity); - ACE_UPDATE_NODE_LAYOUT_PROPERTY(TextPickerLayoutProperty, DigitalCrownSensitivity, crownSensitivity, frameNode); -} - -void TextPickerModelStatic::SetDigitalCrownSensitivity(FrameNode* frameNode, std::optional& valueOpt) +void TextPickerModelStatic::SetDigitalCrownSensitivity(FrameNode* frameNode, const std::optional& valueOpt) { if (valueOpt) { if (valueOpt.value() < CROWN_SENSITIVITY_MIN || valueOpt.value() > CROWN_SENSITIVITY_MAX) { @@ -575,7 +563,7 @@ void TextPickerModelStatic::SetCascadeColumnsNode(FrameNode* frameNode, auto textPickerPattern = frameNode->GetPattern(); CHECK_NULL_VOID(textPickerPattern); std::vector reOptions; - // Caculate max depth + // Calculate max depth size_t columnCount = options.empty()? 0 : 1; for (size_t i = 0; i < options.size(); i++) { size_t tmp = textPickerPattern->ProcessCascadeOptionDepth(options[i]); diff --git a/frameworks/core/components_ng/pattern/text_picker/textpicker_model_static.h b/frameworks/core/components_ng/pattern/text_picker/textpicker_model_static.h index b07c07687875735cd617b6c9f288604ba491043a..c066d59e6223233886622205f4fde2b5508a7719 100644 --- a/frameworks/core/components_ng/pattern/text_picker/textpicker_model_static.h +++ b/frameworks/core/components_ng/pattern/text_picker/textpicker_model_static.h @@ -41,8 +41,7 @@ public: static void InitialSetupSinglePicker(FrameNode* frameNode, uint32_t columnKind); static void SetCanLoop(FrameNode* frameNode, const bool value); - static void SetDigitalCrownSensitivity(FrameNode* frameNode, int32_t crownSensitivity); - static void SetDigitalCrownSensitivity(FrameNode* frameNode, std::optional& crownSensitivity); + static void SetDigitalCrownSensitivity(FrameNode* frameNode, const std::optional& crownSensitivity); static void SetSelected(FrameNode* frameNode, uint32_t value); static void SetSelecteds(FrameNode* frameNode, const std::vector& values); static void SetHasSelectAttr(FrameNode* frameNode, bool value); diff --git a/frameworks/core/components_ng/pattern/waterflow/water_flow_model_static.cpp b/frameworks/core/components_ng/pattern/waterflow/water_flow_model_static.cpp index c3ef70ddbda4d48b6d131cb3db26333ab8292759..5c755c032bd79347d8febdd4afd2aa8f150fe412 100644 --- a/frameworks/core/components_ng/pattern/waterflow/water_flow_model_static.cpp +++ b/frameworks/core/components_ng/pattern/waterflow/water_flow_model_static.cpp @@ -23,6 +23,8 @@ namespace OHOS::Ace::NG { +const auto DEFAULT_CONSTRAINT_SIZE = CalcLength(0.0_vp); + RefPtr WaterFlowModelStatic::CreateFrameNode(int32_t nodeId) { auto frameNode = FrameNode::CreateFrameNode(V2::WATERFLOW_ETS_TAG, nodeId, AceType::MakeRefPtr()); @@ -163,44 +165,36 @@ void WaterFlowModelStatic::SetRowsGap(FrameNode* frameNode, const std::optional< } } -void WaterFlowModelStatic::SetItemMinWidth(FrameNode* frameNode, const std::optional& minWidth) +void WaterFlowModelStatic::SetItemMinWidth(FrameNode* frameNode, const std::optional& minWidth) { CHECK_NULL_VOID(frameNode); auto layoutProperty = frameNode->GetLayoutProperty(); CHECK_NULL_VOID(layoutProperty); - if (minWidth) { - layoutProperty->UpdateItemMinSize(CalcSize(CalcLength(minWidth.value()), std::nullopt)); - } + layoutProperty->UpdateItemMinSize(CalcSize(minWidth.value_or(DEFAULT_CONSTRAINT_SIZE), std::nullopt)); } -void WaterFlowModelStatic::SetItemMinHeight(FrameNode* frameNode, const std::optional& minHeight) +void WaterFlowModelStatic::SetItemMinHeight(FrameNode* frameNode, const std::optional& minHeight) { CHECK_NULL_VOID(frameNode); auto layoutProperty = frameNode->GetLayoutProperty(); CHECK_NULL_VOID(layoutProperty); - if (minHeight) { - layoutProperty->UpdateItemMinSize(CalcSize(std::nullopt, CalcLength(minHeight.value()))); - } + layoutProperty->UpdateItemMinSize(CalcSize(std::nullopt, minHeight.value_or(DEFAULT_CONSTRAINT_SIZE))); } -void WaterFlowModelStatic::SetItemMaxWidth(FrameNode* frameNode, const std::optional& maxWidth) +void WaterFlowModelStatic::SetItemMaxWidth(FrameNode* frameNode, const std::optional& maxWidth) { CHECK_NULL_VOID(frameNode); auto layoutProperty = frameNode->GetLayoutProperty(); CHECK_NULL_VOID(layoutProperty); - if (maxWidth) { - layoutProperty->UpdateItemMaxSize(CalcSize(CalcLength(maxWidth.value()), std::nullopt)); - } + layoutProperty->UpdateItemMaxSize(CalcSize(maxWidth.value_or(DEFAULT_CONSTRAINT_SIZE), std::nullopt)); } -void WaterFlowModelStatic::SetItemMaxHeight(FrameNode* frameNode, const std::optional& maxHeight) +void WaterFlowModelStatic::SetItemMaxHeight(FrameNode* frameNode, const std::optional& maxHeight) { CHECK_NULL_VOID(frameNode); auto layoutProperty = frameNode->GetLayoutProperty(); CHECK_NULL_VOID(layoutProperty); - if (maxHeight) { - layoutProperty->UpdateItemMaxSize(CalcSize(std::nullopt, CalcLength(maxHeight.value()))); - } + layoutProperty->UpdateItemMaxSize(CalcSize(std::nullopt, maxHeight.value_or(DEFAULT_CONSTRAINT_SIZE))); } void WaterFlowModelStatic::SetLayoutDirection(FrameNode* frameNode, const std::optional& value) diff --git a/frameworks/core/components_ng/pattern/waterflow/water_flow_model_static.h b/frameworks/core/components_ng/pattern/waterflow/water_flow_model_static.h index ebeabdb2e7f242fbad2fddcb1f4df0c5d70e11d9..e699164fb858619ff28471ce4c63b4e0a42cfd08 100644 --- a/frameworks/core/components_ng/pattern/waterflow/water_flow_model_static.h +++ b/frameworks/core/components_ng/pattern/waterflow/water_flow_model_static.h @@ -31,10 +31,10 @@ public: static void SetScrollEnabled(FrameNode* frameNode, bool scrollEnabled); static void SetColumnsGap(FrameNode* frameNode, const std::optional& value); static void SetRowsGap(FrameNode* frameNode, const std::optional& value); - static void SetItemMinWidth(FrameNode* frameNode, const std::optional& minWidth); - static void SetItemMaxWidth(FrameNode* frameNode, const std::optional& maxWidth); - static void SetItemMinHeight(FrameNode* frameNode, const std::optional& minHeight); - static void SetItemMaxHeight(FrameNode* frameNode, const std::optional& maxHeight); + static void SetItemMinWidth(FrameNode* frameNode, const std::optional& minWidth); + static void SetItemMaxWidth(FrameNode* frameNode, const std::optional& maxWidth); + static void SetItemMinHeight(FrameNode* frameNode, const std::optional& minHeight); + static void SetItemMaxHeight(FrameNode* frameNode, const std::optional& maxHeight); static void SetLayoutDirection(FrameNode* frameNode, const std::optional& value); static void SetNestedScroll(FrameNode* frameNode, const NestedScrollOptions& nestedOpt); static void SetFriction(FrameNode* frameNode, const std::optional& friction); diff --git a/frameworks/core/interfaces/native/implementation/water_flow_modifier.cpp b/frameworks/core/interfaces/native/implementation/water_flow_modifier.cpp index dcf849363f4fa1fb43382c7cd05395d19a5108e9..b9b7f7b851658971b9b53adc23a07b935e7007a2 100644 --- a/frameworks/core/interfaces/native/implementation/water_flow_modifier.cpp +++ b/frameworks/core/interfaces/native/implementation/water_flow_modifier.cpp @@ -122,16 +122,16 @@ void ItemConstraintSizeImpl(Ark_NativePointer node, // TODO: Reset value return; } - auto minWidth = Converter::OptConvert(optValue->minWidth); + auto minWidth = Converter::OptConvert(optValue->minWidth); WaterFlowModelStatic::SetItemMinWidth(frameNode, minWidth); - auto minHeight = Converter::OptConvert(optValue->minHeight); + auto minHeight = Converter::OptConvert(optValue->minHeight); WaterFlowModelStatic::SetItemMinHeight(frameNode, minHeight); - auto maxWidth = Converter::OptConvert(optValue->maxWidth); + auto maxWidth = Converter::OptConvert(optValue->maxWidth); WaterFlowModelStatic::SetItemMaxWidth(frameNode, maxWidth); - auto maxHeight = Converter::OptConvert(optValue->maxHeight); + auto maxHeight = Converter::OptConvert(optValue->maxHeight); WaterFlowModelStatic::SetItemMaxHeight(frameNode, maxHeight); }