mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-02 03:58:33 +08:00
add_child/remove_child to virtual function
This commit is contained in:
parent
0efe0534e9
commit
c5ca6184ee
@ -267,6 +267,12 @@ ret_t widget_add_child(widget_t* widget, widget_t* child) {
|
||||
widget->children = array_create(4);
|
||||
}
|
||||
|
||||
if(widget->vt->add_child) {
|
||||
if(widget->vt->add_child(widget, child) == RET_OK) {
|
||||
return RET_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return array_push(widget->children, child);
|
||||
}
|
||||
|
||||
@ -281,6 +287,12 @@ ret_t widget_remove_child(widget_t* widget, widget_t* child) {
|
||||
widget->key_target = NULL;
|
||||
}
|
||||
|
||||
if(widget->vt->remove_child) {
|
||||
if(widget->vt->remove_child(widget, child) == RET_OK) {
|
||||
return RET_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return array_remove(widget->children, NULL, child, NULL);
|
||||
}
|
||||
|
||||
|
@ -109,6 +109,8 @@ typedef ret_t (*widget_on_click_t)(widget_t* widget, pointer_event_t* e);
|
||||
typedef ret_t (*widget_on_pointer_down_t)(widget_t* widget, pointer_event_t* e);
|
||||
typedef ret_t (*widget_on_pointer_move_t)(widget_t* widget, pointer_event_t* e);
|
||||
typedef ret_t (*widget_on_pointer_up_t)(widget_t* widget, pointer_event_t* e);
|
||||
typedef ret_t (*widget_on_add_child)(widget_t* widget, widget_t* child);
|
||||
typedef ret_t (*widget_on_remove_child)(widget_t* widget, widget_t* child);
|
||||
typedef ret_t (*widget_on_layout_children_t)(widget_t* widget);
|
||||
typedef ret_t (*widget_get_prop_t)(widget_t* widget, const char* name, value_t* v);
|
||||
typedef ret_t (*widget_set_prop_t)(widget_t* widget, const char* name, const value_t* v);
|
||||
@ -134,6 +136,8 @@ typedef struct _widget_vtable_t {
|
||||
widget_on_pointer_up_t on_pointer_up;
|
||||
widget_on_layout_children_t on_layout_children;
|
||||
widget_invalidate_t invalidate;
|
||||
widget_on_add_child add_child;
|
||||
widget_on_remove_child remove_child;
|
||||
widget_on_event_t on_event;
|
||||
widget_grab_t grab;
|
||||
widget_ungrab_t ungrab;
|
||||
|
Loading…
Reference in New Issue
Block a user