From 82fb100942d5c7e574827a1b30506dc47729b15c Mon Sep 17 00:00:00 2001 From: zhanghang Date: Sun, 25 May 2025 14:42:57 +0800 Subject: [PATCH] =?UTF-8?q?counter=E3=80=81pattern=5Flock=E3=80=81text=5Fc?= =?UTF-8?q?lock=E3=80=81text=5Ftimer=20add=20modifier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhanghang --- .../arkts_native_counter_bridge.cpp | 25 +- .../arkts_native_pattern_lock_bridge.cpp | 53 ++- .../arkts_native_text_clock_bridge.cpp | 59 ++- .../arkts_native_text_timer_bridge.cpp | 55 ++- .../engine/jsi/nativeModule/arkts_utils.h | 2 +- .../jsview/js_pattern_lock.cpp | 14 +- .../jsview/js_progress.cpp | 3 + .../jsview/js_text_clock.cpp | 7 +- .../jsview/models/patternlock_model_impl.h | 3 +- .../jsview/models/text_clock_model_impl.h | 3 +- .../pattern/counter/counter_model_ng.cpp | 138 ++++--- .../pattern/counter/counter_model_ng.h | 5 + .../pattern/patternlock/patternlock_model.h | 5 +- .../patternlock/patternlock_model_ng.cpp | 342 ++++++++++-------- .../patternlock/patternlock_model_ng.h | 12 +- .../pattern/text_clock/text_clock_model.h | 3 +- .../text_clock/text_clock_model_ng.cpp | 66 +++- .../pattern/text_clock/text_clock_model_ng.h | 5 + .../pattern/texttimer/text_timer_model_ng.cpp | 46 +++ .../pattern/texttimer/text_timer_model_ng.h | 10 +- .../core/interfaces/arkoala/arkoala_api.h | 32 ++ frameworks/core/interfaces/cjui/cjui_api.h | 25 ++ .../native/node/counter_modifier.cpp | 51 +++ .../native/node/pattern_lock_modifier.cpp | 101 ++++++ .../native/node/text_clock_modifier.cpp | 160 ++++++++ .../native/node/text_timer_modifier.cpp | 158 ++++++++ .../text_clock/text_clock_pattern_test_ng.cpp | 8 + 27 files changed, 1101 insertions(+), 290 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_counter_bridge.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_counter_bridge.cpp index 9dd4b6cc896..587fe9c27be 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_counter_bridge.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_counter_bridge.cpp @@ -84,13 +84,15 @@ ArkUINativeModuleValue CounterBridge::SetCounterHeight(ArkUIRuntimeCallInfo* run auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value()); CalcDimension height; - ArkTSUtils::ParseJsDimensionVp(vm, heightValue, height, false); + RefPtr heightResObj; + ArkTSUtils::ParseJsDimensionVp(vm, heightValue, height, heightResObj, false); if (LessNotEqual(height.Value(), 0.0)) { GetArkUINodeModifiers()->getCounterModifier()->resetCounterHeight(nativeNode); return panda::JSValueRef::Undefined(vm); } - GetArkUINodeModifiers()->getCounterModifier()->setCounterHeight( - nativeNode, height.Value(), static_cast(height.Unit())); + auto heightRawPtr = AceType::RawPtr(heightResObj); + GetArkUINodeModifiers()->getCounterModifier()->setCounterHeightRes( + nativeNode, height.Value(), static_cast(height.Unit()), heightRawPtr); return panda::JSValueRef::Undefined(vm); } @@ -115,14 +117,15 @@ ArkUINativeModuleValue CounterBridge::SetCounterWidth(ArkUIRuntimeCallInfo* runt auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value()); CalcDimension width; - ArkTSUtils::ParseJsDimensionVp(vm, widthValue, width, false); + RefPtr widthResObj; + ArkTSUtils::ParseJsDimensionVp(vm, widthValue, width, widthResObj, false); if (LessNotEqual(width.Value(), 0.0)) { GetArkUINodeModifiers()->getCounterModifier()->resetCounterWidth(nativeNode); return panda::JSValueRef::Undefined(vm); } - - GetArkUINodeModifiers()->getCounterModifier()->setCounterWidth( - nativeNode, width.Value(), static_cast(width.Unit())); + auto widthRawPtr = AceType::RawPtr(widthResObj); + GetArkUINodeModifiers()->getCounterModifier()->setCounterWidthRes( + nativeNode, width.Value(), static_cast(width.Unit()), widthRawPtr); return panda::JSValueRef::Undefined(vm); } @@ -146,11 +149,13 @@ ArkUINativeModuleValue CounterBridge::SetCounterBackgroundColor(ArkUIRuntimeCall CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm)); auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value()); Color color; - if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color)) { + RefPtr colorResObj; + if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, colorResObj)) { GetArkUINodeModifiers()->getCounterModifier()->resetCounterBackgroundColor(nativeNode); } else { - GetArkUINodeModifiers()->getCounterModifier()->setCounterBackgroundColorWithColorSpace( - nativeNode, color.GetValue(), color.GetColorSpace()); + auto colorRawPtr = AceType::RawPtr(colorResObj); + GetArkUINodeModifiers()->getCounterModifier()->setCounterBackgroundColorRes( + nativeNode, color.GetValue(), color.GetColorSpace(), colorRawPtr); } return panda::JSValueRef::Undefined(vm); } diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_pattern_lock_bridge.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_pattern_lock_bridge.cpp index 61162a276cd..41026796937 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_pattern_lock_bridge.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_pattern_lock_bridge.cpp @@ -34,11 +34,13 @@ ArkUINativeModuleValue PatternLockBridge::SetSideLength(ArkUIRuntimeCallInfo* ru CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm)); auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); CalcDimension sideLength; - if (!(ArkTSUtils::ParseJsDimensionVp(vm, secondArg, sideLength))) { + RefPtr sideLengthResObj; + if (!(ArkTSUtils::ParseJsDimensionVp(vm, secondArg, sideLength, sideLengthResObj))) { GetArkUINodeModifiers()->getPatternLockModifier()->resetPatternLockSideLength(nativeNode); } - GetArkUINodeModifiers()->getPatternLockModifier()->setPatternLockSideLength( - nativeNode, sideLength.Value(), static_cast(sideLength.Unit())); + auto sideLengthRawPtr = AceType::RawPtr(sideLengthResObj); + GetArkUINodeModifiers()->getPatternLockModifier()->setPatternLockSideLengthRes( + nativeNode, sideLength.Value(), static_cast(sideLength.Unit()), sideLengthRawPtr); return panda::JSValueRef::Undefined(vm); } @@ -117,10 +119,13 @@ ArkUINativeModuleValue PatternLockBridge::SetRegularColor(ArkUIRuntimeCallInfo* CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm)); auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); Color color; - if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color)) { + RefPtr regularColorResObj; + if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, regularColorResObj)) { GetArkUINodeModifiers()->getPatternLockModifier()->resetPatternLockRegularColor(nativeNode); } else { - GetArkUINodeModifiers()->getPatternLockModifier()->setPatternLockRegularColor(nativeNode, color.GetValue()); + auto regularColorRawPtr = AceType::RawPtr(regularColorResObj); + GetArkUINodeModifiers()->getPatternLockModifier()->setPatternLockRegularColorRes( + nativeNode, color.GetValue(), regularColorRawPtr); } return panda::JSValueRef::Undefined(vm); } @@ -145,10 +150,13 @@ ArkUINativeModuleValue PatternLockBridge::SetPathColor(ArkUIRuntimeCallInfo* run CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm)); auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); Color color; - if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color)) { + RefPtr pathColorResObj; + if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, pathColorResObj)) { GetArkUINodeModifiers()->getPatternLockModifier()->resetPatternLockPathColor(nativeNode); } else { - GetArkUINodeModifiers()->getPatternLockModifier()->setPatternLockPathColor(nativeNode, color.GetValue()); + auto pathColorRawPtr = AceType::RawPtr(pathColorResObj); + GetArkUINodeModifiers()->getPatternLockModifier()->setPatternLockPathColorRes( + nativeNode, color.GetValue(), pathColorRawPtr); } return panda::JSValueRef::Undefined(vm); } @@ -173,10 +181,13 @@ ArkUINativeModuleValue PatternLockBridge::SetPatternLockActiveColor(ArkUIRuntime CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm)); auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); Color color; - if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color)) { + RefPtr activeColorResObj; + if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, activeColorResObj)) { GetArkUINodeModifiers()->getPatternLockModifier()->resetPatternLockActiveColor(nativeNode); } else { - GetArkUINodeModifiers()->getPatternLockModifier()->setPatternLockActiveColor(nativeNode, color.GetValue()); + auto activeColorRawPtr = AceType::RawPtr(activeColorResObj); + GetArkUINodeModifiers()->getPatternLockModifier()->setPatternLockActiveColorRes( + nativeNode, color.GetValue(), activeColorRawPtr); } return panda::JSValueRef::Undefined(vm); } @@ -201,9 +212,12 @@ ArkUINativeModuleValue PatternLockBridge::SetPatternLockCircleRadius(ArkUIRuntim CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm)); auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); CalcDimension circleRadius; - if (ArkTSUtils::ParseJsDimensionVp(vm, secondArg, circleRadius) && !(circleRadius.IsNonPositive())) { - GetArkUINodeModifiers()->getPatternLockModifier()->setPatternLockCircleRadius( - nativeNode, circleRadius.Value(), static_cast(circleRadius.Unit())); + RefPtr circleRadiusResObj; + if (ArkTSUtils::ParseJsDimensionVp(vm, secondArg, circleRadius, circleRadiusResObj) && + !(circleRadius.IsNonPositive())) { + auto circleRadiusRawPtr = AceType::RawPtr(circleRadiusResObj); + GetArkUINodeModifiers()->getPatternLockModifier()->setPatternLockCircleRadiusRes( + nativeNode, circleRadius.Value(), static_cast(circleRadius.Unit()), circleRadiusRawPtr); } else { GetArkUINodeModifiers()->getPatternLockModifier()->resetPatternLockCircleRadius(nativeNode); } @@ -230,10 +244,13 @@ ArkUINativeModuleValue PatternLockBridge::SetPatternLockSelectedColor(ArkUIRunti CHECK_NULL_RETURN(firstArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm)); auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value()); Color color; - if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color)) { + RefPtr selectedColorResObj; + if (!ArkTSUtils::ParseJsColorAlpha(vm, secondArg, color, selectedColorResObj)) { GetArkUINodeModifiers()->getPatternLockModifier()->resetPatternLockSelectedColor(nativeNode); } else { - GetArkUINodeModifiers()->getPatternLockModifier()->setPatternLockSelectedColor(nativeNode, color.GetValue()); + auto selectedColorRawPtr = AceType::RawPtr(selectedColorResObj); + GetArkUINodeModifiers()->getPatternLockModifier()->setPatternLockSelectedColorRes( + nativeNode, color.GetValue(), selectedColorRawPtr); } return panda::JSValueRef::Undefined(vm); } @@ -269,11 +286,13 @@ ArkUINativeModuleValue PatternLockBridge::SetPatternLockActivateCircleStyle(ArkU auto jsEnable = obj->Get(vm, panda::StringRef::NewFromUtf8(vm, "enableWaveEffect")); auto jsEnableForeground = obj->Get(vm, panda::StringRef::NewFromUtf8(vm, "enableForeground")); Color color; - if (!ArkTSUtils::ParseJsColorAlpha(vm, jsColor, color)) { + RefPtr colorResObj; + if (!ArkTSUtils::ParseJsColorAlpha(vm, jsColor, color, colorResObj)) { GetArkUINodeModifiers()->getPatternLockModifier()->resetPatternLockActiveCircleColor(nativeNode); } else { - GetArkUINodeModifiers()->getPatternLockModifier()->setPatternLockActiveCircleColor( - nativeNode, color.GetValue()); + auto activeCircleColorRawPtr = AceType::RawPtr(colorResObj); + GetArkUINodeModifiers()->getPatternLockModifier()->setPatternLockActiveCircleColorRes( + nativeNode, color.GetValue(), activeCircleColorRawPtr); } CalcDimension circleRadius; if (jsRadius->IsObject(vm) && ArkTSUtils::ParseJsLengthMetrics(vm, jsRadius, circleRadius) && diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_text_clock_bridge.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_text_clock_bridge.cpp index 5406cba4223..4150edde427 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_text_clock_bridge.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_text_clock_bridge.cpp @@ -119,12 +119,14 @@ ArkUINativeModuleValue TextClockBridge::SetFontColor(ArkUIRuntimeCallInfo* runti CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm)); auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value()); Color color; + RefPtr fontColorResObj; auto nodeModifiers = GetArkUINodeModifiers(); CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm)); - if (!ArkTSUtils::ParseJsColorAlpha(vm, fontColorArg, color)) { + if (!ArkTSUtils::ParseJsColorAlpha(vm, fontColorArg, color, fontColorResObj)) { nodeModifiers->getTextClockModifier()->resetFontColor(nativeNode); } else { - nodeModifiers->getTextClockModifier()->setFontColor(nativeNode, color.GetValue()); + auto fontColorRawPtr = AceType::RawPtr(fontColorResObj); + nodeModifiers->getTextClockModifier()->setFontColorRes(nativeNode, color.GetValue(), fontColorRawPtr); } return panda::JSValueRef::Undefined(vm); } @@ -151,14 +153,16 @@ ArkUINativeModuleValue TextClockBridge::SetFontSize(ArkUIRuntimeCallInfo* runtim CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm)); auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value()); CalcDimension fontSize; + RefPtr fontSizeResObj; auto nodeModifiers = GetArkUINodeModifiers(); CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm)); - if (!ArkTSUtils::ParseJsDimensionNG(vm, fontSizeArg, fontSize, DimensionUnit::FP, false) - || fontSize.Value() < 0 || fontSize.Unit() == DimensionUnit::PERCENT) { + if (!ArkTSUtils::ParseJsDimensionNG(vm, fontSizeArg, fontSize, DimensionUnit::FP, fontSizeResObj, false) || + fontSize.Value() < 0 || fontSize.Unit() == DimensionUnit::PERCENT) { nodeModifiers->getTextClockModifier()->resetFontSize(nativeNode); } else { - nodeModifiers->getTextClockModifier()->setFontSize( - nativeNode, fontSize.Value(), static_cast(fontSize.Unit())); + auto fontSizeRawPtr = AceType::RawPtr(fontSizeResObj); + nodeModifiers->getTextClockModifier()->setFontSizeRes( + nativeNode, fontSize.Value(), static_cast(fontSize.Unit()), fontSizeRawPtr); } return panda::JSValueRef::Undefined(vm); } @@ -221,16 +225,18 @@ ArkUINativeModuleValue TextClockBridge::SetFontWeight(ArkUIRuntimeCallInfo* runt CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm)); auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value()); std::string fontWeight; + RefPtr fontWeightResObj; if (!fontWeightArg->IsNull()) { if (fontWeightArg->IsNumber()) { fontWeight = std::to_string(fontWeightArg->Int32Value(vm)); - } else if (fontWeightArg->IsString(vm)) { - fontWeight = fontWeightArg->ToString(vm)->ToString(vm); + } else { + ArkTSUtils::ParseJsString(vm, fontWeightArg, fontWeight, fontWeightResObj); } } auto nodeModifiers = GetArkUINodeModifiers(); CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm)); - nodeModifiers->getTextClockModifier()->setFontWeight(nativeNode, fontWeight.c_str()); + auto fontWeightRawPtr = AceType::RawPtr(fontWeightResObj); + nodeModifiers->getTextClockModifier()->setFontWeightRes(nativeNode, fontWeight.c_str(), fontWeightRawPtr); return panda::JSValueRef::Undefined(vm); } @@ -257,13 +263,15 @@ ArkUINativeModuleValue TextClockBridge::SetFontFamily(ArkUIRuntimeCallInfo* runt auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value()); std::string fontFamilyStr; + RefPtr fontFamilyResObj; auto nodeModifiers = GetArkUINodeModifiers(); CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm)); - if (!ArkTSUtils::ParseJsFontFamiliesToString(vm, fontFamilyArg, fontFamilyStr)) { + if (!ArkTSUtils::ParseJsFontFamiliesToString(vm, fontFamilyArg, fontFamilyStr, fontFamilyResObj)) { nodeModifiers->getTextClockModifier()->resetFontFamily(nativeNode); return panda::JSValueRef::Undefined(vm); } - nodeModifiers->getTextClockModifier()->setFontFamily(nativeNode, fontFamilyStr.c_str()); + auto fontFamilyRawPtr = AceType::RawPtr(fontFamilyResObj); + nodeModifiers->getTextClockModifier()->setFontFamilyRes(nativeNode, fontFamilyStr.c_str(), fontFamilyRawPtr); return panda::JSValueRef::Undefined(vm); } @@ -331,16 +339,20 @@ ArkUINativeModuleValue TextClockBridge::SetTextShadow(ArkUIRuntimeCallInfo* runt auto offsetXArray = std::make_unique(length); auto offsetYArray = std::make_unique(length); auto fillArray = std::make_unique(length); - bool radiusParseResult = ArkTSUtils::ParseArray( - vm, runtimeCallInfo->GetCallArgRef(NUM_1), radiusArray.get(), length, ArkTSUtils::parseShadowRadius); + std::vector> radiusResObjArray; + std::vector> colorResObjArray; + std::vector> offsetXResObjArray; + std::vector> offsetYResObjArray; + bool radiusParseResult = ArkTSUtils::ParseArrayWithResObj(vm, runtimeCallInfo->GetCallArgRef(NUM_1), + radiusArray.get(), length, ArkTSUtils::parseShadowRadiusWithResObj, radiusResObjArray); bool typeParseResult = ArkTSUtils::ParseArray( vm, runtimeCallInfo->GetCallArgRef(NUM_2), typeArray.get(), length, ArkTSUtils::parseShadowType); - bool colorParseResult = ArkTSUtils::ParseArray( - vm, runtimeCallInfo->GetCallArgRef(NUM_3), colorArray.get(), length, ArkTSUtils::parseShadowColor); - bool offsetXParseResult = ArkTSUtils::ParseArray( - vm, runtimeCallInfo->GetCallArgRef(NUM_4), offsetXArray.get(), length, ArkTSUtils::parseShadowOffset); - bool offsetYParseResult = ArkTSUtils::ParseArray( - vm, runtimeCallInfo->GetCallArgRef(NUM_5), offsetYArray.get(), length, ArkTSUtils::parseShadowOffset); + bool colorParseResult = ArkTSUtils::ParseArrayWithResObj(vm, runtimeCallInfo->GetCallArgRef(NUM_3), + colorArray.get(), length, ArkTSUtils::parseShadowColorWithResObj, colorResObjArray); + bool offsetXParseResult = ArkTSUtils::ParseArrayWithResObj(vm, runtimeCallInfo->GetCallArgRef(NUM_4), + offsetXArray.get(), length, ArkTSUtils::parseShadowOffsetWithResObj, offsetXResObjArray); + bool offsetYParseResult = ArkTSUtils::ParseArrayWithResObj(vm, runtimeCallInfo->GetCallArgRef(NUM_5), + offsetYArray.get(), length, ArkTSUtils::parseShadowOffsetWithResObj, offsetYResObjArray); bool fillParseResult = ArkTSUtils::ParseArray( vm, runtimeCallInfo->GetCallArgRef(NUM_6), fillArray.get(), length, ArkTSUtils::parseShadowFill); if (!radiusParseResult || !colorParseResult || !offsetXParseResult || @@ -349,6 +361,8 @@ ArkUINativeModuleValue TextClockBridge::SetTextShadow(ArkUIRuntimeCallInfo* runt } auto textShadowArray = std::make_unique(length); CHECK_NULL_RETURN(textShadowArray.get(), panda::JSValueRef::Undefined(vm)); + auto textShadowResArray = std::make_unique(length); + CHECK_NULL_RETURN(textShadowResArray.get(), panda::JSValueRef::Undefined(vm)); for (uint32_t i = 0; i < length; i++) { textShadowArray[i].radius = radiusArray[i]; textShadowArray[i].type = typeArray[i]; @@ -356,10 +370,15 @@ ArkUINativeModuleValue TextClockBridge::SetTextShadow(ArkUIRuntimeCallInfo* runt textShadowArray[i].offsetX = offsetXArray[i]; textShadowArray[i].offsetY = offsetYArray[i]; textShadowArray[i].fill = fillArray[i]; + textShadowResArray[i].radiusResObj = AceType::RawPtr(radiusResObjArray[i]); + textShadowResArray[i].colorResObj = AceType::RawPtr(colorResObjArray[i]); + textShadowResArray[i].offsetXResObj = AceType::RawPtr(offsetXResObjArray[i]); + textShadowResArray[i].offsetYResObj = AceType::RawPtr(offsetYResObjArray[i]); } auto nodeModifiers = GetArkUINodeModifiers(); CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm)); - nodeModifiers->getTextClockModifier()->setTextShadow(nativeNode, textShadowArray.get(), length); + nodeModifiers->getTextClockModifier()->setTextShadowRes( + nativeNode, textShadowArray.get(), textShadowResArray.get(), length); return panda::JSValueRef::Undefined(vm); } diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_text_timer_bridge.cpp b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_text_timer_bridge.cpp index 1c799d3ca8c..639514cc633 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_text_timer_bridge.cpp +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_native_text_timer_bridge.cpp @@ -48,12 +48,14 @@ ArkUINativeModuleValue TextTimerBridge::SetFontColor(ArkUIRuntimeCallInfo* runti CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm)); auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value()); Color color; + RefPtr colorResObj; auto nodeModifiers = GetArkUINodeModifiers(); CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm)); - if (!ArkTSUtils::ParseJsColorAlpha(vm, paramArg, color)) { + if (!ArkTSUtils::ParseJsColorAlpha(vm, paramArg, color, colorResObj)) { nodeModifiers->getTextTimerModifier()->resetFontColor(nativeNode); } else { - nodeModifiers->getTextTimerModifier()->setFontColor(nativeNode, color.GetValue()); + auto colorRawPtr = AceType::RawPtr(colorResObj); + nodeModifiers->getTextTimerModifier()->setFontColorRes(nativeNode, color.GetValue(), colorRawPtr); } return panda::JSValueRef::Undefined(vm); } @@ -80,14 +82,16 @@ ArkUINativeModuleValue TextTimerBridge::SetFontSize(ArkUIRuntimeCallInfo* runtim CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm)); auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value()); CalcDimension fontSize; + RefPtr fontSizeResObj; auto nodeModifiers = GetArkUINodeModifiers(); CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm)); - if (!ArkTSUtils::ParseJsDimensionFp(vm, fontSizeArg, fontSize) || fontSize.Value() < 0 || + if (!ArkTSUtils::ParseJsDimensionFp(vm, fontSizeArg, fontSize, fontSizeResObj) || fontSize.Value() < 0 || fontSize.Unit() == DimensionUnit::PERCENT) { nodeModifiers->getTextTimerModifier()->resetFontSize(nativeNode); } else { - nodeModifiers->getTextTimerModifier()->setFontSize( - nativeNode, fontSize.Value(), static_cast(fontSize.Unit())); + auto fontSizeRawPtr = AceType::RawPtr(fontSizeResObj); + nodeModifiers->getTextTimerModifier()->setFontSizeRes( + nativeNode, fontSize.Value(), static_cast(fontSize.Unit()), fontSizeRawPtr); } return panda::JSValueRef::Undefined(vm); } @@ -150,18 +154,20 @@ ArkUINativeModuleValue TextTimerBridge::SetFontWeight(ArkUIRuntimeCallInfo* runt CHECK_NULL_RETURN(nodeArg->IsNativePointer(vm), panda::JSValueRef::Undefined(vm)); auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value()); std::string fontWeight; + RefPtr fontWeightResObj; if (!fontWeightArg->IsNull()) { if (fontWeightArg->IsNumber()) { fontWeight = std::to_string(fontWeightArg->Int32Value(vm)); } else if (fontWeightArg->IsString(vm)) { fontWeight = fontWeightArg->ToString(vm)->ToString(vm); } else if (fontWeightArg->IsObject(vm)) { - ArkTSUtils::ParseJsString(vm, fontWeightArg, fontWeight); + ArkTSUtils::ParseJsString(vm, fontWeightArg, fontWeight, fontWeightResObj); } } auto nodeModifiers = GetArkUINodeModifiers(); CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm)); - nodeModifiers->getTextTimerModifier()->setFontWeight(nativeNode, fontWeight.c_str()); + auto fontWeightRawPtr = AceType::RawPtr(fontWeightResObj); + nodeModifiers->getTextTimerModifier()->setFontWeightRes(nativeNode, fontWeight.c_str(), fontWeightRawPtr); return panda::JSValueRef::Undefined(vm); } @@ -188,13 +194,15 @@ ArkUINativeModuleValue TextTimerBridge::SetFontFamily(ArkUIRuntimeCallInfo* runt auto nativeNode = nodePtr(nodeArg->ToNativePointer(vm)->Value()); std::string fontFamilyStr; + RefPtr fontFamilyResObj; auto nodeModifiers = GetArkUINodeModifiers(); CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm)); - if (!ArkTSUtils::ParseJsFontFamiliesToString(vm, fontFamilyArg, fontFamilyStr)) { + if (!ArkTSUtils::ParseJsFontFamiliesToString(vm, fontFamilyArg, fontFamilyStr, fontFamilyResObj)) { nodeModifiers->getTextTimerModifier()->resetFontFamily(nativeNode); return panda::JSValueRef::Undefined(vm); } - nodeModifiers->getTextTimerModifier()->setFontFamily(nativeNode, fontFamilyStr.c_str()); + auto fontFamilyRawPtr = AceType::RawPtr(fontFamilyResObj); + nodeModifiers->getTextTimerModifier()->setFontFamilyRes(nativeNode, fontFamilyStr.c_str(), fontFamilyRawPtr); return panda::JSValueRef::Undefined(vm); } @@ -261,16 +269,20 @@ ArkUINativeModuleValue TextTimerBridge::SetTextShadow(ArkUIRuntimeCallInfo* runt auto offsetXArray = std::make_unique(length); auto offsetYArray = std::make_unique(length); auto fillArray = std::make_unique(length); - bool radiusParseResult = ArkTSUtils::ParseArray( - vm, runtimeCallInfo->GetCallArgRef(NUM_1), radiusArray.get(), length, ArkTSUtils::parseShadowRadius); + std::vector> radiusResObjArray; + std::vector> colorResObjArray; + std::vector> offsetXResObjArray; + std::vector> offsetYResObjArray; + bool radiusParseResult = ArkTSUtils::ParseArrayWithResObj(vm, runtimeCallInfo->GetCallArgRef(NUM_1), + radiusArray.get(), length, ArkTSUtils::parseShadowRadiusWithResObj, radiusResObjArray); bool typeParseResult = ArkTSUtils::ParseArray( vm, runtimeCallInfo->GetCallArgRef(NUM_2), typeArray.get(), length, ArkTSUtils::parseShadowType); - bool colorParseResult = ArkTSUtils::ParseArray( - vm, runtimeCallInfo->GetCallArgRef(NUM_3), colorArray.get(), length, ArkTSUtils::parseShadowColor); - bool offsetXParseResult = ArkTSUtils::ParseArray( - vm, runtimeCallInfo->GetCallArgRef(NUM_4), offsetXArray.get(), length, ArkTSUtils::parseShadowOffset); - bool offsetYParseResult = ArkTSUtils::ParseArray( - vm, runtimeCallInfo->GetCallArgRef(NUM_5), offsetYArray.get(), length, ArkTSUtils::parseShadowOffset); + bool colorParseResult = ArkTSUtils::ParseArrayWithResObj(vm, runtimeCallInfo->GetCallArgRef(NUM_3), + colorArray.get(), length, ArkTSUtils::parseShadowColorWithResObj, colorResObjArray); + bool offsetXParseResult = ArkTSUtils::ParseArrayWithResObj(vm, runtimeCallInfo->GetCallArgRef(NUM_4), + offsetXArray.get(), length, ArkTSUtils::parseShadowOffsetWithResObj, offsetXResObjArray); + bool offsetYParseResult = ArkTSUtils::ParseArrayWithResObj(vm, runtimeCallInfo->GetCallArgRef(NUM_5), + offsetYArray.get(), length, ArkTSUtils::parseShadowOffsetWithResObj, offsetYResObjArray); bool fillParseResult = ArkTSUtils::ParseArray( vm, runtimeCallInfo->GetCallArgRef(NUM_6), fillArray.get(), length, ArkTSUtils::parseShadowFill); if (!radiusParseResult || !colorParseResult || !offsetXParseResult || @@ -279,6 +291,8 @@ ArkUINativeModuleValue TextTimerBridge::SetTextShadow(ArkUIRuntimeCallInfo* runt } auto textShadowArray = std::make_unique(length); CHECK_NULL_RETURN(textShadowArray.get(), panda::JSValueRef::Undefined(vm)); + auto textShadowResArray = std::make_unique(length); + CHECK_NULL_RETURN(textShadowResArray.get(), panda::JSValueRef::Undefined(vm)); for (uint32_t i = 0; i < length; i++) { textShadowArray[i].radius = radiusArray[i]; textShadowArray[i].type = typeArray[i]; @@ -286,10 +300,15 @@ ArkUINativeModuleValue TextTimerBridge::SetTextShadow(ArkUIRuntimeCallInfo* runt textShadowArray[i].offsetX = offsetXArray[i]; textShadowArray[i].offsetY = offsetYArray[i]; textShadowArray[i].fill = fillArray[i]; + textShadowResArray[i].radiusResObj = AceType::RawPtr(radiusResObjArray[i]); + textShadowResArray[i].colorResObj = AceType::RawPtr(colorResObjArray[i]); + textShadowResArray[i].offsetXResObj = AceType::RawPtr(offsetXResObjArray[i]); + textShadowResArray[i].offsetYResObj = AceType::RawPtr(offsetYResObjArray[i]); } auto nodeModifiers = GetArkUINodeModifiers(); CHECK_NULL_RETURN(nodeModifiers, panda::JSValueRef::Undefined(vm)); - nodeModifiers->getTextTimerModifier()->setTextShadow(nativeNode, textShadowArray.get(), length); + nodeModifiers->getTextTimerModifier()->setTextShadowRes( + nativeNode, textShadowArray.get(), textShadowResArray.get(), length); return panda::JSValueRef::Undefined(vm); } diff --git a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h index fe3484498cd..7a67015bb35 100644 --- a/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h +++ b/frameworks/bridge/declarative_frontend/engine/jsi/nativeModule/arkts_utils.h @@ -199,7 +199,7 @@ public: } template static bool ParseArrayWithResObj(const EcmaVM *vm, const Local &arg, T *array, int32_t defaultLength, - std::function &, const RefPtr &)> getValue, + std::function &, RefPtr &)> getValue, std::vector>& resObjArray) { CHECK_NULL_RETURN(vm, false); diff --git a/frameworks/bridge/declarative_frontend/jsview/js_pattern_lock.cpp b/frameworks/bridge/declarative_frontend/jsview/js_pattern_lock.cpp index 2de45ae219b..ce8d892e2ca 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_pattern_lock.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_pattern_lock.cpp @@ -134,7 +134,7 @@ void JSPatternLock::SetSelectedColor(const JSCallbackInfo& info) if (SystemProperties::ConfigChangePerform()) { bool state = ParseJsColor(info[0], selectedColor, resObj); if (resObj) { - PatternLockModel::GetInstance()->CreateWithResourceObj(JsResourceType::SELECTEDCOLOR, resObj); + PatternLockModel::GetInstance()->CreateWithResourceObj(PatternLockResourceType::SELECTEDCOLOR, resObj); } else if (state) { PatternLockModel::GetInstance()->SetSelectedColor(selectedColor); } else { @@ -174,7 +174,7 @@ void JSPatternLock::SetPathColor(const JSCallbackInfo& info) if (SystemProperties::ConfigChangePerform()) { bool state = ParseJsColor(info[0], pathColor, resObj); if (resObj) { - PatternLockModel::GetInstance()->CreateWithResourceObj(JsResourceType::PATHCOLOR, resObj); + PatternLockModel::GetInstance()->CreateWithResourceObj(PatternLockResourceType::PATHCOLOR, resObj); } else if (state) { PatternLockModel::GetInstance()->SetPathColor(pathColor); } else { @@ -203,7 +203,7 @@ void JSPatternLock::SetActiveColor(const JSCallbackInfo& info) if (SystemProperties::ConfigChangePerform()) { bool state = ParseJsColor(info[0], activeColor, resObj); if (resObj) { - PatternLockModel::GetInstance()->CreateWithResourceObj(JsResourceType::ACTIVECOLOR, resObj); + PatternLockModel::GetInstance()->CreateWithResourceObj(PatternLockResourceType::ACTIVECOLOR, resObj); } else if (state) { PatternLockModel::GetInstance()->SetActiveColor(activeColor); } else { @@ -232,7 +232,7 @@ void JSPatternLock::SetRegularColor(const JSCallbackInfo& info) if (SystemProperties::ConfigChangePerform()) { bool state = ParseJsColor(info[0], regularColor, resObj); if (resObj) { - PatternLockModel::GetInstance()->CreateWithResourceObj(JsResourceType::REGULARCOLOR, resObj); + PatternLockModel::GetInstance()->CreateWithResourceObj(PatternLockResourceType::REGULARCOLOR, resObj); } else if (state) { PatternLockModel::GetInstance()->SetRegularColor(regularColor); } else { @@ -261,7 +261,7 @@ void JSPatternLock::SetCircleRadius(const JSCallbackInfo& info) if (SystemProperties::ConfigChangePerform()) { bool state = ParseJsDimensionVp(info[0], radius, resObj); if (resObj) { - PatternLockModel::GetInstance()->CreateWithResourceObj(JsResourceType::CIRCLERADIUS, resObj); + PatternLockModel::GetInstance()->CreateWithResourceObj(PatternLockResourceType::CIRCLERADIUS, resObj); } else if (state && !radius.IsNonPositive()) { PatternLockModel::GetInstance()->SetCircleRadius(radius); } else { @@ -298,7 +298,7 @@ void JSPatternLock::SetSideLength(const JSCallbackInfo& info) if (SystemProperties::ConfigChangePerform()) { bool state = ParseJsDimensionVp(info[0], sideLength, resObj); if (resObj) { - PatternLockModel::GetInstance()->CreateWithResourceObj(JsResourceType::SIDELENGTH, resObj); + PatternLockModel::GetInstance()->CreateWithResourceObj(PatternLockResourceType::SIDELENGTH, resObj); } else if (state && sideLength.IsNonNegative()) { PatternLockModel::GetInstance()->SetSideLength(sideLength); } else { @@ -356,7 +356,7 @@ void JSPatternLock::SetActiveCircleColor(const JSRef& info) if (SystemProperties::ConfigChangePerform()) { bool state = ParseJsColor(info, activeColor, resObj); if (resObj) { - PatternLockModel::GetInstance()->CreateWithResourceObj(JsResourceType::ACTIVECIRCLECOLOR, resObj); + PatternLockModel::GetInstance()->CreateWithResourceObj(PatternLockResourceType::ACTIVECIRCLECOLOR, resObj); } else if (state) { PatternLockModel::GetInstance()->SetActiveCircleColor(activeColor); } else { diff --git a/frameworks/bridge/declarative_frontend/jsview/js_progress.cpp b/frameworks/bridge/declarative_frontend/jsview/js_progress.cpp index 1df343efefd..c1d8cd77859 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_progress.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_progress.cpp @@ -152,6 +152,9 @@ void JSProgress::SetColor(const JSCallbackInfo& info) beginColor = theme->GetRingProgressBeginSideColor(); colorVal = (g_progressType == ProgressType::CAPSULE) ? theme->GetCapsuleParseFailedSelectColor() : theme->GetTrackParseFailedSelectedColor(); + } else { + endColor = colorVal; + beginColor = colorVal; } NG::GradientColor endSideColor; NG::GradientColor beginSideColor; diff --git a/frameworks/bridge/declarative_frontend/jsview/js_text_clock.cpp b/frameworks/bridge/declarative_frontend/jsview/js_text_clock.cpp index f25d8561e7e..7a4ac7a2f2e 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_text_clock.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_text_clock.cpp @@ -197,6 +197,7 @@ void JSTextClock::SetFontWeight(const JSCallbackInfo& info) RefPtr textTheme = GetTheme(); CHECK_NULL_VOID(textTheme); const auto& fontWeight = info[0]; + RefPtr weightResObj; if (fontWeight->IsUndefined()) { TextClockModel::GetInstance()->SetFontWeight(textTheme->GetTextStyleClock().GetFontWeight()); return; @@ -207,7 +208,11 @@ void JSTextClock::SetFontWeight(const JSCallbackInfo& info) if (fontWeight->IsNumber()) { weight = std::to_string(fontWeight->ToNumber()); } else { - ParseJsString(fontWeight, weight); + ParseJsString(fontWeight, weight, weightResObj); + if (SystemProperties::ConfigChangePerform() && weightResObj) { + TextClockModel::GetInstance()->CreateWithFontWeightResourceObj(weightResObj); + return; + } } TextClockModel::GetInstance()->SetFontWeight(ConvertStrToFontWeight(weight)); } else { diff --git a/frameworks/bridge/declarative_frontend/jsview/models/patternlock_model_impl.h b/frameworks/bridge/declarative_frontend/jsview/models/patternlock_model_impl.h index 714885ca543..7192d1c350b 100644 --- a/frameworks/bridge/declarative_frontend/jsview/models/patternlock_model_impl.h +++ b/frameworks/bridge/declarative_frontend/jsview/models/patternlock_model_impl.h @@ -38,7 +38,8 @@ public: void SetEnableWaveEffect(bool enableWaveEffect) override; void SetEnableForeground(bool enableForeground) override; void SetSkipUnselectedPoint(bool isSkipUnselectedPoint) override; - void CreateWithResourceObj(JsResourceType jsResourceType, const RefPtr& resObj) override {}; + void CreateWithResourceObj( + PatternLockResourceType PatternLockResourceType, const RefPtr& resObj) override {}; }; } // namespace OHOS::Ace::Framework diff --git a/frameworks/bridge/declarative_frontend/jsview/models/text_clock_model_impl.h b/frameworks/bridge/declarative_frontend/jsview/models/text_clock_model_impl.h index 74cb7320ec4..802f7bf1fee 100644 --- a/frameworks/bridge/declarative_frontend/jsview/models/text_clock_model_impl.h +++ b/frameworks/bridge/declarative_frontend/jsview/models/text_clock_model_impl.h @@ -40,7 +40,8 @@ public: void CreateWithTextColorResourceObj(const RefPtr& resObj) override {}; void CreateWithFontSizeResourceObj(const RefPtr& resObj) override {}; void CreateWithFontFamilyResourceObj(const RefPtr& resObj) override {}; - + void CreateWithFontWeightResourceObj(const RefPtr& resObj) override {}; + private: static RefPtr GetComponent(); }; diff --git a/frameworks/core/components_ng/pattern/counter/counter_model_ng.cpp b/frameworks/core/components_ng/pattern/counter/counter_model_ng.cpp index 359a987af2b..b6c9d2a6887 100644 --- a/frameworks/core/components_ng/pattern/counter/counter_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/counter/counter_model_ng.cpp @@ -377,75 +377,99 @@ void CounterModelNG::CreateWithResourceObj(JsCounterResourceType jsResourceType, { auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); CHECK_NULL_VOID(frameNode); + CreateWithResourceObj(frameNode, jsResourceType, resObj); +} + +void CounterModelNG::CreateWithResourceObj( + FrameNode* frameNode, JsCounterResourceType jsResourceType, const RefPtr& resObj) +{ auto pattern = frameNode->GetPattern(); CHECK_NULL_VOID(pattern); std::string key; switch (jsResourceType) { - case JsCounterResourceType::Height: { - key = "counter.height"; - auto&& updateFunc = [pattern, key, this](const RefPtr& resObj, bool isFirstLoad = false) { - Dimension height; - if (ResourceParseUtils::ConvertFromResObjNG(resObj, height)) { - auto frameNode = pattern->GetHost(); - CHECK_NULL_VOID(frameNode); - auto pipelineContext = frameNode->GetContext(); - CHECK_NULL_VOID(pipelineContext); - if (pipelineContext->IsSystmColorChange() || isFirstLoad) { - if (LessNotEqual(height.Value(), 0.0)) { - return; - } - SetHeight(AceType::RawPtr(frameNode), height); - } - } - }; - updateFunc(resObj, true); - pattern->AddResObj(key, resObj, std::move(updateFunc)); + case JsCounterResourceType::Height: + HandleHeightResource(frameNode, resObj); break; - } - case JsCounterResourceType::Width: { - key = "counter.width"; - auto&& updateFunc = [pattern, key, this](const RefPtr& resObj, bool isFirstLoad = false) { - Dimension width; - if (ResourceParseUtils::ConvertFromResObjNG(resObj, width)) { - auto frameNode = pattern->GetHost(); - CHECK_NULL_VOID(frameNode); - auto pipelineContext = frameNode->GetContext(); - CHECK_NULL_VOID(pipelineContext); - if (pipelineContext->IsSystmColorChange() || isFirstLoad) { - if (LessNotEqual(width.Value(), 0.0)) { - return; - } - SetWidth(AceType::RawPtr(frameNode), width); - } - } - }; - updateFunc(resObj, true); - pattern->AddResObj(key, resObj, std::move(updateFunc)); + case JsCounterResourceType::Width: + HandleWidthResource(frameNode, resObj); break; - } - case JsCounterResourceType::BackgroundColor: { - key = "counter.backgroundColor"; - auto&& updateFunc = [pattern, key, this](const RefPtr& resObj, bool isFirstLoad = false) { - Color color; - if (ResourceParseUtils::ParseResColor(resObj, color)) { - auto frameNode = pattern->GetHost(); - CHECK_NULL_VOID(frameNode); - auto pipelineContext = frameNode->GetContext(); - CHECK_NULL_VOID(pipelineContext); - if (pipelineContext->IsSystmColorChange() || isFirstLoad) { - SetBackgroundColor(AceType::RawPtr(frameNode), color); - } - } - }; - updateFunc(resObj, true); - pattern->AddResObj(key, resObj, std::move(updateFunc)); + case JsCounterResourceType::BackgroundColor: + HandleBackgroundColorResource(frameNode, resObj); break; - } default: LOGE("Unsupported JsCounterResourceType"); break; } } + +void CounterModelNG::HandleHeightResource(FrameNode* frameNode, const RefPtr& resObj) +{ + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string key = "counter.height"; + auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFirstLoad = false) { + Dimension height; + if (!ResourceParseUtils::ConvertFromResObjNG(resObj, height)) { + return; + } + auto frameNode = pattern->GetHost(); + CHECK_NULL_VOID(frameNode); + auto pipelineContext = frameNode->GetContext(); + CHECK_NULL_VOID(pipelineContext); + if (pipelineContext->IsSystmColorChange() || isFirstLoad) { + if (!LessNotEqual(height.Value(), 0.0)) { + SetHeight(AceType::RawPtr(frameNode), height); + } + } + }; + updateFunc(resObj, true); + pattern->AddResObj(key, resObj, std::move(updateFunc)); +} + +void CounterModelNG::HandleWidthResource(FrameNode* frameNode, const RefPtr& resObj) +{ + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string key = "counter.width"; + auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFirstLoad = false) { + Dimension width; + if (!ResourceParseUtils::ConvertFromResObjNG(resObj, width)) { + return; + } + auto frameNode = pattern->GetHost(); + CHECK_NULL_VOID(frameNode); + auto pipelineContext = frameNode->GetContext(); + CHECK_NULL_VOID(pipelineContext); + if (pipelineContext->IsSystmColorChange() || isFirstLoad) { + if (!LessNotEqual(width.Value(), 0.0)) { + SetWidth(AceType::RawPtr(frameNode), width); + } + } + }; + updateFunc(resObj, true); + pattern->AddResObj(key, resObj, std::move(updateFunc)); +} + +void CounterModelNG::HandleBackgroundColorResource(FrameNode* frameNode, const RefPtr& resObj) +{ + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string key = "counter.backgroundColor"; + auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFirstLoad = false) { + Color color; + if (ResourceParseUtils::ParseResColor(resObj, color)) { + auto frameNode = pattern->GetHost(); + CHECK_NULL_VOID(frameNode); + auto pipelineContext = frameNode->GetContext(); + CHECK_NULL_VOID(pipelineContext); + if (pipelineContext->IsSystmColorChange() || isFirstLoad) { + SetBackgroundColor(AceType::RawPtr(frameNode), color); + } + } + }; + updateFunc(resObj, true); + pattern->AddResObj(key, resObj, std::move(updateFunc)); +} } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/counter/counter_model_ng.h b/frameworks/core/components_ng/pattern/counter/counter_model_ng.h index e12b7ee4f12..7c4db701cb2 100644 --- a/frameworks/core/components_ng/pattern/counter/counter_model_ng.h +++ b/frameworks/core/components_ng/pattern/counter/counter_model_ng.h @@ -43,6 +43,11 @@ public: static void ResetBackgroundColor(FrameNode* frameNode); static void SetOnInc(FrameNode* frameNode, CounterEventFunc&& onInc); static void SetOnDec(FrameNode* frameNode, CounterEventFunc&& onDec); + static void CreateWithResourceObj( + FrameNode* frameNode, JsCounterResourceType resourceType, const RefPtr& resObj); + static void HandleHeightResource(FrameNode* frameNode, const RefPtr& resObj); + static void HandleWidthResource(FrameNode* frameNode, const RefPtr& resObj); + static void HandleBackgroundColorResource(FrameNode* frameNode, const RefPtr& resObj); private: RefPtr CreateButtonChild( diff --git a/frameworks/core/components_ng/pattern/patternlock/patternlock_model.h b/frameworks/core/components_ng/pattern/patternlock/patternlock_model.h index cbb9845c84b..75b1ccebf2f 100644 --- a/frameworks/core/components_ng/pattern/patternlock/patternlock_model.h +++ b/frameworks/core/components_ng/pattern/patternlock/patternlock_model.h @@ -23,7 +23,7 @@ #include "core/common/resource/resource_object.h" namespace OHOS::Ace { -enum class JsResourceType { +enum class PatternLockResourceType { SELECTEDCOLOR, PATHCOLOR, ACTIVECOLOR, @@ -53,7 +53,8 @@ public: virtual void SetEnableWaveEffect(bool enableWaveEffect); virtual void SetEnableForeground(bool enableForeground); virtual void SetSkipUnselectedPoint(bool isSkipUnselectedPoint); - virtual void CreateWithResourceObj(JsResourceType jsResourceType, const RefPtr& resObj); + virtual void CreateWithResourceObj( + PatternLockResourceType PatternLockResourceType, const RefPtr& resObj); private: static std::unique_ptr instance_; diff --git a/frameworks/core/components_ng/pattern/patternlock/patternlock_model_ng.cpp b/frameworks/core/components_ng/pattern/patternlock/patternlock_model_ng.cpp index 08264f8e92a..33ef9ac353c 100644 --- a/frameworks/core/components_ng/pattern/patternlock/patternlock_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/patternlock/patternlock_model_ng.cpp @@ -197,168 +197,214 @@ void PatternLockModelNG::SetDotConnect(FrameNode* frameNode, std::functionSetOnDotConnect(std::move(onDotConnect)); } -void PatternLockModelNG::CreateWithResourceObj(JsResourceType jsResourceType, const RefPtr& resObj) +void PatternLockModelNG::CreateWithResourceObj( + PatternLockResourceType PatternLockResourceType, const RefPtr& resObj) { auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); CHECK_NULL_VOID(frameNode); - auto pattern = frameNode->GetPattern(); - CHECK_NULL_VOID(pattern); - if (resObj) { - switch (jsResourceType) { - case JsResourceType::SELECTEDCOLOR: { - std::string key = "patternLock.selectedColor"; - auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFristLoad = false) { - std::string color = pattern->GetResCacheMapByKey(key); - Color result; - if (color.empty()) { - if (ResourceParseUtils::ParseResColor(resObj, result)) { - pattern->AddResCache(key, result.ColorToString()); - } else { - auto pipeline = PipelineBase::GetCurrentContext(); - CHECK_NULL_VOID(pipeline); - auto theme = pipeline->GetTheme(); - CHECK_NULL_VOID(theme); - result = theme->GetSelectedColor(); - } - } else { - result = Color::ColorFromString(color); - } - pattern->UpdateSelectedColor(result, isFristLoad); - }; - updateFunc(resObj, true); - pattern->AddResObj(key, resObj, std::move(updateFunc)); + CreateWithResourceObj(frameNode, PatternLockResourceType, resObj); +} +void PatternLockModelNG::CreateWithResourceObj( + FrameNode* frameNode, PatternLockResourceType PatternLockResourceType, const RefPtr& resObj) +{ + if (resObj) { + switch (PatternLockResourceType) { + case PatternLockResourceType::SELECTEDCOLOR: + HandleSelectedColorResource(frameNode, resObj); break; - } - case JsResourceType::PATHCOLOR: { - std::string key = "patternLock.pathColor"; - auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFristLoad = false) { - std::string color = pattern->GetResCacheMapByKey(key); - Color result; - if (color.empty()) { - if (ResourceParseUtils::ParseResColor(resObj, result)) { - pattern->AddResCache(key, result.ColorToString()); - } else { - auto pipeline = PipelineBase::GetCurrentContext(); - CHECK_NULL_VOID(pipeline); - auto theme = pipeline->GetTheme(); - CHECK_NULL_VOID(theme); - result = theme->GetPathColor(); - } - } else { - result = Color::ColorFromString(color); - } - pattern->UpdatePathColor(result, isFristLoad); - }; - updateFunc(resObj, true); - pattern->AddResObj(key, resObj, std::move(updateFunc)); + case PatternLockResourceType::PATHCOLOR: + HandlePathColorResource(frameNode, resObj); break; - } - case JsResourceType::ACTIVECOLOR: { - std::string key = "patternLock.activeColor"; - auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFristLoad = false) { - std::string color = pattern->GetResCacheMapByKey(key); - Color result; - if (color.empty()) { - if (ResourceParseUtils::ParseResColor(resObj, result)) { - pattern->AddResCache(key, result.ColorToString()); - } else { - auto pipeline = PipelineBase::GetCurrentContext(); - CHECK_NULL_VOID(pipeline); - auto theme = pipeline->GetTheme(); - CHECK_NULL_VOID(theme); - result = theme->GetActiveColor(); - } - } else { - result = Color::ColorFromString(color); - } - pattern->UpdateActiveColor(result, isFristLoad); - }; - updateFunc(resObj, true); - pattern->AddResObj(key, resObj, std::move(updateFunc)); + case PatternLockResourceType::ACTIVECOLOR: + HandleActiveColorResource(frameNode, resObj); break; - } - case JsResourceType::REGULARCOLOR: { - std::string key = "patternLock.regularColor"; - auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFristLoad = false) { - std::string color = pattern->GetResCacheMapByKey(key); - Color result; - if (color.empty()) { - if (ResourceParseUtils::ParseResColor(resObj, result)) { - pattern->AddResCache(key, result.ColorToString()); - } else { - auto pipeline = PipelineBase::GetCurrentContext(); - CHECK_NULL_VOID(pipeline); - auto theme = pipeline->GetTheme(); - CHECK_NULL_VOID(theme); - result = theme->GetRegularColor(); - } - } else { - result = Color::ColorFromString(color); - } - pattern->UpdateRegularColor(result, isFristLoad); - }; - updateFunc(resObj, true); - pattern->AddResObj(key, resObj, std::move(updateFunc)); + case PatternLockResourceType::REGULARCOLOR: + HandleRegularColorResource(frameNode, resObj); break; - } - case JsResourceType::CIRCLERADIUS: { - std::string key = "patternLock.circleRadius"; - auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFristLoad = false) { - CalcDimension result; - if (!ResourceParseUtils::ParseResDimensionVp(resObj, result)) { - auto pipeline = PipelineBase::GetCurrentContext(); - CHECK_NULL_VOID(pipeline); - auto theme = pipeline->GetTheme(); - CHECK_NULL_VOID(theme); - result = theme->GetCircleRadius(); - } - pattern->UpdateCircleRadius(result, isFristLoad); - }; - updateFunc(resObj, true); - pattern->AddResObj(key, resObj, std::move(updateFunc)); + case PatternLockResourceType::CIRCLERADIUS: + HandleCircleRadiusResource(frameNode, resObj); break; - } - case JsResourceType::SIDELENGTH: { - std::string key = "patternLock.sideLength"; - auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFristLoad = false) { - CalcDimension result; - if (!ResourceParseUtils::ParseResDimensionVp(resObj, result)) { - auto pipeline = PipelineBase::GetCurrentContext(); - CHECK_NULL_VOID(pipeline); - auto theme = pipeline->GetTheme(); - CHECK_NULL_VOID(theme); - result = theme->GetSideLength(); - } - pattern->UpdateSideLength(result, isFristLoad); - }; - updateFunc(resObj, true); - pattern->AddResObj(key, resObj, std::move(updateFunc)); + case PatternLockResourceType::SIDELENGTH: + HandleSideLengthResource(frameNode, resObj); break; - } - case JsResourceType::ACTIVECIRCLECOLOR: { - std::string key = "patternLock.activeCircleColor"; - auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFristLoad = false) { - std::string color = pattern->GetResCacheMapByKey(key); - Color result; - if (color.empty()) { - if (ResourceParseUtils::ParseResColor(resObj, result)) { - pattern->AddResCache(key, result.ColorToString()); - } else { - result = Color::TRANSPARENT; - } - } else { - result = Color::ColorFromString(color); - } - pattern->UpdateActiveCircleColor(result, isFristLoad); - }; - updateFunc(resObj, true); - pattern->AddResObj(key, resObj, std::move(updateFunc)); + case PatternLockResourceType::ACTIVECIRCLECOLOR: + HandleActiveCircleColorResource(frameNode, resObj); break; - } default: break; } } } + +void PatternLockModelNG::HandleSelectedColorResource(FrameNode* frameNode, const RefPtr& resObj) +{ + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string key = "patternLock.selectedColor"; + auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFristLoad = false) { + std::string color = pattern->GetResCacheMapByKey(key); + Color result; + if (color.empty()) { + if (ResourceParseUtils::ParseResColor(resObj, result)) { + pattern->AddResCache(key, result.ColorToString()); + } else { + auto pipeline = PipelineBase::GetCurrentContext(); + CHECK_NULL_VOID(pipeline); + auto theme = pipeline->GetTheme(); + CHECK_NULL_VOID(theme); + result = theme->GetSelectedColor(); + } + } else { + result = Color::ColorFromString(color); + } + pattern->UpdateSelectedColor(result, isFristLoad); + }; + updateFunc(resObj, true); + pattern->AddResObj(key, resObj, std::move(updateFunc)); +} + +void PatternLockModelNG::HandlePathColorResource(FrameNode* frameNode, const RefPtr& resObj) +{ + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string key = "patternLock.pathColor"; + auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFristLoad = false) { + std::string color = pattern->GetResCacheMapByKey(key); + Color result; + if (color.empty()) { + if (ResourceParseUtils::ParseResColor(resObj, result)) { + pattern->AddResCache(key, result.ColorToString()); + } else { + auto pipeline = PipelineBase::GetCurrentContext(); + CHECK_NULL_VOID(pipeline); + auto theme = pipeline->GetTheme(); + CHECK_NULL_VOID(theme); + result = theme->GetPathColor(); + } + } else { + result = Color::ColorFromString(color); + } + pattern->UpdatePathColor(result, isFristLoad); + }; + updateFunc(resObj, true); + pattern->AddResObj(key, resObj, std::move(updateFunc)); +} + +void PatternLockModelNG::HandleActiveColorResource(FrameNode* frameNode, const RefPtr& resObj) +{ + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string key = "patternLock.activeColor"; + auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFristLoad = false) { + std::string color = pattern->GetResCacheMapByKey(key); + Color result; + if (color.empty()) { + if (ResourceParseUtils::ParseResColor(resObj, result)) { + pattern->AddResCache(key, result.ColorToString()); + } else { + auto pipeline = PipelineBase::GetCurrentContext(); + CHECK_NULL_VOID(pipeline); + auto theme = pipeline->GetTheme(); + CHECK_NULL_VOID(theme); + result = theme->GetActiveColor(); + } + } else { + result = Color::ColorFromString(color); + } + pattern->UpdateActiveColor(result, isFristLoad); + }; + updateFunc(resObj, true); + pattern->AddResObj(key, resObj, std::move(updateFunc)); +} + +void PatternLockModelNG::HandleRegularColorResource(FrameNode* frameNode, const RefPtr& resObj) +{ + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string key = "patternLock.regularColor"; + auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFristLoad = false) { + std::string color = pattern->GetResCacheMapByKey(key); + Color result; + if (color.empty()) { + if (ResourceParseUtils::ParseResColor(resObj, result)) { + pattern->AddResCache(key, result.ColorToString()); + } else { + auto pipeline = PipelineBase::GetCurrentContext(); + CHECK_NULL_VOID(pipeline); + auto theme = pipeline->GetTheme(); + CHECK_NULL_VOID(theme); + result = theme->GetRegularColor(); + } + } else { + result = Color::ColorFromString(color); + } + pattern->UpdateRegularColor(result, isFristLoad); + }; + updateFunc(resObj, true); + pattern->AddResObj(key, resObj, std::move(updateFunc)); +} + +void PatternLockModelNG::HandleCircleRadiusResource(FrameNode* frameNode, const RefPtr& resObj) +{ + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string key = "patternLock.circleRadius"; + auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFristLoad = false) { + CalcDimension result; + if (!ResourceParseUtils::ParseResDimensionVp(resObj, result)) { + auto pipeline = PipelineBase::GetCurrentContext(); + CHECK_NULL_VOID(pipeline); + auto theme = pipeline->GetTheme(); + CHECK_NULL_VOID(theme); + result = theme->GetCircleRadius(); + } + pattern->UpdateCircleRadius(result, isFristLoad); + }; + updateFunc(resObj, true); + pattern->AddResObj(key, resObj, std::move(updateFunc)); +} + +void PatternLockModelNG::HandleSideLengthResource(FrameNode* frameNode, const RefPtr& resObj) +{ + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string key = "patternLock.sideLength"; + auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFristLoad = false) { + CalcDimension result; + if (!ResourceParseUtils::ParseResDimensionVp(resObj, result)) { + auto pipeline = PipelineBase::GetCurrentContext(); + CHECK_NULL_VOID(pipeline); + auto theme = pipeline->GetTheme(); + CHECK_NULL_VOID(theme); + result = theme->GetSideLength(); + } + pattern->UpdateSideLength(result, isFristLoad); + }; + updateFunc(resObj, true); + pattern->AddResObj(key, resObj, std::move(updateFunc)); +} + +void PatternLockModelNG::HandleActiveCircleColorResource(FrameNode* frameNode, const RefPtr& resObj) +{ + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + std::string key = "patternLock.activeCircleColor"; + auto&& updateFunc = [pattern, key](const RefPtr& resObj, bool isFristLoad = false) { + std::string color = pattern->GetResCacheMapByKey(key); + Color result; + if (color.empty()) { + if (ResourceParseUtils::ParseResColor(resObj, result)) { + pattern->AddResCache(key, result.ColorToString()); + } else { + result = Color::TRANSPARENT; + } + } else { + result = Color::ColorFromString(color); + } + pattern->UpdateActiveCircleColor(result, isFristLoad); + }; + updateFunc(resObj, true); + pattern->AddResObj(key, resObj, std::move(updateFunc)); +} } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/patternlock/patternlock_model_ng.h b/frameworks/core/components_ng/pattern/patternlock/patternlock_model_ng.h index fcd2aca294e..96280db13ca 100644 --- a/frameworks/core/components_ng/pattern/patternlock/patternlock_model_ng.h +++ b/frameworks/core/components_ng/pattern/patternlock/patternlock_model_ng.h @@ -38,7 +38,8 @@ public: void SetEnableWaveEffect(bool enableWaveEffect) override; void SetEnableForeground(bool enableForeground) override; void SetSkipUnselectedPoint(bool isSkipUnselectedPoint) override; - void CreateWithResourceObj(JsResourceType jsResourceType, const RefPtr& resObj) override; + void CreateWithResourceObj( + PatternLockResourceType PatternLockResourceType, const RefPtr& resObj) override; static void SetActiveColor(FrameNode* frameNode, const Color& activeColor); static void SetCircleRadius(FrameNode* frameNode, const Dimension& radius); @@ -55,6 +56,15 @@ public: static void SetSkipUnselectedPoint(FrameNode* frameNode, bool isSkipUnselectedPoint); static void SetPatternComplete(FrameNode* frameNode, NG::PatternLockCompleteEvent&& onComplete); static void SetDotConnect(FrameNode* frameNode, std::function&& onDotConnect); + static void CreateWithResourceObj( + FrameNode* frameNode, PatternLockResourceType PatternLockResourceType, const RefPtr& resObj); + static void HandleSelectedColorResource(FrameNode* frameNode, const RefPtr& resObj); + static void HandlePathColorResource(FrameNode* frameNode, const RefPtr& resObj); + static void HandleActiveColorResource(FrameNode* frameNode, const RefPtr& resObj); + static void HandleRegularColorResource(FrameNode* frameNode, const RefPtr& resObj); + static void HandleCircleRadiusResource(FrameNode* frameNode, const RefPtr& resObj); + static void HandleSideLengthResource(FrameNode* frameNode, const RefPtr& resObj); + static void HandleActiveCircleColorResource(FrameNode* frameNode, const RefPtr& resObj); }; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/text_clock/text_clock_model.h b/frameworks/core/components_ng/pattern/text_clock/text_clock_model.h index 2cceae957ad..b6d0d2fb40a 100644 --- a/frameworks/core/components_ng/pattern/text_clock/text_clock_model.h +++ b/frameworks/core/components_ng/pattern/text_clock/text_clock_model.h @@ -47,7 +47,8 @@ public: virtual void CreateWithTextColorResourceObj(const RefPtr& resObj) = 0; virtual void CreateWithFontSizeResourceObj(const RefPtr& resObj) = 0; virtual void CreateWithFontFamilyResourceObj(const RefPtr& resObj) = 0; - + virtual void CreateWithFontWeightResourceObj(const RefPtr& resObj) = 0; + private: static std::unique_ptr instance_; static std::mutex mutex_; diff --git a/frameworks/core/components_ng/pattern/text_clock/text_clock_model_ng.cpp b/frameworks/core/components_ng/pattern/text_clock/text_clock_model_ng.cpp index 85e8e36c0e6..ce7583a4eb1 100644 --- a/frameworks/core/components_ng/pattern/text_clock/text_clock_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/text_clock/text_clock_model_ng.cpp @@ -70,7 +70,10 @@ void TextClockModelNG::SetTextShadow(const std::vector& value) ACE_UPDATE_NODE_LAYOUT_PROPERTY(TextClockLayoutProperty, TextShadow, shadows, frameNode); }; ACE_UPDATE_LAYOUT_PROPERTY(TextClockLayoutProperty, TextShadow, value); - updateFunc(resObj); + if (SystemProperties::ConfigChangePerform()) { + updateFunc(resObj); + pattern->AddResObj("textClock.shadow", resObj, std::move(updateFunc)); + } } void TextClockModelNG::SetFontFeature(const FONT_FEATURES_LIST& value) @@ -205,7 +208,26 @@ void TextClockModelNG::SetHoursWest(FrameNode* frameNode, float hoursWest) void TextClockModelNG::SetTextShadow(FrameNode* frameNode, const std::vector& value) { + CHECK_NULL_VOID(frameNode); + RefPtr resObj = AceType::MakeRefPtr(); + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + if (!frameNode) { + return; + } + std::vector shadows = value; + for (auto& shadow : shadows) { + shadow.ReloadResources(); + } + ACE_UPDATE_NODE_LAYOUT_PROPERTY(TextClockLayoutProperty, TextShadow, shadows, frameNode); + }; ACE_UPDATE_NODE_LAYOUT_PROPERTY(TextClockLayoutProperty, TextShadow, value, frameNode); + if (SystemProperties::ConfigChangePerform()) { + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + updateFunc(resObj); + pattern->AddResObj("textClock.shadow", resObj, std::move(updateFunc)); + } } void TextClockModelNG::SetFontFeature(FrameNode* frameNode, const FONT_FEATURES_LIST& value) @@ -318,7 +340,11 @@ void TextClockModelNG::CreateWithTextColorResourceObj(const RefPtrGetMainFrameNode(); CHECK_NULL_VOID(frameNode); + CreateWithTextColorResourceObj(frameNode, resObj); +} +void TextClockModelNG::CreateWithTextColorResourceObj(FrameNode* frameNode, const RefPtr& resObj) +{ auto pattern = frameNode->GetPattern(); CHECK_NULL_VOID(pattern); @@ -345,7 +371,11 @@ void TextClockModelNG::CreateWithFontSizeResourceObj(const RefPtrGetMainFrameNode(); CHECK_NULL_VOID(frameNode); + CreateWithFontSizeResourceObj(frameNode, resObj); +} +void TextClockModelNG::CreateWithFontSizeResourceObj(FrameNode* frameNode, const RefPtr& resObj) +{ auto pattern = frameNode->GetPattern(); CHECK_NULL_VOID(pattern); std::string key = "textClockFontSize"; @@ -369,7 +399,11 @@ void TextClockModelNG::CreateWithFontFamilyResourceObj(const RefPtrGetMainFrameNode(); CHECK_NULL_VOID(frameNode); + CreateWithFontFamilyResourceObj(frameNode, resObj); +} +void TextClockModelNG::CreateWithFontFamilyResourceObj(FrameNode* frameNode, const RefPtr& resObj) +{ auto pattern = frameNode->GetPattern(); CHECK_NULL_VOID(pattern); @@ -383,4 +417,34 @@ void TextClockModelNG::CreateWithFontFamilyResourceObj(const RefPtrAddResObj(key, resObj, std::move(updateFunc)); } + +void TextClockModelNG::CreateWithFontWeightResourceObj(const RefPtr& resObj) +{ + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + CHECK_NULL_VOID(frameNode); + CreateWithFontWeightResourceObj(frameNode, resObj); +} + +void TextClockModelNG::CreateWithFontWeightResourceObj(FrameNode* frameNode, const RefPtr& resObj) +{ + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + const std::string key = "textClockFontWeight"; + auto updateFunc = [pattern, key](const RefPtr& obj) { + std::string weightStr; + auto node = pattern->GetHost(); + CHECK_NULL_VOID(node); + if (ResourceParseUtils::ParseResString(obj, weightStr)) { + SetFontWeight(AceType::RawPtr(node), StringUtils::StringToFontWeight(weightStr, FontWeight::NORMAL)); + } else { + auto pipeline = PipelineBase::GetCurrentContext(); + CHECK_NULL_VOID(pipeline); + auto textClockTheme = pipeline->GetTheme(pattern->GetThemeScopeId()); + CHECK_NULL_VOID(textClockTheme); + SetFontWeight(AceType::RawPtr(node), textClockTheme->GetTextStyleClock().GetFontWeight()); + } + }; + updateFunc(resObj); + pattern->AddResObj(key, resObj, std::move(updateFunc)); +} } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/text_clock/text_clock_model_ng.h b/frameworks/core/components_ng/pattern/text_clock/text_clock_model_ng.h index d726c268b1e..b5541db9797 100644 --- a/frameworks/core/components_ng/pattern/text_clock/text_clock_model_ng.h +++ b/frameworks/core/components_ng/pattern/text_clock/text_clock_model_ng.h @@ -50,6 +50,7 @@ public: void CreateWithTextColorResourceObj(const RefPtr& resObj) override; void CreateWithFontSizeResourceObj(const RefPtr& resObj) override; void CreateWithFontFamilyResourceObj(const RefPtr& resObj) override; + void CreateWithFontWeightResourceObj(const RefPtr& resObj) override; static RefPtr CreateFrameNode(int32_t nodeId); static RefPtr InitTextController(FrameNode* frameNode); @@ -69,6 +70,10 @@ public: static void SetJSTextClockController(FrameNode* frameNode, const RefPtr& controller); static RefPtr GetJSTextClockController(FrameNode* frameNode); static void SetOnDateChange(FrameNode* frameNode, std::function&& onChange); + static void CreateWithTextColorResourceObj(FrameNode* frameNode, const RefPtr& resObj); + static void CreateWithFontSizeResourceObj(FrameNode* frameNode, const RefPtr& resObj); + static void CreateWithFontFamilyResourceObj(FrameNode* frameNode, const RefPtr& resObj); + static void CreateWithFontWeightResourceObj(FrameNode* frameNode, const RefPtr& resObj); }; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/components_ng/pattern/texttimer/text_timer_model_ng.cpp b/frameworks/core/components_ng/pattern/texttimer/text_timer_model_ng.cpp index ec5647569f4..45b7e7b8432 100644 --- a/frameworks/core/components_ng/pattern/texttimer/text_timer_model_ng.cpp +++ b/frameworks/core/components_ng/pattern/texttimer/text_timer_model_ng.cpp @@ -74,7 +74,28 @@ void TextTimerModelNG::SetTextColor(const Color& value) void TextTimerModelNG::SetTextShadow(const std::vector& value) { + + auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); + CHECK_NULL_VOID(frameNode); + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + RefPtr resObj = AceType::MakeRefPtr(); + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + if (!frameNode) { + return; + } + std::vector shadows = value; + for (auto& shadow : shadows) { + shadow.ReloadResources(); + } + ACE_UPDATE_NODE_LAYOUT_PROPERTY(TextTimerLayoutProperty, TextShadow, shadows, frameNode); + }; ACE_UPDATE_LAYOUT_PROPERTY(TextTimerLayoutProperty, TextShadow, value); + if (SystemProperties::ConfigChangePerform()) { + updateFunc(resObj); + pattern->AddResObj("textTimer.shadow", resObj, std::move(updateFunc)); + } } void TextTimerModelNG::SetItalicFontStyle(Ace::FontStyle value) @@ -180,7 +201,26 @@ void TextTimerModelNG::SetFormat(FrameNode* frameNode, const std::string& format void TextTimerModelNG::SetTextShadow(FrameNode* frameNode, const std::vector& value) { + CHECK_NULL_VOID(frameNode); + RefPtr resObj = AceType::MakeRefPtr(); + auto&& updateFunc = [value, weak = AceType::WeakClaim(frameNode)](const RefPtr& resObj) { + auto frameNode = weak.Upgrade(); + if (!frameNode) { + return; + } + std::vector shadows = value; + for (auto& shadow : shadows) { + shadow.ReloadResources(); + } + ACE_UPDATE_NODE_LAYOUT_PROPERTY(TextTimerLayoutProperty, TextShadow, shadows, frameNode); + }; ACE_UPDATE_NODE_LAYOUT_PROPERTY(TextTimerLayoutProperty, TextShadow, value, frameNode); + if (SystemProperties::ConfigChangePerform()) { + auto pattern = frameNode->GetPattern(); + CHECK_NULL_VOID(pattern); + updateFunc(resObj); + pattern->AddResObj("textTimer.shadow", resObj, std::move(updateFunc)); + } } void TextTimerModelNG::SetBuilderFunc(FrameNode* frameNode, TextTimerMakeCallback&& makeFunc) @@ -284,6 +324,12 @@ void TextTimerModelNG::CreateWithResourceObj( { auto frameNode = ViewStackProcessor::GetInstance()->GetMainFrameNode(); CHECK_NULL_VOID(frameNode); + CreateWithResourceObj(frameNode, jsResourceType, resObj); +} + +void TextTimerModelNG::CreateWithResourceObj( + FrameNode* frameNode, JsTextTimerResourceType jsResourceType, const RefPtr& resObj) +{ if (resObj) { switch (jsResourceType) { case JsTextTimerResourceType::TEXTCOLOR: diff --git a/frameworks/core/components_ng/pattern/texttimer/text_timer_model_ng.h b/frameworks/core/components_ng/pattern/texttimer/text_timer_model_ng.h index 60d86b905a1..16fcc77c569 100644 --- a/frameworks/core/components_ng/pattern/texttimer/text_timer_model_ng.h +++ b/frameworks/core/components_ng/pattern/texttimer/text_timer_model_ng.h @@ -51,10 +51,6 @@ public: void SetFontWeight(FontWeight value) override; void SetFontFamily(const std::vector& value) override; void CreateWithResourceObj(JsTextTimerResourceType jsResourceType, const RefPtr& resObj) override; - void HandleTextColor(FrameNode* frameNode, const RefPtr& resObj); - void HandleFontWeight(FrameNode* frameNode, const RefPtr& resObj); - void HandleFontSize(FrameNode* frameNode, const RefPtr& resObj); - void HandleFontFamily(FrameNode* frameNode, const RefPtr& resObj); static RefPtr CreateFrameNode(int32_t nodeId); static RefPtr InitTextController(FrameNode* frameNode); static void SetIsCountDown(FrameNode* frameNode, bool isCountDown); @@ -70,6 +66,12 @@ public: static void SetJSTextTimerController(FrameNode* frameNode, const RefPtr& controller); static void SetOnTimer(FrameNode* frameNode, std::function&& onChange); static RefPtr GetJSTextTimerController(FrameNode* frameNode); + static void HandleTextColor(FrameNode* frameNode, const RefPtr& resObj); + static void HandleFontWeight(FrameNode* frameNode, const RefPtr& resObj); + static void HandleFontSize(FrameNode* frameNode, const RefPtr& resObj); + static void HandleFontFamily(FrameNode* frameNode, const RefPtr& resObj); + static void CreateWithResourceObj( + FrameNode* frameNode, JsTextTimerResourceType jsResourceType, const RefPtr& resObj); }; } // namespace OHOS::Ace::NG diff --git a/frameworks/core/interfaces/arkoala/arkoala_api.h b/frameworks/core/interfaces/arkoala/arkoala_api.h index 271c8cb08bc..e13c14840b7 100644 --- a/frameworks/core/interfaces/arkoala/arkoala_api.h +++ b/frameworks/core/interfaces/arkoala/arkoala_api.h @@ -506,6 +506,13 @@ struct ArkUITextShadowStruct { ArkUI_Uint32 fill; }; +struct ArkUITextShadowResStruct { + void* radiusResObj; + void* colorResObj; + void* offsetXResObj; + void* offsetYResObj; +}; + struct ArkUITextDetectConfigStruct { ArkUI_CharPtr types; void* onResult; @@ -4667,12 +4674,16 @@ struct ArkUICounterModifier { void (*setEnableDec)(ArkUINodeHandle node, ArkUI_Bool value); void (*resetEnableDec)(ArkUINodeHandle node); void (*setCounterHeight)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit); + void (*setCounterHeightRes)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, void* heightRawPtr); void (*resetCounterHeight)(ArkUINodeHandle node); void (*setCounterWidth)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit); + void (*setCounterWidthRes)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, void* widthRawPtr); void (*resetCounterWidth)(ArkUINodeHandle node); void (*setCounterBackgroundColor)(ArkUINodeHandle node, ArkUI_Uint32 color); void (*setCounterBackgroundColorWithColorSpace)( ArkUINodeHandle node, ArkUI_Uint32 color, ArkUI_Int32 colorSpace); + void (*setCounterBackgroundColorRes)( + ArkUINodeHandle node, ArkUI_Uint32 color, ArkUI_Int32 colorSpace, void* colorRawPtr); void (*resetCounterBackgroundColor)(ArkUINodeHandle node); void (*setCounterOnInc)(ArkUINodeHandle node, void* callback); void (*resetCounterOnInc)(ArkUINodeHandle node); @@ -5417,16 +5428,22 @@ struct ArkUITextClockModifier { void (*setFormat)(ArkUINodeHandle node, ArkUI_CharPtr format); void (*resetFormat)(ArkUINodeHandle node); void (*setFontColor)(ArkUINodeHandle node, ArkUI_Uint32 color); + void (*setFontColorRes)(ArkUINodeHandle node, ArkUI_Uint32 color, void* fontColorRawPtr); void (*resetFontColor)(ArkUINodeHandle node); void (*setFontSize)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit); + void (*setFontSizeRes)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, void* fontSizeRawPtr); void (*resetFontSize)(ArkUINodeHandle node); void (*setFontStyle)(ArkUINodeHandle node, ArkUI_Uint32 fontStyle); void (*resetFontStyle)(ArkUINodeHandle node); void (*setFontWeight)(ArkUINodeHandle node, ArkUI_CharPtr weight); + void (*setFontWeightRes)(ArkUINodeHandle node, ArkUI_CharPtr weight, void* fontWeightRawPtr); void (*resetFontWeight)(ArkUINodeHandle node); void (*setFontFamily)(ArkUINodeHandle node, ArkUI_CharPtr fontFamily); + void (*setFontFamilyRes)(ArkUINodeHandle node, ArkUI_CharPtr fontFamily, void* fontFamilyRawPtr); void (*resetFontFamily)(ArkUINodeHandle node); void (*setTextShadow)(ArkUINodeHandle node, struct ArkUITextShadowStruct* shadows, ArkUI_Uint32 length); + void (*setTextShadowRes)(ArkUINodeHandle node, struct ArkUITextShadowStruct* shadows, + struct ArkUITextShadowResStruct* shadowsRes, ArkUI_Uint32 length); void (*resetTextShadow)(ArkUINodeHandle node); void (*setFontFeature)(ArkUINodeHandle node, ArkUI_CharPtr value); void (*resetFontFeature)(ArkUINodeHandle node); @@ -5510,18 +5527,24 @@ struct ArkUITextPickerModifier { struct ArkUITextTimerModifier { void (*setFontColor)(ArkUINodeHandle node, ArkUI_Uint32 color); + void (*setFontColorRes)(ArkUINodeHandle node, ArkUI_Uint32 color, void* fontColorRawPtr); void (*resetFontColor)(ArkUINodeHandle node); void (*setFontSize)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit); + void (*setFontSizeRes)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, void* fontSizeRawPtr); void (*resetFontSize)(ArkUINodeHandle node); void (*setFontStyle)(ArkUINodeHandle node, ArkUI_Uint32 fontStyle); void (*resetFontStyle)(ArkUINodeHandle node); void (*setFontWeight)(ArkUINodeHandle node, ArkUI_CharPtr weight); + void (*setFontWeightRes)(ArkUINodeHandle node, ArkUI_CharPtr weight, void* fontWeightRawPtr); void (*resetFontWeight)(ArkUINodeHandle node); void (*setFontFamily)(ArkUINodeHandle node, ArkUI_CharPtr fontFamily); + void (*setFontFamilyRes)(ArkUINodeHandle node, ArkUI_CharPtr fontFamily, void* fontFamilyRawPtr); void (*resetFontFamily)(ArkUINodeHandle node); void (*setFormat)(ArkUINodeHandle node, ArkUI_CharPtr format); void (*resetFormat)(ArkUINodeHandle node); void (*setTextShadow)(ArkUINodeHandle node, struct ArkUITextShadowStruct* shadows, ArkUI_Uint32 length); + void (*setTextShadowRes)(ArkUINodeHandle node, struct ArkUITextShadowStruct* shadows, + struct ArkUITextShadowResStruct* shadowsRes, ArkUI_Uint32 length); void (*resetTextShadow)(ArkUINodeHandle node); void (*setTextTimerOptions)(ArkUINodeHandle node, ArkUI_Bool isCountDown, ArkUI_Float64 count); void (*setTextTimerOnTimer)(ArkUINodeHandle node, void* callback); @@ -5873,22 +5896,31 @@ struct ArkUIPatternLockControllerModifier { struct ArkUIPatternLockModifier { void (*setPatternLockActiveColor)(ArkUINodeHandle node, ArkUI_Uint32 value); + void (*setPatternLockActiveColorRes)(ArkUINodeHandle node, ArkUI_Uint32 value, void* activeColorRawPtr); void (*resetPatternLockActiveColor)(ArkUINodeHandle node); void (*setPatternLockCircleRadius)(ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit); + void (*setPatternLockCircleRadiusRes)( + ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit, void* circleRadiusRawPtr); void (*resetPatternLockCircleRadius)(ArkUINodeHandle node); void (*setPatternLockSelectedColor)(ArkUINodeHandle node, ArkUI_Uint32 value); + void (*setPatternLockSelectedColorRes)(ArkUINodeHandle node, ArkUI_Uint32 value, void* selectedColorRawPtr); void (*resetPatternLockSelectedColor)(ArkUINodeHandle node); void (*setPatternLockSideLength)(ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit); + void (*setPatternLockSideLengthRes)( + ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit, void* sideLengthRawPtr); void (*resetPatternLockSideLength)(ArkUINodeHandle node); void (*setPatternLockAutoReset)(ArkUINodeHandle node, ArkUI_Uint32 value); void (*resetPatternLockAutoReset)(ArkUINodeHandle node); void (*setPatternLockPathStrokeWidth)(ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit); void (*resetPatternLockPathStrokeWidth)(ArkUINodeHandle node); void (*setPatternLockRegularColor)(ArkUINodeHandle node, ArkUI_Uint32 color); + void (*setPatternLockRegularColorRes)(ArkUINodeHandle node, ArkUI_Uint32 color, void* regularColorRawPtr); void (*resetPatternLockRegularColor)(ArkUINodeHandle node); void (*setPatternLockPathColor)(ArkUINodeHandle node, ArkUI_Uint32 color); + void (*setPatternLockPathColorRes)(ArkUINodeHandle node, ArkUI_Uint32 color, void* pathColorRawPtr); void (*resetPatternLockPathColor)(ArkUINodeHandle node); void (*setPatternLockActiveCircleColor)(ArkUINodeHandle node, ArkUI_Uint32 value); + void (*setPatternLockActiveCircleColorRes)(ArkUINodeHandle node, ArkUI_Uint32 value, void* activeCircleColorRawPtr); void (*resetPatternLockActiveCircleColor)(ArkUINodeHandle node); void (*setPatternLockActiveCircleRadius)(ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit); void (*resetPatternLockActiveCircleRadius)(ArkUINodeHandle node); diff --git a/frameworks/core/interfaces/cjui/cjui_api.h b/frameworks/core/interfaces/cjui/cjui_api.h index b9530a6ff72..c976d5b34e9 100644 --- a/frameworks/core/interfaces/cjui/cjui_api.h +++ b/frameworks/core/interfaces/cjui/cjui_api.h @@ -2051,12 +2051,16 @@ struct CJUICounterModifier { void (*setEnableDec)(ArkUINodeHandle node, ArkUI_Bool value); void (*resetEnableDec)(ArkUINodeHandle node); void (*setCounterHeight)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit); + void (*setCounterHeightRes)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, void* heightRawPtr); void (*resetCounterHeight)(ArkUINodeHandle node); void (*setCounterWidth)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit); + void (*setCounterWidthRes)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, void* widthRawPtr); void (*resetCounterWidth)(ArkUINodeHandle node); void (*setCounterBackgroundColor)(ArkUINodeHandle node, ArkUI_Uint32 color); void (*setCounterBackgroundColorWithColorSpace)( ArkUINodeHandle node, ArkUI_Uint32 color, ArkUI_Int32 colorSpace); + void (*setCounterBackgroundColorRes)( + ArkUINodeHandle node, ArkUI_Uint32 color, ArkUI_Int32 colorSpace, void* colorRawPtr); void (*resetCounterBackgroundColor)(ArkUINodeHandle node); }; @@ -2659,16 +2663,22 @@ struct CJUITextClockModifier { void (*setFormat)(ArkUINodeHandle node, ArkUI_CharPtr format); void (*resetFormat)(ArkUINodeHandle node); void (*setFontColor)(ArkUINodeHandle node, ArkUI_Uint32 color); + void (*setFontColorRes)(ArkUINodeHandle node, ArkUI_Uint32 color, void* fontColorRawPtr); void (*resetFontColor)(ArkUINodeHandle node); void (*setFontSize)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit); + void (*setFontSizeRes)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, void* fontSizeRawPtr); void (*resetFontSize)(ArkUINodeHandle node); void (*setFontStyle)(ArkUINodeHandle node, ArkUI_Uint32 fontStyle); void (*resetFontStyle)(ArkUINodeHandle node); void (*setFontWeight)(ArkUINodeHandle node, ArkUI_CharPtr weight); + void (*setFontWeightRes)(ArkUINodeHandle node, ArkUI_CharPtr weight, void* fontWeightRawPtr); void (*resetFontWeight)(ArkUINodeHandle node); void (*setFontFamily)(ArkUINodeHandle node, ArkUI_CharPtr fontFamily); + void (*setFontFamilyRes)(ArkUINodeHandle node, ArkUI_CharPtr fontFamily, void* fontFamilyRawPtr); void (*resetFontFamily)(ArkUINodeHandle node); void (*setTextShadow)(ArkUINodeHandle node, struct ArkUITextShadowStruct* shadows, ArkUI_Uint32 length); + void (*setTextShadowRes)(ArkUINodeHandle node, struct ArkUITextShadowStruct* shadows, + struct ArkUITextShadowResStruct* shadowsRes, ArkUI_Uint32 length); void (*resetTextShadow)(ArkUINodeHandle node); void (*setFontFeature)(ArkUINodeHandle node, ArkUI_CharPtr value); void (*resetFontFeature)(ArkUINodeHandle node); @@ -2720,18 +2730,24 @@ struct CJUITextPickerModifier { struct CJUITextTimerModifier { void (*setFontColor)(ArkUINodeHandle node, ArkUI_Uint32 color); + void (*setFontColorRes)(ArkUINodeHandle node, ArkUI_Uint32 color, void* fontColorRawPtr); void (*resetFontColor)(ArkUINodeHandle node); void (*setFontSize)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit); + void (*setFontSizeRes)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, void* fontSizeRawPtr); void (*resetFontSize)(ArkUINodeHandle node); void (*setFontStyle)(ArkUINodeHandle node, ArkUI_Uint32 fontStyle); void (*resetFontStyle)(ArkUINodeHandle node); void (*setFontWeight)(ArkUINodeHandle node, ArkUI_CharPtr weight); + void (*setFontWeightRes)(ArkUINodeHandle node, ArkUI_CharPtr weight, void* fontWeightRawPtr); void (*resetFontWeight)(ArkUINodeHandle node); void (*setFontFamily)(ArkUINodeHandle node, ArkUI_CharPtr fontFamily); + void (*setFontFamilyRes)(ArkUINodeHandle node, ArkUI_CharPtr fontFamily, void* fontFamilyRawPtr); void (*resetFontFamily)(ArkUINodeHandle node); void (*setFormat)(ArkUINodeHandle node, ArkUI_CharPtr format); void (*resetFormat)(ArkUINodeHandle node); void (*setTextShadow)(ArkUINodeHandle node, struct ArkUITextShadowStruct* shadows, ArkUI_Uint32 length); + void (*setTextShadowRes)(ArkUINodeHandle node, struct ArkUITextShadowStruct* shadows, + struct ArkUITextShadowResStruct* shadowsRes, ArkUI_Uint32 length); void (*resetTextShadow)(ArkUINodeHandle node); }; @@ -3042,22 +3058,31 @@ struct CJUIPatternLockControllerModifier { struct CJUIPatternLockModifier { void (*setPatternLockActiveColor)(ArkUINodeHandle node, ArkUI_Uint32 value); + void (*setPatternLockActiveColorRes)(ArkUINodeHandle node, ArkUI_Uint32 value, void* activeColorRawPtr); void (*resetPatternLockActiveColor)(ArkUINodeHandle node); void (*setPatternLockCircleRadius)(ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit); + void (*setPatternLockCircleRadiusRes)( + ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit, void* circleRadiusRawPtr); void (*resetPatternLockCircleRadius)(ArkUINodeHandle node); void (*setPatternLockSelectedColor)(ArkUINodeHandle node, ArkUI_Uint32 value); + void (*setPatternLockSelectedColorRes)(ArkUINodeHandle node, ArkUI_Uint32 value, void* selectedColorRawPtr); void (*resetPatternLockSelectedColor)(ArkUINodeHandle node); void (*setPatternLockSideLength)(ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit); + void (*setPatternLockSideLengthRes)( + ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit, void* sideLengthRawPtr); void (*resetPatternLockSideLength)(ArkUINodeHandle node); void (*setPatternLockAutoReset)(ArkUINodeHandle node, ArkUI_Uint32 value); void (*resetPatternLockAutoReset)(ArkUINodeHandle node); void (*setPatternLockPathStrokeWidth)(ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit); void (*resetPatternLockPathStrokeWidth)(ArkUINodeHandle node); void (*setPatternLockRegularColor)(ArkUINodeHandle node, ArkUI_Uint32 color); + void (*setPatternLockRegularColorRes)(ArkUINodeHandle node, ArkUI_Uint32 color, void* regularColorRawPtr); void (*resetPatternLockRegularColor)(ArkUINodeHandle node); void (*setPatternLockPathColor)(ArkUINodeHandle node, ArkUI_Uint32 color); + void (*setPatternLockPathColorRes)(ArkUINodeHandle node, ArkUI_Uint32 color, void* pathColorRawPtr); void (*resetPatternLockPathColor)(ArkUINodeHandle node); void (*setPatternLockActiveCircleColor)(ArkUINodeHandle node, ArkUI_Uint32 value); + void (*setPatternLockActiveCircleColorRes)(ArkUINodeHandle node, ArkUI_Uint32 value, void* activeCircleColorRawPtr); void (*resetPatternLockActiveCircleColor)(ArkUINodeHandle node); void (*setPatternLockActiveCircleRadius)(ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit); void (*resetPatternLockActiveCircleRadius)(ArkUINodeHandle node); diff --git a/frameworks/core/interfaces/native/node/counter_modifier.cpp b/frameworks/core/interfaces/native/node/counter_modifier.cpp index 06f62145c79..d3c1c76ae85 100644 --- a/frameworks/core/interfaces/native/node/counter_modifier.cpp +++ b/frameworks/core/interfaces/native/node/counter_modifier.cpp @@ -49,6 +49,20 @@ void SetCounterHeight(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 uni Dimension height = Dimension(value, static_cast(unit)); CounterModelNG::SetHeight(frameNode, height); } + +void SetCounterHeightRes(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, void* heightRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + Dimension height = Dimension(value, static_cast(unit)); + CounterModelNG::SetHeight(frameNode, height); + if (SystemProperties::ConfigChangePerform() && heightRawPtr) { + auto* fontWeight = reinterpret_cast(heightRawPtr); + auto heightResObj = AceType::Claim(fontWeight); + CounterModelNG::CreateWithResourceObj(frameNode, JsCounterResourceType::Height, heightResObj); + } +} + void ResetCounterHeight(ArkUINodeHandle node) {} void SetCounterWidth(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit) { @@ -58,6 +72,19 @@ void SetCounterWidth(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit CounterModelNG::SetWidth(frameNode, width); } +void SetCounterWidthRes(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, void* widthRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + Dimension width = Dimension(value, static_cast(unit)); + CounterModelNG::SetWidth(frameNode, width); + if (SystemProperties::ConfigChangePerform() && widthRawPtr) { + auto* fontWeight = reinterpret_cast(widthRawPtr); + auto widthResObj = AceType::Claim(fontWeight); + CounterModelNG::CreateWithResourceObj(frameNode, JsCounterResourceType::Width, widthResObj); + } +} + void ResetCounterWidth(ArkUINodeHandle node) {} void SetCounterBackgroundColor(ArkUINodeHandle node, ArkUI_Uint32 color) @@ -78,6 +105,24 @@ void SetCounterBackgroundColorWithColorSpace(ArkUINodeHandle node, ArkUI_Uint32 backgroundColor.SetColorSpace(ColorSpace::SRGB); } CounterModelNG::SetBackgroundColor(frameNode, backgroundColor); +} + +void SetCounterBackgroundColorRes(ArkUINodeHandle node, ArkUI_Uint32 color, ArkUI_Int32 colorSpace, void* colorRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + Color backgroundColor { color }; + if (ColorSpace::DISPLAY_P3 == colorSpace) { + backgroundColor.SetColorSpace(ColorSpace::DISPLAY_P3); + } else { + backgroundColor.SetColorSpace(ColorSpace::SRGB); + } + CounterModelNG::SetBackgroundColor(frameNode, backgroundColor); + + if (SystemProperties::ConfigChangePerform() && colorRawPtr) { + auto* colorResObj = reinterpret_cast(colorRawPtr); + CounterModelNG::CreateWithResourceObj( + frameNode, JsCounterResourceType::BackgroundColor, AceType::Claim(colorResObj)); + } } void ResetCounterBackgroundColor(ArkUINodeHandle node) @@ -135,11 +180,14 @@ const ArkUICounterModifier* GetCounterModifier() .setEnableDec = SetEnableDec, .resetEnableDec = ResetEnableDec, .setCounterHeight = SetCounterHeight, + .setCounterHeightRes = SetCounterHeightRes, .resetCounterHeight = ResetCounterHeight, .setCounterWidth = SetCounterWidth, + .setCounterWidthRes = SetCounterWidthRes, .resetCounterWidth = ResetCounterWidth, .setCounterBackgroundColor = SetCounterBackgroundColor, .setCounterBackgroundColorWithColorSpace = SetCounterBackgroundColorWithColorSpace, + .setCounterBackgroundColorRes = SetCounterBackgroundColorRes, .resetCounterBackgroundColor = ResetCounterBackgroundColor, .setCounterOnInc = SetCounterOnInc, .resetCounterOnInc = ResetCounterOnInc, @@ -160,11 +208,14 @@ const CJUICounterModifier* GetCJUICounterModifier() .setEnableDec = SetEnableDec, .resetEnableDec = ResetEnableDec, .setCounterHeight = SetCounterHeight, + .setCounterHeightRes = SetCounterHeightRes, .resetCounterHeight = ResetCounterHeight, .setCounterWidth = SetCounterWidth, + .setCounterWidthRes = SetCounterWidthRes, .resetCounterWidth = ResetCounterWidth, .setCounterBackgroundColor = SetCounterBackgroundColor, .setCounterBackgroundColorWithColorSpace = SetCounterBackgroundColorWithColorSpace, + .setCounterBackgroundColorRes = SetCounterBackgroundColorRes, .resetCounterBackgroundColor = ResetCounterBackgroundColor, }; CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line diff --git a/frameworks/core/interfaces/native/node/pattern_lock_modifier.cpp b/frameworks/core/interfaces/native/node/pattern_lock_modifier.cpp index 7bab4804037..1e6cb4798e5 100644 --- a/frameworks/core/interfaces/native/node/pattern_lock_modifier.cpp +++ b/frameworks/core/interfaces/native/node/pattern_lock_modifier.cpp @@ -24,6 +24,18 @@ void SetPatternLockActiveColor(ArkUINodeHandle node, uint32_t value) PatternLockModelNG::SetActiveColor(frameNode, Color(value)); } +void SetPatternLockActiveColorRes(ArkUINodeHandle node, uint32_t value, void* activeColorRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + PatternLockModelNG::SetActiveColor(frameNode, Color(value)); + if (SystemProperties::ConfigChangePerform() && activeColorRawPtr) { + auto* activeColor = reinterpret_cast(activeColorRawPtr); + auto activeColorResObj = AceType::Claim(activeColor); + PatternLockModelNG::CreateWithResourceObj(frameNode, PatternLockResourceType::ACTIVECOLOR, activeColorResObj); + } +} + void ResetPatternLockActiveColor(ArkUINodeHandle node) { auto *frameNode = reinterpret_cast(node); @@ -51,6 +63,19 @@ void SetPatternLockCircleRadius(ArkUINodeHandle node, ArkUI_Float32 number, ArkU PatternLockModelNG::SetCircleRadius(frameNode, Dimension(number, static_cast(unit))); } +void SetPatternLockCircleRadiusRes( + ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit, void* circleRadiusRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + PatternLockModelNG::SetCircleRadius(frameNode, Dimension(number, static_cast(unit))); + if (SystemProperties::ConfigChangePerform() && circleRadiusRawPtr) { + auto* circleRadius = reinterpret_cast(circleRadiusRawPtr); + auto circleRadiusResObj = AceType::Claim(circleRadius); + PatternLockModelNG::CreateWithResourceObj(frameNode, PatternLockResourceType::CIRCLERADIUS, circleRadiusResObj); + } +} + void SetPatternLockSelectedColor(ArkUINodeHandle node, uint32_t value) { auto *frameNode = reinterpret_cast(node); @@ -58,6 +83,19 @@ void SetPatternLockSelectedColor(ArkUINodeHandle node, uint32_t value) PatternLockModelNG::SetSelectedColor(frameNode, Color(value)); } +void SetPatternLockSelectedColorRes(ArkUINodeHandle node, uint32_t value, void* selectedColorRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + PatternLockModelNG::SetSelectedColor(frameNode, Color(value)); + if (SystemProperties::ConfigChangePerform() && selectedColorRawPtr) { + auto* selectedColor = reinterpret_cast(selectedColorRawPtr); + auto selectedColorResObj = AceType::Claim(selectedColor); + PatternLockModelNG::CreateWithResourceObj( + frameNode, PatternLockResourceType::SELECTEDCOLOR, selectedColorResObj); + } +} + void ResetPatternLockSelectedColor(ArkUINodeHandle node) { auto *frameNode = reinterpret_cast(node); @@ -75,6 +113,18 @@ void SetPatternLockSideLength(ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_ PatternLockModelNG::SetSideLength(frameNode, Dimension(number, static_cast(unit))); } +void SetPatternLockSideLengthRes(ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 unit, void* sideLengthRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + PatternLockModelNG::SetSideLength(frameNode, Dimension(number, static_cast(unit))); + if (SystemProperties::ConfigChangePerform() && sideLengthRawPtr) { + auto* sideLength = reinterpret_cast(sideLengthRawPtr); + auto sideLengthResObj = AceType::Claim(sideLength); + PatternLockModelNG::CreateWithResourceObj(frameNode, PatternLockResourceType::SIDELENGTH, sideLengthResObj); + } +} + void ResetPatternLockSideLength(ArkUINodeHandle node) { auto *frameNode = reinterpret_cast(node); @@ -123,6 +173,18 @@ void SetPatternLockRegularColor(ArkUINodeHandle node, uint32_t color) PatternLockModelNG::SetRegularColor(frameNode, Color(color)); } +void SetPatternLockRegularColorRes(ArkUINodeHandle node, uint32_t color, void* regularColorRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + PatternLockModelNG::SetRegularColor(frameNode, Color(color)); + if (SystemProperties::ConfigChangePerform() && regularColorRawPtr) { + auto* regularColor = reinterpret_cast(regularColorRawPtr); + auto regularColorResObj = AceType::Claim(regularColor); + PatternLockModelNG::CreateWithResourceObj(frameNode, PatternLockResourceType::REGULARCOLOR, regularColorResObj); + } +} + void ResetPatternLockRegularColor(ArkUINodeHandle node) { auto *frameNode = reinterpret_cast(node); @@ -140,6 +202,18 @@ void SetPatternLockPathColor(ArkUINodeHandle node, uint32_t color) PatternLockModelNG::SetPathColor(frameNode, Color(color)); } +void SetPatternLockPathColorRes(ArkUINodeHandle node, uint32_t color, void* pathColorRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + PatternLockModelNG::SetPathColor(frameNode, Color(color)); + if (SystemProperties::ConfigChangePerform() && pathColorRawPtr) { + auto* pathColor = reinterpret_cast(pathColorRawPtr); + auto pathColorResObj = AceType::Claim(pathColor); + PatternLockModelNG::CreateWithResourceObj(frameNode, PatternLockResourceType::PATHCOLOR, pathColorResObj); + } +} + void ResetPatternLockPathColor(ArkUINodeHandle node) { auto *frameNode = reinterpret_cast(node); @@ -157,6 +231,19 @@ void SetPatternLockActiveCircleColor(ArkUINodeHandle node, uint32_t value) PatternLockModelNG::SetActiveCircleColor(frameNode, Color(value)); } +void SetPatternLockActiveCircleColorRes(ArkUINodeHandle node, uint32_t value, void* activeCircleColorRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + PatternLockModelNG::SetActiveCircleColor(frameNode, Color(value)); + if (SystemProperties::ConfigChangePerform() && activeCircleColorRawPtr) { + auto* activeCircleColor = reinterpret_cast(activeCircleColorRawPtr); + auto activeCircleColorResObj = AceType::Claim(activeCircleColor); + PatternLockModelNG::CreateWithResourceObj( + frameNode, PatternLockResourceType::ACTIVECIRCLECOLOR, activeCircleColorResObj); + } +} + void ResetPatternLockActiveCircleColor(ArkUINodeHandle node) { auto *frameNode = reinterpret_cast(node); @@ -267,22 +354,29 @@ const ArkUIPatternLockModifier* GetPatternLockModifier() CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line static const ArkUIPatternLockModifier modifier = { .setPatternLockActiveColor = SetPatternLockActiveColor, + .setPatternLockActiveColorRes = SetPatternLockActiveColorRes, .resetPatternLockActiveColor = ResetPatternLockActiveColor, .setPatternLockCircleRadius = SetPatternLockCircleRadius, + .setPatternLockCircleRadiusRes = SetPatternLockCircleRadiusRes, .resetPatternLockCircleRadius = ResetPatternLockCircleRadius, .setPatternLockSelectedColor = SetPatternLockSelectedColor, + .setPatternLockSelectedColorRes = SetPatternLockSelectedColorRes, .resetPatternLockSelectedColor = ResetPatternLockSelectedColor, .setPatternLockSideLength = SetPatternLockSideLength, + .setPatternLockSideLengthRes = SetPatternLockSideLengthRes, .resetPatternLockSideLength = ResetPatternLockSideLength, .setPatternLockAutoReset = SetPatternLockAutoReset, .resetPatternLockAutoReset = ResetPatternLockAutoReset, .setPatternLockPathStrokeWidth = SetPatternLockPathStrokeWidth, .resetPatternLockPathStrokeWidth = ResetPatternLockPathStrokeWidth, .setPatternLockRegularColor = SetPatternLockRegularColor, + .setPatternLockRegularColorRes = SetPatternLockRegularColorRes, .resetPatternLockRegularColor = ResetPatternLockRegularColor, .setPatternLockPathColor = SetPatternLockPathColor, + .setPatternLockPathColorRes = SetPatternLockPathColorRes, .resetPatternLockPathColor = ResetPatternLockPathColor, .setPatternLockActiveCircleColor = SetPatternLockActiveCircleColor, + .setPatternLockActiveCircleColorRes = SetPatternLockActiveCircleColorRes, .resetPatternLockActiveCircleColor = ResetPatternLockActiveCircleColor, .setPatternLockActiveCircleRadius = SetPatternLockActiveCircleRadius, .resetPatternLockActiveCircleRadius = ResetPatternLockActiveCircleRadius, @@ -306,22 +400,29 @@ const CJUIPatternLockModifier* GetCJUIPatternLockModifier() CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line static const CJUIPatternLockModifier modifier = { .setPatternLockActiveColor = SetPatternLockActiveColor, + .setPatternLockActiveColorRes = SetPatternLockActiveColorRes, .resetPatternLockActiveColor = ResetPatternLockActiveColor, .setPatternLockCircleRadius = SetPatternLockCircleRadius, + .setPatternLockCircleRadiusRes = SetPatternLockCircleRadiusRes, .resetPatternLockCircleRadius = ResetPatternLockCircleRadius, .setPatternLockSelectedColor = SetPatternLockSelectedColor, + .setPatternLockSelectedColorRes = SetPatternLockSelectedColorRes, .resetPatternLockSelectedColor = ResetPatternLockSelectedColor, .setPatternLockSideLength = SetPatternLockSideLength, + .setPatternLockSideLengthRes = SetPatternLockSideLengthRes, .resetPatternLockSideLength = ResetPatternLockSideLength, .setPatternLockAutoReset = SetPatternLockAutoReset, .resetPatternLockAutoReset = ResetPatternLockAutoReset, .setPatternLockPathStrokeWidth = SetPatternLockPathStrokeWidth, .resetPatternLockPathStrokeWidth = ResetPatternLockPathStrokeWidth, .setPatternLockRegularColor = SetPatternLockRegularColor, + .setPatternLockRegularColorRes = SetPatternLockRegularColorRes, .resetPatternLockRegularColor = ResetPatternLockRegularColor, .setPatternLockPathColor = SetPatternLockPathColor, + .setPatternLockPathColorRes = SetPatternLockPathColorRes, .resetPatternLockPathColor = ResetPatternLockPathColor, .setPatternLockActiveCircleColor = SetPatternLockActiveCircleColor, + .setPatternLockActiveCircleColorRes = SetPatternLockActiveCircleColorRes, .resetPatternLockActiveCircleColor = ResetPatternLockActiveCircleColor, .setPatternLockActiveCircleRadius = SetPatternLockActiveCircleRadius, .resetPatternLockActiveCircleRadius = ResetPatternLockActiveCircleRadius, diff --git a/frameworks/core/interfaces/native/node/text_clock_modifier.cpp b/frameworks/core/interfaces/native/node/text_clock_modifier.cpp index 48861c00a8c..97c5128fff4 100644 --- a/frameworks/core/interfaces/native/node/text_clock_modifier.cpp +++ b/frameworks/core/interfaces/native/node/text_clock_modifier.cpp @@ -13,12 +13,14 @@ * limitations under the License. */ #include "core/interfaces/native/node/text_clock_modifier.h" +#include "ui/resource/resource_object.h" #include "bridge/common/utils/utils.h" #include "core/components/common/properties/text_style_parser.h" #include "core/components_ng/pattern/text_clock/text_clock_event_hub.h" #include "core/components_ng/pattern/text_clock/text_clock_model_ng.h" #include "core/components_ng/pattern/text_clock/text_clock_pattern.h" +#include "core/common/resource/resource_parse_utils.h" namespace OHOS::Ace::NG { constexpr Ace::FontStyle DEFAULT_FONT_STYLE = Ace::FontStyle::NORMAL; @@ -49,6 +51,18 @@ void SetFontColor(ArkUINodeHandle node, ArkUI_Uint32 color) TextClockModelNG::SetFontColor(frameNode, Color(color)); } +void SetFontColorRes(ArkUINodeHandle node, ArkUI_Uint32 color, void* fontColorRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + TextClockModelNG::SetFontColor(frameNode, Color(color)); + if (SystemProperties::ConfigChangePerform() && fontColorRawPtr) { + auto* fontColor = reinterpret_cast(fontColorRawPtr); + auto pathColorResObj = AceType::Claim(fontColor); + TextClockModelNG::CreateWithTextColorResourceObj(frameNode, pathColorResObj); + } +} + void ResetFontColor(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); @@ -67,6 +81,18 @@ void SetFontSize(ArkUINodeHandle node, ArkUI_Float32 fontSizeValue, ArkUI_Int32 TextClockModelNG::SetFontSize(frameNode, CalcDimension(fontSizeValue, (DimensionUnit)fontSizeUnit)); } +void SetFontSizeRes(ArkUINodeHandle node, ArkUI_Float32 fontSizeValue, ArkUI_Int32 fontSizeUnit, void* fontSizeRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + TextClockModelNG::SetFontSize(frameNode, CalcDimension(fontSizeValue, (DimensionUnit)fontSizeUnit)); + if (SystemProperties::ConfigChangePerform() && fontSizeRawPtr) { + auto* fontSize = reinterpret_cast(fontSizeRawPtr); + auto pathFontSizeResObj = AceType::Claim(fontSize); + TextClockModelNG::CreateWithFontSizeResourceObj(frameNode, pathFontSizeResObj); + } +} + void ResetFontSize(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); @@ -96,6 +122,19 @@ void SetFontWeight(ArkUINodeHandle node, ArkUI_CharPtr fontWeight) TextClockModelNG::SetFontWeight(frameNode, Framework::ConvertStrToFontWeight(fontWeightStr)); } +void SetFontWeightRes(ArkUINodeHandle node, ArkUI_CharPtr fontWeight, void* fontWeightRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + std::string fontWeightStr = fontWeight; + TextClockModelNG::SetFontWeight(frameNode, Framework::ConvertStrToFontWeight(fontWeightStr)); + if (SystemProperties::ConfigChangePerform() && fontWeightRawPtr) { + auto* fontWeight = reinterpret_cast(fontWeightRawPtr); + auto pathFontWeightResObj = AceType::Claim(fontWeight); + TextClockModelNG::CreateWithFontWeightResourceObj(frameNode, pathFontWeightResObj); + } +} + void ResetFontWeight(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); @@ -112,6 +151,20 @@ void SetFontFamily(ArkUINodeHandle node, ArkUI_CharPtr fontFamily) TextClockModelNG::SetFontFamily(frameNode, fontFamilyResult); } +void SetFontFamilyRes(ArkUINodeHandle node, ArkUI_CharPtr fontFamily, void* fontFamilyRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + std::string familiesStr = fontFamily; + std::vector fontFamilyResult = Framework::ConvertStrToFontFamilies(familiesStr); + TextClockModelNG::SetFontFamily(frameNode, fontFamilyResult); + if (SystemProperties::ConfigChangePerform() && fontFamilyRawPtr) { + auto* fontFamily = reinterpret_cast(fontFamilyRawPtr); + auto pathFontFamilyResObj = AceType::Claim(fontFamily); + TextClockModelNG::CreateWithFontFamilyResourceObj(frameNode, pathFontFamilyResObj); + } +} + void ResetFontFamily(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); @@ -141,6 +194,103 @@ void SetTextShadow(ArkUINodeHandle node, struct ArkUITextShadowStruct* shadows, TextClockModelNG::SetTextShadow(frameNode, shadowList); } +void ParseShadowRadiusUpdate(const RefPtr& radiusResObj, Shadow& shadow) +{ + if (!radiusResObj) { + return; + } + auto&& updateFunc = [](const RefPtr& resObj, Shadow& shadow) { + double radius = 0.0; + ResourceParseUtils::ParseResDouble(resObj, radius); + shadow.SetBlurRadius(std::max(radius, 0.0)); + }; + shadow.AddResource("shadow.radius", radiusResObj, std::move(updateFunc)); +} + +void ParseShadowColorUpdate(const RefPtr& colorResObj, Shadow& shadow) +{ + if (!colorResObj) { + return; + } + auto&& updateFunc = [](const RefPtr& resObj, Shadow& shadow) { + Color color; + ResourceParseUtils::ParseResColor(resObj, color); + shadow.SetColor(color); + }; + shadow.AddResource("shadow.colorValue", colorResObj, std::move(updateFunc)); +} + +void ParseShadowOffsetXUpdate(const RefPtr& offsetXResObj, Shadow& shadow) +{ + if (!offsetXResObj) { + return; + } + auto&& updateFunc = [](const RefPtr& resObj, Shadow& shadow) { + CalcDimension xValue; + ResourceParseUtils::ParseResResource(resObj, xValue); + shadow.SetOffsetX(xValue.Value()); + }; + shadow.AddResource("shadow.offsetX", offsetXResObj, std::move(updateFunc)); +} + +void ParseShadowOffsetYUpdate(const RefPtr& offsetYResObj, Shadow& shadow) +{ + if (!offsetYResObj) { + return; + } + auto&& updateFunc = [](const RefPtr& resObj, Shadow& shadow) { + CalcDimension yValue; + ResourceParseUtils::ParseResResource(resObj, yValue); + shadow.SetOffsetY(yValue.Value()); + }; + shadow.AddResource("shadow.offsetY", offsetYResObj, std::move(updateFunc)); +} + +void SetTextShadowRes( + ArkUINodeHandle node, ArkUITextShadowStruct* shadows, ArkUITextShadowResStruct* shadowsRes, ArkUI_Uint32 length) +{ + CHECK_NULL_VOID(shadows); + CHECK_NULL_VOID(shadowsRes); + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + std::vector shadowList(length); + for (uint32_t i = 0; i < length; i++) { + Shadow shadow; + ArkUITextShadowStruct* shadowStruct = &shadows[i]; + ArkUITextShadowResStruct* shadowResStruct = &shadowsRes[i]; + shadow.SetBlurRadius(shadowStruct->radius); + shadow.SetShadowType(static_cast(shadowStruct->type)); + shadow.SetColor(Color(shadowStruct->color)); + shadow.SetOffsetX(shadowStruct->offsetX); + shadow.SetOffsetY(shadowStruct->offsetY); + shadow.SetIsFilled(static_cast(shadowStruct->fill)); + if (SystemProperties::ConfigChangePerform()) { + auto* radius = shadowResStruct->radiusResObj ? + reinterpret_cast(shadowResStruct->radiusResObj) : nullptr; + if (radius) { + ParseShadowRadiusUpdate(AceType::Claim(radius), shadow); + } + auto* color = shadowResStruct->colorResObj ? + reinterpret_cast(shadowResStruct->colorResObj) : nullptr; + if (color) { + ParseShadowColorUpdate(AceType::Claim(color), shadow); + } + auto* offsetX = shadowResStruct->offsetXResObj ? + reinterpret_cast(shadowResStruct->offsetXResObj) : nullptr; + if (offsetX) { + ParseShadowOffsetXUpdate(AceType::Claim(offsetX), shadow); + } + auto* offsetY = shadowResStruct->offsetYResObj ? + reinterpret_cast(shadowResStruct->offsetYResObj) : nullptr; + if (offsetY) { + ParseShadowOffsetYUpdate(AceType::Claim(offsetY), shadow); + } + } + shadowList.at(i) = shadow; + } + TextClockModelNG::SetTextShadow(frameNode, shadowList); +} + void ResetTextShadow(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); @@ -218,16 +368,21 @@ const ArkUITextClockModifier* GetTextClockModifier() .setFormat = TextClockModifier::SetFormat, .resetFormat = TextClockModifier::ResetFormat, .setFontColor = TextClockModifier::SetFontColor, + .setFontColorRes = TextClockModifier::SetFontColorRes, .resetFontColor = TextClockModifier::ResetFontColor, .setFontSize = TextClockModifier::SetFontSize, + .setFontSizeRes = TextClockModifier::SetFontSizeRes, .resetFontSize = TextClockModifier::ResetFontSize, .setFontStyle = TextClockModifier::SetFontStyle, .resetFontStyle = TextClockModifier::ResetFontStyle, .setFontWeight = TextClockModifier::SetFontWeight, + .setFontWeightRes = TextClockModifier::SetFontWeightRes, .resetFontWeight = TextClockModifier::ResetFontWeight, .setFontFamily = TextClockModifier::SetFontFamily, + .setFontFamilyRes = TextClockModifier::SetFontFamilyRes, .resetFontFamily = TextClockModifier::ResetFontFamily, .setTextShadow = TextClockModifier::SetTextShadow, + .setTextShadowRes = TextClockModifier::SetTextShadowRes, .resetTextShadow = TextClockModifier::ResetTextShadow, .setFontFeature = TextClockModifier::SetFontFeature, .resetFontFeature = TextClockModifier::ResetFontFeature, @@ -249,16 +404,21 @@ const CJUITextClockModifier* GetCJUITextClockModifier() .setFormat = TextClockModifier::SetFormat, .resetFormat = TextClockModifier::ResetFormat, .setFontColor = TextClockModifier::SetFontColor, + .setFontColorRes = TextClockModifier::SetFontColorRes, .resetFontColor = TextClockModifier::ResetFontColor, .setFontSize = TextClockModifier::SetFontSize, + .setFontSizeRes = TextClockModifier::SetFontSizeRes, .resetFontSize = TextClockModifier::ResetFontSize, .setFontStyle = TextClockModifier::SetFontStyle, .resetFontStyle = TextClockModifier::ResetFontStyle, .setFontWeight = TextClockModifier::SetFontWeight, + .setFontWeightRes = TextClockModifier::SetFontWeightRes, .resetFontWeight = TextClockModifier::ResetFontWeight, .setFontFamily = TextClockModifier::SetFontFamily, + .setFontFamilyRes = TextClockModifier::SetFontFamilyRes, .resetFontFamily = TextClockModifier::ResetFontFamily, .setTextShadow = TextClockModifier::SetTextShadow, + .setTextShadowRes = TextClockModifier::SetTextShadowRes, .resetTextShadow = TextClockModifier::ResetTextShadow, .setFontFeature = TextClockModifier::SetFontFeature, .resetFontFeature = TextClockModifier::ResetFontFeature, diff --git a/frameworks/core/interfaces/native/node/text_timer_modifier.cpp b/frameworks/core/interfaces/native/node/text_timer_modifier.cpp index dd5adae24f8..747c84318ae 100644 --- a/frameworks/core/interfaces/native/node/text_timer_modifier.cpp +++ b/frameworks/core/interfaces/native/node/text_timer_modifier.cpp @@ -19,6 +19,7 @@ #include "core/components_ng/base/view_abstract.h" #include "core/components_ng/pattern/texttimer/text_timer_model_ng.h" #include "core/components_ng/pattern/texttimer/text_timer_event_hub.h" +#include "core/common/resource/resource_parse_utils.h" namespace OHOS::Ace::NG { constexpr Dimension DEFAULT_FONT_SIZE = Dimension(16.0, DimensionUnit::FP); const std::vector DEFAULT_FONT_FAMILY = { "HarmonyOS Sans" }; @@ -33,6 +34,18 @@ void SetFontColor(ArkUINodeHandle node, ArkUI_Uint32 color) TextTimerModelNG::SetFontColor(frameNode, Color(color)); } +void SetFontColorRes(ArkUINodeHandle node, ArkUI_Uint32 color, void* colorRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + TextTimerModelNG::SetFontColor(frameNode, Color(color)); + if (SystemProperties::ConfigChangePerform() && colorRawPtr) { + auto* color = reinterpret_cast(colorRawPtr); + auto colorResObj = AceType::Claim(color); + TextTimerModelNG::CreateWithResourceObj(frameNode, JsTextTimerResourceType::TEXTCOLOR, colorResObj); + } +} + void ResetFontColor(ArkUINodeHandle node) { auto *frameNode = reinterpret_cast(node); @@ -51,6 +64,18 @@ void SetFontSize(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit) TextTimerModelNG::SetFontSize(frameNode, Dimension(value, static_cast(unit))); } +void SetFontSizeRes(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit, void* fontSizeRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + TextTimerModelNG::SetFontSize(frameNode, Dimension(value, static_cast(unit))); + if (SystemProperties::ConfigChangePerform() && fontSizeRawPtr) { + auto* fontSize = reinterpret_cast(fontSizeRawPtr); + auto fontSizeResObj = AceType::Claim(fontSize); + TextTimerModelNG::CreateWithResourceObj(frameNode, JsTextTimerResourceType::FONTSIZE, fontSizeResObj); + } +} + void ResetFontSize(ArkUINodeHandle node) { auto *frameNode = reinterpret_cast(node); @@ -80,6 +105,19 @@ void SetFontWeight(ArkUINodeHandle node, ArkUI_CharPtr fontWeight) TextTimerModelNG::SetFontWeight(frameNode, Framework::ConvertStrToFontWeight(fontWeightStr)); } +void SetFontWeightRes(ArkUINodeHandle node, ArkUI_CharPtr fontWeight, void* fontWeightRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + std::string fontWeightStr = fontWeight; + TextTimerModelNG::SetFontWeight(frameNode, Framework::ConvertStrToFontWeight(fontWeightStr)); + if (SystemProperties::ConfigChangePerform() && fontWeightRawPtr) { + auto* fontWeight = reinterpret_cast(fontWeightRawPtr); + auto fontWeightResObj = AceType::Claim(fontWeight); + TextTimerModelNG::CreateWithResourceObj(frameNode, JsTextTimerResourceType::FONTWEIGHT, fontWeightResObj); + } +} + void ResetFontWeight(ArkUINodeHandle node) { auto *frameNode = reinterpret_cast(node); @@ -96,6 +134,20 @@ void SetFontFamily(ArkUINodeHandle node, ArkUI_CharPtr fontFamily) TextTimerModelNG::SetFontFamily(frameNode, fontFamilyResult); } +void SetFontFamilyRes(ArkUINodeHandle node, ArkUI_CharPtr fontFamily, void* fontFamilyRawPtr) +{ + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + std::string familiesStr = fontFamily; + std::vector fontFamilyResult = Framework::ConvertStrToFontFamilies(familiesStr); + TextTimerModelNG::SetFontFamily(frameNode, fontFamilyResult); + if (SystemProperties::ConfigChangePerform() && fontFamilyRawPtr) { + auto* fontFamily = reinterpret_cast(fontFamilyRawPtr); + auto fontFamilyResObj = AceType::Claim(fontFamily); + TextTimerModelNG::CreateWithResourceObj(frameNode, JsTextTimerResourceType::FONTFAMILY, fontFamilyResObj); + } +} + void ResetFontFamily(ArkUINodeHandle node) { auto *frameNode = reinterpret_cast(node); @@ -157,6 +209,102 @@ void SetTextShadow(ArkUINodeHandle node, struct ArkUITextShadowStruct* shadows, TextTimerModelNG::SetTextShadow(frameNode, shadowList); } +void ParseShadowRadiusUpdate(const RefPtr& radiusResObj, Shadow& shadow) +{ + if (!radiusResObj) { + return; + } + auto&& updateFunc = [](const RefPtr& resObj, Shadow& shadow) { + double radius = 0.0; + ResourceParseUtils::ParseResDouble(resObj, radius); + shadow.SetBlurRadius(std::max(radius, 0.0)); + }; + shadow.AddResource("shadow.radius", radiusResObj, std::move(updateFunc)); +} + +void ParseShadowColorUpdate(const RefPtr& colorResObj, Shadow& shadow) +{ + if (!colorResObj) { + return; + } + auto&& updateFunc = [](const RefPtr& resObj, Shadow& shadow) { + Color color; + ResourceParseUtils::ParseResColor(resObj, color); + shadow.SetColor(color); + }; + shadow.AddResource("shadow.colorValue", colorResObj, std::move(updateFunc)); +} + +void ParseShadowOffsetXUpdate(const RefPtr& offsetXResObj, Shadow& shadow) +{ + if (!offsetXResObj) { + return; + } + auto&& updateFunc = [](const RefPtr& resObj, Shadow& shadow) { + CalcDimension xValue; + ResourceParseUtils::ParseResResource(resObj, xValue); + shadow.SetOffsetX(xValue.Value()); + }; + shadow.AddResource("shadow.offsetX", offsetXResObj, std::move(updateFunc)); +} + +void ParseShadowOffsetYUpdate(const RefPtr& offsetYResObj, Shadow& shadow) +{ + if (!offsetYResObj) { + return; + } + auto&& updateFunc = [](const RefPtr& resObj, Shadow& shadow) { + CalcDimension yValue; + ResourceParseUtils::ParseResResource(resObj, yValue); + shadow.SetOffsetY(yValue.Value()); + }; + shadow.AddResource("shadow.offsetY", offsetYResObj, std::move(updateFunc)); +} + +void SetTextShadowRes( + ArkUINodeHandle node, ArkUITextShadowStruct* shadows, ArkUITextShadowResStruct* shadowsRes, ArkUI_Uint32 length) +{ + CHECK_NULL_VOID(shadows); + CHECK_NULL_VOID(shadowsRes); + auto* frameNode = reinterpret_cast(node); + CHECK_NULL_VOID(frameNode); + std::vector shadowList(length); + for (uint32_t i = 0; i < length; i++) { + Shadow shadow; + ArkUITextShadowStruct* shadowStruct = &shadows[i]; + ArkUITextShadowResStruct* shadowResStruct = &shadowsRes[i]; + shadow.SetBlurRadius(shadowStruct->radius); + shadow.SetShadowType(static_cast(shadowStruct->type)); + shadow.SetColor(Color(shadowStruct->color)); + shadow.SetOffsetX(shadowStruct->offsetX); + shadow.SetOffsetY(shadowStruct->offsetY); + shadow.SetIsFilled(static_cast(shadowStruct->fill)); + if (SystemProperties::ConfigChangePerform()) { + auto* radius = shadowResStruct->radiusResObj ? + reinterpret_cast(shadowResStruct->radiusResObj) : nullptr; + if (radius) { + ParseShadowRadiusUpdate(AceType::Claim(radius), shadow); + } + auto* color = shadowResStruct->colorResObj ? + reinterpret_cast(shadowResStruct->colorResObj) : nullptr; + if (color) { + ParseShadowColorUpdate(AceType::Claim(color), shadow); + } + auto* offsetX = shadowResStruct->offsetXResObj ? + reinterpret_cast(shadowResStruct->offsetXResObj) : nullptr; + if (offsetX) { + ParseShadowOffsetXUpdate(AceType::Claim(offsetX), shadow); + } + auto* offsetY = shadowResStruct->offsetYResObj ? + reinterpret_cast(shadowResStruct->offsetYResObj) : nullptr; + if (offsetY) { + ParseShadowOffsetYUpdate(AceType::Claim(offsetY), shadow); + } + } + shadowList.at(i) = shadow; + } + TextTimerModelNG::SetTextShadow(frameNode, shadowList); +} void ResetTextShadow(ArkUINodeHandle node) { auto* frameNode = reinterpret_cast(node); @@ -203,18 +351,23 @@ const ArkUITextTimerModifier* GetTextTimerModifier() CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line static const ArkUITextTimerModifier modifier = { .setFontColor = TextTimerModifier::SetFontColor, + .setFontColorRes = TextTimerModifier::SetFontColorRes, .resetFontColor = TextTimerModifier::ResetFontColor, .setFontSize = TextTimerModifier::SetFontSize, + .setFontSizeRes = TextTimerModifier::SetFontSizeRes, .resetFontSize = TextTimerModifier::ResetFontSize, .setFontStyle = TextTimerModifier::SetFontStyle, .resetFontStyle = TextTimerModifier::ResetFontStyle, .setFontWeight = TextTimerModifier::SetFontWeight, + .setFontWeightRes = TextTimerModifier::SetFontWeightRes, .resetFontWeight = TextTimerModifier::ResetFontWeight, .setFontFamily = TextTimerModifier::SetFontFamily, + .setFontFamilyRes = TextTimerModifier::SetFontFamilyRes, .resetFontFamily = TextTimerModifier::ResetFontFamily, .setFormat = TextTimerModifier::SetFormat, .resetFormat = TextTimerModifier::ResetFormat, .setTextShadow = TextTimerModifier::SetTextShadow, + .setTextShadowRes = TextTimerModifier::SetTextShadowRes, .resetTextShadow = TextTimerModifier::ResetTextShadow, .setTextTimerOptions = TextTimerModifier::setTextTimerOptions, .setTextTimerOnTimer = TextTimerModifier::SetTextTimerOnTimer, @@ -230,18 +383,23 @@ const CJUITextTimerModifier* GetCJUITextTimerModifier() CHECK_INITIALIZED_FIELDS_BEGIN(); // don't move this line static const CJUITextTimerModifier modifier = { .setFontColor = TextTimerModifier::SetFontColor, + .setFontColorRes = TextTimerModifier::SetFontColorRes, .resetFontColor = TextTimerModifier::ResetFontColor, .setFontSize = TextTimerModifier::SetFontSize, + .setFontSizeRes = TextTimerModifier::SetFontSizeRes, .resetFontSize = TextTimerModifier::ResetFontSize, .setFontStyle = TextTimerModifier::SetFontStyle, .resetFontStyle = TextTimerModifier::ResetFontStyle, .setFontWeight = TextTimerModifier::SetFontWeight, + .setFontWeightRes = TextTimerModifier::SetFontWeightRes, .resetFontWeight = TextTimerModifier::ResetFontWeight, .setFontFamily = TextTimerModifier::SetFontFamily, + .setFontFamilyRes = TextTimerModifier::SetFontFamilyRes, .resetFontFamily = TextTimerModifier::ResetFontFamily, .setFormat = TextTimerModifier::SetFormat, .resetFormat = TextTimerModifier::ResetFormat, .setTextShadow = TextTimerModifier::SetTextShadow, + .setTextShadowRes = TextTimerModifier::SetTextShadowRes, .resetTextShadow = TextTimerModifier::ResetTextShadow, }; CHECK_INITIALIZED_FIELDS_END(modifier, 0, 0, 0); // don't move this line diff --git a/test/unittest/core/pattern/text_clock/text_clock_pattern_test_ng.cpp b/test/unittest/core/pattern/text_clock/text_clock_pattern_test_ng.cpp index f601a86d1a7..e7222fb3c69 100644 --- a/test/unittest/core/pattern/text_clock/text_clock_pattern_test_ng.cpp +++ b/test/unittest/core/pattern/text_clock/text_clock_pattern_test_ng.cpp @@ -937,5 +937,13 @@ HWTEST_F(TextClockPatternTestNG, TextClockUpdateFontFamily003, TestSize.Level1) std::vector fontFamilies = {"Arial", "sans-serif"}; pattern->UpdateTextClockFontFamily(fontFamilies); EXPECT_EQ(layoutProperty->GetFontFamily().value(), fontFamilies); + + /** + * @tc.steps: step4. Execute font family update operation + * @tc.expected: Font specifications should be correctly applied + */ + std::vector typefaceOptions = {"Roboto", "Helvetica Neue"}; + pattern->UpdateTextClockFontFamily(typefaceOptions); + EXPECT_EQ(layoutProperty->GetFontFamily().value(), typefaceOptions); } } // namespace OHOS::Ace::NG \ No newline at end of file -- Gitee