mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
CAPI新增focusBox接口
Signed-off-by: wanglili12 <wanglili65@huawei.com> Change-Id: I71f8c7abe834f3de4557594ce5009fc68dd9bc27
This commit is contained in:
parent
3be770b92b
commit
78bb66d554
@ -7382,7 +7382,7 @@ ArkUINativeModuleValue CommonBridge::SetFocusBox(ArkUIRuntimeCallInfo* runtimeCa
|
||||
int32_t hasValue = 0;
|
||||
CalcDimension margin;
|
||||
if (!marginArg->IsUndefined() && !marginArg->IsNull()) {
|
||||
if (ArkTSUtils::ParseJsDimensionVpNG(vm, marginArg, margin, true)) {
|
||||
if (ArkTSUtils::ParseJsDimensionFpNG(vm, marginArg, margin, false)) {
|
||||
hasValue = 1;
|
||||
} else if (ArkTSUtils::ParseJsLengthMetrics(vm, marginArg, margin)) {
|
||||
hasValue = 1;
|
||||
@ -7391,7 +7391,7 @@ ArkUINativeModuleValue CommonBridge::SetFocusBox(ArkUIRuntimeCallInfo* runtimeCa
|
||||
hasValue = hasValue << 1;
|
||||
CalcDimension width;
|
||||
if (!widthArg->IsUndefined() && !widthArg->IsNull()) {
|
||||
if (ArkTSUtils::ParseJsDimensionVpNG(vm, widthArg, width, true) && GreatOrEqual(width.Value(), 0.0f)) {
|
||||
if (ArkTSUtils::ParseJsDimensionFpNG(vm, widthArg, width, false) && GreatOrEqual(width.Value(), 0.0f)) {
|
||||
hasValue += 1;
|
||||
} else if (ArkTSUtils::ParseJsLengthMetrics(vm, widthArg, width) && GreatOrEqual(width.Value(), 0.0f)) {
|
||||
hasValue += 1;
|
||||
@ -7402,8 +7402,9 @@ ArkUINativeModuleValue CommonBridge::SetFocusBox(ArkUIRuntimeCallInfo* runtimeCa
|
||||
if (!colorArg->IsUndefined() && !colorArg->IsNull() && ParseColorMetricsToColor(vm, colorArg, strokeColor)) {
|
||||
hasValue += 1;
|
||||
}
|
||||
GetArkUINodeModifiers()->getCommonModifier()->setFocusBoxStyle(
|
||||
nativeNode, margin.Value(), width.Value(), strokeColor.GetValue(), hasValue);
|
||||
GetArkUINodeModifiers()->getCommonModifier()->setFocusBoxStyle(nativeNode, margin.Value(),
|
||||
static_cast<int>(margin.Unit()), width.Value(), static_cast<int>(width.Unit()), strokeColor.GetValue(),
|
||||
hasValue);
|
||||
return panda::JSValueRef::Undefined(vm);
|
||||
}
|
||||
|
||||
|
@ -1726,8 +1726,8 @@ struct ArkUICommonModifier {
|
||||
void (*setDragPreview)(ArkUINodeHandle node, ArkUIDragPreview dragPreview);
|
||||
void (*resetDragPreview)(ArkUINodeHandle node);
|
||||
ArkUI_Int32 (*getNodeUniqueId)(ArkUINodeHandle node);
|
||||
void (*setFocusBoxStyle)(ArkUINodeHandle node, ArkUI_Float32 valueMargin, ArkUI_Float32 valueStrokeWidth,
|
||||
ArkUI_Uint32 valueColor, ArkUI_Uint32 hasValue);
|
||||
void (*setFocusBoxStyle)(ArkUINodeHandle node, ArkUI_Float32 valueMargin, ArkUI_Int32 marginUnit,
|
||||
ArkUI_Float32 valueStrokeWidth, ArkUI_Int32 widthUnit, ArkUI_Uint32 valueColor, ArkUI_Uint32 hasValue);
|
||||
void (*resetFocusBoxStyle)(ArkUINodeHandle node);
|
||||
};
|
||||
|
||||
|
@ -6065,23 +6065,31 @@ ArkUI_Int32 GetNodeUniqueId(ArkUINodeHandle node)
|
||||
return frameNode->GetId();
|
||||
}
|
||||
|
||||
void SetFocusBoxStyle(ArkUINodeHandle node, ArkUI_Float32 valueMargin, ArkUI_Float32 valueStrokeWidth,
|
||||
ArkUI_Uint32 valueColor, ArkUI_Uint32 hasValue)
|
||||
void SetFocusBoxStyle(ArkUINodeHandle node, ArkUI_Float32 valueMargin, ArkUI_Int32 marginUnit,
|
||||
ArkUI_Float32 valueStrokeWidth, ArkUI_Int32 widthUnit, ArkUI_Uint32 valueColor, ArkUI_Uint32 hasValue)
|
||||
{
|
||||
CHECK_NULL_VOID(node);
|
||||
auto* frameNode = reinterpret_cast<FrameNode*>(node);
|
||||
auto marginUnitEnum = static_cast<OHOS::Ace::DimensionUnit>(marginUnit);
|
||||
auto widthUnitEnum = static_cast<OHOS::Ace::DimensionUnit>(widthUnit);
|
||||
NG::FocusBoxStyle style;
|
||||
if ((hasValue >> 2) & 1) { // margin
|
||||
CalcDimension margin;
|
||||
margin.SetValue(valueMargin);
|
||||
if ((hasValue >> 2) & 1) { // 2: margin
|
||||
CalcDimension margin = CalcDimension(valueMargin, DimensionUnit::FP);
|
||||
if (marginUnitEnum >= OHOS::Ace::DimensionUnit::PX && marginUnitEnum <= OHOS::Ace::DimensionUnit::CALC &&
|
||||
marginUnitEnum != OHOS::Ace::DimensionUnit::PERCENT) {
|
||||
margin.SetUnit(marginUnitEnum);
|
||||
}
|
||||
style.margin = margin;
|
||||
}
|
||||
if ((hasValue >> 1) & 1) { // strokeWidth
|
||||
CalcDimension strokeWidth;
|
||||
strokeWidth.SetValue(valueStrokeWidth);
|
||||
if ((hasValue >> 1) & 1) { // 1: strokeWidth
|
||||
CalcDimension strokeWidth = CalcDimension(valueStrokeWidth, DimensionUnit::FP);
|
||||
if (widthUnitEnum >= OHOS::Ace::DimensionUnit::PX && widthUnitEnum <= OHOS::Ace::DimensionUnit::CALC &&
|
||||
widthUnitEnum != OHOS::Ace::DimensionUnit::PERCENT) {
|
||||
strokeWidth.SetUnit(widthUnitEnum);
|
||||
}
|
||||
style.strokeWidth = strokeWidth;
|
||||
}
|
||||
if ((hasValue >> 0) & 1) { // strokeColor
|
||||
if ((hasValue >> 0) & 1) { // 0: strokeColor
|
||||
Color strokeColor(valueColor);
|
||||
style.strokeColor = strokeColor;
|
||||
}
|
||||
|
@ -1647,7 +1647,21 @@ typedef enum {
|
||||
*
|
||||
*/
|
||||
NODE_UNIQUE_ID = 95,
|
||||
|
||||
|
||||
/**
|
||||
* @brief Set the current component system focus box style.
|
||||
*
|
||||
* Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute: \n
|
||||
* .value[0].f32: The distance between the focus box and the edge of the component. \n
|
||||
* Positive numbers represent the outer side, negative numbers represent the inner side. \n
|
||||
* Percentage is not supported. \n
|
||||
* .value[1].f32: Focus box width. Negative numbers and percentages are not supported. \n
|
||||
* .value[2].u32: Focus box color. \n
|
||||
* \n
|
||||
*
|
||||
*/
|
||||
NODE_FOCUS_BOX = 96,
|
||||
|
||||
/**
|
||||
* @brief Defines the text content attribute, which can be set, reset, and obtained as required through APIs.
|
||||
*
|
||||
|
@ -3718,6 +3718,24 @@ int32_t SetTransition(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t SetFocusBox(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
|
||||
{
|
||||
if (item->size != NUM_3) {
|
||||
return ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
auto* fullImpl = GetFullImpl();
|
||||
int32_t unit = GetDefaultUnit(node, UNIT_FP);
|
||||
fullImpl->getNodeModifiers()->getCommonModifier()->setFocusBoxStyle(
|
||||
node->uiNodeHandle, item->value[0].f32, unit, item->value[1].f32, unit, item->value[2].u32, NUM_7);
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
void ResetFocusBox(ArkUI_NodeHandle node)
|
||||
{
|
||||
auto* fullImpl = GetFullImpl();
|
||||
fullImpl->getNodeModifiers()->getCommonModifier()->resetFocusBoxStyle(node->uiNodeHandle);
|
||||
}
|
||||
|
||||
const ArkUI_AttributeItem* GetTransition(ArkUI_NodeHandle node)
|
||||
{
|
||||
g_attributeItem.object = node->transitionOption;
|
||||
@ -12605,6 +12623,7 @@ int32_t SetCommonAttribute(ArkUI_NodeHandle node, int32_t subTypeId, const ArkUI
|
||||
SetAreaChangeRatio,
|
||||
SetTransition,
|
||||
nullptr,
|
||||
SetFocusBox,
|
||||
};
|
||||
if (static_cast<uint32_t>(subTypeId) >= sizeof(setters) / sizeof(Setter*)) {
|
||||
TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "common node attribute: %{public}d NOT IMPLEMENT", subTypeId);
|
||||
@ -12823,6 +12842,7 @@ void ResetCommonAttribute(ArkUI_NodeHandle node, int32_t subTypeId)
|
||||
ResetAreaChangeRatio,
|
||||
nullptr,
|
||||
nullptr,
|
||||
ResetFocusBox,
|
||||
};
|
||||
if (static_cast<uint32_t>(subTypeId) >= sizeof(resetters) / sizeof(Resetter*)) {
|
||||
TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "common node attribute: %{public}d NOT IMPLEMENT", subTypeId);
|
||||
|
Loading…
Reference in New Issue
Block a user