mirror of
https://github.com/zlgopen/awtk.git
synced 2025-05-08 11:33:48 +08:00
improve list_view_h
This commit is contained in:
parent
fe2809f7bb
commit
24ccf4c90a
@ -2,6 +2,7 @@
|
||||
|
||||
2025/05/07
|
||||
* 增加函数 fscript_set_name
|
||||
* 修改移除list_view_h内的scroll_view时没有复位相关数据导致可能访问野指针的问题(感谢朝泽提供补丁)
|
||||
|
||||
2025/05/06
|
||||
* object hash 兼容32位系统(感谢兆坤提供补丁)。
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "scroll_view/scroll_view.h"
|
||||
|
||||
static ret_t list_view_h_on_add_child(widget_t* widget, widget_t* child);
|
||||
static ret_t list_view_h_on_remove_child(widget_t* widget, widget_t* child);
|
||||
|
||||
static ret_t list_view_h_on_paint_self(widget_t* widget, canvas_t* c) {
|
||||
return widget_paint_helper(widget, c, NULL, NULL);
|
||||
@ -95,6 +96,7 @@ TK_DECL_VTABLE(list_view_h) = {.type = WIDGET_TYPE_LIST_VIEW_H,
|
||||
.get_prop = list_view_h_get_prop,
|
||||
.on_event = list_view_h_on_event,
|
||||
.on_add_child = list_view_h_on_add_child,
|
||||
.on_remove_child = list_view_h_on_remove_child,
|
||||
.on_paint_self = list_view_h_on_paint_self};
|
||||
|
||||
static ret_t list_view_h_on_scroll_view_layout_children(widget_t* widget) {
|
||||
@ -166,6 +168,28 @@ static ret_t list_view_h_on_add_child(widget_t* widget, widget_t* child) {
|
||||
return RET_CONTINUE;
|
||||
}
|
||||
|
||||
static ret_t list_view_h_on_remove_child(widget_t* widget, widget_t* child) {
|
||||
list_view_h_t* list_view_h = LIST_VIEW_H(widget);
|
||||
ENSURE(list_view_h);
|
||||
|
||||
if (list_view_h->scroll_view == child) {
|
||||
scroll_view_t* scroll_view = SCROLL_VIEW(child);
|
||||
|
||||
list_view_h->scroll_view = NULL;
|
||||
scroll_view->on_layout_children = NULL;
|
||||
|
||||
WIDGET_FOR_EACH_CHILD_BEGIN_R(widget, iter, i)
|
||||
if (iter && iter != child && tk_str_eq(iter->vt->type, WIDGET_TYPE_SCROLL_VIEW)) {
|
||||
list_view_h->scroll_view = iter;
|
||||
scroll_view->on_layout_children = list_view_h_on_scroll_view_layout_children;
|
||||
break;
|
||||
}
|
||||
WIDGET_FOR_EACH_CHILD_END();
|
||||
}
|
||||
|
||||
return RET_CONTINUE;
|
||||
}
|
||||
|
||||
widget_t* list_view_h_create(widget_t* parent, xy_t x, xy_t y, wh_t w, wh_t h) {
|
||||
return widget_create(parent, TK_REF_VTABLE(list_view_h), x, y, w, h);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user