From cfc811900df13e21d8ab9b2fbedc940d2b3e47d5 Mon Sep 17 00:00:00 2001 From: Gabor Kiss-Vamosi Date: Thu, 12 Jul 2018 18:18:43 +0200 Subject: [PATCH] send LV_SIGNAL_LONG_PRESS on LV_GROUP_KEY_ENTER long press --- lv_core/lv_indev.c | 20 +++++++++++++------- lv_fonts/lv_fonts.mk | 1 + lv_objx/lv_btn.c | 5 +++-- lv_themes/lv_themes.mk | 1 + 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lv_core/lv_indev.c b/lv_core/lv_indev.c index c68f897b7..f0279df42 100644 --- a/lv_core/lv_indev.c +++ b/lv_core/lv_indev.c @@ -336,12 +336,18 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) else if(data->state == LV_INDEV_STATE_PR && i->proc.last_state == LV_INDEV_STATE_PR) { if(data->key == LV_GROUP_KEY_ENTER && i->proc.long_pr_sent == 0 && - lv_tick_elaps(i->proc.pr_timestamp) > LV_INDEV_LONG_PRESS_TIME && - i->group->edit_mode_en) + lv_tick_elaps(i->proc.pr_timestamp) > LV_INDEV_LONG_PRESS_TIME ) { - i->group->editing = i->group->editing ? 0 : 1; /*Change between edit and navigate*/ - lv_obj_t * focused = lv_group_get_focused(i->group); - if(focused) lv_obj_invalidate(focused); + lv_obj_t * focused = lv_group_get_focused(i->group); + /*If edit mode is enabled then change between edit and navigate on long press*/ + if (i->group->edit_mode_en) { + i->group->editing = i->group->editing ? 0 : 1; + if(focused) lv_obj_invalidate(focused); + } + /*If edit mode is disabled just send a long press signal*/ + else { + focused->signal_func(focused, LV_SIGNAL_LONG_PRESS, indev_act); + } i->proc.long_pr_sent = 1; } } @@ -355,9 +361,9 @@ static void indev_keypad_proc(lv_indev_t * i, lv_indev_data_t * data) } else if(data->key == LV_GROUP_KEY_PREV) { lv_group_focus_prev(i->group); } else if(data->key == LV_GROUP_KEY_ENTER && - (i->proc.long_pr_sent || (i->group->editing == 0 && i->group->edit_mode_en))) + (i->group->edit_mode_en && i->group->editing == 0)) { - /*Do nothing. Don't send the ENTER if pressed long was sent or in navigation mode*/ + /*Do nothing. Don't send the ENTER if in navigation mode*/ } else { lv_group_send_data(i->group, data->key); } diff --git a/lv_fonts/lv_fonts.mk b/lv_fonts/lv_fonts.mk index ba59d0f27..8c9cde836 100644 --- a/lv_fonts/lv_fonts.mk +++ b/lv_fonts/lv_fonts.mk @@ -1,3 +1,4 @@ +CSRCS += lv_font_builtin.c CSRCS += lv_font_dejavu_10.c CSRCS += lv_font_dejavu_20.c CSRCS += lv_font_dejavu_30.c diff --git a/lv_objx/lv_btn.c b/lv_objx/lv_btn.c index 49f312927..da999cc66 100644 --- a/lv_objx/lv_btn.c +++ b/lv_objx/lv_btn.c @@ -384,10 +384,11 @@ static bool lv_btn_design(lv_obj_t * btn, const lv_area_t * mask, lv_design_mode ancestor_design(btn, mask, mode); #if USE_LV_ANIMATION if(btn != ink_obj) { - lv_draw_rect(&btn->coords, mask,btn->style_p, LV_OPA_COVER); + lv_style_t * style = lv_obj_get_style(btn); + lv_draw_rect(&btn->coords, mask, style, LV_OPA_COVER); } else { lv_btn_ext_t * ext = lv_obj_get_ext_attr(btn); - lv_opa_t opa_scale = lv_obj_get_opa_scale(obj); + lv_opa_t opa_scale = lv_obj_get_opa_scale(btn); /*Draw the normal button*/ lv_draw_rect(&btn->coords, mask, ext->styles[ink_bg_state], opa_scale); diff --git a/lv_themes/lv_themes.mk b/lv_themes/lv_themes.mk index 7e3b2a29c..4b8c55a3e 100644 --- a/lv_themes/lv_themes.mk +++ b/lv_themes/lv_themes.mk @@ -5,6 +5,7 @@ CSRCS += lv_theme_night.c CSRCS += lv_theme_templ.c CSRCS += lv_theme_zen.c CSRCS += lv_theme_material.c +CSRCS += lv_theme_mono.c DEPPATH += --dep-path lvgl/lv_themes