Skip to content

Commit f058916

Browse files
committed
feat(gui): change the call timing and parameter list for the runtask()
BREAKING CHANGE: The runtask() method takes two arguments and is called before each task is processed.
1 parent 2511b9a commit f058916

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

include/LCUI/gui/widget_base.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ typedef struct LCUI_WidgetPrototypeRec_ *LCUI_WidgetPrototype;
132132
typedef const struct LCUI_WidgetPrototypeRec_ *LCUI_WidgetPrototypeC;
133133

134134
typedef void(*LCUI_WidgetFunction)(LCUI_Widget);
135+
typedef void(*LCUI_WidgetTaskHandler)(LCUI_Widget, int);
135136
typedef void(*LCUI_WidgetResizer)(LCUI_Widget, float*, float*);
136137
typedef void(*LCUI_WidgetAttrSetter)(LCUI_Widget, const char*, const char*);
137138
typedef void(*LCUI_WidgetTextSetter)(LCUI_Widget, const char*);
@@ -146,7 +147,7 @@ typedef struct LCUI_WidgetPrototypeRec_ {
146147
LCUI_WidgetFunction refresh; /**< 数据刷新函数 */
147148
LCUI_WidgetFunction destroy; /**< 析构函数 */
148149
LCUI_WidgetFunction update; /**< 样式处理函数 */
149-
LCUI_WidgetFunction runtask; /**< 自定义任务处理函数 */
150+
LCUI_WidgetTaskHandler runtask; /**< 自定义任务处理函数 */
150151
LCUI_WidgetAttrSetter setattr; /**< 属性设置函数 */
151152
LCUI_WidgetTextSetter settext; /**< 文本内容设置函数 */
152153
LCUI_WidgetPropertyBinder bindprop; /**< 属性绑定函数 */

src/gui/widget_task.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,19 +640,22 @@ static void Widget_UpdateSelf(LCUI_Widget w, LCUI_WidgetTaskContext ctx)
640640

641641
Widget_BeginDiff(w, ctx);
642642
states = w->task.states;
643-
if (states[LCUI_WTASK_USER] && w->proto && w->proto->runtask) {
644-
states[LCUI_WTASK_USER] = FALSE;
645-
w->proto->runtask(w);
646-
}
647643
w->task.for_self = FALSE;
648644
for (i = 0; i < LCUI_WTASK_REFLOW; ++i) {
649645
if (states[i]) {
646+
if (w->proto && w->proto->runtask) {
647+
w->proto->runtask(w, i);
648+
}
650649
states[i] = FALSE;
651650
if (self.handlers[i]) {
652651
self.handlers[i](w);
653652
}
654653
}
655654
}
655+
if (states[LCUI_WTASK_USER] && w->proto && w->proto->runtask) {
656+
states[LCUI_WTASK_USER] = FALSE;
657+
w->proto->runtask(w, LCUI_WTASK_USER);
658+
}
656659
Widget_EndDiff(w, ctx);
657660
Widget_AddState(w, LCUI_WSTATE_UPDATED);
658661
}

0 commit comments

Comments
 (0)