diff --git a/src/lv_core/lv_obj.c b/src/lv_core/lv_obj.c index e801da845..114dfa3cc 100644 --- a/src/lv_core/lv_obj.c +++ b/src/lv_core/lv_obj.c @@ -2580,7 +2580,7 @@ const void * _lv_obj_get_style_ptr(const lv_obj_t * obj, uint8_t part, lv_style_ switch(prop) { case LV_STYLE_TEXT_FONT: case LV_STYLE_VALUE_FONT: - return LV_THEME_DEFAULT_FONT_NORMAL; + return lv_theme_get_font_normal(); #if LV_USE_ANIMATION case LV_STYLE_TRANSITION_PATH: return &lv_anim_path_def; diff --git a/src/lv_themes/lv_theme.h b/src/lv_themes/lv_theme.h index 0984c026c..30ec6c9c5 100644 --- a/src/lv_themes/lv_theme.h +++ b/src/lv_themes/lv_theme.h @@ -141,6 +141,11 @@ typedef enum { LV_THEME_WIN, LV_THEME_WIN_BTN, /*The buttons are initialized separately*/ #endif + + _LV_THEME_BUILTIN_LAST, + _LV_THEME_CUSTOM_START = _LV_THEME_BUILTIN_LAST, + _LV_THEME_CUSTOM_LAST = 0xFFFF, + } lv_theme_style_t; typedef struct { diff --git a/src/lv_themes/lv_theme_material.c b/src/lv_themes/lv_theme_material.c index b9c6be6b9..399f3295a 100644 --- a/src/lv_themes/lv_theme_material.c +++ b/src/lv_themes/lv_theme_material.c @@ -1205,10 +1205,10 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) lv_style_list_add_style(list, &bg); lv_style_list_add_style(list, &list_bg); - lv_obj_clean_style_list(obj, LV_LIST_PART_SCRL); + lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE); - lv_obj_clean_style_list(obj, LV_LIST_PART_SCRLBAR); - list = lv_obj_get_style_list(obj, LV_LIST_PART_SCRLBAR); + lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR); + list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR); lv_style_list_add_style(list, &sb); break; diff --git a/src/lv_themes/lv_theme_mono.c b/src/lv_themes/lv_theme_mono.c index 6740c0222..ff90ac08f 100644 --- a/src/lv_themes/lv_theme_mono.c +++ b/src/lv_themes/lv_theme_mono.c @@ -850,10 +850,10 @@ void lv_theme_mono_apply(lv_obj_t * obj, lv_theme_style_t name) lv_style_list_add_style(list, &style_bg); lv_style_list_add_style(list, &style_pad_none); - lv_obj_clean_style_list(obj, LV_LIST_PART_SCRL); + lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE); - lv_obj_clean_style_list(obj, LV_LIST_PART_SCRLBAR); - list = lv_obj_get_style_list(obj, LV_LIST_PART_SCRLBAR); + lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR); + list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR); lv_style_list_add_style(list, &style_sb); break; diff --git a/src/lv_themes/lv_theme_template.c b/src/lv_themes/lv_theme_template.c index 5c45eb38d..37575e7d8 100644 --- a/src/lv_themes/lv_theme_template.c +++ b/src/lv_themes/lv_theme_template.c @@ -24,7 +24,7 @@ /********************** * STATIC PROTOTYPES **********************/ -static void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name); +static void theme_apply(lv_obj_t * obj, lv_theme_style_t name); /********************** @@ -377,13 +377,13 @@ lv_theme_t * lv_theme_template_init(lv_color_t color_primary, lv_color_t color_s table_init(); win_init(); - theme.apply_xcb = lv_theme_material_apply; + theme.apply_xcb = theme_apply; return &theme; } -void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) +void theme_apply(lv_obj_t * obj, lv_theme_style_t name) { lv_style_list_t * list; @@ -703,11 +703,11 @@ void lv_theme_material_apply(lv_obj_t * obj, lv_theme_style_t name) list = lv_obj_get_style_list(obj, LV_LIST_PART_BG); lv_style_list_add_style(list, &style_bg); - lv_obj_clean_style_list(obj, LV_LIST_PART_SCRL); - list = lv_obj_get_style_list(obj, LV_LIST_PART_SCRL); + lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLABLE); + list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLABLE); - lv_obj_clean_style_list(obj, LV_LIST_PART_SCRLBAR); - list = lv_obj_get_style_list(obj, LV_LIST_PART_SCRLBAR); + lv_obj_clean_style_list(obj, LV_LIST_PART_SCROLLBAR); + list = lv_obj_get_style_list(obj, LV_LIST_PART_SCROLLBAR); lv_style_list_add_style(list, &style_bg); break; diff --git a/src/lv_widgets/lv_list.c b/src/lv_widgets/lv_list.c index b6f1c98bc..483551d08 100644 --- a/src/lv_widgets/lv_list.c +++ b/src/lv_widgets/lv_list.c @@ -836,10 +836,10 @@ static lv_style_list_t * lv_list_get_style(lv_obj_t * list, uint8_t part) case LV_LIST_PART_BG: style_dsc_p = &list->style_list; break; - case LV_LIST_PART_SCRL: + case LV_LIST_PART_SCROLLABLE: style_dsc_p = &ext->page.scrl->style_list; break; - case LV_LIST_PART_SCRLBAR: + case LV_LIST_PART_SCROLLBAR: style_dsc_p = &ext->page.scrlbar.style; break; #if LV_USE_ANIMATION diff --git a/src/lv_widgets/lv_list.h b/src/lv_widgets/lv_list.h index 0c539cf46..9de27ac68 100644 --- a/src/lv_widgets/lv_list.h +++ b/src/lv_widgets/lv_list.h @@ -57,10 +57,10 @@ typedef struct { /** List styles. */ enum { LV_LIST_PART_BG = LV_PAGE_PART_BG, /**< List background style */ - LV_LIST_PART_SCRLBAR = LV_PAGE_PART_SCROLLBAR, /**< List scrollbar style. */ + LV_LIST_PART_SCROLLBAR = LV_PAGE_PART_SCROLLBAR, /**< List scrollbar style. */ LV_LIST_PART_EDGE_FLASH = LV_PAGE_PART_EDGE_FLASH, /**< List edge flash style. */ _LV_LIST_PART_VIRTUAL_LAST = _LV_PAGE_PART_VIRTUAL_LAST, - LV_LIST_PART_SCRL = LV_PAGE_PART_SCROLLABLE, /**< List scrollable area style. */ + LV_LIST_PART_SCROLLABLE = LV_PAGE_PART_SCROLLABLE, /**< List scrollable area style. */ _LV_LIST_PART_REAL_LAST = _LV_PAGE_PART_REAL_LAST, }; typedef uint8_t lv_list_style_t; diff --git a/src/lv_widgets/lv_page.c b/src/lv_widgets/lv_page.c index a3af010bf..7aa0a00e6 100644 --- a/src/lv_widgets/lv_page.c +++ b/src/lv_widgets/lv_page.c @@ -953,14 +953,37 @@ static lv_res_t lv_page_scrollable_signal(lv_obj_t * scrl, lv_signal_t sign, voi } } else if(sign == LV_SIGNAL_DRAG_END) { - /*Scroll propagation is finished on drag end*/ if(page_ext->scroll_prop_obj) { lv_obj_t * scroller_page = page_ext->scroll_prop_obj; + lv_page_ext_t * scroller_page_ext = lv_obj_get_ext_attr(scroller_page); page_ext->scroll_prop_obj = NULL; lv_obj_set_drag_parent(scroller_page, false); lv_obj_set_drag_parent(lv_page_get_scrl(scroller_page), false); + /*Hide scrollbars if required*/ + if(scroller_page_ext->scrlbar.mode == LV_SCRLBAR_MODE_DRAG) { + lv_area_t sb_area_tmp; + if(scroller_page_ext->scrlbar.hor_draw) { + lv_area_copy(&sb_area_tmp, &scroller_page_ext->scrlbar.hor_area); + sb_area_tmp.x1 += scroller_page->coords.x1; + sb_area_tmp.y1 += scroller_page->coords.y1; + sb_area_tmp.x2 += scroller_page->coords.x1; + sb_area_tmp.y2 += scroller_page->coords.y1; + lv_obj_invalidate_area(scroller_page, &sb_area_tmp); + scroller_page_ext->scrlbar.hor_draw = 0; + } + if(scroller_page_ext->scrlbar.ver_draw) { + lv_area_copy(&sb_area_tmp, &scroller_page_ext->scrlbar.ver_area); + sb_area_tmp.x1 += scroller_page->coords.x1; + sb_area_tmp.y1 += scroller_page->coords.y1; + sb_area_tmp.x2 += scroller_page->coords.x1; + sb_area_tmp.y2 += scroller_page->coords.y1; + lv_obj_invalidate_area(scroller_page, &sb_area_tmp); + scroller_page_ext->scrlbar.ver_draw = 0; + } + } + /*The scrolling can be chained so stop all of them*/ lv_page_ext_t * scroller_ext = lv_obj_get_ext_attr(scroller_page); while(scroller_ext->scroll_prop_obj) { @@ -1150,7 +1173,11 @@ static void scrl_reposition(lv_obj_t * page) if(refr_x || refr_y) { lv_obj_set_pos(scrl, new_x, new_y); } - scrlbar_refresh(page); + + lv_page_ext_t * ext = lv_obj_get_ext_attr(page); + + /*The scrollbars are important only if they are visible now*/ + if(ext->scrlbar.hor_draw || ext->scrlbar.ver_draw) scrlbar_refresh(page); } /** @@ -1209,21 +1236,6 @@ static void scrlbar_refresh(lv_obj_t * page) lv_obj_invalidate_area(page, &sb_area_tmp); } - if(ext->scrlbar.mode == LV_SCRLBAR_MODE_DRAG) { - lv_obj_t * indev_obj = lv_indev_get_obj_act(); - - if(indev_obj == NULL) return; - while(indev_obj && lv_obj_get_drag_parent(indev_obj)) { - indev_obj = lv_obj_get_parent(indev_obj); - } - - if(indev_obj != scrl) { - ext->scrlbar.hor_draw = 0; - ext->scrlbar.ver_draw = 0; - return; - } - } - /*Full sized horizontal scrollbar*/ if(scrl_w <= obj_w - bg_left - bg_right) { lv_area_set_width(&ext->scrlbar.hor_area, obj_w - 2 * sb_hor_pad);