add ui_loader_load_widget_with_parent

This commit is contained in:
lixianjing 2021-06-24 22:13:30 +08:00
parent 6eb1b2796c
commit b8ae59f2e7
2 changed files with 18 additions and 0 deletions

View File

@ -32,11 +32,16 @@ ret_t ui_loader_load(ui_loader_t* loader, const uint8_t* data, uint32_t size, ui
}
widget_t* ui_loader_load_widget(const char* name) {
return ui_loader_load_widget_with_parent(name, NULL);
}
widget_t* ui_loader_load_widget_with_parent(const char* name, widget_t* parent) {
ui_loader_t* loader = default_ui_loader();
ui_builder_t* builder = ui_builder_default_create(name);
const asset_info_t* ui = assets_manager_ref(assets_manager(), ASSET_TYPE_UI, name);
return_value_if_fail(ui != NULL, NULL);
builder->widget = parent;
ui_loader_load(loader, ui->data, ui->size, builder);
assets_manager_unref(assets_manager(), ui);
ui_builder_destroy(builder);

View File

@ -87,6 +87,19 @@ ret_t ui_loader_load(ui_loader_t* loader, const uint8_t* data, uint32_t size,
*/
widget_t* ui_loader_load_widget(const char* name);
/**
* @method ui_loader_load_widget_with_parent
*
* widget对象widget对象指定父控件对象widget
*
* @param {const char*} name
* @param {widget_t*} parent
*
* @return {widget_t*} widget对象
*
*/
widget_t* ui_loader_load_widget_with_parent(const char* name, widget_t* parent);
END_C_DECLS
#endif /*TK_UI_LOADER_H*/