From d02297160cf7ec4a8d25dea33c183d9ee16951df Mon Sep 17 00:00:00 2001 From: lixianjing Date: Fri, 1 Apr 2022 11:32:29 +0800 Subject: [PATCH] improve edit/combox/mledit empty style --- docs/changes.md | 3 +++ src/ext_widgets/mledit/mledit.c | 9 +++++---- src/widgets/combo_box.c | 10 ++++++---- src/widgets/edit.c | 9 +++++---- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/docs/changes.md b/docs/changes.md index f68f3e1df..280ea6bbb 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -1,4 +1,7 @@ # 最新动态 +2022/04/01 + * 完善给edit、mledit和combo\_box增加了empty\_over状态(感谢雨欣提供补丁) + 2022/03/31 * 增加带统计功能的stream (感谢林福提供) * 增加移除和替换 qaction 的 action\_darray\_thread(感谢林福提供) diff --git a/src/ext_widgets/mledit/mledit.c b/src/ext_widgets/mledit/mledit.c index bf9e8d812..d1c0e16d0 100644 --- a/src/ext_widgets/mledit/mledit.c +++ b/src/ext_widgets/mledit/mledit.c @@ -510,8 +510,6 @@ static ret_t mledit_update_status(widget_t* widget) { if (widget->text.size == 0) { if (widget->focused) { widget_set_state(widget, WIDGET_STATE_EMPTY_FOCUS); - } else if (tk_str_eq(widget->state, WIDGET_STATE_OVER)) { - widget_set_state(widget, WIDGET_STATE_EMPTY_OVER); } else { widget_set_state(widget, WIDGET_STATE_EMPTY); } @@ -618,8 +616,11 @@ static ret_t mledit_on_event(widget_t* widget, event_t* e) { break; } case EVT_POINTER_ENTER: - widget_set_state(widget, WIDGET_STATE_OVER); - mledit_update_status(widget); + if (widget->text.size == 0) { + widget_set_state(widget, WIDGET_STATE_EMPTY_OVER); + } else { + widget_set_state(widget, WIDGET_STATE_OVER); + } break; case EVT_POINTER_DOWN: { pointer_event_t evt = *(pointer_event_t*)e; diff --git a/src/widgets/combo_box.c b/src/widgets/combo_box.c index 9c25abb60..daf3836d7 100644 --- a/src/widgets/combo_box.c +++ b/src/widgets/combo_box.c @@ -101,8 +101,6 @@ static ret_t combo_box_update_status(widget_t* widget) { if (widget->text.size == 0) { if (widget->focused) { widget_set_state(widget, WIDGET_STATE_EMPTY_FOCUS); - } else if (tk_str_eq(widget->state, WIDGET_STATE_OVER)) { - widget_set_state(widget, WIDGET_STATE_EMPTY_OVER); } else { widget_set_state(widget, WIDGET_STATE_EMPTY); } @@ -434,8 +432,12 @@ static ret_t combo_box_on_event(widget_t* widget, event_t* e) { return combo_box_update_status(widget); break; case EVT_POINTER_ENTER: - widget_set_state(widget, WIDGET_STATE_OVER); - return combo_box_update_status(widget); + if (widget->text.size == 0) { + widget_set_state(widget, WIDGET_STATE_EMPTY_OVER); + } else { + widget_set_state(widget, WIDGET_STATE_OVER); + } + return RET_OK; break; default: break; diff --git a/src/widgets/edit.c b/src/widgets/edit.c index 4bcae7034..27831d736 100644 --- a/src/widgets/edit.c +++ b/src/widgets/edit.c @@ -496,8 +496,6 @@ static ret_t edit_update_status(widget_t* widget) { if (widget->text.size == 0) { if (widget->focused) { widget_set_state(widget, WIDGET_STATE_EMPTY_FOCUS); - } else if (tk_str_eq(widget->state, WIDGET_STATE_OVER)) { - widget_set_state(widget, WIDGET_STATE_EMPTY_OVER); } else { widget_set_state(widget, WIDGET_STATE_EMPTY); } @@ -915,8 +913,11 @@ ret_t edit_on_event(widget_t* widget, event_t* e) { edit_update_status(widget); break; case EVT_POINTER_ENTER: - widget_set_state(widget, WIDGET_STATE_OVER); - edit_update_status(widget); + if (widget->text.size == 0) { + widget_set_state(widget, WIDGET_STATE_EMPTY_OVER); + } else { + widget_set_state(widget, WIDGET_STATE_OVER); + } break; default: break;