!30569 NDK C-API add attribute

Merge pull request !30569 from firminly/liyi
This commit is contained in:
openharmony_ci 2024-04-17 07:41:41 +00:00 committed by Gitee
commit ad49966854
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
38 changed files with 685 additions and 298 deletions

View File

@ -146,6 +146,17 @@ public:
// Percentage unit conversion is not supported.
double ConvertToPx() const;
double GetNativeValue(DimensionUnit unit) const
{
if (unit_ == unit) {
return value_;
} else if (unit == DimensionUnit::PX) {
return ConvertToPx();
} else {
return ConvertToVp();
}
}
// support percentage unit conversion
double ConvertToPxWithSize(double size) const;

View File

@ -3773,11 +3773,19 @@ ArkUINativeModuleValue CommonBridge::SetLayoutWeight(ArkUIRuntimeCallInfo* runti
Local<JSValueRef> firstArg = runtimeCallInfo->GetCallArgRef(NUM_0);
Local<JSValueRef> secondArg = runtimeCallInfo->GetCallArgRef(NUM_1);
auto nativeNode = nodePtr(firstArg->ToNativePointer(vm)->Value());
int32_t layoutWeight = 0;
float layoutWeight = 0.0f;
if (secondArg->IsNumber()) {
layoutWeight = secondArg->Int32Value(vm);
if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TWELVE)) {
layoutWeight = secondArg->ToNumber(vm)->Value();
} else {
layoutWeight = secondArg->Int32Value(vm);
}
} else if (secondArg->IsString()) {
layoutWeight = StringUtils::StringToInt(secondArg->ToString(vm)->ToString());
if (Container::GreatOrEqualAPIVersion(PlatformVersion::VERSION_TWELVE)) {
layoutWeight = StringUtils::StringToFloat(secondArg->ToString(vm)->ToString());
} else {
layoutWeight = StringUtils::StringToInt(secondArg->ToString(vm)->ToString());
}
}
GetArkUINodeModifiers()->getCommonModifier()->setLayoutWeight(nativeNode, layoutWeight);
return panda::JSValueRef::Undefined(vm);

View File

@ -25,7 +25,6 @@
#include <utility>
#include <vector>
#include <unordered_map>
#include "interfaces/native/native_event.h"
#include "base/geometry/calc_dimension.h"
#include "base/geometry/dimension.h"

View File

@ -21,7 +21,6 @@
#include <unistd.h>
#include <vector>
#include "interfaces/native/native_event.h"
#include "interfaces/native/native_interface_xcomponent.h"
#include "interfaces/native/ui_input_event.h"

View File

@ -2863,10 +2863,10 @@ void ViewAbstract::SetFlexGrow(FrameNode* frameNode, float value)
ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, FlexGrow, value, frameNode);
}
void ViewAbstract::SetLayoutWeight(FrameNode* frameNode, int32_t value)
void ViewAbstract::SetLayoutWeight(FrameNode* frameNode, float value)
{
CHECK_NULL_VOID(frameNode);
ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, LayoutWeight, static_cast<float>(value), frameNode);
ACE_UPDATE_NODE_LAYOUT_PROPERTY(LayoutProperty, LayoutWeight, value, frameNode);
}
void ViewAbstract::ResetMaxSize(FrameNode* frameNode, bool resetWidth)
@ -3505,9 +3505,9 @@ Dimension ViewAbstract::GetFlexBasis(FrameNode* frameNode)
return value;
}
float ViewAbstract::GetMinWidth(FrameNode* frameNode)
Dimension ViewAbstract::GetMinWidth(FrameNode* frameNode)
{
float value = 0.0f;
Dimension value = Dimension(0.0f);
const auto& layoutProperty = frameNode->GetLayoutProperty();
CHECK_NULL_RETURN(layoutProperty, value);
const auto& property = layoutProperty->GetCalcLayoutConstraint();
@ -3516,15 +3516,15 @@ float ViewAbstract::GetMinWidth(FrameNode* frameNode)
if (size.has_value()) {
auto width = size->Width();
if (width.has_value()) {
value = width.value().GetDimension().Value();
return width.value().GetDimension();
}
}
return value;
}
float ViewAbstract::GetMaxWidth(FrameNode* frameNode)
Dimension ViewAbstract::GetMaxWidth(FrameNode* frameNode)
{
float value = 0.0f;
Dimension value = Dimension(0.0f);
const auto& layoutProperty = frameNode->GetLayoutProperty();
CHECK_NULL_RETURN(layoutProperty, value);
const auto& property = layoutProperty->GetCalcLayoutConstraint();
@ -3533,15 +3533,15 @@ float ViewAbstract::GetMaxWidth(FrameNode* frameNode)
if (size.has_value()) {
auto width = size->Width();
if (width.has_value()) {
value = width.value().GetDimension().Value();
return width.value().GetDimension();
}
}
return value;
}
float ViewAbstract::GetMinHeight(FrameNode* frameNode)
Dimension ViewAbstract::GetMinHeight(FrameNode* frameNode)
{
float value = 0.0f;
Dimension value = Dimension(0.0f);
const auto& layoutProperty = frameNode->GetLayoutProperty();
CHECK_NULL_RETURN(layoutProperty, value);
const auto& property = layoutProperty->GetCalcLayoutConstraint();
@ -3550,15 +3550,15 @@ float ViewAbstract::GetMinHeight(FrameNode* frameNode)
if (size.has_value()) {
auto height = size->Height();
if (height.has_value()) {
value = height.value().GetDimension().Value();
return height.value().GetDimension();
}
}
return value;
}
float ViewAbstract::GetMaxHeight(FrameNode* frameNode)
Dimension ViewAbstract::GetMaxHeight(FrameNode* frameNode)
{
float value = 0.0f;
Dimension value = Dimension(0.0f);
const auto& layoutProperty = frameNode->GetLayoutProperty();
CHECK_NULL_RETURN(layoutProperty, value);
const auto& property = layoutProperty->GetCalcLayoutConstraint();
@ -3567,7 +3567,7 @@ float ViewAbstract::GetMaxHeight(FrameNode* frameNode)
if (size.has_value()) {
auto height = size->Height();
if (height.has_value()) {
value = height.value().GetDimension().Value();
return height.value().GetDimension();
}
}
return value;
@ -3694,9 +3694,9 @@ Alignment ViewAbstract::GetAlign(FrameNode *frameNode)
return value;
}
float ViewAbstract::GetWidth(FrameNode* frameNode)
Dimension ViewAbstract::GetWidth(FrameNode* frameNode)
{
float value = -1.0f;
Dimension value = Dimension(-1.0f);
const auto& layoutProperty = frameNode->GetLayoutProperty();
CHECK_NULL_RETURN(layoutProperty, value);
const auto& property = layoutProperty->GetCalcLayoutConstraint();
@ -3705,15 +3705,15 @@ float ViewAbstract::GetWidth(FrameNode* frameNode)
if (size.has_value()) {
auto width = size->Width();
if (width.has_value()) {
value = width.value().GetDimension().Value();
return width.value().GetDimension();
}
}
return value;
}
float ViewAbstract::GetHeight(FrameNode* frameNode)
Dimension ViewAbstract::GetHeight(FrameNode* frameNode)
{
float value = -1.0f;
Dimension value = Dimension(-1.0f);
const auto& layoutProperty = frameNode->GetLayoutProperty();
CHECK_NULL_RETURN(layoutProperty, value);
const auto& property = layoutProperty->GetCalcLayoutConstraint();
@ -3722,7 +3722,7 @@ float ViewAbstract::GetHeight(FrameNode* frameNode)
if (size.has_value()) {
auto height = size->Height();
if (height.has_value()) {
value = height.value().GetDimension().Value();
return height.value().GetDimension();
}
}
return value;
@ -4050,4 +4050,24 @@ void ViewAbstract::SetBackgroundImageResizableSlice(FrameNode* frameNode, const
{
ACE_UPDATE_NODE_RENDER_CONTEXT(BackgroundImageResizableSlice, slice, frameNode);
}
void ViewAbstract::SetOnTouchIntercept(FrameNode* frameNode, TouchInterceptFunc&& touchInterceptFunc)
{
auto gestureHub = frameNode->GetOrCreateGestureEventHub();
CHECK_NULL_VOID(gestureHub);
gestureHub->SetOnTouchIntercept(std::move(touchInterceptFunc));
}
float ViewAbstract::GetLayoutWeight(FrameNode* frameNode)
{
float layoutWeight = 0.0f;
CHECK_NULL_RETURN(frameNode, layoutWeight);
auto layoutProperty = frameNode->GetLayoutProperty();
CHECK_NULL_RETURN(layoutProperty, layoutWeight);
auto& magicItemProperty = layoutProperty->GetMagicItemProperty();
if (magicItemProperty.HasLayoutWeight()) {
return magicItemProperty.GetLayoutWeight().value_or(layoutWeight);
}
return layoutWeight;
}
} // namespace OHOS::Ace::NG

View File

@ -492,7 +492,7 @@ public:
static void ResetFlexShrink(FrameNode* frameNode);
static void SetFlexShrink(FrameNode* frameNode, float value);
static void SetFlexGrow(FrameNode* frameNode, float value);
static void SetLayoutWeight(FrameNode* frameNode, int32_t value);
static void SetLayoutWeight(FrameNode* frameNode, float value);
static void ResetMaxSize(FrameNode* frameNode, bool resetWidth);
static void ResetMinSize(FrameNode* frameNode, bool resetWidth);
static void SetMinWidth(FrameNode* frameNode, const CalcLength& minWidth);
@ -602,10 +602,10 @@ public:
static float GetFlexGrow(FrameNode* frameNode);
static float GetFlexShrink(FrameNode* frameNode);
static Dimension GetFlexBasis(FrameNode* frameNode);
static float GetMinWidth(FrameNode* frameNode);
static float GetMaxWidth(FrameNode* frameNode);
static float GetMinHeight(FrameNode* frameNode);
static float GetMaxHeight(FrameNode* frameNode);
static Dimension GetMinWidth(FrameNode* frameNode);
static Dimension GetMaxWidth(FrameNode* frameNode);
static Dimension GetMinHeight(FrameNode* frameNode);
static Dimension GetMaxHeight(FrameNode* frameNode);
static Dimension GetGrayScale(FrameNode* frameNode);
static InvertVariant GetInvert(FrameNode* frameNode);
static Dimension GetSepia(FrameNode* frameNode);
@ -619,8 +619,8 @@ public:
static Dimension GetBrightness(FrameNode* frameNode);
static Dimension GetSaturate(FrameNode* frameNode);
static BackgroundImagePosition GetBackgroundImagePosition(FrameNode* frameNode);
static float GetWidth(FrameNode* frameNode);
static float GetHeight(FrameNode* frameNode);
static Dimension GetWidth(FrameNode* frameNode);
static Dimension GetHeight(FrameNode* frameNode);
static Color GetBackgroundColor(FrameNode* frameNode);
static std::string GetBackgroundImageSrc(FrameNode* frameNode);
static ImageRepeat GetBackgroundImageRepeat(FrameNode* frameNode);
@ -632,6 +632,8 @@ public:
static TranslateOptions GetTranslate(FrameNode* frameNode);
static float GetAspectRatio(FrameNode* frameNode);
static BlendApplyType GetBlendApplyType(FrameNode* frameNode);
static void SetOnTouchIntercept(FrameNode* frameNode, TouchInterceptFunc &&touchInterceptFunc);
static float GetLayoutWeight(FrameNode* frameNode);
private:
static void AddDragFrameNodeToManager();

View File

@ -177,4 +177,12 @@ int32_t ScrollableModelNG::GetAlwaysEnabled(FrameNode* frameNode)
return pattern->GetAlwaysEnabled();
}
void ScrollableModelNG::SetOnReachEnd(FrameNode* frameNode, OnReachEvent&& onReachEnd)
{
CHECK_NULL_VOID(frameNode);
auto eventHub = frameNode->GetEventHub<ScrollableEventHub>();
CHECK_NULL_VOID(eventHub);
eventHub->SetOnReachEnd(std::move(onReachEnd));
}
} // namespace OHOS::Ace::NG

View File

@ -48,6 +48,8 @@ public:
static int32_t GetEdgeEffect(FrameNode* frameNode);
static int32_t GetAlwaysEnabled(FrameNode* frameNode);
static void SetOnReachEnd(FrameNode* frameNode, OnReachEvent&& onReachEnd);
};
} // namespace OHOS::Ace::NG
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_NG_PATTERN_SCROLLABLE_SCROLLABLE_MODEL_H

View File

@ -606,4 +606,12 @@ bool ToggleModelNG::GetSwitchIsOn(FrameNode* frameNode)
ACE_GET_NODE_PAINT_PROPERTY_WITH_DEFAULT_VALUE(SwitchPaintProperty, IsOn, value, frameNode, value);
return value;
}
Color ToggleModelNG::GetUnselectedColor(FrameNode* frameNode)
{
Color value;
ACE_GET_NODE_PAINT_PROPERTY_WITH_DEFAULT_VALUE(
SwitchPaintProperty, UnselectedColor, value, frameNode, Color(DEFAULT_COLOR));
return value;
}
} // namespace OHOS::Ace::NG

View File

