mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
add ui_loader_load_widget_with_parent
This commit is contained in:
parent
6eb1b2796c
commit
b8ae59f2e7
@ -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);
|
||||
|
@ -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*/
|
||||
|
Loading…
Reference in New Issue
Block a user