mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2024-11-23 07:01:24 +00:00
【CAPI】新增CustomSpan接口
Signed-off-by: wanjining <wanjining@huawei.com> Change-Id: I16a837e5d6af65f4825841b059b1fea6d8595a1a
This commit is contained in:
parent
50c680d391
commit
693ebbba64
@ -599,6 +599,57 @@ public:
|
||||
std::optional<std::function<void(NG::DrawingContext&, CustomSpanOptions)>> onDraw;
|
||||
};
|
||||
|
||||
class ACE_EXPORT CustomSpanNode : public FrameNode {
|
||||
DECLARE_ACE_TYPE(CustomSpanNode, FrameNode);
|
||||
|
||||
public:
|
||||
static RefPtr<CustomSpanNode> CreateFrameNode(int32_t nodeId)
|
||||
{
|
||||
auto customSpanNode = AceType::MakeRefPtr<CustomSpanNode>(
|
||||
V2::CUSTOM_SPAN_NODE_ETS_TAG, nodeId);
|
||||
customSpanNode->InitializePatternAndContext();
|
||||
ElementRegister::GetInstance()->AddUINode(customSpanNode);
|
||||
return customSpanNode;
|
||||
}
|
||||
|
||||
static RefPtr<CustomSpanNode> GetOrCreateSpanNode(
|
||||
const std::string& tag, int32_t nodeId)
|
||||
{
|
||||
auto frameNode = GetFrameNode(tag, nodeId);
|
||||
CHECK_NULL_RETURN(!frameNode, AceType::DynamicCast<CustomSpanNode>(frameNode));
|
||||
auto customSpanNode = AceType::MakeRefPtr<CustomSpanNode>(tag, nodeId);
|
||||
customSpanNode->InitializePatternAndContext();
|
||||
ElementRegister::GetInstance()->AddUINode(customSpanNode);
|
||||
return customSpanNode;
|
||||
}
|
||||
|
||||
CustomSpanNode(const std::string& tag, int32_t nodeId) :
|
||||
FrameNode(tag, nodeId, AceType::MakeRefPtr<Pattern>()) {}
|
||||
~CustomSpanNode() override = default;
|
||||
|
||||
const RefPtr<CustomSpanItem>& GetSpanItem() const
|
||||
{
|
||||
return customSpanItem_;
|
||||
}
|
||||
|
||||
bool IsAtomicNode() const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void DumpInfo() override
|
||||
{
|
||||
FrameNode::DumpInfo();
|
||||
CHECK_NULL_VOID(customSpanItem_);
|
||||
customSpanItem_->DumpInfo();
|
||||
}
|
||||
|
||||
private:
|
||||
RefPtr<CustomSpanItem> customSpanItem_ = MakeRefPtr<CustomSpanItem>();
|
||||
|
||||
ACE_DISALLOW_COPY_AND_MOVE(CustomSpanNode);
|
||||
};
|
||||
|
||||
struct ImageSpanItem : public PlaceholderSpanItem {
|
||||
DECLARE_ACE_TYPE(ImageSpanItem, PlaceholderSpanItem);
|
||||
|
||||
|
@ -2552,6 +2552,10 @@ void TextPattern::CollectSpanNodes(std::stack<SpanNodeInfo> nodes, bool& isSpanH
|
||||
if (tag == V2::PLACEHOLDER_SPAN_ETS_TAG) {
|
||||
continue;
|
||||
}
|
||||
if (tag == V2::CUSTOM_SPAN_NODE_ETS_TAG) {
|
||||
AddChildSpanItem(current.node);
|
||||
childNodes_.emplace_back(current.node);
|
||||
}
|
||||
const auto& nextChildren = current.node->GetChildren();
|
||||
if (nextChildren.empty()) {
|
||||
continue;
|
||||
@ -2706,6 +2710,13 @@ void TextPattern::AddChildSpanItem(const RefPtr<UINode>& child)
|
||||
placeholderSpan->placeholderSpanNodeId = placeholderSpanNode->GetId();
|
||||
spans_.emplace_back(placeholderSpan);
|
||||
}
|
||||
} else if (child->GetTag() == V2::CUSTOM_SPAN_NODE_ETS_TAG) {
|
||||
auto customSpanNode = DynamicCast<CustomSpanNode>(child);
|
||||
if (customSpanNode) {
|
||||
auto customSpan = customSpanNode->GetSpanItem();
|
||||
customSpan->placeholderSpanNodeId = customSpanNode->GetId();
|
||||
spans_.emplace_back(customSpan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -606,4 +606,7 @@ const char MOVING_PHOTO_ETS_TAG[] = "MovingPhoto";
|
||||
// LinearIndicator
|
||||
const char LINEARINDICATOR_COMPONENT_TAG[] = "LinearIndicatorComponent";
|
||||
const char LINEARINDICATOR_ETS_TAG[] = "LinearIndicator";
|
||||
|
||||
// CustomSpanNode
|
||||
const char CUSTOM_SPAN_NODE_ETS_TAG[] = "CustomSpanNode";
|
||||
} // namespace OHOS::Ace::V2
|
||||
|
@ -615,5 +615,8 @@ ACE_FORCE_EXPORT extern const char MOVING_PHOTO_ETS_TAG[];
|
||||
// LinearIndicator
|
||||
ACE_EXPORT extern const char LINEARINDICATOR_COMPONENT_TAG[];
|
||||
ACE_EXPORT extern const char LINEARINDICATOR_ETS_TAG[];
|
||||
|
||||
// CustomSpanNode
|
||||
ACE_EXPORT extern const char CUSTOM_SPAN_NODE_ETS_TAG[];
|
||||
} // namespace OHOS::Ace::V2
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_COMPONENTS_V2_INSPECTOR_INSPECTOR_CONSTANTS_H
|
||||
|
@ -685,7 +685,8 @@ enum ArkUINodeType {
|
||||
ARKUI_IMAGE_ANIMATOR,
|
||||
ARKUI_CIRCLE,
|
||||
ARKUI_TAB_CONTENT,
|
||||
ARKUI_NAVIGATION
|
||||
ARKUI_NAVIGATION,
|
||||
ARKUI_CUSTOM_SPAN,
|
||||
};
|
||||
|
||||
enum ArkUIEventCategory {
|
||||
@ -1092,6 +1093,8 @@ struct ArkUICustomNodeEvent {
|
||||
ArkUI_Int64 extraParam;
|
||||
ArkUI_Int64 canvas;
|
||||
ArkUI_Int32 data[8];
|
||||
ArkUIEventCallbackArg numberData[ARKUI_ASYNC_EVENT_ARGS_COUNT];
|
||||
ArkUIEventCallbackArg numberReturnData[ARKUI_ASYNC_EVENT_ARGS_COUNT];
|
||||
};
|
||||
|
||||
struct ArkUIExpectedFrameRateRange {
|
||||
@ -4752,6 +4755,7 @@ struct ArkUIExtendedNodeAPI {
|
||||
ArkUI_Int32 (*getCustomMethodFlag)(ArkUINodeHandle node);
|
||||
|
||||
void (*registerCustomNodeAsyncEvent)(ArkUINodeHandle nodePtr, ArkUI_Int32 kind, void* extraParam);
|
||||
void (*registerCustomSpanAsyncEvent)(ArkUINodeHandle nodePtr, ArkUI_Int32 kind, void* extraParam);
|
||||
ArkUI_Int32 (*unregisterCustomNodeAsyncEvent)(ArkUINodeHandle nodePtr, ArkUI_Int32 kind);
|
||||
void (*registerCustomNodeAsyncEventReceiver)(void (*eventReceiver)(ArkUICustomNodeEvent* event));
|
||||
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "core/interfaces/native/node/node_scroll_modifier.h"
|
||||
#include "core/interfaces/native/node/node_slider_modifier.h"
|
||||
#include "core/interfaces/native/node/node_swiper_modifier.h"
|
||||
#include "core/interfaces/native/node/node_span_modifier.h"
|
||||
#include "core/interfaces/native/node/node_text_area_modifier.h"
|
||||
#include "core/interfaces/native/node/node_text_input_modifier.h"
|
||||
#include "core/interfaces/native/node/node_text_modifier.h"
|
||||
@ -1323,6 +1324,20 @@ void RegisterCustomNodeAsyncEvent(ArkUINodeHandle node, int32_t eventType, void*
|
||||
}
|
||||
}
|
||||
|
||||
void RegisterCustomSpanAsyncEvent(ArkUINodeHandle node, int32_t eventType, void* extraParam)
|
||||
{
|
||||
switch (eventType) {
|
||||
case ArkUIAPINodeFlags::CUSTOM_MEASURE:
|
||||
NodeModifier::SetCustomSpanOnMeasure(node, extraParam);
|
||||
break;
|
||||
case ArkUIAPINodeFlags::CUSTOM_DRAW:
|
||||
NodeModifier::SetCustomSpanOnDraw(node, extraParam);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ArkUI_Int32 UnregisterCustomNodeEvent(ArkUINodeHandle node, ArkUI_Int32 eventType)
|
||||
{
|
||||
auto companion = ViewModel::GetCompanion(node);
|
||||
@ -1763,6 +1778,7 @@ ArkUIExtendedNodeAPI impl_extended = {
|
||||
SetCustomMethodFlag,
|
||||
GetCustomMethodFlag,
|
||||
RegisterCustomNodeAsyncEvent,
|
||||
RegisterCustomSpanAsyncEvent,
|
||||
UnregisterCustomNodeEvent,
|
||||
RegisterCustomNodeEventReceiver,
|
||||
SetCustomCallback, // setCustomCallback
|
||||
|
@ -44,6 +44,7 @@ constexpr int NUM_0 = 0;
|
||||
constexpr int NUM_1 = 1;
|
||||
constexpr int NUM_2 = 2;
|
||||
constexpr int NUM_3 = 3;
|
||||
constexpr int NUM_32 = 32;
|
||||
constexpr int DEFAULT_LENGTH = 4;
|
||||
void SetSpanContent(ArkUINodeHandle node, const char* value)
|
||||
{
|
||||
@ -458,6 +459,49 @@ const ArkUISpanModifier* GetSpanModifier()
|
||||
ResetTextTextShadow, GetTextShadow };
|
||||
return &modifier;
|
||||
}
|
||||
|
||||
void SetCustomSpanOnMeasure(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<CustomSpanNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
std::function<CustomSpanMetrics(CustomSpanMeasureInfo)> onMeasureFunc =
|
||||
[node, extraParam](CustomSpanMeasureInfo customSpanMeasureInfo) -> CustomSpanMetrics {
|
||||
ArkUICustomNodeEvent event;
|
||||
event.kind = ArkUIAPINodeFlags::CUSTOM_MEASURE;
|
||||
event.extraParam = reinterpret_cast<intptr_t>(extraParam);
|
||||
event.numberData[0].f32 = customSpanMeasureInfo.fontSize;
|
||||
SendArkUIAsyncCustomEvent(&event);
|
||||
float width = event.numberReturnData[0].f32;
|
||||
float height = event.numberReturnData[1].f32;
|
||||
return { width, height };
|
||||
};
|
||||
frameNode->GetSpanItem()->onMeasure = onMeasureFunc;
|
||||
}
|
||||
|
||||
void SetCustomSpanOnDraw(ArkUINodeHandle node, void* extraParam)
|
||||
{
|
||||
auto* frameNode = reinterpret_cast<CustomSpanNode*>(node);
|
||||
CHECK_NULL_VOID(frameNode);
|
||||
std::function<void(NG::DrawingContext&, CustomSpanOptions)> onDrawFunc =
|
||||
[node, extraParam](NG::DrawingContext& context, CustomSpanOptions customSpanOptions) {
|
||||
auto canvas = reinterpret_cast<uintptr_t>(&context.canvas);
|
||||
ArkUICustomNodeEvent event;
|
||||
event.kind = ArkUIAPINodeFlags::CUSTOM_DRAW;
|
||||
event.extraParam = reinterpret_cast<intptr_t>(extraParam);
|
||||
event.data[NUM_0] = (ArkUI_Int32)(canvas & 0xffffffff);
|
||||
event.data[NUM_1] =
|
||||
(ArkUI_Int32)((static_cast<uint64_t>(canvas) >> NUM_32) & 0xffffffff);
|
||||
event.data[NUM_2] = context.width;
|
||||
event.data[NUM_3] = context.height;
|
||||
event.canvas = reinterpret_cast<intptr_t>(&context.canvas);
|
||||
event.numberData[0].f32 = customSpanOptions.x;
|
||||
event.numberData[1].f32 = customSpanOptions.lineTop;
|
||||
event.numberData[2].f32 = customSpanOptions.lineBottom;
|
||||
event.numberData[3].f32 = customSpanOptions.baseline;
|
||||
SendArkUIAsyncCustomEvent(&event);
|
||||
};
|
||||
frameNode->GetSpanItem()->onDraw = onDrawFunc;
|
||||
}
|
||||
} // namespace NodeModifier
|
||||
|
||||
} // namespace OHOS::Ace::NG
|
@ -19,6 +19,8 @@
|
||||
#include "core/interfaces/native/node/node_api.h"
|
||||
|
||||
namespace OHOS::Ace::NG::NodeModifier {
|
||||
const ArkUISpanModifier* GetSpanModifier();
|
||||
const ArkUISpanModifier* GetSpanModifier();
|
||||
void SetCustomSpanOnMeasure(ArkUINodeHandle node, void* extraParam);
|
||||
void SetCustomSpanOnDraw(ArkUINodeHandle node, void* extraParam);
|
||||
}
|
||||
#endif
|
@ -37,6 +37,7 @@
|
||||
#include "core/components_ng/pattern/stack/stack_model_ng.h"
|
||||
#include "core/components_ng/pattern/tabs/tab_content_model_ng.h"
|
||||
#include "core/components_ng/pattern/tabs/tabs_model_ng.h"
|
||||
#include "core/components_ng/pattern/text/span/span_object.h"
|
||||
#include "core/components_ng/pattern/text_field/text_field_model_ng.h"
|
||||
#include "core/components_ng/pattern/text/image_span_view.h"
|
||||
#include "core/components_ng/pattern/text/text_model_ng.h"
|
||||
@ -478,6 +479,14 @@ void* createTabContentNode(ArkUI_Int32 nodeId)
|
||||
return AceType::RawPtr(frameNode);
|
||||
}
|
||||
|
||||
void* createCustomSpanNode(ArkUI_Int32 nodeId)
|
||||
{
|
||||
auto customSpanNode = CustomSpanNode::CreateFrameNode(nodeId);
|
||||
CHECK_NULL_RETURN(customSpanNode, nullptr);
|
||||
customSpanNode->IncRefCount();
|
||||
return AceType::RawPtr(customSpanNode);
|
||||
}
|
||||
|
||||
using createArkUIFrameNode = void*(ArkUI_Int32 nodeId);
|
||||
void* CreateNode(ArkUINodeType tag, ArkUI_Int32 nodeId)
|
||||
{
|
||||
@ -539,6 +548,7 @@ void* CreateNode(ArkUINodeType tag, ArkUI_Int32 nodeId)
|
||||
createCircleNode,
|
||||
createTabContentNode,
|
||||
createNavigationNode,
|
||||
createCustomSpanNode,
|
||||
};
|
||||
if (tag >= sizeof(createArkUIFrameNodes) / sizeof(createArkUIFrameNode*)) {
|
||||
TAG_LOGE(AceLogTag::ACE_NATIVE_NODE, "fail to create %{public}d type of node", tag);
|
||||
|
@ -1982,5 +1982,69 @@
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_DialogDismissEvent_GetDismissReason"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_NodeCustomEvent_GetCustomSpanMeasureInfo"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_NodeCustomEvent_SetCustomSpanMetrics"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_NodeCustomEvent_GetCustomSpanDrawInfo"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CustomSpanMeasureInfo_Create"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CustomSpanMeasureInfo_Dispose"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CustomSpanMeasureInfo_GetFontSize"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CustomSpanMetrics_Create"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CustomSpanMetrics_Dispose"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CustomSpanMetrics_SetWidth"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CustomSpanMetrics_SetHeight"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CustomSpanDrawInfo_Create"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CustomSpanDrawInfo_Dispose"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CustomSpanDrawInfo_GetXOffset"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CustomSpanDrawInfo_GetLineTop"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CustomSpanDrawInfo_GetLineBottom"
|
||||
},
|
||||
{
|
||||
"first_introduced": "12",
|
||||
"name": "OH_ArkUI_CustomSpanDrawInfo_GetBaseLine"
|
||||
}
|
||||
]
|
||||
|
@ -121,6 +121,8 @@ typedef enum {
|
||||
ARKUI_NODE_GRID,
|
||||
/** Grid item. */
|
||||
ARKUI_NODE_GRID_ITEM,
|
||||
/** Custom_Span. */
|
||||
ARKUI_NODE_CUSTOM_SPAN,
|
||||
} ArkUI_NodeType;
|
||||
|
||||
/**
|
||||
@ -7130,6 +7132,45 @@ ArkUI_NodeHandle OH_ArkUI_NodeCustomEvent_GetNodeHandle(ArkUI_NodeCustomEvent* e
|
||||
*/
|
||||
ArkUI_NodeCustomEventType OH_ArkUI_NodeCustomEvent_GetEventType(ArkUI_NodeCustomEvent* event);
|
||||
|
||||
/**
|
||||
* @brief 通过自定义组件事件获取自定义段落组件的测量信息。
|
||||
*
|
||||
* @param event 自定义组件事件。
|
||||
* @param info 需要获取的测量信息。
|
||||
* @return 错误码。
|
||||
* {@link ARKUI_ERROR_CODE_NO_ERROR} 成功。
|
||||
* {@link ARKUI_ERROR_CODE_PARAM_INVALID} 函数参数异常。
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_NodeCustomEvent_GetCustomSpanMeasureInfo(
|
||||
ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanMeasureInfo* info);
|
||||
|
||||
/**
|
||||
* @brief 通过自定义组件事件设置自定义段落的度量指标。
|
||||
*
|
||||
* @param event 自定义组件事件。
|
||||
* @param metrics 需要获取的度量指标信息。
|
||||
* @return 错误码。
|
||||
* {@link ARKUI_ERROR_CODE_NO_ERROR} 成功。
|
||||
* {@link ARKUI_ERROR_CODE_PARAM_INVALID} 函数参数异常。
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_NodeCustomEvent_SetCustomSpanMetrics(
|
||||
ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanMetrics* metrics);
|
||||
|
||||
/**
|
||||
* @brief 通过自定义组件事件获取自定义段落组件的绘制信息。
|
||||
*
|
||||
* @param event 自定义组件事件。
|
||||
* @param event 需要获取的绘制信息。
|
||||
* @return 错误码。
|
||||
* {@link ARKUI_ERROR_CODE_NO_ERROR} 成功。
|
||||
* {@link ARKUI_ERROR_CODE_PARAM_INVALID} 函数参数异常。
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_NodeCustomEvent_GetCustomSpanDrawInfo(
|
||||
ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanDrawInfo* info);
|
||||
|
||||
/**
|
||||
* @brief Adds a component to a node content.
|
||||
*
|
||||
|
@ -2039,6 +2039,27 @@ typedef struct {
|
||||
float perspective;
|
||||
} ArkUI_RotationOptions;
|
||||
|
||||
/**
|
||||
* @brief defines the measure info of the custom span.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef struct ArkUI_CustomSpanMeasureInfo ArkUI_CustomSpanMeasureInfo;
|
||||
|
||||
/**
|
||||
* @brief defines the metrics of the custom span.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef struct ArkUI_CustomSpanMetrics ArkUI_CustomSpanMetrics;
|
||||
|
||||
/**
|
||||
* @brief defines the draw info of the custom span.
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
typedef struct ArkUI_CustomSpanDrawInfo ArkUI_CustomSpanDrawInfo;
|
||||
|
||||
/**
|
||||
* @brief Creates a size constraint.
|
||||
*
|
||||
@ -3587,6 +3608,120 @@ int32_t OH_ArkUI_ListChildrenMainSizeOption_UpdateSize(ArkUI_ListChildrenMainSiz
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_ListChildrenMainSizeOption_GetMainSize(ArkUI_ListChildrenMainSize* option, int32_t index);
|
||||
|
||||
/**
|
||||
* @brief 创建自定义段落组件测量信息。
|
||||
*
|
||||
* @return CustomSpanMeasureInfo实例。
|
||||
* @since 12
|
||||
*/
|
||||
ArkUI_CustomSpanMeasureInfo* OH_ArkUI_CustomSpanMeasureInfo_Create();
|
||||
|
||||
/**
|
||||
* @brief 销毁自定义段落组件测量信息。
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
void OH_ArkUI_CustomSpanMeasureInfo_Dispose(ArkUI_CustomSpanMeasureInfo* info);
|
||||
|
||||
/**
|
||||
* @brief 获取自定义段落组件的字体大小。
|
||||
*
|
||||
* @param info 自定义段落组件测量信息指针。
|
||||
* @return 字体大小。若函数参数异常,返回-1.0f。
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_CustomSpanMeasureInfo_GetFontSize(ArkUI_CustomSpanMeasureInfo* info);
|
||||
|
||||
/**
|
||||
* @brief 创建自定义段落组件度量信息。
|
||||
*
|
||||
* @return CustomSpanMetrics实例。
|
||||
* @since 12
|
||||
*/
|
||||
ArkUI_CustomSpanMetrics* OH_ArkUI_CustomSpanMetrics_Create();
|
||||
|
||||
/**
|
||||
* @brief 销毁自定义段落组件度量信息。
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
void OH_ArkUI_CustomSpanMetrics_Dispose(ArkUI_CustomSpanMetrics* metrics);
|
||||
|
||||
/**
|
||||
* @brief 设置自定义段落组件的宽度。
|
||||
*
|
||||
* @param metrics CustomSpanMetrics实例。
|
||||
* @param width 宽度大小,单位为px。
|
||||
* @return 错误码。
|
||||
* {@link ARKUI_ERROR_CODE_NO_ERROR} 成功。
|
||||
* {@link ARKUI_ERROR_CODE_PARAM_INVALID} 函数参数异常。
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_CustomSpanMetrics_SetWidth(ArkUI_CustomSpanMetrics* metrics, float width);
|
||||
|
||||
/**
|
||||
* @brief 设置自定义段落组件的高度。
|
||||
*
|
||||
* @param metrics CustomSpanMetrics实例。
|
||||
* @param height 高度大小,单位为px。
|
||||
* @return 错误码。
|
||||
* {@link ARKUI_ERROR_CODE_NO_ERROR} 成功。
|
||||
* {@link ARKUI_ERROR_CODE_PARAM_INVALID} 函数参数异常。
|
||||
* @since 12
|
||||
*/
|
||||
int32_t OH_ArkUI_CustomSpanMetrics_SetHeight(ArkUI_CustomSpanMetrics* metrics, float height);
|
||||
|
||||
/**
|
||||
* @brief 创建自定义段落组件绘制信息。
|
||||
*
|
||||
* @return CustomSpanDrawInfo实例。
|
||||
* @since 12
|
||||
*/
|
||||
ArkUI_CustomSpanDrawInfo* OH_ArkUI_CustomSpanDrawInfo_Create();
|
||||
|
||||
/**
|
||||
* @brief 销毁自定义段落组件绘制信息。
|
||||
*
|
||||
* @since 12
|
||||
*/
|
||||
void OH_ArkUI_CustomSpanDrawInfo_Dispose(ArkUI_CustomSpanDrawInfo* info);
|
||||
|
||||
/**
|
||||
* @brief 获取自定义段落组件相对于挂载组件的x轴偏移值。
|
||||
*
|
||||
* @param info 自定义段落组件绘制信息指针。
|
||||
* @return x轴偏移值。若函数参数异常,返回0.0f。
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_CustomSpanDrawInfo_GetXOffset(ArkUI_CustomSpanDrawInfo* info);
|
||||
|
||||
/**
|
||||
* @brief 获取自定义段落组件相对于挂载组件的上边距。
|
||||
*
|
||||
* @param info 自定义段落组件绘制信息指针。
|
||||
* @return 上边距值。若函数参数异常,返回0.0f。
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_CustomSpanDrawInfo_GetLineTop(ArkUI_CustomSpanDrawInfo* info);
|
||||
|
||||
/**
|
||||
* @brief 获取自定义段落组件相对于挂载组件的下边距。
|
||||
*
|
||||
* @param info 自定义段落组件绘制信息指针。
|
||||
* @return 下边距值。若函数参数异常,返回0.0f。
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_CustomSpanDrawInfo_GetLineBottom(ArkUI_CustomSpanDrawInfo* info);
|
||||
|
||||
/**
|
||||
* @brief 获取自定义段落组件相对于挂载组件的基线偏移量。
|
||||
*
|
||||
* @param info 自定义段落组件绘制信息指针。
|
||||
* @return 基线偏移量值。若函数参数异常,返回0.0f。
|
||||
* @since 12
|
||||
*/
|
||||
float OH_ArkUI_CustomSpanDrawInfo_GetBaseLine(ArkUI_CustomSpanDrawInfo* info);
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
@ -114,6 +114,143 @@ ArkUI_NodeCustomEventType OH_ArkUI_NodeCustomEvent_GetEventType(ArkUI_NodeCustom
|
||||
return static_cast<ArkUI_NodeCustomEventType>(event->event->kind);
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_NodeCustomEvent_GetCustomSpanMeasureInfo(
|
||||
ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanMeasureInfo* info)
|
||||
{
|
||||
if (!event || !info || !event->event) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
info->fontSize = event->event->numberData[0].f32;
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_NodeCustomEvent_SetCustomSpanMetrics(
|
||||
ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanMetrics* metrics)
|
||||
{
|
||||
if (!event || !metrics || !event->event) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
event->event->numberReturnData[0].f32 = metrics->width;
|
||||
event->event->numberReturnData[1].f32 = metrics->height;
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_NodeCustomEvent_GetCustomSpanDrawInfo(
|
||||
ArkUI_NodeCustomEvent* event, ArkUI_CustomSpanDrawInfo* info)
|
||||
{
|
||||
if (!event || !info || !event->event) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
info->optionsX = event->event->numberData[0].f32;
|
||||
info->optionsLineTop = event->event->numberData[1].f32;
|
||||
info->optionsLineBottom = event->event->numberData[2].f32;
|
||||
info->optionsBaseLine = event->event->numberData[3].f32;
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
ArkUI_CustomSpanMeasureInfo* OH_ArkUI_CustomSpanMeasureInfo_Create()
|
||||
{
|
||||
ArkUI_CustomSpanMeasureInfo* info = new ArkUI_CustomSpanMeasureInfo { 0 };
|
||||
return info;
|
||||
}
|
||||
|
||||
void OH_ArkUI_CustomSpanMeasureInfo_Dispose(ArkUI_CustomSpanMeasureInfo* info)
|
||||
{
|
||||
if (!info) {
|
||||
return;
|
||||
}
|
||||
delete info;
|
||||
info = nullptr;
|
||||
}
|
||||
|
||||
float OH_ArkUI_CustomSpanMeasureInfo_GetFontSize(ArkUI_CustomSpanMeasureInfo* info)
|
||||
{
|
||||
if (!info) {
|
||||
return 0.0f;
|
||||
}
|
||||
return info->fontSize;
|
||||
}
|
||||
|
||||
ArkUI_CustomSpanMetrics* OH_ArkUI_CustomSpanMetrics_Create()
|
||||
{
|
||||
ArkUI_CustomSpanMetrics* metrics = new ArkUI_CustomSpanMetrics { 0, 0 };
|
||||
return metrics;
|
||||
}
|
||||
|
||||
void OH_ArkUI_CustomSpanMetrics_Dispose(ArkUI_CustomSpanMetrics* metrics)
|
||||
{
|
||||
if (!metrics) {
|
||||
return;
|
||||
}
|
||||
delete metrics;
|
||||
metrics = nullptr;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_CustomSpanMetrics_SetWidth(ArkUI_CustomSpanMetrics* metrics, float width)
|
||||
{
|
||||
if (!metrics) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
metrics->width = width;
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_CustomSpanMetrics_SetHeight(ArkUI_CustomSpanMetrics* metrics, float height)
|
||||
{
|
||||
if (!metrics) {
|
||||
return ARKUI_ERROR_CODE_PARAM_INVALID;
|
||||
}
|
||||
metrics->height = height;
|
||||
return ARKUI_ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
ArkUI_CustomSpanDrawInfo* OH_ArkUI_CustomSpanDrawInfo_Create()
|
||||
{
|
||||
ArkUI_CustomSpanDrawInfo* info = new ArkUI_CustomSpanDrawInfo { 0, 0, 0, 0 };
|
||||
return info;
|
||||
}
|
||||
|
||||
void OH_ArkUI_CustomSpanDrawInfo_Dispose(ArkUI_CustomSpanDrawInfo* info)
|
||||
{
|
||||
if (!info) {
|
||||
return;
|
||||
}
|
||||
delete info;
|
||||
info = nullptr;
|
||||
}
|
||||
|
||||
float OH_ArkUI_CustomSpanDrawInfo_GetXOffset(ArkUI_CustomSpanDrawInfo* info)
|
||||
{
|
||||
if (!info) {
|
||||
return 0.0f;
|
||||
}
|
||||
return info->optionsX;
|
||||
}
|
||||
|
||||
float OH_ArkUI_CustomSpanDrawInfo_GetLineTop(ArkUI_CustomSpanDrawInfo* info)
|
||||
{
|
||||
if (!info) {
|
||||
return 0.0f;
|
||||
}
|
||||
return info->optionsLineTop;
|
||||
}
|
||||
|
||||
float OH_ArkUI_CustomSpanDrawInfo_GetLineBottom(ArkUI_CustomSpanDrawInfo* info)
|
||||
{
|
||||
if (!info) {
|
||||
return 0.0f;
|
||||
}
|
||||
return info->optionsLineBottom;
|
||||
}
|
||||
|
||||
float OH_ArkUI_CustomSpanDrawInfo_GetBaseLine(ArkUI_CustomSpanDrawInfo* info)
|
||||
{
|
||||
if (!info) {
|
||||
return 0.0f;
|
||||
}
|
||||
return info->optionsBaseLine;
|
||||
}
|
||||
|
||||
int32_t OH_ArkUI_LayoutConstraint_GetMaxWidth(const ArkUI_LayoutConstraint* constraint)
|
||||
{
|
||||
CHECK_NULL_RETURN(constraint, -1);
|
||||
|
@ -68,7 +68,7 @@ int32_t RegisterNodeCustomEvent(ArkUI_NodeHandle node, ArkUI_NodeCustomEventType
|
||||
}
|
||||
|
||||
if (eventType & ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE) {
|
||||
if (node->type == ARKUI_NODE_CUSTOM) {
|
||||
if (node->type == ARKUI_NODE_CUSTOM || node->type == ARKUI_NODE_CUSTOM_SPAN) {
|
||||
NodeAddExtraData(node, ARKUI_NODE_CUSTOM_EVENT_ON_MEASURE, targetId, userData);
|
||||
} else {
|
||||
return ERROR_CODE_NATIVE_IMPL_TYPE_NOT_SUPPORTED;
|
||||
@ -95,8 +95,13 @@ int32_t RegisterNodeCustomEvent(ArkUI_NodeHandle node, ArkUI_NodeCustomEventType
|
||||
NodeAddExtraData(node, ARKUI_NODE_CUSTOM_EVENT_ON_OVERLAY_DRAW, targetId, userData);
|
||||
}
|
||||
auto* impl = GetFullImpl();
|
||||
impl->getExtendedAPI()->registerCustomNodeAsyncEvent(
|
||||
node->uiNodeHandle, eventType, reinterpret_cast<void*>(node));
|
||||
if (node->type == ARKUI_NODE_CUSTOM_SPAN) {
|
||||
impl->getExtendedAPI()->registerCustomSpanAsyncEvent(
|
||||
node->uiNodeHandle, eventType, reinterpret_cast<void*>(node));
|
||||
} else {
|
||||
impl->getExtendedAPI()->registerCustomNodeAsyncEvent(
|
||||
node->uiNodeHandle, eventType, reinterpret_cast<void*>(node));
|
||||
}
|
||||
return ERROR_CODE_NO_ERROR;
|
||||
}
|
||||
|
||||
|
@ -140,6 +140,22 @@ struct ArkUI_AccessibilityValue {
|
||||
ArkUI_OptionalCharPtr text;
|
||||
};
|
||||
|
||||
struct ArkUI_CustomSpanMeasureInfo {
|
||||
float fontSize;
|
||||
};
|
||||
|
||||
struct ArkUI_CustomSpanMetrics {
|
||||
float width;
|
||||
float height;
|
||||
};
|
||||
|
||||
struct ArkUI_CustomSpanDrawInfo {
|
||||
float optionsX;
|
||||
float optionsLineTop;
|
||||
float optionsLineBottom;
|
||||
float optionsBaseLine;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
@ -147,7 +147,8 @@ ArkUI_NodeHandle CreateNode(ArkUI_NodeType type)
|
||||
ARKUI_CHECKBOX, ARKUI_XCOMPONENT, ARKUI_DATE_PICKER, ARKUI_TIME_PICKER, ARKUI_TEXT_PICKER,
|
||||
ARKUI_CALENDAR_PICKER, ARKUI_SLIDER, ARKUI_RADIO, ARKUI_IMAGE_ANIMATOR, ARKUI_STACK, ARKUI_SWIPER,
|
||||
ARKUI_SCROLL, ARKUI_LIST, ARKUI_LIST_ITEM, ARKUI_LIST_ITEM_GROUP, ARKUI_COLUMN, ARKUI_ROW, ARKUI_FLEX,
|
||||
ARKUI_REFRESH, ARKUI_WATER_FLOW, ARKUI_FLOW_ITEM, ARKUI_RELATIVE_CONTAINER, ARKUI_GRID, ARKUI_GRID_ITEM };
|
||||
ARKUI_REFRESH, ARKUI_WATER_FLOW, ARKUI_FLOW_ITEM, ARKUI_RELATIVE_CONTAINER, ARKUI_GRID, ARKUI_GRID_ITEM,
|
||||
ARKUI_CUSTOM_SPAN };
|
||||
// already check in entry point.
|
||||
uint32_t nodeType = type < MAX_NODE_SCOPE_NUM ? type : (type - MAX_NODE_SCOPE_NUM + BASIC_COMPONENT_NUM);
|
||||
auto* impl = GetFullImpl();
|
||||
|
@ -273,6 +273,7 @@ std::unordered_map<uint32_t, std::string> ACCESSIBILITY_ROLE_CONVERT_PROPERTY_MA
|
||||
{ static_cast<uint32_t>(ARKUI_NODE_RELATIVE_CONTAINER), "RelativeContainer" },
|
||||
{ static_cast<uint32_t>(ARKUI_NODE_GRID), "Grid" },
|
||||
{ static_cast<uint32_t>(ARKUI_NODE_GRID_ITEM), "GridItem" },
|
||||
{ static_cast<uint32_t>(ARKUI_NODE_CUSTOM_SPAN), "CustomSpan" },
|
||||
};
|
||||
|
||||
std::unordered_map<std::string, uint32_t> ACCESSIBILITY_ROLE_CONVERT_NATIVE_MAP = {
|
||||
@ -310,6 +311,7 @@ std::unordered_map<std::string, uint32_t> ACCESSIBILITY_ROLE_CONVERT_NATIVE_MAP
|
||||
{ "RelativeContainer", static_cast<uint32_t>(ARKUI_NODE_RELATIVE_CONTAINER) },
|
||||
{ "Grid", static_cast<uint32_t>(ARKUI_NODE_GRID) },
|
||||
{ "GridItem", static_cast<uint32_t>(ARKUI_NODE_GRID_ITEM) },
|
||||
{ "CustomSpan", static_cast<uint32_t>(ARKUI_NODE_CUSTOM_SPAN) },
|
||||
};
|
||||
|
||||
void ResetAttributeItem()
|
||||
@ -12479,6 +12481,9 @@ bool CheckIfAttributeLegal(ArkUI_NodeHandle node, int32_t type)
|
||||
auto it = SPAN_ATTRIBUTES_MAP.find(type);
|
||||
return it != SPAN_ATTRIBUTES_MAP.end();
|
||||
}
|
||||
if (node->type == ARKUI_NODE_CUSTOM_SPAN) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user