@ -70,6 +70,7 @@ public:
static Color GetSelectedColor(FrameNode* frameNode);
static Color GetSwitchPointColor(FrameNode* frameNode);
static bool GetSwitchIsOn(FrameNode* frameNode);
static Color GetUnselectedColor(FrameNode* frameNode);
private:
static void ReCreateFrameNode(

View File

@ -16,7 +16,7 @@
#include "core/components_ng/pattern/xcomponent/xcomponent_pattern.h"
#include "interfaces/native/event/ui_input_event_impl.h"
#include "interfaces/native/native_event.h"
#include "interfaces/native/ui_input_event.h"
#include "base/geometry/ng/size_t.h"
#include "base/log/dump_log.h"

View File

@ -172,6 +172,9 @@ struct ArkUITouchEvent {
*
*/
bool preventDefault;
ArkUI_Int32 subKind; // ArkUIEventSubKind actually
ArkUI_Int32 interceptResult;
};
struct ArkUIStringAndFloat {
@ -584,6 +587,7 @@ enum ArkUIEventSubKind {
ON_VISIBLE_AREA_CHANGE = 9,
ON_GESTURE = 10,
ON_FOCUS = 11,
ON_TOUCH_INTERCEPT = 12,
ON_IMAGE_COMPLETE = ARKUI_MAX_EVENT_NUM * ARKUI_IMAGE,
ON_IMAGE_ERROR,
// components events
@ -644,6 +648,7 @@ enum ArkUIEventSubKind {
ON_TIME_PICKER_CHANGE = ARKUI_MAX_EVENT_NUM * ARKUI_TIME_PICKER,
ON_CALENDAR_PICKER_CHANGE = ARKUI_MAX_EVENT_NUM * ARKUI_CALENDAR_PICKER,
ON_WILL_SCROLL = ARKUI_MAX_EVENT_NUM * ARKUI_WATER_FLOW,
ON_REACH_END,
};
enum ArkUIAPIGestureAsyncEventSubKind {
@ -819,6 +824,7 @@ struct ArkUITextFont {
ArkUI_Float32 fontSize;
ArkUI_Int32 fontStyle;
ArkUI_CharPtr fontFamilies;
ArkUI_Int32 fontSizeUnit;
};
struct ArkUIOverlayOptions {
@ -1144,7 +1150,7 @@ struct ArkUICommonModifier {
ArkUI_Bool (*getFocusable)(ArkUINodeHandle node);
ArkUI_Bool (*getDefaultFocus)(ArkUINodeHandle node);
ArkUI_Int32 (*getResponseRegion)(ArkUINodeHandle node, ArkUI_Float32* values);
ArkUI_CharPtr (*getOverlay)(ArkUINodeHandle node, ArkUIOverlayOptions* options);
ArkUI_CharPtr (*getOverlay)(ArkUINodeHandle node, ArkUIOverlayOptions* options, ArkUI_Int32 unit);
ArkUI_Bool (*getAccessibilityGroup)(ArkUINodeHandle node);
ArkUI_CharPtr (*getAccessibilityText)(ArkUINodeHandle node);
ArkUI_CharPtr (*getAccessibilityDescription)(ArkUINodeHandle node);
@ -1152,9 +1158,9 @@ struct ArkUICommonModifier {
void (*setNeedFocus)(ArkUINodeHandle node, ArkUI_Bool value);
ArkUI_Bool (*getNeedFocus)(ArkUINodeHandle node);
ArkUI_Float32 (*getOpacity)(ArkUINodeHandle node);
void (*getBorderWidth)(ArkUINodeHandle node, ArkUI_Float32* values);
void (*getBorderWidth)(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32 unit);
void (*getBorderWidthDimension)(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32* units);
void (*getBorderRadius)(ArkUINodeHandle node, ArkUI_Float32* values);
void (*getBorderRadius)(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32 unit);
void (*getBorderColor)(ArkUINodeHandle node, ArkUI_Uint32* values);
void (*getBorderStyle)(ArkUINodeHandle node, ArkUI_Int32* values);
ArkUI_Int32 (*getZIndex)(ArkUINodeHandle node);
@ -1167,9 +1173,9 @@ struct ArkUICommonModifier {
ArkUI_Int32 (*getShadow)(ArkUINodeHandle node);
void (*getCustomShadow)(ArkUINodeHandle node, ArkUICustomShadowOptions* options);
ArkUI_Int32 (*getSweepGradient)(
ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Uint32* colors, ArkUI_Float32* stops);
ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Uint32* colors, ArkUI_Float32* stops, ArkUI_Int32 unit);
ArkUI_Int32 (*getRadialGradient)(
ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Uint32* colors, ArkUI_Float32* stops);
ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Uint32* colors, ArkUI_Float32* stops, ArkUI_Int32 unit);
void (*getMask)(ArkUINodeHandle node, ArkUIMaskOptions* options);
void (*getBlendMode)(ArkUINodeHandle node, ArkUIBlendModeOptions* options);
ArkUI_Int32 (*getDirection)(ArkUINodeHandle node);
@ -1189,11 +1195,11 @@ struct ArkUICommonModifier {
void (*getRotate)(ArkUINodeHandle node, ArkUIRotateType* rotateType);
ArkUI_Float32 (*getBrightness)(ArkUINodeHandle node);
ArkUI_Float32 (*getSaturate)(ArkUINodeHandle node);
void (*getBackgroundImagePosition)(ArkUINodeHandle node, ArkUIPositionOptions* position);
void (*getBackgroundImagePosition)(ArkUINodeHandle node, ArkUIPositionOptions* position, ArkUI_Int32 unit);
ArkUI_Float32 (*getFlexGrow)(ArkUINodeHandle node);
ArkUI_Float32 (*getFlexShrink)(ArkUINodeHandle node);
ArkUI_Float32 (*getFlexBasis)(ArkUINodeHandle node);
void (*getConstraintSize)(ArkUINodeHandle node, ArkUIConstraintSizeOptions* options);
void (*getConstraintSize)(ArkUINodeHandle node, ArkUIConstraintSizeOptions* options, ArkUI_Int32 unit);
ArkUI_Float32 (*getGrayScale)(ArkUINodeHandle node);
ArkUI_Float32 (*getInvert)(ArkUINodeHandle node);
ArkUI_Float32 (*getSepia)(ArkUINodeHandle node);
@ -1203,24 +1209,27 @@ struct ArkUICommonModifier {
ArkUI_Int32 (*getLinearGradient)(
ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Uint32* colors, ArkUI_Float32* stop);
ArkUI_Int32 (*getAlign)(ArkUINodeHandle node);
ArkUI_Float32 (*getWidth)(ArkUINodeHandle node);
ArkUI_Float32 (*getHeight)(ArkUINodeHandle node);
ArkUI_Float32 (*getWidth)(ArkUINodeHandle node, ArkUI_Int32 unit);
ArkUI_Float32 (*getHeight)(ArkUINodeHandle node, ArkUI_Int32 unit);
ArkUI_Uint32 (*getBackgroundColor)(ArkUINodeHandle node);
void (*getBackgroundImage)(ArkUINodeHandle node, ArkUIBackgroundImage* options);
void (*getPadding)(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32 length);
void (*getPadding)(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32 length, ArkUI_Int32 unit);
void (*getPaddingDimension)(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32* units);
void (*getConfigSize)(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32* units);
ArkUI_CharPtr (*getKey)(ArkUINodeHandle node);
ArkUI_Int32 (*getEnabled)(ArkUINodeHandle node);
void (*getMargin)(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32 length);
void (*getMargin)(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32 length, ArkUI_Int32 unit);
void (*getMarginDimension)(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32* units);
void (*getTranslate)(ArkUINodeHandle node, ArkUI_Float32* values);
void (*getTranslate)(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32 unit);
void (*setMoveTransition)(ArkUINodeHandle node, ArkUI_Int32 value, const ArkUIAnimationOptionType* opacityOption);
ArkUIMoveTransitionType (*getMoveTransition)(ArkUINodeHandle node);
void (*resetMask)(ArkUINodeHandle node);
ArkUI_Float32 (*getAspectRatio)(ArkUINodeHandle node);
void (*setBackgroundImageResizable)(ArkUINodeHandle node, ArkUIStringAndFloat* options);
void (*resetBackgroundImageResizable)(ArkUINodeHandle node);
ArkUI_Float32 (*getLayoutWeight)(ArkUINodeHandle node);
void (*setBackgroundImageSizeWidthUnit)(ArkUINodeHandle node, ArkUI_Float32 valueWidth, ArkUI_Float32 valueHeight,
ArkUI_Int32 typeWidth, ArkUI_Int32 typeHeight, ArkUI_Int32 unit);
};
struct ArkUICommonShapeModifier {
@ -1355,7 +1364,7 @@ struct ArkUITextModifier {
ArkUI_Float32 (*getTextMinFontSize)(ArkUINodeHandle node);
ArkUI_Float32 (*getTextMaxFontSize)(ArkUINodeHandle node);
void (*getFont)(ArkUINodeHandle node, ArkUITextFont* font);
ArkUI_Float32 (*getFontSize)(ArkUINodeHandle node);
ArkUI_Float32 (*getFontSize)(ArkUINodeHandle node, ArkUI_Int32 unit);
ArkUI_Int32 (*getFontWeight)(ArkUINodeHandle node);
ArkUI_Int32 (*getItalicFontStyle)(ArkUINodeHandle node);
void (*setEllipsisMode)(ArkUINodeHandle node, ArkUI_Uint32 ellipsisMode);
@ -1410,7 +1419,7 @@ struct ArkUIButtonModifier {
ArkUI_CharPtr heightValue, ArkUI_Int32 heightUnit);
void (*resetButtonSize)(ArkUINodeHandle node);
ArkUI_CharPtr (*getButtonLabel)(ArkUINodeHandle node);
ArkUI_Float32 (*getButtonFontSize)(ArkUINodeHandle node);
ArkUI_Float32 (*getButtonFontSize)(ArkUINodeHandle node, ArkUI_Int32 unit);
ArkUI_Int32 (*getButtonFontWeight)(ArkUINodeHandle node);
ArkUI_Uint32 (*getButtonFontColor)(ArkUINodeHandle node);
void (*setButtonRole)(ArkUINodeHandle node, ArkUI_Uint32 buttonRole);
@ -2167,7 +2176,7 @@ struct ArkUITextInputModifier {
ArkUI_CharPtr (*getTextInputPlaceholder)(ArkUINodeHandle node);
ArkUI_CharPtr (*getTextInputText)(ArkUINodeHandle node);
ArkUI_Uint32 (*getTextInputCaretColor)(ArkUINodeHandle node);
ArkUI_Float32 (*getTextInputCaretStyle)(ArkUINodeHandle node);
ArkUI_Float32 (*getTextInputCaretStyle)(ArkUINodeHandle node, ArkUI_Int32 unit);
ArkUI_Bool (*getTextInputShowUnderline)(ArkUINodeHandle node);
ArkUI_Uint32 (*getTextInputMaxLength)(ArkUINodeHandle node);
ArkUI_Int32 (*getTextInputEnterKeyType)(ArkUINodeHandle node);
@ -2179,14 +2188,14 @@ struct ArkUITextInputModifier {
ArkUI_Bool (*getTextInputShowPasswordIcon)(ArkUINodeHandle node);
ArkUI_Bool (*getTextInputEditing)(ArkUINodeHandle node);
ArkUI_Bool (*getTextInputShowCancelButton)(ArkUINodeHandle node);
ArkUI_Float32 (*getTextInputCancelIconSize)(ArkUINodeHandle node);
ArkUI_Float32 (*getTextInputCancelIconSize)(ArkUINodeHandle node, ArkUI_Int32 unit);
ArkUI_CharPtr (*getTextInputTextCancelIconSrc)(ArkUINodeHandle node);
ArkUI_Uint32 (*getTextInputTextCancelIconColor)(ArkUINodeHandle node);
ArkUI_Int32 (*getTextInputTextAlign)(ArkUINodeHandle node);
ArkUI_Uint32 (*getTextInputFontColor)(ArkUINodeHandle node);
ArkUI_Int32 (*getTextInputFontStyle)(ArkUINodeHandle node);
ArkUI_Int32 (*getTextInputFontWeight)(ArkUINodeHandle node);
ArkUI_Float32 (*getTextInputFontSize)(ArkUINodeHandle node);
ArkUI_Float32 (*getTextInputFontSize)(ArkUINodeHandle node, ArkUI_Int32 unit);
ArkUI_Int32 (*getTextInputCancelButtonStyle)(ArkUINodeHandle node);
void (*setTextInputBackgroundColor)(ArkUINodeHandle node, ArkUI_Uint32 color);
void (*resetTextInputBackgroundColor)(ArkUINodeHandle node);
@ -2411,6 +2420,7 @@ struct ArkUIToggleModifier {
void (*resetToggleUnselectedColor)(ArkUINodeHandle node);
void (*setToggleTrackBorderRadius)(ArkUINodeHandle node, ArkUI_Float32 value, ArkUI_Int32 unit);
void (*resetToggleTrackBorderRadius)(ArkUINodeHandle node);
ArkUI_Uint32 (*getToggleUnselectedColor)(ArkUINodeHandle node);
};
struct ArkUINavigationModifier {
@ -2835,7 +2845,7 @@ struct ArkUISpanModifier {
ArkUI_CharPtr (*getSpanContent)(ArkUINodeHandle node);
void (*getSpanDecoration)(ArkUINodeHandle node, ArkUITextDecorationType* decorationType);
ArkUI_Uint32 (*getSpanFontColor)(ArkUINodeHandle node);
ArkUI_Float32 (*getSpanFontSize)(ArkUINodeHandle node);
ArkUI_Float32 (*getSpanFontSize)(ArkUINodeHandle node, ArkUI_Int32 unit);
ArkUI_Int32 (*getSpanFontStyle)(ArkUINodeHandle node);
ArkUI_Int32 (*getSpanFontWeight)(ArkUINodeHandle node);
ArkUI_Float32 (*getSpanLineHeight)(ArkUINodeHandle node);
@ -3119,6 +3129,7 @@ struct ArkUIXComponentModifier {
ArkUI_Int32 (*getXComponentType)(ArkUINodeHandle node);
ArkUI_Uint32 (*getXComponentSurfaceWidth)(ArkUINodeHandle node);
ArkUI_Uint32 (*getXComponentSurfaceHeight)(ArkUINodeHandle node);
void* (*getNativeXComponent)(ArkUINodeHandle node);
};
struct ArkUIStateModifier {

View File

@ -503,11 +503,11 @@ ArkUI_CharPtr GetButtonLabel(ArkUINodeHandle node)
return g_strValue.c_str();
}
ArkUI_Float32 GetButtonFontSize(ArkUINodeHandle node)
ArkUI_Float32 GetButtonFontSize(ArkUINodeHandle node, ArkUI_Int32 unit)
{
auto *frameNode = reinterpret_cast<FrameNode *>(node);
CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
return ButtonModelNG::GetFontSize(frameNode).Value();
return ButtonModelNG::GetFontSize(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
}
ArkUI_Int32 GetButtonFontWeight(ArkUINodeHandle node)

View File

@ -251,6 +251,7 @@ const ComponentAsyncEventHandler commonNodeAsyncEventHandlers[] = {
nullptr,
nullptr,
NodeModifier::SetOnFocus,
NodeModifier::SetOnTouchIntercept,
};
const ComponentAsyncEventHandler scrollNodeAsyncEventHandlers[] = {
@ -333,6 +334,7 @@ const ComponentAsyncEventHandler listNodeAsyncEventHandlers[] = {
const ComponentAsyncEventHandler WATER_FLOW_NODE_ASYNC_EVENT_HANDLERS[] = {
NodeModifier::SetOnWillScroll,
NodeModifier::SetOnReachEnd,
};
/* clang-format on */

View File

@ -1945,13 +1945,13 @@ ArkUI_Float32 GetSaturate(ArkUINodeHandle node)
return ViewAbstract::GetSaturate(frameNode).Value();
}
void GetBackgroundImagePosition(ArkUINodeHandle node, ArkUIPositionOptions* position)
void GetBackgroundImagePosition(ArkUINodeHandle node, ArkUIPositionOptions* position, ArkUI_Int32 unit)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_VOID(frameNode);
auto imagePosition = ViewAbstract::GetBackgroundImagePosition(frameNode);
position->x = imagePosition.GetSizeX().Value();
position->y = imagePosition.GetSizeY().Value();
position->x = imagePosition.GetSizeX().GetNativeValue(static_cast<DimensionUnit>(unit));
position->y = imagePosition.GetSizeY().GetNativeValue(static_cast<DimensionUnit>(unit));
}
/**
@ -4152,14 +4152,14 @@ ArkUI_Int32 GetResponseRegion(ArkUINodeHandle node, ArkUI_Float32* values)
return index;
}
ArkUI_CharPtr GetOverlay(ArkUINodeHandle node, ArkUIOverlayOptions* options)
ArkUI_CharPtr GetOverlay(ArkUINodeHandle node, ArkUIOverlayOptions* options, ArkUI_Int32 unit)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(frameNode, nullptr);
NG::OverlayOptions overlayOptions = ViewAbstract::GetOverlay(frameNode);
options->align = ParseAlignmentToIndex(overlayOptions.align);
options->x = overlayOptions.x.Value();
options->y = overlayOptions.y.Value();
options->x = overlayOptions.x.GetNativeValue(static_cast<DimensionUnit>(unit));
options->y = overlayOptions.y.GetNativeValue(static_cast<DimensionUnit>(unit));
options->content = overlayOptions.content.c_str();
g_strValue = overlayOptions.content;
return g_strValue.c_str();
@ -4244,10 +4244,10 @@ void SetConstraintSize(ArkUINodeHandle node, const ArkUI_Float32* values, const
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_VOID(frameNode);
ViewAbstract::SetMinWidth(frameNode, CalcLength(values[NUM_0], DimensionUnit::VP));
ViewAbstract::SetMaxWidth(frameNode, CalcLength(values[NUM_1], DimensionUnit::VP));
ViewAbstract::SetMinHeight(frameNode, CalcLength(values[NUM_2], DimensionUnit::VP));
ViewAbstract::SetMaxHeight(frameNode, CalcLength(values[NUM_3], DimensionUnit::VP));
ViewAbstract::SetMinWidth(frameNode, CalcLength(values[NUM_0], static_cast<DimensionUnit>(units[NUM_0])));
ViewAbstract::SetMaxWidth(frameNode, CalcLength(values[NUM_1], static_cast<DimensionUnit>(units[NUM_1])));
ViewAbstract::SetMinHeight(frameNode, CalcLength(values[NUM_2], static_cast<DimensionUnit>(units[NUM_2])));
ViewAbstract::SetMaxHeight(frameNode, CalcLength(values[NUM_3], static_cast<DimensionUnit>(units[NUM_3])));
}
void ResetConstraintSize(ArkUINodeHandle node)
@ -4267,15 +4267,15 @@ ArkUI_Float32 GetOpacity(ArkUINodeHandle node)
return ViewAbstract::GetOpacity(frameNode);
}
void GetBorderWidth(ArkUINodeHandle node, ArkUI_Float32* values)
void GetBorderWidth(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32 unit)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_VOID(frameNode);
auto width = ViewAbstract::GetBorderWidth(frameNode);
values[NUM_0] = width.topDimen->Value();
values[NUM_1] = width.rightDimen->Value();
values[NUM_2] = width.bottomDimen->Value();
values[NUM_3] = width.leftDimen->Value();
values[NUM_0] = width.topDimen->GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_1] = width.rightDimen->GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_2] = width.bottomDimen->GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_3] = width.leftDimen->GetNativeValue(static_cast<DimensionUnit>(unit));
}
void GetBorderWidthDimension(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32* units)
@ -4293,15 +4293,15 @@ void GetBorderWidthDimension(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_
units[NUM_3] = static_cast<ArkUI_Int32>(borderWidth.leftDimen->Unit());
}
void GetBorderRadius(ArkUINodeHandle node, ArkUI_Float32* values)
void GetBorderRadius(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32 unit)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_VOID(frameNode);
auto radius = ViewAbstract::GetBorderRadius(frameNode);
values[NUM_0] = radius.radiusTopLeft->Value();
values[NUM_1] = radius.radiusTopRight->Value();
values[NUM_2] = radius.radiusBottomLeft->Value();
values[NUM_3] = radius.radiusBottomRight->Value();
values[NUM_0] = radius.radiusTopLeft->GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_1] = radius.radiusTopRight->GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_2] = radius.radiusBottomLeft->GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_3] = radius.radiusBottomRight->GetNativeValue(static_cast<DimensionUnit>(unit));
}
void GetBorderColor(ArkUINodeHandle node, ArkUI_Uint32* values)
@ -4422,15 +4422,16 @@ void GetCustomShadow(ArkUINodeHandle node, ArkUICustomShadowOptions* options)
options->fill = static_cast<ArkUI_Int32>(shadow->GetIsFilled());
}
ArkUI_Int32 GetSweepGradient(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Uint32* colors, ArkUI_Float32* stops)
ArkUI_Int32 GetSweepGradient(
ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Uint32* colors, ArkUI_Float32* stops, ArkUI_Int32 unit)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
auto gradient = ViewAbstract::GetSweepGradient(frameNode);
auto sweepGradient = gradient.GetSweepGradient();
values[NUM_0] = sweepGradient->centerX->Value();
values[NUM_1] = sweepGradient->centerY->Value();
values[NUM_0] = sweepGradient->centerX->GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_1] = sweepGradient->centerY->GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_2] = sweepGradient->startAngle->Value();
values[NUM_3] = sweepGradient->endAngle->Value();
values[NUM_4] = sweepGradient->rotation->Value();
@ -4447,15 +4448,16 @@ ArkUI_Int32 GetSweepGradient(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_
return index;
}
ArkUI_Int32 GetRadialGradient(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Uint32* colors, ArkUI_Float32* stops)
ArkUI_Int32 GetRadialGradient(
ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Uint32* colors, ArkUI_Float32* stops, ArkUI_Int32 unit)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(frameNode, ERROR_INT_CODE);
auto gradient = ViewAbstract::GetRadialGradient(frameNode);
auto radialGradient = gradient.GetRadialGradient();
values[NUM_0] = radialGradient->radialCenterX->Value();
values[NUM_1] = radialGradient->radialCenterY->Value();
values[NUM_0] = radialGradient->radialCenterX->GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_1] = radialGradient->radialCenterY->GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_2] = gradient.GetInnerRadius();
values[NUM_3] = gradient.GetRepeat();
@ -4541,14 +4543,14 @@ ArkUI_Float32 GetFlexBasis(ArkUINodeHandle node)
return ViewAbstract::GetFlexBasis(frameNode).Value();
}
void GetConstraintSize(ArkUINodeHandle node, ArkUIConstraintSizeOptions* options)
void GetConstraintSize(ArkUINodeHandle node, ArkUIConstraintSizeOptions* options, ArkUI_Int32 unit)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_VOID(frameNode);
options->minWidth = ViewAbstract::GetMinWidth(frameNode);
options->maxWidth = ViewAbstract::GetMaxWidth(frameNode);
options->minHeight = ViewAbstract::GetMinHeight(frameNode);
options->maxHeight = ViewAbstract::GetMaxHeight(frameNode);
options->minWidth = ViewAbstract::GetMinWidth(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
options->maxWidth = ViewAbstract::GetMaxWidth(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
options->minHeight = ViewAbstract::GetMinHeight(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
options->maxHeight = ViewAbstract::GetMaxHeight(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
}
ArkUI_Float32 GetGrayScale(ArkUINodeHandle node)
@ -4624,18 +4626,18 @@ ArkUI_Int32 GetAlign(ArkUINodeHandle node)
return ConvertAlignmentToInt(ViewAbstract::GetAlign(frameNode));
}
ArkUI_Float32 GetWidth(ArkUINodeHandle node)
ArkUI_Float32 GetWidth(ArkUINodeHandle node, ArkUI_Int32 unit)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
return ViewAbstract::GetWidth(frameNode);
return ViewAbstract::GetWidth(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
}
ArkUI_Float32 GetHeight(ArkUINodeHandle node)
ArkUI_Float32 GetHeight(ArkUINodeHandle node, ArkUI_Int32 unit)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
return ViewAbstract::GetHeight(frameNode);
return ViewAbstract::GetHeight(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
}
ArkUI_Uint32 GetBackgroundColor(ArkUINodeHandle node)
@ -4653,15 +4655,15 @@ void GetBackgroundImage(ArkUINodeHandle node, ArkUIBackgroundImage* options)
options->repeat = static_cast<int>(ViewAbstract::GetBackgroundImageRepeat(frameNode));
}
void GetPadding(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32 length)
void GetPadding(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32 length, ArkUI_Int32 unit)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_VOID(frameNode);
auto padding = ViewAbstract::GetPadding(frameNode);
values[NUM_0] = padding.top->GetDimension().Value();
values[NUM_1] = padding.right->GetDimension().Value();
values[NUM_2] = padding.bottom->GetDimension().Value();
values[NUM_3] = padding.left->GetDimension().Value();
values[NUM_0] = padding.top->GetDimension().GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_1] = padding.right->GetDimension().GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_2] = padding.bottom->GetDimension().GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_3] = padding.left->GetDimension().GetNativeValue(static_cast<DimensionUnit>(unit));
length = NUM_4;
}
@ -4706,15 +4708,15 @@ int GetEnabled(ArkUINodeHandle node)
return static_cast<ArkUI_Int32>(ViewAbstract::GetEnabled(frameNode));
}
void GetMargin(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32 length)
void GetMargin(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32 length, ArkUI_Int32 unit)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_VOID(frameNode);
auto margin = ViewAbstract::GetMargin(frameNode);
values[NUM_0] = margin.top->GetDimension().Value();
values[NUM_1] = margin.right->GetDimension().Value();
values[NUM_2] = margin.bottom->GetDimension().Value();
values[NUM_3] = margin.left->GetDimension().Value();
values[NUM_0] = margin.top->GetDimension().GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_1] = margin.right->GetDimension().GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_2] = margin.bottom->GetDimension().GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_3] = margin.left->GetDimension().GetNativeValue(static_cast<DimensionUnit>(unit));
length = NUM_4;
}
@ -4733,14 +4735,14 @@ void GetMarginDimension(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32
units[NUM_3] = static_cast<ArkUI_Int32>(margin.left->GetDimension().Unit());
}
void GetTranslate(ArkUINodeHandle node, ArkUI_Float32* values)
void GetTranslate(ArkUINodeHandle node, ArkUI_Float32* values, ArkUI_Int32 unit)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_VOID(frameNode);
auto translate = ViewAbstract::GetTranslate(frameNode);
values[NUM_0] = translate.x.Value();
values[NUM_1] = translate.y.Value();
values[NUM_2] = translate.z.Value();
values[NUM_0] = translate.x.GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_1] = translate.y.GetNativeValue(static_cast<DimensionUnit>(unit));
values[NUM_2] = translate.z.GetNativeValue(static_cast<DimensionUnit>(unit));
}
ArkUI_Float32 GetAspectRatio(ArkUINodeHandle node)
@ -4750,6 +4752,28 @@ ArkUI_Float32 GetAspectRatio(ArkUINodeHandle node)
return ViewAbstract::GetAspectRatio(frameNode);
}
ArkUI_Float32 GetLayoutWeight(ArkUINodeHandle node)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
return ViewAbstract::GetLayoutWeight(frameNode);
}
void SetBackgroundImageSizeWithUnit(ArkUINodeHandle node, ArkUI_Float32 valueWidth, ArkUI_Float32 valueHeight,
ArkUI_Int32 typeWidth, ArkUI_Int32 typeHeight, ArkUI_Int32 unit)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_VOID(frameNode);
BackgroundImageSize bgImgSize;
CalcDimension width(valueWidth, static_cast<DimensionUnit>(unit));
CalcDimension height(valueHeight, static_cast<DimensionUnit>(unit));
bgImgSize.SetSizeTypeX(static_cast<OHOS::Ace::BackgroundImageSizeType>(typeWidth));
bgImgSize.SetSizeValueX(width.GetNativeValue(DimensionUnit::PX));
bgImgSize.SetSizeTypeY(static_cast<OHOS::Ace::BackgroundImageSizeType>(typeHeight));
bgImgSize.SetSizeValueY(height.GetNativeValue(DimensionUnit::PX));
ViewAbstract::SetBackgroundImageSize(frameNode, bgImgSize);
}
} // namespace
namespace NodeModifier {
@ -4808,7 +4832,8 @@ const ArkUICommonModifier* GetCommonModifier()
GetInvert, GetSepia, GetContrast, GetForegroundColor, GetBlur, GetLinearGradient, GetAlign, GetWidth,
GetHeight, GetBackgroundColor, GetBackgroundImage, GetPadding, GetPaddingDimension, GetConfigSize, GetKey,
GetEnabled, GetMargin, GetMarginDimension, GetTranslate, SetMoveTransition, GetMoveTransition, ResetMask,
GetAspectRatio, SetBackgroundImageResizable, ResetBackgroundImageResizable };
GetAspectRatio, SetBackgroundImageResizable, ResetBackgroundImageResizable, GetLayoutWeight,
SetBackgroundImageSizeWithUnit };
return &modifier;
}
@ -5049,6 +5074,7 @@ void SetOnTouch(ArkUINodeHandle node, void* extraParam)
event.touchEvent.touchPointes = nullptr;
event.touchEvent.touchPointSize = 0;
}
event.touchEvent.subKind = ON_TOUCH;
std::array<ArkUIHistoryTouchEvent, MAX_HISTORY_EVENT_COUNT> allHistoryEvents;
std::array<std::array<ArkUITouchPoint, MAX_POINTS>, MAX_HISTORY_EVENT_COUNT> allHistoryPoints;
if (!eventInfo.GetHistoryPointerEvent().empty() && eventInfo.GetHistoryPointerEvent().size() ==
@ -5103,5 +5129,49 @@ void SetOnTouch(ArkUINodeHandle node, void* extraParam)
ViewAbstract::SetOnTouch(frameNode, std::move(onEvent));
}
void SetOnTouchIntercept(ArkUINodeHandle node, void* extraParam)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_VOID(frameNode);
int32_t nodeId = frameNode->GetId();
auto onTouchIntercept = [nodeId, extraParam](TouchEventInfo& eventInfo) -> NG::HitTestMode {
globalEventInfo = eventInfo;
ArkUINodeEvent touchEvent;
touchEvent.kind = TOUCH_EVENT;
touchEvent.extraParam = reinterpret_cast<intptr_t>(extraParam);
touchEvent.nodeId = nodeId;
const std::list<TouchLocationInfo>& changeTouch = eventInfo.GetChangedTouches();
if (changeTouch.size() > 0) {
TouchLocationInfo front = changeTouch.front();
touchEvent.touchEvent.action = static_cast<int32_t>(front.GetTouchType());
ConvertTouchLocationInfoToPoint(front, touchEvent.touchEvent.actionTouchPoint);
}
touchEvent.touchEvent.timeStamp = eventInfo.GetTimeStamp().time_since_epoch().count();
touchEvent.touchEvent.sourceType = static_cast<int32_t>(eventInfo.GetSourceDevice());
std::array<ArkUITouchPoint, MAX_POINTS> touchPoints;
if (!eventInfo.GetTouches().empty()) {
size_t index = 0;
for (auto& touchLocationInfo: eventInfo.GetTouches()) {
if (index >= MAX_POINTS) {
break;
}
ConvertTouchLocationInfoToPoint(touchLocationInfo, touchPoints[index++]);
}
touchEvent.touchEvent.touchPointes = &touchPoints[0];
touchEvent.touchEvent.touchPointSize = eventInfo.GetTouches().size() < MAX_POINTS ?
eventInfo.GetTouches().size() : MAX_POINTS;
} else {
touchEvent.touchEvent.touchPointes = nullptr;
touchEvent.touchEvent.touchPointSize = 0;
}
touchEvent.touchEvent.historyEvents = nullptr;
touchEvent.touchEvent.historySize = 0;
touchEvent.touchEvent.subKind = ON_TOUCH_INTERCEPT;
touchEvent.touchEvent.interceptResult = 0;
SendArkUIAsyncEvent(&touchEvent);
return static_cast<NG::HitTestMode>(touchEvent.touchEvent.interceptResult);
};
ViewAbstract::SetOnTouchIntercept(frameNode, std::move(onTouchIntercept));
}
} // namespace NodeModifier
} // namespace OHOS::Ace::NG

View File

@ -27,4 +27,5 @@ void SetOnBlur(ArkUINodeHandle node, void* extraParam);
void SetOnAreaChange(ArkUINodeHandle node, void* extraParam);
void SetOnClick(ArkUINodeHandle node, void* extraParam);
void SetOnTouch(ArkUINodeHandle node, void* extraParam);
void SetOnTouchIntercept(ArkUINodeHandle node, void* extraParam);
} // namespace OHOS::Ace::NG::NodeModifier

View File

@ -96,7 +96,7 @@ ArkUIGesture* createSwipeGesture(ArkUI_Int32 fingers, ArkUI_Int32 directions, Ar
swipeDirection.type = SwipeDirection::HORIZONTAL;
}
if (directions & ArkUI_GESTURE_DIRECTION_VERTICAL) {
swipeDirection.type = SwipeDirection::VERTICAL;
swipeDirection.type += SwipeDirection::VERTICAL;
}
auto swipeGestureObject = AceType::MakeRefPtr<SwipeGesture>(fingers, swipeDirection, speed);
swipeGestureObject->IncRefCount();

View File

@ -162,11 +162,11 @@ void SetSpanFontSize(ArkUINodeHandle node, ArkUI_Float32 number, ArkUI_Int32 uni
SpanModelNG::SetFontSize(uiNode, Dimension(number, static_cast<DimensionUnit>(unit)));
}
float GetSpanFontSize(ArkUINodeHandle node)
float GetSpanFontSize(ArkUINodeHandle node, ArkUI_Int32 unit)
{
auto* uiNode = reinterpret_cast<UINode*>(node);
CHECK_NULL_RETURN(uiNode, DEFAULT_FONT_SIZE.Value());
return SpanModelNG::GetFontSize(uiNode).Value();
return SpanModelNG::GetFontSize(uiNode).GetNativeValue(static_cast<DimensionUnit>(unit));
}
void ResetSpanFontSize(ArkUINodeHandle node)

View File

@ -485,7 +485,7 @@ void GetTextAreaPlaceholderFont(ArkUINodeHandle node, ArkUITextFont* font)
CHECK_NULL_VOID(frameNode);
Font value = TextFieldModelNG::GetPlaceholderFont(frameNode);
if (value.fontSize.has_value()) {
font->fontSize = value.fontSize.value().Value();
font->fontSize = value.fontSize.value().GetNativeValue(static_cast<DimensionUnit>(font->fontSizeUnit));
}
if (value.fontWeight.has_value()) {
font->fontWeight = static_cast<ArkUI_Int32>(value.fontWeight.value());

View File

@ -652,11 +652,11 @@ ArkUI_Uint32 GetTextInputCaretColor(ArkUINodeHandle node)
return TextFieldModelNG::GetCaretColor(frameNode).GetValue();
}
ArkUI_Float32 GetTextInputCaretStyle(ArkUINodeHandle node)
ArkUI_Float32 GetTextInputCaretStyle(ArkUINodeHandle node, ArkUI_Int32 unit)
{
auto *frameNode = reinterpret_cast<FrameNode *>(node);
CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
return TextFieldModelNG::GetCaretStyle(frameNode).Value();
return TextFieldModelNG::GetCaretStyle(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
}
ArkUI_Bool GetTextInputShowUnderline(ArkUINodeHandle node)
@ -693,7 +693,7 @@ void GetTextInputPlaceholderFont(ArkUINodeHandle node, ArkUITextFont* font)
CHECK_NULL_VOID(frameNode);
Font value = TextFieldModelNG::GetPlaceholderFont(frameNode);
if (value.fontSize.has_value()) {
font->fontSize = value.fontSize.value().Value();
font->fontSize = value.fontSize.value().GetNativeValue(static_cast<DimensionUnit>(font->fontSizeUnit));
}
if (value.fontWeight.has_value()) {
font->fontWeight = static_cast<ArkUI_Int32>(value.fontWeight.value());
@ -765,11 +765,11 @@ ArkUI_Int32 GetTextInputCancelButtonStyle(ArkUINodeHandle node)
return static_cast<ArkUI_Int32>(TextFieldModelNG::GetCleanNodeStyle(frameNode));
}
ArkUI_Float32 GetTextInputCancelIconSize(ArkUINodeHandle node)
ArkUI_Float32 GetTextInputCancelIconSize(ArkUINodeHandle node, ArkUI_Int32 unit)
{
auto *frameNode = reinterpret_cast<FrameNode *>(node);
CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
return TextFieldModelNG::GetCancelIconSize(frameNode).Value();
return TextFieldModelNG::GetCancelIconSize(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
}
ArkUI_CharPtr getTextInputTextCancelIconSrc(ArkUINodeHandle node)
@ -815,11 +815,11 @@ ArkUI_Int32 GetTextInputFontWeight(ArkUINodeHandle node)
return static_cast<ArkUI_Int32>(TextFieldModelNG::GetFontWeight(frameNode));
}
ArkUI_Float32 GetTextInputFontSize(ArkUINodeHandle node)
ArkUI_Float32 GetTextInputFontSize(ArkUINodeHandle node, ArkUI_Int32 unit)
{
auto *frameNode = reinterpret_cast<FrameNode *>(node);
CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
return TextFieldModelNG::GetFontSize(frameNode).Value();
return TextFieldModelNG::GetFontSize(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit));
}
void SetTextInputBackgroundColor(ArkUINodeHandle node, ArkUI_Uint32 color)

View File

@ -681,7 +681,7 @@ void GetFont(ArkUINodeHandle node, ArkUITextFont* font)
CHECK_NULL_VOID(frameNode);
Font value = TextModelNG::GetFont(frameNode);
if (value.fontSize.has_value()) {
font->fontSize = value.fontSize.value().Value();
font->fontSize = value.fontSize.value().GetNativeValue(static_cast<DimensionUnit>(font->fontSizeUnit));
}
if (value.fontWeight.has_value()) {
font->fontWeight = static_cast<ArkUI_Int32>(value.fontWeight.value());
@ -705,11 +705,12 @@ void GetFont(ArkUINodeHandle node, ArkUITextFont* font)
}
}
ArkUI_Float32 GetFontSize(ArkUINodeHandle node)
ArkUI_Float32 GetFontSize(ArkUINodeHandle node, ArkUI_Int32 unit)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(frameNode, ERROR_FLOAT_CODE);
return static_cast<ArkUI_Float32>(TextModelNG::GetFontSize(frameNode).Value());
return static_cast<ArkUI_Float32>(
TextModelNG::GetFontSize(frameNode).GetNativeValue(static_cast<DimensionUnit>(unit)));
}
ArkUI_Int32 GetFontWeight(ArkUINodeHandle node)

View File

@ -326,6 +326,13 @@ ArkUI_Bool GetToggleIsOn(ArkUINodeHandle node)
CHECK_NULL_RETURN(frameNode, ERROR_UINT_CODE);
return static_cast<ArkUI_Bool>(ToggleModelNG::GetSwitchIsOn(frameNode));
}
ArkUI_Uint32 GetToggleUnselectedColor(ArkUINodeHandle node)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_RETURN(frameNode, ERROR_UINT_CODE);
return ToggleModelNG::GetUnselectedColor(frameNode).GetValue();
}
} // namespace
namespace NodeModifier {
const ArkUIToggleModifier* GetToggleModifier()
@ -356,6 +363,7 @@ const ArkUIToggleModifier* GetToggleModifier()
ResetToggleUnselectedColor,
SetToggleTrackBorderRadius,
ResetToggleTrackBorderRadius,
GetToggleUnselectedColor,
};
return &modifier;

View File

@ -16,6 +16,7 @@
#include "core/components_ng/base/frame_node.h"
#include "core/components_ng/pattern/xcomponent/xcomponent_model_ng.h"
#include "core/components_ng/pattern/xcomponent/xcomponent_pattern.h"
#include "core/pipeline/base/element_register.h"
#include "core/components_ng/base/view_abstract.h"
#include "frameworks/bridge/common/utils/utils.h"
@ -120,6 +121,16 @@ ArkUI_Uint32 GetXComponentSurfaceHeight(ArkUINodeHandle node)
CHECK_NULL_RETURN(frameNode, ERROR_UINT_CODE);
return XComponentModelNG::GetXComponentSurfaceHeight(frameNode);
}
void* GetNativeXComponent(ArkUINodeHandle node)
{
auto *frameNode = reinterpret_cast<FrameNode *>(node);
CHECK_NULL_RETURN(frameNode, nullptr);
auto xcPattern = frameNode->GetPattern<XComponentPattern>();
CHECK_NULL_RETURN(xcPattern, nullptr);
auto pair = xcPattern->GetNativeXComponent();
return reinterpret_cast<void*>(pair.second.lock().get());
}
} // namespace
namespace NodeModifier {
@ -141,6 +152,7 @@ const ArkUIXComponentModifier* GetXComponentModifier()
GetXComponentType,
GetXComponentSurfaceWidth,
GetXComponentSurfaceHeight,
GetNativeXComponent,
};
return &modifier;

View File

@ -378,5 +378,19 @@ void SetOnWillScroll(ArkUINodeHandle node, void* extraParam)
};
ScrollableModelNG::SetOnWillScroll(frameNode, std::move(onWillScroll));
}
void SetOnReachEnd(ArkUINodeHandle node, void* extraParam)
{
auto* frameNode = reinterpret_cast<FrameNode*>(node);
CHECK_NULL_VOID(frameNode);
auto onReachEnd = [node, extraParam]() -> void {
ArkUINodeEvent event;
event.kind = COMPONENT_ASYNC_EVENT;
event.extraParam = reinterpret_cast<intptr_t>(extraParam);
event.componentAsyncEvent.subKind = ON_REACH_END;
SendArkUIAsyncEvent(&event);
};
ScrollableModelNG::SetOnReachEnd(frameNode, std::move(onReachEnd));
}
} // namespace NodeModifier
} // namespace OHOS::Ace::NG

View File

@ -22,5 +22,6 @@ namespace OHOS::Ace::NG::NodeModifier {
const ArkUIWaterFlowModifier* GetWaterFlowModifier();
void SetOnWillScroll(ArkUINodeHandle node, void* extraParam);
void SetOnReachEnd(ArkUINodeHandle node, void* extraParam);
} // namespace OHOS::Ace::NG::NodeModifier
#endif // FRAMEWORKS_INTERFACE_INNER_API_NATIVE_NODE_WATER_FLOW_MODIFIER_H

View File

@ -20,6 +20,7 @@
#include "core/event/axis_event.h"
#include "core/interfaces/arkoala/arkoala_api.h"
#include "interfaces/native/node/event_converter.h"
#include "base/error/error_code.h"
#ifdef __cplusplus
extern "C" {
@ -956,6 +957,23 @@ double OH_ArkUI_AxisEvent_GetPinchAxisScaleValue(const ArkUI_UIInputEvent* event
return 0.0;
}
int32_t OH_ArkUI_PointerEvent_SetInterceptHitTestMode(const ArkUI_UIInputEvent* event, HitTestMode mode)
{
if (!event) {
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
}
switch (event->eventTypeId) {
case C_TOUCH_EVENT_ID: {
auto* touchEvent = reinterpret_cast<ArkUITouchEvent*>(event->inputEvent);
touchEvent->interceptResult = static_cast<int32_t>(mode);
break;
}
default:
return OHOS::Ace::ERROR_CODE_PARAM_INVALID;
}
return OHOS::Ace::ERROR_CODE_NO_ERROR;
}
#ifdef __cplusplus
};
#endif

View File

@ -630,5 +630,13 @@
{
"first_introduced": "12",
"name": "OH_ArkUI_GetContextFromNapiValue"
}
},
{
"first_introduced": "12",
"name": "OH_NativeXComponent_GetNativeXComponent"
},
{
"first_introduced": "12",
"name": "OH_ArkUI_PointerEvent_SetInterceptHitTestMode"
}
]

View File

@ -1,78 +0,0 @@
/*
* Copyright (c) 2024 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @addtogroup ArkUI_NativeModule
* @{
*
* @brief Provides UI capabilities of ArkUI on the native side, such as UI
* component creation and destruction, tree node operations, attribute setting,
* and event listening.
*
* @since 12
*/
/**
* @file native_event.h
*
* @brief Provides the event type definitions of ArkUI on the native side.
*
* @library libace_ndk.z.so
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 12
*/
#ifndef ARKUI_NATIVE_EVENT
#define ARKUI_NATIVE_EVENT
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Enumerates the hit test modes.
*
* @since 12
*/
typedef enum {
/** Both the node and its child node respond to the hit test of a touch event, but its sibling node is blocked from
* the hit test.
*/
HTM_DEFAULT = 0,
/** The node responds to the hit test of a touch event, but its child node and sibling node are blocked from the hit
* test.
*/
HTM_BLOCK,
/** Both the node and its child node respond to the hit test of a touch event, and its sibling node is also
* considered during the hit test.
*/
HTM_TRANSPARENT,
/** The node does not respond to the hit test of a touch event, but its child node and sibling node are considered
* during the hit test.
*/
HTM_NONE,
} HitTestMode;
#ifdef __cplusplus
};
#endif
#endif // ARKUI_NATIVE_EVENT
/** @} */

View File

@ -17,6 +17,8 @@
#include "node/node_model.h"
#include "ui_input_event.h"
#include "native_node.h"
#include "core/interfaces/arkoala/arkoala_api.h"
#include "base/error/error_code.h"
#include "frameworks/core/components/xcomponent/native_interface_xcomponent_impl.h"
@ -298,6 +300,16 @@ int32_t OH_NativeXComponent_GetTouchEventSourceType(
: OH_NATIVEXCOMPONENT_RESULT_BAD_PARAMETER;
}
OH_NativeXComponent* OH_NativeXComponent_GetNativeXComponent(ArkUI_NodeHandle node)
{
if (node == nullptr || node->type != ARKUI_NODE_XCOMPONENT) {
return nullptr;
}
auto nodeModifiers = OHOS::Ace::NodeModel::GetFullImpl()->getNodeModifiers();
return reinterpret_cast<OH_NativeXComponent*>(
nodeModifiers->getXComponentModifier()->getNativeXComponent(node->uiNodeHandle));
}
#ifdef __cplusplus
};
#endif

View File

@ -39,7 +39,6 @@
#include <stdbool.h>
#include <stdint.h>
#include "native_event.h"
#include "native_type.h"
#include "native_xcomponent_key_event.h"
#include "ui_input_event.h"
@ -725,6 +724,17 @@ int32_t OH_NativeXComponent_RegisterOnTouchInterceptCallback(
int32_t OH_NativeXComponent_GetTouchEventSourceType(
OH_NativeXComponent* component, int32_t pointId, OH_NativeXComponent_EventSourceType* sourceType);
/**
* @brief Obtains the pointer to an <b>OH_NativeXComponent</b> instance based on the specified component
* instance created by the native API.
*
* @param node Indicates the pointer to the component instance created by the native API.
* @return Returns the pointer to the <b>OH_NativeXComponent</b> instance.
* @since 12
* @version 1.0
*/
OH_NativeXComponent* OH_NativeXComponent_GetNativeXComponent(ArkUI_NodeHandle node);
#ifdef __cplusplus
};
#endif

View File

@ -36,7 +36,6 @@
#ifndef ARKUI_NATIVE_NODE_H
#define ARKUI_NATIVE_NODE_H
#include "native_event.h"
#include "native_type.h"
#include "ui_input_event.h"
@ -1370,6 +1369,19 @@ typedef enum {
*
*/
NODE_ASPECT_RATIO,
/**
* @brief Defines the weight of the component within its row, column, or flex container for proportional
* distribution of available space within the container.
* This attribute can be set, reset, and obtained as required through APIs.
*
* Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n
* .value[0].f32: weight of the component along the main axis. \n
* \n
* Format of the return value {@link ArkUI_AttributeItem}:\n
* .value[0].f32: weight of the component along the main axis. \n
*
*/
NODE_LAYOUT_WEIGHT,
/**
* @brief Defines the text content attribute, which can be set, reset, and obtained as required through APIs.
@ -1857,6 +1869,18 @@ typedef enum {
*
*/
NODE_TOGGLE_VALUE,
/**
* @brief Defines the color of the component when it is deselected.
* This attribute can be set, reset, and obtained as required through APIs.
*
* Format of the {@link ArkUI_AttributeItem} parameter for setting the attribute:\n
*.value[0].u32: background color, in 0xARGB format. For example, 0xFFFF0000 indicates red. \n
* \n
* Format of the return value {@link ArkUI_AttributeItem}:\n
* .value[0].u32: background color, in 0xARGB format. \n
*
*/
NODE_TOGGLE_UNSELECTED_COLOR,
/**
* @brief Defines the foreground color of the loading progress bar.
@ -3912,6 +3936,14 @@ typedef enum {
* application screen, in vp. \n
*/
NODE_ON_CLICK,
/**
* @brief Defines event interception.
*
* This event is triggered when the component is touched. \n
* When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is
* {@link ArkUI_UIInputEvent}. \n
*/
NODE_ON_TOUCH_INTERCEPT,
/**
* @brief Defines the image loading success event.
*
@ -4285,6 +4317,14 @@ typedef enum {
* <b>ArkUI_NodeComponentEvent.data[1].i32</b>: current scroll state. \n
*/
NODE_ON_WILL_SCROLL = MAX_NODE_SCOPE_NUM * ARKUI_NODE_WATER_FLOW,
/**
* @brief Defines the event triggered when the <b>ARKUI_NODE_WATER_FLOW</b> component reaches the end edge.
*
* \n
* When the event callback occurs, the union type in the {@link ArkUI_NodeEvent} object is {@link ArkUI_NodeComponentEvent}. \n
* {@link ArkUI_NodeComponentEvent} does not contain parameters. \n
*/
NODE_ON_REACH_END,
} ArkUI_NodeEventType;
/**
@ -5062,6 +5102,16 @@ typedef struct {
* @return Returns the custom data.
*/
void* (*getUserData)(ArkUI_NodeHandle node);
/**
* @brief Sets the unit for a component.
*
* @param node Indicates the component for which you want to set the unit.
* @param unit Indicates the unit, which is an enumerated value of {@link ArkUI_LengthMetricUnit}.
* The default value is <b>ARKUI_LENGTH_METRIC_UNIT_DEFAULT</b>.
* @return Returns <b>0</b> if the operation is successful; returns <b>401</b> if a parameter error occurs.
*/
int32_t (*setLengthMetricUnit)(ArkUI_NodeHandle node, ArkUI_LengthMetricUnit unit);
} ArkUI_NativeNodeAPI_1;
/**

View File

@ -1446,6 +1446,22 @@ typedef enum {
ARKUI_FINISH_CALLBACK_LOGICALLY,
} ArkUI_FinishCallbackType;
/**
* @brief Enumerates the component units.
*
* @since 12
*/
typedef enum {
/** Default, which is fp for fonts and vp for non-fonts. */
ARKUI_LENGTH_METRIC_UNIT_DEFAULT = -1,
/** px. */
ARKUI_LENGTH_METRIC_UNIT_PX = 0,
/** vp. */
ARKUI_LENGTH_METRIC_UNIT_VP,
/** fp. */
ARKUI_LENGTH_METRIC_UNIT_FP
} ArkUI_LengthMetricUnit;
/**
* @brief Creates a size constraint.
*

View File

@ -198,6 +198,10 @@ ArkUI_Int32 ConvertOriginEventType(ArkUI_NodeEventType type, int32_t nodeType)
return ON_SWIPER_GESTURE_SWIPE;
case NODE_ON_WILL_SCROLL:
return ON_WILL_SCROLL;
case NODE_ON_TOUCH_INTERCEPT:
return ON_TOUCH_INTERCEPT;
case NODE_ON_REACH_END:
return ON_REACH_END;
default:
return -1;
}
@ -284,6 +288,10 @@ ArkUI_Int32 ConvertToNodeEventType(ArkUIEventSubKind type)
return NODE_SCROLL_EVENT_ON_SCROLL_STOP;
case ON_WILL_SCROLL:
return NODE_ON_WILL_SCROLL;
case ON_TOUCH_INTERCEPT:
return NODE_ON_TOUCH_INTERCEPT;
case ON_REACH_END:
return NODE_ON_REACH_END;
default:
return -1;
}
@ -307,6 +315,7 @@ bool IsTouchEvent(ArkUI_Int32 type)
{
switch (type) {
case NODE_TOUCH_EVENT:
case NODE_ON_TOUCH_INTERCEPT:
return true;
default:
return false;
@ -331,7 +340,8 @@ bool ConvertEvent(ArkUINodeEvent* origin, ArkUI_NodeEvent* event)
}
case TOUCH_EVENT: {
event->category = static_cast<int32_t>(NODE_EVENT_CATEGORY_INPUT_EVENT);
event->kind = ConvertToNodeEventType(ON_TOUCH);
ArkUIEventSubKind subKind = static_cast<ArkUIEventSubKind>(origin->touchEvent.subKind);
event->kind = ConvertToNodeEventType(subKind);
return true;
}
default:

View File

@ -81,6 +81,13 @@ ArkUI_NativeNodeAPI_1 nodeImpl_1 = {
OHOS::Ace::NodeModel::GetLayoutPosition,
OHOS::Ace::NodeModel::MeasureNode,
OHOS::Ace::NodeModel::LayoutNode,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
nullptr,
OHOS::Ace::NodeModel::SetLengthMetricUnit,
};
ArkUI_NativeDialogAPI_1 dialogImpl_1 = {

View File

@ -366,7 +366,7 @@ void HandleInnerNodeEvent(ArkUINodeEvent* innerEvent)
subKind = static_cast<ArkUIEventSubKind>(innerEvent->textInputEvent.subKind);
break;
case TOUCH_EVENT:
subKind = ON_TOUCH;
subKind = static_cast<ArkUIEventSubKind>(innerEvent->touchEvent.subKind);
break;
default:
break; /* Empty */
@ -383,7 +383,7 @@ void HandleInnerNodeEvent(ArkUINodeEvent* innerEvent)
if (g_eventReceiver && ConvertEvent(innerEvent, &event)) {
event.targetId = innerEvent->nodeId;
ArkUI_UIInputEvent uiEvent;
if (eventType == NODE_TOUCH_EVENT) {
if (eventType == NODE_TOUCH_EVENT || eventType == NODE_ON_TOUCH_INTERCEPT) {
uiEvent.inputType = ARKUI_UIINPUTEVENT_TYPE_TOUCH;
uiEvent.eventTypeId = C_TOUCH_EVENT_ID;
uiEvent.inputEvent = &(innerEvent->touchEvent);
@ -410,6 +410,20 @@ int32_t CheckEvent(ArkUI_NodeEvent* event)
return 0;
}
int32_t SetLengthMetricUnit(ArkUI_NodeHandle nodePtr, ArkUI_LengthMetricUnit unit)
{
if (!nodePtr) {
return ERROR_CODE_PARAM_INVALID;
}
if (!InRegion(static_cast<int32_t>(ARKUI_LENGTH_METRIC_UNIT_DEFAULT),
static_cast<int32_t>(ARKUI_LENGTH_METRIC_UNIT_FP), static_cast<int32_t>(unit))) {
return ERROR_CODE_PARAM_INVALID;
}
nodePtr->lengthMetricUnit = unit;
return ERROR_CODE_NO_ERROR;
}
void ApplyModifierFinish(ArkUI_NodeHandle nodePtr)
{
// already check in entry point.

View File

@ -32,6 +32,7 @@ struct ArkUI_Node {
ArkUINodeHandle uiNodeHandle = nullptr;
void* extraData = nullptr;
void* extraCustomData = nullptr;
ArkUI_LengthMetricUnit lengthMetricUnit = ARKUI_LENGTH_METRIC_UNIT_DEFAULT;
};
struct ArkUI_Context {
@ -77,4 +78,6 @@ void HandleInnerNodeEvent(ArkUINodeEvent* innerEvent);
void ApplyModifierFinish(ArkUI_NodeHandle nodePtr);
void MarkDirty(ArkUI_NodeHandle nodePtr, ArkUI_NodeDirtyFlag dirtyFlag);
int32_t SetLengthMetricUnit(ArkUI_NodeHandle nodePtr, ArkUI_LengthMetricUnit unit);
}; // namespace OHOS::Ace::NodeModel

View File

@ -64,7 +64,6 @@ constexpr int NUM_29 = 29;
constexpr int NUM_59 = 59;
constexpr int NUM_100 = 100;
constexpr int NUM_400 = 400;
constexpr int DEFAULT_UNIT = 1;
const int ALLOW_SIZE_1(1);
const int ALLOW_SIZE_2(2);
const int ALLOW_SIZE_4(4);
@ -127,6 +126,7 @@ const std::vector<std::string> CURVE_ARRAY = { "linear", "ease", "ease-in", "eas
"fast-out-slow-in", "linear-out-slow-in", "fast-out-linear-in", "extreme-deceleration", "sharp", "rhythm", "smooth",
"friction" };
const std::vector<std::string> FONT_STYLES = { "normal", "italic" };
const std::vector<std::string> LENGTH_METRIC_UNIT = { "px", "vp", "fp" };
std::unordered_map<int32_t, bool> SPAN_ATTRIBUTES_MAP = {
{ static_cast<int32_t>(NODE_SPAN_CONTENT), true },
{ static_cast<int32_t>(NODE_TEXT_DECORATION), true },
@ -223,6 +223,14 @@ uint32_t StringToColorInt(const char* string, uint32_t defaultValue = 0)
return defaultValue;
}
int32_t GetDefaultUnit(ArkUI_NodeHandle nodePtr, int32_t defaultUnit)
{
if (nodePtr->lengthMetricUnit == ARKUI_LENGTH_METRIC_UNIT_DEFAULT) {
return defaultUnit;
}
return static_cast<int32_t>(nodePtr->lengthMetricUnit);
}
int StringToInt(const char* string, int defaultValue = 0)
{
char* end;
@ -580,7 +588,7 @@ int32_t SetWidth(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
auto* fullImpl = GetFullImpl();
// 1 for vp. check in DimensionUnit.
fullImpl->getNodeModifiers()->getCommonModifier()->setWidth(
node->uiNodeHandle, item->value[NUM_0].f32, UNIT_VP, nullptr);
node->uiNodeHandle, item->value[NUM_0].f32, GetDefaultUnit(node, UNIT_VP), nullptr);
return ERROR_CODE_NO_ERROR;
}
@ -593,7 +601,7 @@ void ResetWidth(ArkUI_NodeHandle node)
const ArkUI_AttributeItem* GetWidth(ArkUI_NodeHandle node)
{
auto modifier = GetFullImpl()->getNodeModifiers()->getCommonModifier();
g_numberValues[0].f32 = modifier->getWidth(node->uiNodeHandle);
g_numberValues[0].f32 = modifier->getWidth(node->uiNodeHandle, GetDefaultUnit(node, UNIT_VP));
if (LessNotEqual(g_numberValues[0].f32, 0.0f)) {
return nullptr;
}
@ -610,7 +618,7 @@ int32_t SetHeight(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
auto* fullImpl = GetFullImpl();
// 1 for vp. check in DimensionUnit.
fullImpl->getNodeModifiers()->getCommonModifier()->setHeight(
node->uiNodeHandle, item->value[NUM_0].f32, UNIT_VP, nullptr);
node->uiNodeHandle, item->value[NUM_0].f32, GetDefaultUnit(node, UNIT_VP), nullptr);
return ERROR_CODE_NO_ERROR;
}
@ -623,7 +631,7 @@ void ResetHeight(ArkUI_NodeHandle node)
const ArkUI_AttributeItem* GetHeight(ArkUI_NodeHandle node)
{
auto modifier = GetFullImpl()->getNodeModifiers()->getCommonModifier();
g_numberValues[0].f32 = modifier->getHeight(node->uiNodeHandle);
g_numberValues[0].f32 = modifier->getHeight(node->uiNodeHandle, GetDefaultUnit(node, UNIT_VP));
if (LessNotEqual(g_numberValues[0].f32, 0.0f)) {
return nullptr;
}
@ -720,10 +728,11 @@ int32_t SetPadding(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
int rightIndex = item->size == NUM_1 ? NUM_0 : NUM_1;
int bottomIndex = item->size == NUM_1 ? NUM_0 : NUM_2;
int leftIndex = item->size == NUM_1 ? NUM_0 : NUM_3;
struct ArkUISizeType top = { item->value[topIndex].f32, UNIT_VP };
struct ArkUISizeType right = { item->value[rightIndex].f32, UNIT_VP };
struct ArkUISizeType bottom = { item->value[bottomIndex].f32, UNIT_VP };
struct ArkUISizeType left = { item->value[leftIndex].f32, UNIT_VP };
int32_t unit = GetDefaultUnit(node, UNIT_VP);
struct ArkUISizeType top = { item->value[topIndex].f32, unit };
struct ArkUISizeType right = { item->value[rightIndex].f32, unit };
struct ArkUISizeType bottom = { item->value[bottomIndex].f32, unit };
struct ArkUISizeType left = { item->value[leftIndex].f32, unit };
fullImpl->getNodeModifiers()->getCommonModifier()->setPadding(node->uiNodeHandle, &top, &right, &bottom, &left);
return ERROR_CODE_NO_ERROR;
}
@ -743,7 +752,8 @@ const ArkUI_AttributeItem* GetPadding(ArkUI_NodeHandle node)
auto* fullImpl = GetFullImpl();
ArkUI_Float32 paddings[NUM_4];
ArkUI_Int32 length = 0;
fullImpl->getNodeModifiers()->getCommonModifier()->getPadding(node->uiNodeHandle, paddings, length);
ArkUI_Int32 unit = GetDefaultUnit(node, UNIT_VP);
fullImpl->getNodeModifiers()->getCommonModifier()->getPadding(node->uiNodeHandle, paddings, length, unit);
g_numberValues[NUM_0].f32 = paddings[NUM_0];
g_numberValues[NUM_1].f32 = paddings[NUM_1];
g_numberValues[NUM_2].f32 = paddings[NUM_2];
@ -808,7 +818,7 @@ int32_t SetMargin(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
auto* fullImpl = GetFullImpl();
ArkUISizeType top, right, bottom, left;
top.value = right.value = bottom.value = left.value = NUM_0;
top.unit = right.unit = bottom.unit = left.unit = DEFAULT_UNIT;
top.unit = right.unit = bottom.unit = left.unit = GetDefaultUnit(node, UNIT_VP);
if (item->size == NUM_1) {
top.value = right.value = bottom.value = left.value = item->value[NUM_0].f32;
} else if (item->size == NUM_4) {
@ -835,7 +845,8 @@ const ArkUI_AttributeItem* GetMargin(ArkUI_NodeHandle node)
auto* fullImpl = GetFullImpl();
ArkUI_Float32 margins[NUM_4];
ArkUI_Int32 length = 0;
fullImpl->getNodeModifiers()->getCommonModifier()->getMargin(node->uiNodeHandle, margins, length);
ArkUI_Int32 unit = GetDefaultUnit(node, UNIT_VP);
fullImpl->getNodeModifiers()->getCommonModifier()->getMargin(node->uiNodeHandle, margins, length, unit);
g_numberValues[NUM_0].f32 = margins[NUM_0];
g_numberValues[NUM_1].f32 = margins[NUM_1];
g_numberValues[NUM_2].f32 = margins[NUM_2];
@ -852,9 +863,10 @@ int32_t SetTranslate(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
auto fullImpl = GetFullImpl();
ArkUI_Float32 values[item->size];
ArkUI_Int32 units[item->size];
int32_t unit = GetDefaultUnit(node, UNIT_VP);
for (int i = 0; i < item->size; ++i) {
values[i] = item->value[i].f32;
units[i] = UNIT_VP;
units[i] = unit;
}
fullImpl->getNodeModifiers()->getCommonModifier()->setTranslate(node->uiNodeHandle, values, units, item->size);
@ -873,7 +885,8 @@ const ArkUI_AttributeItem* GetTranslate(ArkUI_NodeHandle node)
{
auto* fullImpl = GetFullImpl();
ArkUI_Float32 translate[NUM_3];
fullImpl->getNodeModifiers()->getCommonModifier()->getTranslate(node->uiNodeHandle, translate);
ArkUI_Int32 unit = GetDefaultUnit(node, UNIT_VP);
fullImpl->getNodeModifiers()->getCommonModifier()->getTranslate(node->uiNodeHandle, translate, unit);
g_numberValues[NUM_0].f32 = translate[NUM_0];
g_numberValues[NUM_1].f32 = translate[NUM_1];
g_numberValues[NUM_2].f32 = translate[NUM_2];
@ -891,7 +904,8 @@ int32_t SetScale(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
for (int i = 0; i < item->size; i++) {
values[i] = item->value[i].f32;
}
ArkUI_Int32 units[NUM_2] = { UNIT_VP, UNIT_VP };
int32_t unit = GetDefaultUnit(node, UNIT_VP);
ArkUI_Int32 units[NUM_2] = { unit, unit };
fullImpl->getNodeModifiers()->getCommonModifier()->setScale(node->uiNodeHandle, values, item->size, units, NUM_2);
return ERROR_CODE_NO_ERROR;
}
@ -1175,8 +1189,9 @@ int32_t SetBorderWidth(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
}
// already check in entry point.
auto* fullImpl = GetFullImpl();
int32_t unit = GetDefaultUnit(node, UNIT_VP);
float widthVals[ALLOW_SIZE_4] = { 0, 0, 0, 0 };
int widthUnits[ALLOW_SIZE_4] = { DEFAULT_UNIT, DEFAULT_UNIT, DEFAULT_UNIT, DEFAULT_UNIT };
int widthUnits[ALLOW_SIZE_4] = { unit, unit, unit, unit };
if (item->size == 1) {
if (LessNotEqual(item->value[0].f32, 0.0f)) {
@ -1211,7 +1226,8 @@ const ArkUI_AttributeItem* GetBorderWidth(ArkUI_NodeHandle node)
{
auto* fullImpl = GetFullImpl();
ArkUI_Float32 borderWidth[NUM_4];
fullImpl->getNodeModifiers()->getCommonModifier()->getBorderWidth(node->uiNodeHandle, borderWidth);
auto unit = GetDefaultUnit(node, UNIT_VP);
fullImpl->getNodeModifiers()->getCommonModifier()->getBorderWidth(node->uiNodeHandle, borderWidth, unit);
g_numberValues[NUM_0].f32 = borderWidth[NUM_0];
g_numberValues[NUM_1].f32 = borderWidth[NUM_1];
g_numberValues[NUM_2].f32 = borderWidth[NUM_2];
@ -1227,7 +1243,8 @@ int32_t SetBorderRadius(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
// already check in entry point.
auto* fullImpl = GetFullImpl();
float radiusVals[ALLOW_SIZE_4] = { NUM_1, NUM_1, NUM_1, NUM_1 };
int radiusUnits[ALLOW_SIZE_4] = { DEFAULT_UNIT, DEFAULT_UNIT, DEFAULT_UNIT, DEFAULT_UNIT };
int32_t unit = GetDefaultUnit(node, UNIT_VP);
int radiusUnits[ALLOW_SIZE_4] = { unit, unit, unit, unit };
if (item->size == 1) {
if (LessNotEqual(item->value[NUM_0].f32, 0.0f)) {
@ -1263,7 +1280,8 @@ const ArkUI_AttributeItem* GetBorderRadius(ArkUI_NodeHandle node)
{
auto* fullImpl = GetFullImpl();
ArkUI_Float32 borderRadius[NUM_4];
fullImpl->getNodeModifiers()->getCommonModifier()->getBorderRadius(node->uiNodeHandle, borderRadius);
ArkUI_Int32 unit = GetDefaultUnit(node, UNIT_VP);
fullImpl->getNodeModifiers()->getCommonModifier()->getBorderRadius(node->uiNodeHandle, borderRadius, unit);
g_numberValues[NUM_0].f32 = borderRadius[NUM_0];
g_numberValues[NUM_1].f32 = borderRadius[NUM_1];
g_numberValues[NUM_2].f32 = borderRadius[NUM_2];
@ -1892,13 +1910,13 @@ int32_t SetOverlay(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
if (item->size > 1) {
values[2] = 1;
values[3] = item->value[1].f32;
values[4] = UNIT_VP;
values[NUM_4] = GetDefaultUnit(node, UNIT_VP);
}
if (item->size > 2) {
values[5] = 1;
values[6] = item->value[2].f32;
values[7] = UNIT_VP;
values[NUM_7] = GetDefaultUnit(node, UNIT_VP);
}
values[8] = item->size > 0 ? 1 : 0;
values[9] = item->size > 1 ? 1 : 0;
@ -1910,8 +1928,9 @@ int32_t SetOverlay(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
const ArkUI_AttributeItem* GetOverlay(ArkUI_NodeHandle node)
{
ArkUIOverlayOptions options;
ArkUI_Int32 unit = GetDefaultUnit(node, UNIT_VP);
auto contentStr = GetFullImpl()->getNodeModifiers()->getCommonModifier()->getOverlay(
node->uiNodeHandle, &options);
node->uiNodeHandle, &options, unit);
g_attributeItem.string = contentStr;
int index = 0;
//index 0 : align
@ -1938,7 +1957,8 @@ int32_t SetBackgroundImagePosition(ArkUI_NodeHandle node, const ArkUI_AttributeI
}
auto fullImpl = GetFullImpl();
ArkUI_Float32 values[] = { item->value[NUM_0].f32, item->value[NUM_1].f32 };
ArkUI_Int32 units[] = { DEFAULT_UNIT, DEFAULT_UNIT };
int32_t unit = GetDefaultUnit(node, UNIT_VP);
ArkUI_Int32 units[] = { unit, unit };
fullImpl->getNodeModifiers()->getCommonModifier()->setBackgroundImagePosition(
node->uiNodeHandle, values, units, false, NUM_2);
@ -1956,8 +1976,9 @@ const ArkUI_AttributeItem* GetBackgroundImagePosition(ArkUI_NodeHandle node)
{
auto fullImpl = GetFullImpl();
ArkUIPositionOptions positionOption = { 0.0f, 0.0f };
ArkUI_Int32 unit = GetDefaultUnit(node, UNIT_VP);
fullImpl->getNodeModifiers()->getCommonModifier()->getBackgroundImagePosition(node->uiNodeHandle,
&positionOption);
&positionOption, unit);
g_numberValues[NUM_0].f32 = positionOption.x;
g_numberValues[NUM_1].f32 = positionOption.y;
g_attributeItem.size = NUM_2;
@ -1981,13 +2002,14 @@ int32_t SetSweepGradient(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
colors[i * NUM_3 + NUM_1].i32 = true;
colors[i * NUM_3 + NUM_2].f32 = colorStop->stops[i];
}
int32_t unit = GetDefaultUnit(node, UNIT_VP);
ArkUIInt32orFloat32 values[NUM_13] = {
{static_cast<ArkUI_Int32>(false)},
{static_cast<ArkUI_Float32>(DEFAULT_X)},
{static_cast<ArkUI_Int32>(UNIT_VP)},
{static_cast<ArkUI_Int32>(unit)},
{static_cast<ArkUI_Int32>(false)},
{static_cast<ArkUI_Float32>(DEFAULT_Y)},
{static_cast<ArkUI_Int32>(UNIT_VP)},
{static_cast<ArkUI_Int32>(unit)},
{static_cast<ArkUI_Int32>(false)},
{static_cast<ArkUI_Float32>(NUM_0)},
{static_cast<ArkUI_Int32>(false)},
@ -2041,8 +2063,9 @@ const ArkUI_AttributeItem* GetSweepGradient(ArkUI_NodeHandle node)
ArkUI_Uint32 colors[NUM_10];
//default size 10
ArkUI_Float32 stops[NUM_10];
ArkUI_Int32 unit = GetDefaultUnit(node, UNIT_VP);
auto resultValue = GetFullImpl()->getNodeModifiers()->getCommonModifier()->getSweepGradient(
node->uiNodeHandle, values, colors, stops);
node->uiNodeHandle, values, colors, stops, unit);
//centerX
g_numberValues[NUM_0].f32 = values[NUM_0];
//centerY
@ -2087,6 +2110,7 @@ int32_t SetRadialGradient(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item
const ArkUI_ColorStop* colorStop = reinterpret_cast<ArkUI_ColorStop*>(item->object);
int size = colorStop->size;
ArkUIInt32orFloat32 colors[size * NUM_3];
int32_t unit = GetDefaultUnit(node, UNIT_VP);
for (int i = 0; i < size; i++) {
colors[i * NUM_3 + NUM_0].u32 = colorStop->colors[i];
colors[i * NUM_3 + NUM_1].i32 = true;
@ -2096,13 +2120,13 @@ int32_t SetRadialGradient(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item
ArkUIInt32orFloat32 values[NUM_10] = {
{ static_cast<ArkUI_Int32>(false) },
{ static_cast<ArkUI_Float32>(DEFAULT_X) },
{ static_cast<ArkUI_Float32>(UNIT_VP) },
{ static_cast<ArkUI_Float32>(unit) },
{ static_cast<ArkUI_Int32>(false) },
{ static_cast<ArkUI_Float32>(DEFAULT_Y) },
{ static_cast<ArkUI_Float32>(UNIT_VP) },
{ static_cast<ArkUI_Float32>(unit) },
{ static_cast<ArkUI_Int32>(false) },
{ static_cast<ArkUI_Float32>(NUM_0) },
{ static_cast<ArkUI_Float32>(UNIT_VP) },
{ static_cast<ArkUI_Float32>(unit) },
{ static_cast<ArkUI_Int32>(false) }
};
@ -2142,8 +2166,10 @@ const ArkUI_AttributeItem* GetRadialGradient(ArkUI_NodeHandle node)
ArkUI_Uint32 colors[NUM_10];
//default size 10
ArkUI_Float32 stops[NUM_10];
ArkUI_Int32 unit = GetDefaultUnit(node, UNIT_VP);
auto resultValue = GetFullImpl()->getNodeModifiers()->getCommonModifier()->getRadialGradient(
node->uiNodeHandle, values, colors, stops);
node->uiNodeHandle, values, colors, stops, unit);
//centerX
g_numberValues[NUM_0].f32 = values[NUM_0];
//centerY
@ -2457,7 +2483,8 @@ int32_t SetConstraintSize(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item
auto* fullImpl = GetFullImpl();
ArkUI_Float32 constraintSize[ALLOW_SIZE_4] = { 0.0f, FLT_MAX, 0.0f, FLT_MAX };
ArkUI_Int32 units[ALLOW_SIZE_4] = { UNIT_VP, UNIT_VP, UNIT_VP, UNIT_VP };
int32_t unit = GetDefaultUnit(node, UNIT_VP);
ArkUI_Int32 units[ALLOW_SIZE_4] = { unit, unit, unit, unit };
if (item->size == 1) {
if (LessNotEqual(item->value[0].f32, 0.0f)) {
@ -2492,7 +2519,8 @@ void ResetConstraintSize(ArkUI_NodeHandle node)
const ArkUI_AttributeItem* GetConstraintSize(ArkUI_NodeHandle node)
{
ArkUIConstraintSizeOptions options;
GetFullImpl()->getNodeModifiers()->getCommonModifier()->getConstraintSize(node->uiNodeHandle, &options);
ArkUI_Int32 unit = GetDefaultUnit(node, UNIT_VP);
GetFullImpl()->getNodeModifiers()->getCommonModifier()->getConstraintSize(node->uiNodeHandle, &options, unit);
g_numberValues[NUM_0].f32 = options.minWidth;
g_numberValues[NUM_1].f32 = options.maxWidth;
g_numberValues[NUM_2].f32 = options.minHeight;
@ -2680,6 +2708,30 @@ const ArkUI_AttributeItem* GetAspectRatio(ArkUI_NodeHandle node)
return &g_attributeItem;
}
int32_t SetLayoutWeight(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
{
auto actualSize = CheckAttributeItemArray(item, REQUIRED_ONE_PARAM);
if (actualSize < 0 || LessNotEqual(item->value[NUM_0].f32, 0.0f)) {
return ERROR_CODE_PARAM_INVALID;
}
auto* fullImpl = GetFullImpl();
fullImpl->getNodeModifiers()->getCommonModifier()->setLayoutWeight(node->uiNodeHandle, item->value[NUM_0].f32);
return ERROR_CODE_NO_ERROR;
}
void ResetLayoutWeight(ArkUI_NodeHandle node)
{
auto* fullImpl = GetFullImpl();
fullImpl->getNodeModifiers()->getCommonModifier()->resetLayoutWeight(node->uiNodeHandle);
}
const ArkUI_AttributeItem* GetLayoutWeight(ArkUI_NodeHandle node)
{
auto modifier = GetFullImpl()->getNodeModifiers()->getCommonModifier();
g_numberValues[0].f32 = modifier->getLayoutWeight(node->uiNodeHandle);
return &g_attributeItem;
}
// Text
int32_t SetFontColor(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
{
@ -2786,19 +2838,20 @@ int32_t SetFontSize(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
return ERROR_CODE_PARAM_INVALID;
}
auto* fullImpl = GetFullImpl();
int32_t unit = GetDefaultUnit(node, UNIT_FP);
if (node->type == ARKUI_NODE_TEXT_INPUT) {
struct ArkUILengthType fontSize = { nullptr, item->value[0].f32, UNIT_FP };
struct ArkUILengthType fontSize = { nullptr, item->value[0].f32, unit };
fullImpl->getNodeModifiers()->getTextInputModifier()->setTextInputFontSize(node->uiNodeHandle, &fontSize);
} else if (node->type == ARKUI_NODE_TEXT) {
fullImpl->getNodeModifiers()->getTextModifier()->setFontSize(node->uiNodeHandle, item->value[0].f32, UNIT_FP);
fullImpl->getNodeModifiers()->getTextModifier()->setFontSize(node->uiNodeHandle, item->value[0].f32, unit);
} else if (node->type == ARKUI_NODE_SPAN) {
fullImpl->getNodeModifiers()->getSpanModifier()->setSpanFontSize(
node->uiNodeHandle, item->value[0].f32, UNIT_FP);
node->uiNodeHandle, item->value[0].f32, unit);
} else if (node->type == ARKUI_NODE_BUTTON) {
fullImpl->getNodeModifiers()->getButtonModifier()->setButtonFontSize(node->uiNodeHandle,
item->value[0].f32, UNIT_FP);
item->value[0].f32, unit);
} else if (node->type == ARKUI_NODE_TEXT_AREA) {
struct ArkUIResourceLength fontSize = { item->value[0].f32, UNIT_FP, nullptr };
struct ArkUIResourceLength fontSize = { item->value[0].f32, unit, nullptr };
fullImpl->getNodeModifiers()->getTextAreaModifier()->setTextAreaFontSize(node->uiNodeHandle, &fontSize);
} else {
return ERROR_CODE_PARAM_INVALID;
@ -2968,15 +3021,17 @@ int32_t SetCaretStyle(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
}
// already check in entry point.
auto* fullImpl = GetFullImpl();
struct ArkUILengthType width = { nullptr, item->value[NUM_0].f32, DEFAULT_UNIT };
int32_t unit = GetDefaultUnit(node, UNIT_VP);
struct ArkUILengthType width = { nullptr, item->value[NUM_0].f32, unit };
fullImpl->getNodeModifiers()->getTextInputModifier()->setTextInputCaretStyle(node->uiNodeHandle, &width);
return ERROR_CODE_NO_ERROR;
}
const ArkUI_AttributeItem* GetCaretStyle(ArkUI_NodeHandle node)
{
ArkUI_Int32 unit = GetDefaultUnit(node, UNIT_VP);
auto resultValue = GetFullImpl()->getNodeModifiers()->getTextInputModifier()->getTextInputCaretStyle(
node->uiNodeHandle);
node->uiNodeHandle, unit);
g_numberValues[0].f32 = resultValue;
return &g_attributeItem;
}
@ -3143,7 +3198,7 @@ int32_t SetTextInputPlaceholderFont(ArkUI_NodeHandle node, const ArkUI_Attribute
{
// already check in entry point.
auto* fullImpl = GetFullImpl();
struct ArkUILengthType size = { nullptr, 16.0, UNIT_FP };
struct ArkUILengthType size = { nullptr, 16.0, GetDefaultUnit(node, UNIT_FP) };
if (item->size > NUM_0) {
if (LessNotEqual(item->value[NUM_0].f32, 0.0f)) {
return ERROR_CODE_PARAM_INVALID;
@ -3181,6 +3236,7 @@ int32_t SetTextInputPlaceholderFont(ArkUI_NodeHandle node, const ArkUI_Attribute
const ArkUI_AttributeItem* GetTextInputPlaceholderFont(ArkUI_NodeHandle node)
{
ArkUITextFont font;
font.fontSizeUnit = GetDefaultUnit(node, UNIT_FP);
GetFullImpl()->getNodeModifiers()->getTextInputModifier()->getTextInputPlaceholderFont(
node->uiNodeHandle, &font);
int index = 0;
@ -3336,7 +3392,7 @@ int32_t SetTextInputCancelButton(ArkUI_NodeHandle node, const ArkUI_AttributeIte
static_cast<int32_t>(ARKUI_CANCELBUTTON_STYLE_INPUT), item->value[NUM_0].i32)) {
return ERROR_CODE_PARAM_INVALID;
}
struct ArkUISizeType size = { -1.0f, UNIT_VP };
struct ArkUISizeType size = { -1.0f, GetDefaultUnit(node, UNIT_VP) };
if (item->size > NUM_1) {
size.value = item->value[NUM_1].f32;
}
@ -3360,7 +3416,8 @@ const ArkUI_AttributeItem* GetTextInputCancelButton(ArkUI_NodeHandle node)
g_numberValues[index++].i32 =
GetFullImpl()->getNodeModifiers()->getTextInputModifier()->getTextInputCancelButtonStyle(node->uiNodeHandle);
g_numberValues[index++].f32 =
GetFullImpl()->getNodeModifiers()->getTextInputModifier()->getTextInputCancelIconSize(node->uiNodeHandle);
GetFullImpl()->getNodeModifiers()->getTextInputModifier()->getTextInputCancelIconSize(
node->uiNodeHandle, GetDefaultUnit(node, UNIT_VP));
g_numberValues[index++].u32 =
GetFullImpl()->getNodeModifiers()->getTextInputModifier()->getTextInputTextCancelIconColor(node->uiNodeHandle);
g_attributeItem.size = index;
@ -3506,9 +3563,10 @@ int32_t SetScrollScrollSnap(ArkUI_NodeHandle node, const ArkUI_AttributeItem* it
ArkUI_Float32 paginations[item->size - NUM_3];
ArkUI_Int32 paginationParams[item->size + NUM_1];
int32_t unit = GetDefaultUnit(node, UNIT_VP);
for (int i = 0; i < item->size - NUM_3; ++i) {
paginations[i] = item->value[i + NUM_3].f32;
paginationParams[i] = UNIT_VP;
paginationParams[i] = unit;
if (LessNotEqual(item->value[NUM_0].f32, 0.0f)) {
return ERROR_CODE_PARAM_INVALID;
}
@ -3592,12 +3650,13 @@ int32_t SetScrollScrollBarWidth(ArkUI_NodeHandle node, const ArkUI_AttributeItem
}
auto fullImpl = GetFullImpl();
auto attrVal = item->value[NUM_0].f32;
int32_t unit = GetDefaultUnit(node, UNIT_VP);
if (node->type == ARKUI_NODE_LIST) {
auto width = std::to_string(attrVal) + "vp";
auto width = std::to_string(attrVal) + LENGTH_METRIC_UNIT[unit];
fullImpl->getNodeModifiers()->getListModifier()->setListScrollBarWidth(node->uiNodeHandle, width.c_str());
} else if (node->type == ARKUI_NODE_SCROLL) {
fullImpl->getNodeModifiers()->getScrollModifier()->setScrollScrollBarWidth(
node->uiNodeHandle, attrVal, UNIT_VP);
node->uiNodeHandle, attrVal, unit);
}
return ERROR_CODE_NO_ERROR;
}
@ -3823,11 +3882,12 @@ int32_t SetScrollTo(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
return ERROR_CODE_PARAM_INVALID;
}
auto* fullImpl = GetFullImpl();
ArkUI_Float32 values[ALLOW_SIZE_7] = { 0.0, UNIT_VP, 0.0, UNIT_VP, DEFAULT_DURATION, 1, 0.0 };
int32_t defaultUnit = GetDefaultUnit(node, UNIT_VP);
ArkUI_Float32 values[ALLOW_SIZE_7] = { 0.0, defaultUnit, 0.0, defaultUnit, DEFAULT_DURATION, 1, 0.0 };
values[0] = item->value[0].f32;
values[1] = UNIT_VP;
values[1] = defaultUnit;
values[2] = item->value[1].f32;
values[3] = UNIT_VP;
values[NUM_3] = defaultUnit;
if (item->size > 2) {
values[NUM_4] = static_cast<ArkUI_Float32>(item->value[NUM_2].i32);
}
@ -4044,7 +4104,7 @@ const ArkUI_AttributeItem* GetListCachedCount(ArkUI_NodeHandle node)
int32_t SetTextAreaPlaceholderFont(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
{
auto* fullImpl = GetFullImpl();
struct ArkUIResourceLength size = { 16.0, UNIT_FP };
struct ArkUIResourceLength size = { 16.0, GetDefaultUnit(node, UNIT_FP) };
int weight = ARKUI_FONT_WEIGHT_NORMAL;
int style = ARKUI_FONT_STYLE_NORMAL;
if (item->size > NUM_0) {
@ -4073,6 +4133,7 @@ int32_t SetTextAreaPlaceholderFont(ArkUI_NodeHandle node, const ArkUI_AttributeI
const ArkUI_AttributeItem* GetTextAreaPlaceholderFont(ArkUI_NodeHandle node)
{
ArkUITextFont font;
font.fontSizeUnit = GetDefaultUnit(node, UNIT_FP);
GetFullImpl()->getNodeModifiers()->getTextAreaModifier()->getTextAreaPlaceholderFont(
node->uiNodeHandle, &font);
int index = 0;
@ -4451,7 +4512,7 @@ int32_t SetTextBaseLineOffset(ArkUI_NodeHandle node, const ArkUI_AttributeItem*
// already check in entry point.
auto* fullImpl = GetFullImpl();
fullImpl->getNodeModifiers()->getTextModifier()->setTextBaselineOffset(node->uiNodeHandle,
item->value[0].f32, static_cast<int32_t>(DimensionUnit::FP));
item->value[0].f32, GetDefaultUnit(node, UNIT_FP));
return ERROR_CODE_NO_ERROR;
}
@ -4498,7 +4559,7 @@ int32_t SetTextMinFontSize(ArkUI_NodeHandle node, const ArkUI_AttributeItem* ite
}
auto fullImpl = GetFullImpl();
fullImpl->getNodeModifiers()->getTextModifier()->setTextMinFontSize(
node->uiNodeHandle, item->value[0].f32, UNIT_FP);
node->uiNodeHandle, item->value[0].f32, GetDefaultUnit(node, UNIT_FP));
return ERROR_CODE_NO_ERROR;
}
@ -4522,7 +4583,7 @@ int32_t SetTextMaxFontSize(ArkUI_NodeHandle node, const ArkUI_AttributeItem* ite
}
auto fullImpl = GetFullImpl();
fullImpl->getNodeModifiers()->getTextModifier()->setTextMaxFontSize(
node->uiNodeHandle, item->value[0].f32, UNIT_FP);
node->uiNodeHandle, item->value[0].f32, GetDefaultUnit(node, UNIT_FP));
return ERROR_CODE_NO_ERROR;
}
@ -4573,7 +4634,7 @@ int32_t SetTextFont(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
ArkUIFontStruct fontStruct;
fontStruct.fontSizeNumber = size;
fontStruct.fontSizeUnit = UNIT_FP;
fontStruct.fontSizeUnit = GetDefaultUnit(node, UNIT_FP);
fontStruct.fontWeight = weight;
if (familyArray.size() > 0) {
std::vector<const char*> fontFamilies;
@ -4591,6 +4652,7 @@ int32_t SetTextFont(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
const ArkUI_AttributeItem* GetTextFont(ArkUI_NodeHandle node)
{
ArkUITextFont font;
font.fontSizeUnit = GetDefaultUnit(node, UNIT_FP);
GetFullImpl()->getNodeModifiers()->getTextModifier()->getFont(node->uiNodeHandle, &font);
int index = 0;
g_numberValues[index++].f32 = font.fontSize;
@ -4711,6 +4773,31 @@ void ResetToggleValue(ArkUI_NodeHandle node)
fullImpl->getNodeModifiers()->getToggleModifier()->resetToggleIsOn(node->uiNodeHandle);
}
int32_t SetToggleUnSelectedColor(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
{
if (item->size == 0) {
return ERROR_CODE_PARAM_INVALID;
}
auto* fullImpl = GetFullImpl();
fullImpl->getNodeModifiers()->getToggleModifier()->setToggleUnselectedColor(node->uiNodeHandle, item->value[0].u32);
return ERROR_CODE_NO_ERROR;
}
const ArkUI_AttributeItem* GetToggleUnSelectedColor(ArkUI_NodeHandle node)
{
auto resultValue =
GetFullImpl()->getNodeModifiers()->getToggleModifier()->getToggleUnselectedColor(node->uiNodeHandle);
g_numberValues[0].u32 = resultValue;
return &g_attributeItem;
}
void ResetToggleUnSelectedColor(ArkUI_NodeHandle node)
{
auto* fullImpl = GetFullImpl();
fullImpl->getNodeModifiers()->getToggleModifier()->resetToggleUnselectedColor(node->uiNodeHandle);
}
// LoadingProgress Attributes functions
const ArkUI_AttributeItem* GetLoadingProgressColor(ArkUI_NodeHandle node)
{
@ -5338,8 +5425,9 @@ int32_t SetListItemGroupDivider(ArkUI_NodeHandle node, const ArkUI_AttributeItem
}
auto fullImpl = GetFullImpl();
auto color = item->value[NUM_0].u32;
int32_t unit = GetDefaultUnit(node, UNIT_VP);
ArkUI_Float32 values[NUM_3] = { item->value[NUM_1].f32, item->value[NUM_2].f32, item->value[NUM_3].f32 };
ArkUI_Int32 units[NUM_3] = { UNIT_VP, UNIT_VP, UNIT_VP };
ArkUI_Int32 units[NUM_3] = { unit, unit, unit };
fullImpl->getNodeModifiers()->getListItemGroupModifier()->listItemGroupSetDivider(
node->uiNodeHandle, color, values, units, NUM_3);
@ -6201,9 +6289,9 @@ int32_t SetBackgroundImageSize(ArkUI_NodeHandle node, const ArkUI_AttributeItem*
LessNotEqual(item->value[BACKGROUND_IMAGE_HEIGHT_INDEX].f32, 0.0f)) {
return ERROR_CODE_PARAM_INVALID;
}
fullImpl->getNodeModifiers()->getCommonModifier()->setBackgroundImageSize(node->uiNodeHandle,
fullImpl->getNodeModifiers()->getCommonModifier()->setBackgroundImageSizeWidthUnit(node->uiNodeHandle,
item->value[BACKGROUND_IMAGE_WIDTH_INDEX].f32, item->value[BACKGROUND_IMAGE_HEIGHT_INDEX].f32,
IMAGE_SIZE_TYPE_LENGTH_INDEX, IMAGE_SIZE_TYPE_LENGTH_INDEX);
IMAGE_SIZE_TYPE_LENGTH_INDEX, IMAGE_SIZE_TYPE_LENGTH_INDEX, GetDefaultUnit(node, UNIT_VP));
return ERROR_CODE_NO_ERROR;
}
@ -6327,17 +6415,18 @@ int32_t SetTransformCenter(ArkUI_NodeHandle node, const ArkUI_AttributeItem* ite
if (!isTransformCenterValid) {
return ERROR_CODE_PARAM_INVALID;
}
int32_t unit = GetDefaultUnit(node, UNIT_VP);
CalcDimension centerX(HALF, DimensionUnit::PERCENT);
if (CENTER_X_INDEX < actualSize) {
centerX.SetValue(item->value[CENTER_X_INDEX].f32);
centerX.SetUnit(DimensionUnit::VP);
centerX.SetUnit(static_cast<DimensionUnit>(unit));
}
CalcDimension centerY(HALF, DimensionUnit::PERCENT);
if (CENTER_Y_INDEX < actualSize) {
centerY.SetValue(item->value[CENTER_Y_INDEX].f32);
centerY.SetUnit(DimensionUnit::VP);
centerY.SetUnit(static_cast<DimensionUnit>(unit));
}
CalcDimension centerZ(0, DimensionUnit::VP);
CalcDimension centerZ(0, static_cast<DimensionUnit>(unit));
if (CENTER_Z_INDEX < actualSize) {
centerZ.SetValue(item->value[CENTER_Z_INDEX].f32);
}
@ -6440,15 +6529,16 @@ int32_t SetTranslateTransition(ArkUI_NodeHandle node, const ArkUI_AttributeItem*
if (!CheckAnimation(item, actualSize, TRANSLATE_ANIMATION_BASE)) {
return ERROR_CODE_PARAM_INVALID;
}
CalcDimension xDimension(0, DimensionUnit::VP);
int32_t unit = GetDefaultUnit(node, UNIT_VP);
CalcDimension xDimension(0, static_cast<DimensionUnit>(unit));
if (X_INDEX < actualSize) {
xDimension.SetValue(item->value[X_INDEX].f32);
}
CalcDimension yDimension(0, DimensionUnit::VP);
CalcDimension yDimension(0, static_cast<DimensionUnit>(unit));
if (Y_INDEX < actualSize) {
yDimension.SetValue(item->value[Y_INDEX].f32);
}
CalcDimension zDimension(0, DimensionUnit::VP);
CalcDimension zDimension(0, static_cast<DimensionUnit>(unit));
if (Z_INDEX < actualSize) {
zDimension.SetValue(item->value[Z_INDEX].f32);
}
@ -6489,11 +6579,12 @@ int32_t SetOffset(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
if (actualSize < 0) {
return ERROR_CODE_PARAM_INVALID;
}
CalcDimension xDimension(0, DimensionUnit::VP);
int32_t unit = GetDefaultUnit(node, UNIT_VP);
CalcDimension xDimension(0, static_cast<DimensionUnit>(unit));
if (NUM_0 < actualSize) {
xDimension.SetValue(item->value[NUM_0].f32);
}
CalcDimension yDimension(0, DimensionUnit::VP);
CalcDimension yDimension(0, static_cast<DimensionUnit>(unit));
if (NUM_1 < actualSize) {
yDimension.SetValue(item->value[NUM_1].f32);
}
@ -6511,16 +6602,17 @@ int32_t SetMarkAnchor(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
if (actualSize < 0) {
return ERROR_CODE_PARAM_INVALID;
}
CalcDimension xDimension(0, DimensionUnit::VP);
int32_t unit = GetDefaultUnit(node, UNIT_VP);
CalcDimension xDimension(0, static_cast<DimensionUnit>(unit));
if (NUM_0 < actualSize) {
xDimension.SetValue(item->value[NUM_0].f32);
}
CalcDimension yDimension(0, DimensionUnit::VP);
CalcDimension yDimension(0, static_cast<DimensionUnit>(unit));
if (NUM_1 < actualSize) {
yDimension.SetValue(item->value[NUM_1].f32);
}
fullImpl->getNodeModifiers()->getCommonModifier()->setMarkAnchor(node->uiNodeHandle, xDimension.Value(),
static_cast<int32_t>(xDimension.Unit()), yDimension.Value(), static_cast<int32_t>(yDimension.Unit()));
unit, yDimension.Value(), unit);
return ERROR_CODE_NO_ERROR;
}
@ -6585,15 +6677,15 @@ int32_t SetLineHeight(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
if (actualSize < 0) {
return ERROR_CODE_PARAM_INVALID;
}
CalcDimension lineHeight(item->value[0].f32, DimensionUnit::FP);
int32_t unit = GetDefaultUnit(node, UNIT_FP);
switch (node->type) {
case ARKUI_NODE_TEXT:
fullImpl->getNodeModifiers()->getTextModifier()->setTextLineHeight(
node->uiNodeHandle, lineHeight.Value(), static_cast<int32_t>(DimensionUnit::FP));
node->uiNodeHandle, item->value[0].f32, unit);
break;
case ARKUI_NODE_SPAN:
fullImpl->getNodeModifiers()->getSpanModifier()->setSpanLineHeight(
node->uiNodeHandle, lineHeight.Value(), static_cast<int32_t>(DimensionUnit::FP));
node->uiNodeHandle, item->value[0].f32, unit);
break;
default:
break;
@ -6667,7 +6759,7 @@ int32_t SetLetterSpacing(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
break;
case ARKUI_NODE_TEXT:
fullImpl->getNodeModifiers()->getTextModifier()->setTextLetterSpacing(
node->uiNodeHandle, item->value[0].f32, static_cast<int32_t>(DimensionUnit::FP));
node->uiNodeHandle, item->value[0].f32, GetDefaultUnit(node, UNIT_FP));
default:
break;
}
@ -6741,7 +6833,7 @@ int32_t SetTextIndent(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
return ERROR_CODE_PARAM_INVALID;
}
fullImpl->getNodeModifiers()->getTextModifier()->setTextIndent(node->uiNodeHandle,
item->value[0].f32, static_cast<int32_t>(DimensionUnit::FP));
item->value[0].f32, GetDefaultUnit(node, UNIT_FP));
return ERROR_CODE_NO_ERROR;
}
@ -6749,7 +6841,7 @@ void ResetTextIndent(ArkUI_NodeHandle node)
{
auto* fullImpl = GetFullImpl();
fullImpl->getNodeModifiers()->getTextModifier()->setTextIndent(node->uiNodeHandle,
0.0f, static_cast<int32_t>(DimensionUnit::FP));
0.0f, UNIT_FP);
}
int32_t SetTextWordBreak(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
@ -6822,7 +6914,8 @@ int32_t SetSpanTextBackgroundStyle(ArkUI_NodeHandle node, const ArkUI_AttributeI
return ERROR_CODE_PARAM_INVALID;
}
float radiusVals[ALLOW_SIZE_4] = { 0, 0, 0, 0 };
int radiusUnits[ALLOW_SIZE_4] = { DEFAULT_UNIT, DEFAULT_UNIT, DEFAULT_UNIT, DEFAULT_UNIT };
int32_t unit = GetDefaultUnit(node, UNIT_VP);
int radiusUnits[ALLOW_SIZE_4] = { unit, unit, unit, unit };
if (item->size == ALLOW_SIZE_2) {
if (LessNotEqual(item->value[0].f32, 0.0f)) {
@ -7015,7 +7108,7 @@ int32_t SetHintRadius(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
return ERROR_CODE_PARAM_INVALID;
}
fullImpl->getNodeModifiers()->getCalendarPickerModifier()->setHintRadius(
node->uiNodeHandle, item->value[0].f32, static_cast<int32_t>(DimensionUnit::VP));
node->uiNodeHandle, item->value[0].f32, GetDefaultUnit(node, UNIT_VP));
return ERROR_CODE_NO_ERROR;
}
@ -7085,7 +7178,8 @@ int32_t SetEdgeAlignment(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
yOffset = item->value[EDGE_OFFSET_Y_INDEX].f32;
}
sizeArray.emplace_back(yOffset);
std::vector<int32_t> unitArray = { UNIT_VP, UNIT_VP };
int32_t unit = GetDefaultUnit(node, UNIT_VP);
std::vector<int32_t> unitArray = { unit, unit };
fullImpl->getNodeModifiers()->getCalendarPickerModifier()->setEdgeAlign(
node->uiNodeHandle, &sizeArray[0], &unitArray[0], static_cast<int32_t>(sizeArray.size()), defaultAlignment);
return ERROR_CODE_NO_ERROR;
@ -7127,14 +7221,15 @@ int32_t SetCalendarPickerTextStyle(ArkUI_NodeHandle node, const ArkUI_AttributeI
if (CALENDAR_PICKER_FONT_SIZE_INDEX < actualSize) {
fontSize = item->value[CALENDAR_PICKER_FONT_SIZE_INDEX].f32;
}
int32_t unit = GetDefaultUnit(node, UNIT_VP);
fontSizeArray.emplace_back(fontSize);
fontSizeArray.emplace_back(static_cast<float>(DimensionUnit::VP));
fontSizeArray.emplace_back(static_cast<float>(unit));
int32_t fontWeight = 0;
if (CALENDAR_PICKER_FONT_WEIGHT_INDEX < actualSize) {
fontWeight = item->value[CALENDAR_PICKER_FONT_WEIGHT_INDEX].i32;
}
fullImpl->getNodeModifiers()->getCalendarPickerModifier()->setTextStyleWithWeightEnum(
node->uiNodeHandle, fontColor, fontSize, static_cast<int32_t>(DimensionUnit::VP), fontWeight);
node->uiNodeHandle, fontColor, fontSize, unit, fontWeight);
return ERROR_CODE_NO_ERROR;
}
@ -7154,7 +7249,7 @@ void ResetHintRadius(ArkUI_NodeHandle node)
{
auto* fullImpl = GetFullImpl();
fullImpl->getNodeModifiers()->getCalendarPickerModifier()->setHintRadius(
node->uiNodeHandle, DEFAULT_HINT_RADIUS, static_cast<int32_t>(DimensionUnit::VP));
node->uiNodeHandle, DEFAULT_HINT_RADIUS, UNIT_VP);
}
void ResetSelectedDate(ArkUI_NodeHandle node)
@ -7241,8 +7336,8 @@ void ResetTranslateTransition(ArkUI_NodeHandle node)
fullImpl->getNodeModifiers()->getCommonModifier()->setScaleTransition(
node->uiNodeHandle, &scaleFloatArray[0], scaleFloatArray.size(), &animationOption);
fullImpl->getNodeModifiers()->getCommonModifier()->setTranslateTransition(node->uiNodeHandle, 0.0f,
static_cast<int32_t>(DimensionUnit::VP), 0.0f, static_cast<int32_t>(DimensionUnit::VP), 0.0f,
static_cast<int32_t>(DimensionUnit::VP), &animationOption);
UNIT_VP, 0.0f, UNIT_VP, 0.0f,
UNIT_VP, &animationOption);
}
void ResetMoveTransition(ArkUI_NodeHandle node)
@ -7686,25 +7781,26 @@ const ArkUI_AttributeItem* GetFontColor(ArkUI_NodeHandle node)
const ArkUI_AttributeItem* GetFontSize(ArkUI_NodeHandle node)
{
auto fullImpl = GetFullImpl();
auto unit = GetDefaultUnit(node, UNIT_FP);
switch (node->type) {
case ARKUI_NODE_TEXT:
g_numberValues[0].f32 = fullImpl->getNodeModifiers()->getTextModifier()->
getFontSize(node->uiNodeHandle);
getFontSize(node->uiNodeHandle, unit);
g_attributeItem.size = REQUIRED_ONE_PARAM;
break;
case ARKUI_NODE_SPAN:
g_numberValues[0].f32 = fullImpl->getNodeModifiers()->getSpanModifier()->
getSpanFontSize(node->uiNodeHandle);
getSpanFontSize(node->uiNodeHandle, unit);
g_attributeItem.size = REQUIRED_ONE_PARAM;
break;
case ARKUI_NODE_TEXT_INPUT:
g_numberValues[0].f32 = fullImpl->getNodeModifiers()->getTextInputModifier()->
getTextInputFontSize(node->uiNodeHandle);
getTextInputFontSize(node->uiNodeHandle, unit);
g_attributeItem.size = REQUIRED_ONE_PARAM;
break;
case ARKUI_NODE_BUTTON:
g_numberValues[0].f32 = fullImpl->getNodeModifiers()->getButtonModifier()->
getButtonFontSize(node->uiNodeHandle);
getButtonFontSize(node->uiNodeHandle, unit);
g_attributeItem.size = REQUIRED_ONE_PARAM;
break;
default:
@ -8102,9 +8198,9 @@ int32_t SetCheckboxMark(ArkUI_NodeHandle node, const ArkUI_AttributeItem* item)
//set 2 for strokeWidth
strokeWidth = item->value[2].f32;
}
int32_t unit = GetDefaultUnit(node, UNIT_VP);
GetFullImpl()->getNodeModifiers()->getCheckboxModifier()->setMark(
node->uiNodeHandle, strokeColor, size, DEFAULT_UNIT, strokeWidth, DEFAULT_UNIT);
node->uiNodeHandle, strokeColor, size, unit, strokeWidth, unit);
return ERROR_CODE_NO_ERROR;
}
@ -8595,9 +8691,9 @@ int32_t SetWaterFlowColumnsGap(ArkUI_NodeHandle node, const ArkUI_AttributeItem*
return ERROR_CODE_PARAM_INVALID;
}
auto* fullImpl = GetFullImpl();
fullImpl->getNodeModifiers()->getWaterFlowModifier()->setColumnsGap(
node->uiNodeHandle, item->value[NUM_0].f32, UNIT_VP, nullptr);
node->uiNodeHandle, item->value[NUM_0].f32, GetDefaultUnit(node, UNIT_VP), nullptr);
return ERROR_CODE_NO_ERROR;
}
@ -8622,7 +8718,7 @@ int32_t SetWaterFlowRowsGap(ArkUI_NodeHandle node, const ArkUI_AttributeItem* it
}
auto* fullImpl = GetFullImpl();
fullImpl->getNodeModifiers()->getWaterFlowModifier()->setRowsGap(
node->uiNodeHandle, item->value[NUM_0].f32, UNIT_VP, nullptr);
node->uiNodeHandle, item->value[NUM_0].f32, GetDefaultUnit(node, UNIT_VP), nullptr);
return ERROR_CODE_NO_ERROR;
}
@ -8771,7 +8867,8 @@ int32_t SetCommonAttribute(ArkUI_NodeHandle node, int32_t subTypeId, const ArkUI
SetAccessibilityLevel,
SetAccessibilityDescription,
SetNeedFocus,
SetAspectRatio
SetAspectRatio,
SetLayoutWeight
};
if (subTypeId >= sizeof(setters) / sizeof(Setter*)) {
TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "common node attribute: %{public}d NOT IMPLEMENT", subTypeId);
@ -8850,7 +8947,8 @@ const ArkUI_AttributeItem* GetCommonAttribute(ArkUI_NodeHandle node, int32_t sub
GetAccessibilityLevel,
GetAccessibilityDescription,
GetNeedFocus,
GetAspectRatio
GetAspectRatio,
GetLayoutWeight
};
if (subTypeId >= sizeof(getters) / sizeof(Getter*)) {
TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "common node attribute: %{public}d NOT IMPLEMENT", subTypeId);
@ -8933,7 +9031,8 @@ void ResetCommonAttribute(ArkUI_NodeHandle node, int32_t subTypeId)
ResetAccessibilityLevel,
ResetAccessibilityDescription,
nullptr,
ResetAspectRatio
ResetAspectRatio,
ResetLayoutWeight
};
if (subTypeId >= sizeof(resetters) / sizeof(Setter*)) {
TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "common node attribute: %{public}d NOT IMPLEMENT", subTypeId);
@ -9080,7 +9179,8 @@ void ResetImageAttribute(ArkUI_NodeHandle node, int32_t subTypeId)
int32_t SetToggleAttribute(ArkUI_NodeHandle node, int32_t subTypeId, const ArkUI_AttributeItem* value)
{
static Setter* setters[] = { SetToggleSelectedColor, SetToggleSwitchPointColor, SetToggleValue };
static Setter* setters[] = { SetToggleSelectedColor, SetToggleSwitchPointColor, SetToggleValue,
SetToggleUnSelectedColor };
if (subTypeId >= sizeof(setters) / sizeof(Setter*)) {
TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "toggle node attribute: %{public}d NOT IMPLEMENT", subTypeId);
return ERROR_CODE_NATIVE_IMPL_TYPE_NOT_SUPPORTED;
@ -9090,7 +9190,8 @@ int32_t SetToggleAttribute(ArkUI_NodeHandle node, int32_t subTypeId, const ArkUI
const ArkUI_AttributeItem* GetToggleAttribute(ArkUI_NodeHandle node, int32_t subTypeId)
{
static Getter* getters[] = { GetToggleSelectedColor, GetToggleSwitchPointColor, GetToggleValue };
static Getter* getters[] = { GetToggleSelectedColor, GetToggleSwitchPointColor, GetToggleValue,
GetToggleUnSelectedColor };
if (subTypeId >= sizeof(getters) / sizeof(Getter*)) {
TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "slider node attribute: %{public}d NOT IMPLEMENT", subTypeId);
return nullptr;
@ -9101,7 +9202,8 @@ const ArkUI_AttributeItem* GetToggleAttribute(ArkUI_NodeHandle node, int32_t sub
void ResetToggleAttribute(ArkUI_NodeHandle node, int32_t subTypeId)
{
static Resetter* resetters[] = { ResetToggleSelectedColor, ResetToggleSwitchPointColor, ResetToggleValue };
static Resetter* resetters[] = { ResetToggleSelectedColor, ResetToggleSwitchPointColor, ResetToggleValue,
ResetToggleUnSelectedColor };
if (subTypeId >= sizeof(resetters) / sizeof(Resetter*)) {
TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "toggle node attribute: %{public}d NOT IMPLEMENT", subTypeId);
return;

View File

@ -114,6 +114,33 @@ enum {
UI_INPUT_EVENTT_SOURCE_TYPE_TOUCH_SCREEN = 2,
};
/**
* @brief Enumerates the hit test modes.
*
* @since 12
*/
typedef enum {
/** Both the node and its child node respond to the hit test of a touch event, but its sibling node is blocked from
* the hit test.
*/
HTM_DEFAULT = 0,
/** The node responds to the hit test of a touch event, but its child node and sibling node are blocked from the hit
* test.
*/
HTM_BLOCK,
/** Both the node and its child node respond to the hit test of a touch event, and its sibling node is also
* considered during the hit test.
*/
HTM_TRANSPARENT,
/** The node does not respond to the hit test of a touch event, but its child node and sibling node are considered
* during the hit test.
*/
HTM_NONE,
} HitTestMode;
/**
* @brief Obtains the type of this UI input event.
*
@ -592,6 +619,16 @@ double OH_ArkUI_AxisEvent_GetHorizontalAxisValue(const ArkUI_UIInputEvent* event
*/
double OH_ArkUI_AxisEvent_GetPinchAxisScaleValue(const ArkUI_UIInputEvent* event);
/**
* @brief Sets how the component behaves during hit testing.
*
* @param event Indicates the pointer to the current UI input event.
* @param mode Indicates how the component behaves during hit testing. The parameter type is {@link HitTestMode}.
* @return Returns the status code of the execution.
* @since 12
*/
int32_t OH_ArkUI_PointerEvent_SetInterceptHitTestMode(const ArkUI_UIInputEvent* event, HitTestMode mode);
#ifdef __cplusplus
};
#endif