mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-12-01 19:49:11 +08:00
change dialog toast to non-modal
This commit is contained in:
parent
5c88506dcb
commit
c6af8af130
@ -315,7 +315,13 @@ static ret_t on_paint_vgcanvas(void* ctx, event_t* e) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
static ret_t on_timer_show_toast(const timer_info_t* info) {
|
||||
static ret_t on_timer_show_toast_when_opening(const timer_info_t* info) {
|
||||
dialog_toast("Hello AWTK!\nThis is a toast(2)!", 2000);
|
||||
|
||||
return RET_REMOVE;
|
||||
}
|
||||
|
||||
static ret_t on_timer_show_toast_when_closing(const timer_info_t* info) {
|
||||
dialog_toast("Hello AWTK!\nThis is a toast(3)!", 2000);
|
||||
|
||||
return RET_REMOVE;
|
||||
@ -335,9 +341,9 @@ static ret_t on_open_window(void* ctx, event_t* e) {
|
||||
const char* name = (const char*)ctx;
|
||||
|
||||
if (tk_str_eq(name, "toast")) {
|
||||
timer_add(on_timer_show_toast, NULL, 0);
|
||||
dialog_toast("Hello AWTK!\nThis is a toast(1)!", 2000);
|
||||
dialog_toast("Hello AWTK!\nThis is a toast(2)!", 2000);
|
||||
timer_add(on_timer_show_toast_when_opening, NULL, 0);
|
||||
timer_add(on_timer_show_toast_when_closing, NULL, 4700);
|
||||
dialog_toast("Hello AWTK!\nThis is a toast(1)!", 4000);
|
||||
} else if (tk_str_eq(name, "info")) {
|
||||
dialog_info("info", "hello awtk");
|
||||
} else if (tk_str_eq(name, "warn")) {
|
||||
|
@ -4,6 +4,7 @@
|
||||
* 回退widget\_to\_loacl的修改(感谢智明提供补丁)
|
||||
* [关于自定义控件的offset的使用注意事项](how_to_use_offset_in_custom_widget.md)(感谢智明提供补丁)
|
||||
* 修复API注释错误(感谢俊圣提供补丁)
|
||||
* dialog_toast修改为非模态窗口,更新demouiold中对应的示例(感谢泽武提供补丁)
|
||||
|
||||
2023/02/14
|
||||
* 修复fscript注释错误(感谢俊圣提供补丁)
|
||||
|
@ -203,7 +203,7 @@ ret_t dialog_toast(const char* text, uint32_t duration) {
|
||||
return_value_if_fail(dialog_toast != NULL, RET_OOM);
|
||||
|
||||
ENSURE(dialog_toast_push_message(dialog_toast, text, duration) != NULL);
|
||||
return dialog_toast_model(dialog_toast);
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_t dialog_info(const char* title, const char* text) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* 该文件的功能是服务于 dialog_toast 函数,dialog_toast 函数为仿照 android 的 showToast 函数的功能开发的。
|
||||
* 该文件的功能是服务于 dialog_toast 函数,dialog_toast 函数为仿照 android 的 showToast 函数的功能开发的,但此处的 dialog_toast 为非模态对话框。
|
||||
* dialog_toast 函数的功能分别是:
|
||||
* 1,按照时间长度显示用户输入文字信息。
|
||||
* 2,当同时有多出调用地方调用 dialog_toast 函数的显示原则为:
|
||||
@ -183,21 +183,16 @@ static ret_t dialog_toast_quit(dialog_toast_t* dialog_toast, bool_t time_up) {
|
||||
timer_remove(dialog_toast->curr_timer_id);
|
||||
dialog_toast->curr_timer_id = TK_INVALID_ID;
|
||||
}
|
||||
#ifndef AWTK_WEB
|
||||
main_loop_quit(main_loop());
|
||||
#endif
|
||||
}
|
||||
first = FALSE;
|
||||
}
|
||||
dialog_toast->is_empty = dialog_toast->message_list.size == 0;
|
||||
}while (message_list->size > 0);
|
||||
|
||||
#ifdef AWTK_WEB
|
||||
/* 因为 web 状态下,不支持模态,所以当队列中没有信息了,就马上退出 dialog */
|
||||
if (dialog_toast->is_empty) {
|
||||
dialog_toast_close(dialog_toast);
|
||||
}
|
||||
#endif
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@ -354,7 +349,7 @@ static dialog_toast_message_t* dialog_toast_push_message(dialog_toast_t* dialog_
|
||||
|
||||
/* 在关闭 dialog 动画期间不显示消息,等完成关闭动画后重新创建 dialog 再显示消息 */
|
||||
if (!dialog_toast->is_closing && !dialog_toast->is_opening) {
|
||||
ret = dialog_toast_set_curr_message(dialog_toast, message, duration, FALSE);
|
||||
ret = dialog_toast_set_curr_message(dialog_toast, message, duration, TRUE);
|
||||
goto_error_if_fail(ret == RET_OK);
|
||||
}
|
||||
|
||||
@ -371,17 +366,3 @@ error:
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static ret_t dialog_toast_model(dialog_toast_t* dialog_toast) {
|
||||
return_value_if_fail(dialog_toast != NULL && dialog_toast->toast != NULL, RET_BAD_PARAMS);
|
||||
#ifdef AWTK_WEB
|
||||
log_debug("awtk web not support dialog_modal\n");
|
||||
return RET_FAIL;
|
||||
#else
|
||||
log_debug("%s run\n", __FUNCTION__);
|
||||
main_loop_run(main_loop());
|
||||
log_debug("%s quit\n", __FUNCTION__);
|
||||
dialog_toast_close(dialog_toast);
|
||||
return RET_OK;
|
||||
#endif /*AWTK_WEB*/
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user