diff --git a/lv_app/lv_app.c b/lv_app/lv_app.c index 1262dcf22..87f6e8e1b 100644 --- a/lv_app/lv_app.c +++ b/lv_app/lv_app.c @@ -19,6 +19,7 @@ #include "../lv_appx/lv_app_example.h" +#include "../lv_appx/lv_app_phantom.h" #include "../lv_appx/lv_app_sysmon.h" #include "../lv_appx/lv_app_terminal.h" #include "../lv_appx/lv_app_files.h" @@ -77,7 +78,6 @@ static lv_obj_t * app_scr; /*Screen of the applications*/ #if LV_APP_DESKTOP != 0 static lv_obj_t * menuh; /*Holder of timg_bubbleshe menu on the top*/ static lv_obj_t * app_btn; /*The "Apps" button on the menu*/ -//static lv_obj_t * sys_apph; /*Holder of the system app. buttons*/ static lv_obj_t * sc_page; /*A page for the shortcuts */ #endif @@ -124,6 +124,12 @@ void lv_app_init(void) *dsc = lv_app_example_init(); #endif +#if USE_LV_APP_PHANTOM != 0 + dsc = ll_ins_head(&app_dsc_ll); + *dsc = lv_app_phantom_init(); +#endif + + #if USE_LV_APP_SYSMON != 0 dsc = ll_ins_head(&app_dsc_ll); *dsc = lv_app_sysmon_init(); @@ -185,7 +191,7 @@ void lv_app_close(lv_app_inst_t * app) lv_app_con_del(app, NULL); lv_app_con_del(NULL, app); - app->dsc->app_close(app); + if(app->dsc->app_close != NULL) app->dsc->app_close(app); memset(app->app_data, 0, app->dsc->app_data_size); dm_free(app->app_data); @@ -203,6 +209,8 @@ void lv_app_close(lv_app_inst_t * app) lv_obj_t * lv_app_sc_open(lv_app_inst_t * app) { + if(app->dsc->sc_open == NULL) return NULL; + /*Create a basic shortcut*/ #if LV_APP_DESKTOP != 0 app->sc = lv_btn_create(sc_page, NULL); @@ -254,6 +262,7 @@ lv_obj_t * lv_app_sc_open(lv_app_inst_t * app) void lv_app_sc_close(lv_app_inst_t * app) { if(app->sc == NULL) return; + if(app->dsc->sc_close != NULL) app->dsc->sc_close(app); lv_obj_del(app->sc); app->sc = NULL; app->sc_title = NULL; @@ -275,22 +284,24 @@ lv_obj_t * lv_app_win_open(lv_app_inst_t * app) app_list = NULL; } + if(app->dsc->win_open == NULL) return NULL; + app->win = lv_win_create(lv_scr_act(), NULL); lv_obj_set_free_p(app->win, app); lv_obj_set_style(lv_win_get_header(app->win), &app_style.win_header); lv_win_set_title(app->win, app->dsc->name); - - lv_win_set_style_cbtn(app->win, &app_style.win_cbtn_rel, &app_style.win_cbtn_pr); + lv_page_set_sb_mode(lv_win_get_page(app->win), LV_PAGE_SB_MODE_ON); + lv_win_set_styles_cbtn(app->win, &app_style.win_cbtn_rel, &app_style.win_cbtn_pr); if(app->dsc->conf_open != NULL) { - lv_win_add_ctrl_btn(app->win, SYMBOL_SETUP, lv_app_win_conf_action); + lv_win_add_cbtn(app->win, SYMBOL_SETUP, lv_app_win_conf_action); } - lv_win_add_ctrl_btn(app->win, SYMBOL_DOWN, lv_app_win_minim_action); - lv_win_add_ctrl_btn(app->win, SYMBOL_CLOSE,lv_app_win_close_action); + lv_win_add_cbtn(app->win, SYMBOL_DOWN, lv_app_win_minim_action); + lv_win_add_cbtn(app->win, SYMBOL_CLOSE,lv_app_win_close_action); app->win_data = dm_alloc(app->dsc->win_data_size); - app->dsc->win_open(app, app->win); + app->dsc->win_open(app, app->win); return app->win; } @@ -303,7 +314,9 @@ void lv_app_win_close(lv_app_inst_t * app) { if(app->win == NULL) return; - lv_app_kb_close(false); + lv_app_kb_close(false); + + if(app->dsc->win_close != NULL) app->dsc->win_close(app); lv_obj_del(app->win); app->win = NULL; @@ -516,16 +529,6 @@ static void lv_app_init_desktop(void) lv_label_set_text(app_label, "Apps"); lv_obj_set_pos(app_btn, 0, 0); lv_obj_set_pos(menuh, 0, 0); -/* - sys_apph = lv_cont_create(menuh, NULL); - lv_cont_set_layout(sys_apph, LV_CONT_LAYOUT_ROW_M); - lv_cont_set_fit(sys_apph, true, false); - lv_obj_set_style(sys_apph, lv_rects_get(LV_RECTS_TRANSP, NULL)); - lv_obj_t * clock = lv_label_create(sys_apph, NULL); - lv_obj_set_style(clock, &app_style.menu_btn_label); - lv_label_set_text(clock, "20:17"); - - lv_obj_align(sys_apph, NULL, LV_ALIGN_IN_RIGHT_MID, 0, 0);*/ /*Shortcut area*/ sc_page = lv_page_create(lv_scr_act(), NULL); @@ -736,7 +739,7 @@ static lv_action_res_t lv_app_sc_lpr_action(lv_obj_t * sc, lv_dispi_t * dispi) */ static lv_action_res_t lv_app_win_close_action(lv_obj_t * close_btn, lv_dispi_t * dispi) { - lv_obj_t * win = lv_win_get_from_ctrl_btn(close_btn); + lv_obj_t * win = lv_win_get_from_cbtn(close_btn); lv_app_inst_t * app = lv_obj_get_free_p(win); lv_app_kb_close(false); @@ -771,7 +774,7 @@ static lv_action_res_t lv_app_win_close_action(lv_obj_t * close_btn, lv_dispi_t */ static lv_action_res_t lv_app_win_minim_action(lv_obj_t * minim_btn, lv_dispi_t * dispi) { - lv_obj_t * win = lv_win_get_from_ctrl_btn(minim_btn); + lv_obj_t * win = lv_win_get_from_cbtn(minim_btn); lv_app_inst_t * app = lv_obj_get_free_p(win); lv_app_kb_close(false); @@ -797,7 +800,7 @@ static lv_action_res_t lv_app_win_conf_action(lv_obj_t * set_btn, lv_dispi_t * d app_list = NULL; } - lv_obj_t * win = lv_win_get_from_ctrl_btn(set_btn); + lv_obj_t * win = lv_win_get_from_cbtn(set_btn); lv_app_inst_t * app = lv_obj_get_free_p(win); app->conf_win = lv_win_create(lv_scr_act(), NULL); @@ -805,9 +808,9 @@ static lv_action_res_t lv_app_win_conf_action(lv_obj_t * set_btn, lv_dispi_t * d char buf[256]; sprintf(buf, "%s settings", app->dsc->name); - lv_win_add_ctrl_btn(app->conf_win, SYMBOL_CLOSE ,lv_win_close_action); + lv_win_add_cbtn(app->conf_win, SYMBOL_CLOSE ,lv_win_close_action); lv_win_set_title(app->conf_win, buf); - lv_win_set_style_cbtn(app->conf_win, &app_style.win_cbtn_rel, &app_style.win_cbtn_pr); + lv_win_set_styles_cbtn(app->conf_win, &app_style.win_cbtn_rel, &app_style.win_cbtn_pr); lv_obj_t * scrl = lv_page_get_scrl(lv_win_get_page(app->conf_win)); lv_cont_set_layout(scrl, LV_CONT_LAYOUT_COL_L); @@ -840,8 +843,6 @@ static lv_action_res_t lv_app_win_open_anim_create(lv_app_inst_t * app) lv_obj_get_cords(app->sc, &cords); } - - /*Temporally set a simpler style for the window during the animation*/ lv_obj_t * win_page = lv_win_get_page(app->win); lv_page_set_sb_mode(win_page, LV_PAGE_SB_MODE_OFF); @@ -917,12 +918,6 @@ static lv_action_res_t lv_app_win_minim_anim_create(lv_app_inst_t * app) lv_obj_t * win_page = lv_win_get_page(app->win); lv_page_set_sb_mode(win_page, LV_PAGE_SB_MODE_OFF); - /*Hide some elements to speed up the animation*/ - lv_obj_set_hidden(((lv_win_ext_t *)app->win->ext)->btnh, true); - lv_obj_set_hidden(((lv_win_ext_t *)app->win->ext)->title, true); - lv_obj_set_hidden(lv_page_get_scrl(win_page), true); - - /*Hide some elements to speed up the animation*/ lv_obj_set_hidden(((lv_win_ext_t *)app->win->ext)->btnh, true); lv_obj_set_hidden(((lv_win_ext_t *)app->win->ext)->title, true); @@ -981,6 +976,8 @@ static void lv_app_win_open_anim_cb(lv_obj_t * app_win) lv_obj_set_hidden(((lv_win_ext_t *)app_win->ext)->btnh, false); lv_obj_set_hidden(((lv_win_ext_t *)app_win->ext)->title, false); lv_obj_set_hidden(lv_page_get_scrl(win_page), false); + + lv_page_set_sb_mode(win_page, LV_PAGE_SB_MODE_AUTO); } /** diff --git a/lv_app/lv_app_util/lv_app_fsel.c b/lv_app/lv_app_util/lv_app_fsel.c index d8246b5d2..0594613d0 100644 --- a/lv_app/lv_app_util/lv_app_fsel.c +++ b/lv_app/lv_app_util/lv_app_fsel.c @@ -47,6 +47,7 @@ static lv_obj_t * fsel_win; static lv_obj_t * fsel_list; static void * fsel_param; static void (*fsel_ok_action)(void *, const char *); +static lv_style_t style_btn_symbol; /********************** * MACROS @@ -61,7 +62,8 @@ static void (*fsel_ok_action)(void *, const char *); */ void lv_app_fsel_init(void) { - //TODO lv_lists_get(LV_LISTS_TRANSP, &fsel_lists); + lv_style_get(LV_STYLE_BTN_REL, &style_btn_symbol); + style_btn_symbol.font = font_get(LV_IMG_DEF_SYMBOL_FONT); } /** @@ -90,11 +92,14 @@ void lv_app_fsel_open(const char * path, const char * filter, void * param, void /*Check filter: NULL and "" mean no filtering*/ if(fsel_filter == NULL) fsel_filter = ""; + lv_app_style_t * app_style = lv_app_style_get(); + /*Create a window for the File selector*/ fsel_win = lv_win_create(lv_scr_act(), NULL); lv_obj_set_size(fsel_win, LV_HOR_RES, LV_VER_RES); + lv_win_set_styles_cbtn(fsel_win, &app_style->win_cbtn_rel, &app_style->win_cbtn_pr); - lv_win_add_ctrl_btn(fsel_win, "U:/icon_close", fsel_close_action); + lv_win_add_cbtn(fsel_win, SYMBOL_CLOSE, fsel_close_action); fsel_refr(); /*Refresh the list*/ @@ -138,31 +143,32 @@ static void fsel_refr(void) /*Create a new list*/ fsel_list = lv_list_create(fsel_win, NULL); lv_obj_set_width(fsel_list, lv_win_get_width(fsel_win)); - //TODO lv_obj_set_style(fsel_list, lv_lists_get(LV_LISTS_TRANSP, NULL)); + lv_list_set_style_img(fsel_list, &style_btn_symbol); + lv_obj_set_style(lv_page_get_scrl(fsel_list), lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL)); lv_obj_set_drag_parent(fsel_list, true); lv_obj_set_drag_parent(lv_page_get_scrl(fsel_list), true); lv_cont_set_fit(fsel_list, false, true); fs_res_t res = FS_RES_OK; + lv_obj_t * liste; /*At empty path show the drivers */ if(fsel_path[0] == '\0') { char drv[16]; char buf[2]; - lv_obj_t * liste; fs_get_letters(drv); uint8_t i; for(i = 0; drv[i] != '\0'; i++) { buf[0] = drv[i]; buf[1] = '\0'; - liste = lv_list_add(fsel_list, "U:/icon_driver", buf, fsel_drv_action); + liste = lv_list_add(fsel_list, SYMBOL_DRIVE, buf, fsel_drv_action); /*Add long press action to choose the driver as a folder*/ if(fsel_filter[0] == '/') lv_btn_set_lpr_action(liste, fsel_drv_lpr_action); } } /*List the files/folders with fs interface*/ else { - lv_list_add(fsel_list, "U:/icon_up", "Up", fsel_up_action); + liste = lv_list_add(fsel_list, SYMBOL_UP, "Up", fsel_up_action); fs_readdir_t rd; res = fs_readdir_init(&rd, fsel_path); @@ -173,7 +179,7 @@ static void fsel_refr(void) /*At not first page add prev. page button */ if(fsel_file_cnt != 0) { - lv_list_add(fsel_list, "U:/icon_left", "Previous page", fsel_prev_action); + liste = lv_list_add(fsel_list, SYMBOL_LEFT, "Previous page", fsel_prev_action); } char fn[LV_APP_FSEL_FN_MAX_LEN]; @@ -182,7 +188,7 @@ static void fsel_refr(void) uint16_t file_cnt = 0; while(file_cnt <= fsel_file_cnt) { res = fs_readdir(&rd, fn); - if(res != FS_RES_OK || fn[0] == '\0'){ + if(res != FS_RES_OK){ lv_app_notice_add("Can not read the path\nin File selector"); return; } @@ -193,7 +199,7 @@ static void fsel_refr(void) while(res == FS_RES_OK && fn[0] != '\0') { if(fn[0] == '/') { /*Add a folder*/ lv_obj_t * liste; - liste = lv_list_add(fsel_list, "U:/icon_folder", &fn[1], fsel_folder_action); + liste = lv_list_add(fsel_list, SYMBOL_FOLDER, &fn[1], fsel_folder_action); /*Add long press action to choose a folder*/ if(fsel_filter[0] == '/') lv_btn_set_lpr_action(liste, fsel_folder_lpr_action); @@ -204,7 +210,7 @@ static void fsel_refr(void) else if(fsel_filter[0] == '\0' || /*No filtering or ...*/ (strcmp(fs_get_ext(fn), fsel_filter) == 0 && /*.. the filter matches*/ fsel_filter[0] != '/')) { - lv_list_add(fsel_list, "U:/icon_file", fn, fsel_file_action); + liste = lv_list_add(fsel_list, SYMBOL_FILE, fn, fsel_file_action); fsel_file_cnt ++; file_cnt ++; } @@ -214,7 +220,7 @@ static void fsel_refr(void) /*Show only LV_APP_FSEL_MAX_FILE elements and add a Next page button*/ if(fsel_file_cnt != 0 && fsel_file_cnt % LV_APP_FSEL_PAGE_SIZE == 0) { - lv_list_add(fsel_list, "U:/icon_right", "Next page", fsel_next_action); + liste = lv_list_add(fsel_list, SYMBOL_RIGHT, "Next page", fsel_next_action); break; } } @@ -297,7 +303,7 @@ static lv_action_res_t fsel_prev_action(lv_obj_t * prev, lv_dispi_t * dispi) */ static lv_action_res_t fsel_drv_action(lv_obj_t * drv, lv_dispi_t * dispi) { - sprintf(fsel_path, "%s:", lv_list_element_get_txt(drv)); + sprintf(fsel_path, "%s:", lv_list_get_element_text(drv)); fsel_file_cnt = 0; fsel_refr(); return LV_ACTION_RES_INV; @@ -311,7 +317,7 @@ static lv_action_res_t fsel_drv_action(lv_obj_t * drv, lv_dispi_t * dispi) */ static lv_action_res_t fsel_drv_lpr_action(lv_obj_t * drv, lv_dispi_t * dispi) { - sprintf(fsel_path, "%s:", lv_list_element_get_txt(drv)); + sprintf(fsel_path, "%s:", lv_list_get_element_text(drv)); if(fsel_ok_action != NULL) { fsel_ok_action(fsel_param, fsel_path); @@ -330,7 +336,7 @@ static lv_action_res_t fsel_drv_lpr_action(lv_obj_t * drv, lv_dispi_t * dispi) */ static lv_action_res_t fsel_folder_action(lv_obj_t * folder, lv_dispi_t * dispi) { - sprintf(fsel_path, "%s/%s", fsel_path, lv_list_element_get_txt(folder)); + sprintf(fsel_path, "%s/%s", fsel_path, lv_list_get_element_text(folder)); fsel_file_cnt = 0; fsel_refr(); return LV_ACTION_RES_INV; @@ -344,7 +350,7 @@ static lv_action_res_t fsel_folder_action(lv_obj_t * folder, lv_dispi_t * dispi) */ static lv_action_res_t fsel_folder_lpr_action(lv_obj_t * folder, lv_dispi_t * dispi) { - sprintf(fsel_path, "%s/%s", fsel_path, lv_list_element_get_txt(folder)); + sprintf(fsel_path, "%s/%s", fsel_path, lv_list_get_element_text(folder)); if(fsel_ok_action != NULL) { fsel_ok_action(fsel_param, fsel_path); @@ -363,7 +369,7 @@ static lv_action_res_t fsel_folder_lpr_action(lv_obj_t * folder, lv_dispi_t * di */ static lv_action_res_t fsel_file_action(lv_obj_t * file, lv_dispi_t * dispi) { - sprintf(fsel_path, "%s/%s", fsel_path, lv_list_element_get_txt(file)); + sprintf(fsel_path, "%s/%s", fsel_path, lv_list_get_element_text(file)); if(fsel_ok_action != NULL) { fsel_ok_action(fsel_param, fsel_path); diff --git a/lv_app/lv_app_util/lv_app_fsel.h b/lv_app/lv_app_util/lv_app_fsel.h index 684afc10b..4c9be142a 100644 --- a/lv_app/lv_app_util/lv_app_fsel.h +++ b/lv_app/lv_app_util/lv_app_fsel.h @@ -35,7 +35,7 @@ void lv_app_fsel_init(void); * @param filter show only files with a specific extension, e.g. "wav". * "/" means filter to folders. * @param param a free parameter which will be added to 'ok_action' - * @param ok_action an action to call when a file or folder is chosen + * @param ok_action an action to call when a file or folder is chosen (give 'param' and the path as parameters) */ void lv_app_fsel_open(const char * path, const char * filter, void * param, void (*ok_action)(void *, const char *)); diff --git a/lv_app/lv_app_util/lv_app_kb.c b/lv_app/lv_app_util/lv_app_kb.c index 5088c0e74..c666ce42d 100644 --- a/lv_app/lv_app_util/lv_app_kb.c +++ b/lv_app/lv_app_util/lv_app_kb.c @@ -63,6 +63,7 @@ static cord_t kb_ta_ori_size; static uint8_t kb_mode; static void (*kb_close_action)(lv_obj_t *); static void (*kb_ok_action)(lv_obj_t *); +static lv_style_t style_bg; static lv_style_t style_btn_rel; static lv_style_t style_btn_pr; /********************** @@ -78,8 +79,16 @@ static lv_style_t style_btn_pr; */ void lv_app_kb_init(void) { + lv_style_get(LV_STYLE_PLAIN, &style_bg); + style_bg.hpad = 0; + style_bg.vpad = 0; + style_bg.opad = 0; lv_style_get(LV_STYLE_BTN_REL, &style_btn_rel); + style_btn_rel.radius = 0; + style_btn_rel.bwidth = 1 * LV_DOWNSCALE; lv_style_get(LV_STYLE_BTN_PR, &style_btn_pr); + style_btn_pr.radius = 0; + style_btn_pr.bwidth = 1 * LV_DOWNSCALE; } /** @@ -104,6 +113,7 @@ void lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t /*Create a button matrix for the keyboard */ kb_btnm = lv_btnm_create(lv_scr_act(), NULL); + lv_obj_set_style(kb_btnm, &style_bg); lv_obj_set_size(kb_btnm, LV_HOR_RES, LV_VER_RES / 2); lv_obj_align(kb_btnm, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0); lv_btnm_set_action(kb_btnm, lv_app_kb_action); @@ -119,25 +129,29 @@ void lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t } lv_btnm_set_styles_btn(kb_btnm, &style_btn_rel, &style_btn_pr); - /*Reduce the size of the window and align it to the top*/ - kb_win = lv_app_win_get_from_obj(kb_ta); - lv_obj_set_height(kb_win, LV_VER_RES / 2); - lv_obj_set_y(kb_win, 0); + kb_win = NULL; + kb_ta_ori_size = 0; + if(mode & LV_APP_KB_MODE_WIN_RESIZE) { + /*Reduce the size of the window and align it to the top*/ + kb_win = lv_app_win_get_from_obj(kb_ta); + lv_obj_set_height(kb_win, LV_VER_RES / 2); + lv_obj_set_y(kb_win, 0); - /*If the text area is higher then the new size of the window reduce its size too*/ - cord_t win_h = lv_obj_get_height(kb_win); - kb_ta_ori_size = lv_obj_get_height(kb_ta); - if(lv_obj_get_height(kb_ta) > win_h) { - lv_obj_set_height(kb_ta, win_h); + /*If the text area is higher then the new size of the window reduce its size too*/ + cord_t cont_h = lv_obj_get_height(kb_win) - lv_obj_get_height(lv_win_get_header(kb_win)); + kb_ta_ori_size = lv_obj_get_height(kb_ta); + if(lv_obj_get_height(kb_ta) > cont_h - LV_DPI / 10) { + lv_obj_set_height(kb_ta, cont_h - LV_DPI / 10); + } +#if LV_APP_ANIM_LEVEL != 0 + lv_page_focus(lv_win_get_content(kb_win), kb_ta, true); +#else + lv_page_focus(lv_win_get_page(kb_win), kb_ta, false); +#endif } lv_ta_set_cursor_pos(kb_ta, LV_TA_CUR_LAST); -#if LV_APP_ANIM_LEVEL != 0 - lv_page_focus(lv_win_get_content(kb_win), kb_ta, true); -#else - lv_page_focus(lv_win_get_page(kb_win), kb_ta, false); -#endif } /** @@ -155,11 +169,11 @@ void lv_app_kb_close(bool ok) } /*Reset the modified sizes*/ - - lv_obj_set_height(kb_ta, kb_ta_ori_size); - - lv_obj_set_size(kb_win, LV_HOR_RES, LV_VER_RES); - kb_win = NULL; + if((kb_mode & LV_APP_KB_MODE_WIN_RESIZE) && kb_win != NULL) { + lv_obj_set_height(kb_ta, kb_ta_ori_size); + lv_obj_set_size(kb_win, LV_HOR_RES, LV_VER_RES); + kb_win = NULL; + } lv_obj_del(kb_btnm); kb_btnm = NULL; @@ -229,11 +243,13 @@ static lv_action_res_t lv_app_kb_action(lv_obj_t * btnm, uint16_t i) lv_ta_add_text(kb_ta, txt); } + if(kb_mode & LV_APP_KB_MODE_WIN_RESIZE) { #if LV_APP_ANIM_LEVEL != 0 - lv_page_focus(lv_win_get_content(kb_win), kb_ta, true); + lv_page_focus(lv_win_get_content(kb_win), kb_ta, true); #else - lv_page_focus(lv_win_get_page(kb_win), kb_ta, false); + lv_page_focus(lv_win_get_page(kb_win), kb_ta, false); #endif + } return LV_ACTION_RES_OK; } diff --git a/lv_app/lv_app_util/lv_app_kb.h b/lv_app/lv_app_util/lv_app_kb.h index 75afb7f92..a222c2a91 100644 --- a/lv_app/lv_app_util/lv_app_kb.h +++ b/lv_app/lv_app_util/lv_app_kb.h @@ -23,6 +23,7 @@ typedef enum { LV_APP_KB_MODE_TXT = 0x01, LV_APP_KB_MODE_NUM = 0x02, + LV_APP_KB_MODE_WIN_RESIZE = 0x04, }lv_app_kb_mode_t; /********************** diff --git a/lv_appx/lv_app_example.c b/lv_appx/lv_app_example.c index 314bc31fa..fb2a202dd 100644 --- a/lv_appx/lv_app_example.c +++ b/lv_appx/lv_app_example.c @@ -198,7 +198,7 @@ static void my_win_close(lv_app_inst_t * app) static lv_action_res_t ta_rel_action(lv_obj_t * ta, lv_dispi_t * dispi) { lv_ta_set_text(ta, ""); /*Clear the ta*/ - lv_app_kb_open(ta, LV_APP_KB_MODE_TXT, NULL, kb_ok_action); + lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE, NULL, kb_ok_action); return LV_ACTION_RES_OK; } diff --git a/lv_appx/lv_app_files.c b/lv_appx/lv_app_files.c index 91c43965b..487cea87f 100644 --- a/lv_appx/lv_app_files.c +++ b/lv_appx/lv_app_files.c @@ -113,6 +113,7 @@ static lv_app_dsc_t my_app_dsc = }; static lv_style_t style_sc_label; +static lv_style_t style_btn_symbol; /********************** @@ -133,6 +134,8 @@ const lv_app_dsc_t * lv_app_files_init(void) memcpy(&style_sc_label, &app_style->sc_rec_rel, sizeof(lv_style_t)); style_sc_label.font = font_get(LV_APP_FONT_LARGE); + lv_style_get(LV_STYLE_BTN_REL, &style_btn_symbol); + style_btn_symbol.font = font_get(LV_IMG_DEF_SYMBOL_FONT); return &my_app_dsc; } @@ -350,7 +353,8 @@ static void win_create_list(lv_app_inst_t * app) /*Create a new list*/ win_data->file_list = lv_list_create(app->win, NULL); lv_obj_set_width(win_data->file_list, lv_win_get_width(app->win)); - //TODO lv_obj_set_style(win_data->file_list, lv_lists_get(LV_LISTS_TRANSP, NULL)); + lv_list_set_style_img(win_data->file_list, &style_btn_symbol); + lv_obj_set_style(lv_page_get_scrl(win_data->file_list), lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL)); lv_obj_set_drag_parent(win_data->file_list, true); lv_obj_set_drag_parent(lv_page_get_scrl(win_data->file_list), true); lv_cont_set_fit(win_data->file_list, false, true); @@ -381,13 +385,13 @@ static void win_load_file_list(lv_app_inst_t * app) for(i = 0; drv[i] != '\0'; i++) { buf[0] = drv[i]; buf[1] = '\0'; - liste = lv_list_add(win_data->file_list, "U:/icon_driver", buf, win_drv_action); + liste = lv_list_add(win_data->file_list, SYMBOL_DRIVE, buf, win_drv_action); lv_obj_set_free_p(liste, app); } } /*List the files/folders with fs interface*/ else { - liste = lv_list_add(win_data->file_list, "U:/icon_up", "Up", win_up_action); + liste = lv_list_add(win_data->file_list, SYMBOL_UP, "Up", win_up_action); lv_obj_set_free_p(liste, app); fs_readdir_t rd; @@ -399,7 +403,7 @@ static void win_load_file_list(lv_app_inst_t * app) /*At not first page add prev. page button */ if(app_data->file_cnt != 0) { - liste = lv_list_add(win_data->file_list, "U:/icon_left", "Previous page", win_prev_action); + liste = lv_list_add(win_data->file_list, SYMBOL_LEFT, "Previous page", win_prev_action); lv_obj_set_free_p(liste, app); } @@ -409,7 +413,7 @@ static void win_load_file_list(lv_app_inst_t * app) uint16_t file_cnt = 0; while(file_cnt <= app_data->file_cnt) { res = fs_readdir(&rd, fn); - if(res != FS_RES_OK || fn[0] == '\0'){ + if(res != FS_RES_OK ){ lv_app_notice_add("Can not read\nthe path in Files"); return; } @@ -420,13 +424,13 @@ static void win_load_file_list(lv_app_inst_t * app) while(res == FS_RES_OK && fn[0] != '\0') { if(fn[0] == '/') { /*Add a folder*/ lv_obj_t * liste; - liste = lv_list_add(win_data->file_list, "U:/icon_folder", &fn[1], win_folder_action); + liste = lv_list_add(win_data->file_list, SYMBOL_FOLDER, &fn[1], win_folder_action); lv_obj_set_free_p(liste, app); app_data->file_cnt ++; } /*Add a file*/ else { - liste = lv_list_add(win_data->file_list, "U:/icon_file", fn, win_file_action); + liste = lv_list_add(win_data->file_list, SYMBOL_FILE, fn, win_file_action); lv_obj_set_free_p(liste, app); app_data->file_cnt ++; } @@ -436,7 +440,7 @@ static void win_load_file_list(lv_app_inst_t * app) /*Show only LV_APP_FSEL_MAX_FILE elements and add a Next page button*/ if(app_data->file_cnt != 0 && app_data->file_cnt % LV_APP_FILES_PAGE_SIZE == 0) { - liste = lv_list_add(win_data->file_list, "U:/icon_right", "Next page", win_next_action); + liste = lv_list_add(win_data->file_list, SYMBOL_RIGHT, "Next page", win_next_action); lv_obj_set_free_p(liste, app); break; } @@ -525,7 +529,7 @@ static lv_action_res_t win_drv_action(lv_obj_t * drv, lv_dispi_t * dispi) { lv_app_inst_t * app = lv_obj_get_free_p(drv); my_app_data_t * app_data = app->app_data; - sprintf(app_data->path, "%s:", lv_list_element_get_txt(drv)); + sprintf(app_data->path, "%s:", lv_list_get_element_text(drv)); app_data->file_cnt = 0; lv_win_set_title(app->win, app_data->path); my_sc_data_t * sc_data = app->sc_data; @@ -549,7 +553,7 @@ static lv_action_res_t win_folder_action(lv_obj_t * folder, lv_dispi_t * dispi) { lv_app_inst_t * app = lv_obj_get_free_p(folder); my_app_data_t * app_data = app->app_data; - sprintf(app_data->path, "%s/%s", app_data->path, lv_list_element_get_txt(folder)); + sprintf(app_data->path, "%s/%s", app_data->path, lv_list_get_element_text(folder)); app_data->file_cnt = 0; lv_win_set_title(app->win, app_data->path); @@ -577,7 +581,7 @@ static lv_action_res_t win_file_action(lv_obj_t * file, lv_dispi_t * dispi) my_app_data_t * app_data = app->app_data; my_win_data_t * win_data = app->win_data; - sprintf(app_data->fn, "%s", lv_list_element_get_txt(file)); + sprintf(app_data->fn, "%s", lv_list_get_element_text(file)); win_create_list(app); @@ -662,9 +666,9 @@ static lv_action_res_t win_send_settings_element_rel_action(lv_obj_t * element, lv_app_notice_add("CRC sending is\nnot supported yet"); } } else if(id == SEND_SETTINGS_CHUNK_SIZE) { - lv_app_kb_open(element, LV_APP_KB_MODE_NUM, send_settings_kb_close_action, send_settings_kb_ok_action); + lv_app_kb_open(element, LV_APP_KB_MODE_NUM | LV_APP_KB_MODE_WIN_RESIZE, send_settings_kb_close_action, send_settings_kb_ok_action); } else if(id == SEND_SETTINGS_CHUNK_DELAY) { - lv_app_kb_open(element, LV_APP_KB_MODE_NUM, send_settings_kb_close_action, send_settings_kb_ok_action); + lv_app_kb_open(element, LV_APP_KB_MODE_NUM | LV_APP_KB_MODE_WIN_RESIZE, send_settings_kb_close_action, send_settings_kb_ok_action); } return LV_ACTION_RES_OK; diff --git a/lv_appx/lv_app_phantom.c b/lv_appx/lv_app_phantom.c new file mode 100644 index 000000000..75e480e48 --- /dev/null +++ b/lv_appx/lv_app_phantom.c @@ -0,0 +1,143 @@ +/** + * @file lv_app_example.c + * + */ + +/********************* + * INCLUDES + *********************/ +#include "lv_app_phantom.h" +#if LV_APP_ENABLE != 0 && USE_LV_APP_PHANTOM != 0 + +#include "../lv_app/lv_app_util/lv_app_kb.h" +#include + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ + +/*Application specific data for an instance of this application*/ +typedef struct +{ + void (*com_listen)(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, + lv_app_com_type_t type , const void * data, uint32_t size); +}my_app_data_t; + +/*Application specific data a window of this application*/ +typedef struct +{ + +}my_win_data_t; + +/*Application specific data for a shortcut of this application*/ +typedef struct +{ + lv_obj_t * label; +}my_sc_data_t; + +/********************** + * STATIC PROTOTYPES + **********************/ +static void my_app_run(lv_app_inst_t * app, void * conf); +static void my_app_close(lv_app_inst_t * app); +static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, + lv_app_com_type_t type , const void * data, uint32_t size); + +/********************** + * STATIC VARIABLES + **********************/ +static lv_app_dsc_t my_app_dsc = +{ + .name = "Phantom", + .mode = LV_APP_MODE_NONE, + .app_run = my_app_run, + .app_close = my_app_close, + .com_rec = my_com_rec, + .win_open = NULL, + .win_close = NULL, + .sc_open = NULL, + .sc_close = NULL, + .app_data_size = sizeof(my_app_data_t), + .sc_data_size = sizeof(my_sc_data_t), + .win_data_size = sizeof(my_win_data_t), +}; + +/********************** + * MACROS + **********************/ + +/********************** + * GLOBAL FUNCTIONS + **********************/ + +/** + * Initialize the application + * @return pointer to the application descriptor of this application + */ +const lv_app_dsc_t * lv_app_phantom_init(void) +{ + + return &my_app_dsc; +} + +/********************** + * STATIC FUNCTIONS + **********************/ + +/** + * Run an application according to 'app_dsc' + * @param app_dsc pointer to an application descriptor + * @param conf pointer to a lv_app_phantom_conf_t structure with configuration data or NULL if unused + * @return pointer to the opened application or NULL if any error occurred + */ +static void my_app_run(lv_app_inst_t * app, void * conf) +{ + /*Initialize the application*/ + my_app_data_t * app_data = app->app_data; + app_data->com_listen = NULL; + + if(conf != NULL) { + lv_app_phantom_conf_t * my_conf = conf; + app_data->com_listen = my_conf->com_listen; + } +} + +/** + * Close a running application. + * Close the Window and the Shortcut too if opened. + * Free all the allocated memory by this application. + * @param app pointer to an application + */ +static void my_app_close(lv_app_inst_t * app) +{ + /*No dynamically allocated data in 'my_app_data'*/ +} + +/** + * Read the data have been sent to this application + * @param app_send pointer to an application which sent the message + * @param app_rec pointer to an application which is receiving the message + * @param type type of data from 'lv_app_com_type_t' enum + * @param data pointer to the sent data + * @param size length of 'data' in bytes + */ +static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec, + lv_app_com_type_t type , const void * data, uint32_t size) +{ + + my_app_data_t * app_data = app_rec->app_data; + + if(app_data->com_listen != NULL) { + app_data->com_listen(app_send, app_rec, type, data, size); + } +} + +/*-------------------- + * OTHER FUNCTIONS + ---------------------*/ + +#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_EXAMPLE != 0*/ diff --git a/lv_appx/lv_app_phantom.h b/lv_appx/lv_app_phantom.h new file mode 100644 index 000000000..bb7f729f8 --- /dev/null +++ b/lv_appx/lv_app_phantom.h @@ -0,0 +1,42 @@ +/** + * @file lv_app_phantom.h + * + */ + +#ifndef LV_APP_PHANTOM_H +#define LV_APP_PHANTOM_H + +/********************* + * INCLUDES + *********************/ +#include "lvgl/lv_app/lv_app.h" + +#if LV_APP_ENABLE != 0 && USE_LV_APP_PHANTOM != 0 + +/********************* + * DEFINES + *********************/ + +/********************** + * TYPEDEFS + **********************/ +typedef struct +{ + void (*com_listen)(lv_app_inst_t * app_send, + lv_app_inst_t * app_rec, + lv_app_com_type_t type , + const void * data, uint32_t size); +}lv_app_phantom_conf_t; + +/********************** + * GLOBAL PROTOTYPES + **********************/ +const lv_app_dsc_t * lv_app_phantom_init(void); + +/********************** + * MACROS + **********************/ + +#endif /*LV_APP_ENABLE != 0 && USE_LV_APP_PHANTOM != 0*/ + +#endif /* LV_APP_PHANTOM_H */ diff --git a/lv_appx/lv_app_sysmon.c b/lv_appx/lv_app_sysmon.c index 8a0c0f467..1090bf552 100644 --- a/lv_appx/lv_app_sysmon.c +++ b/lv_appx/lv_app_sysmon.c @@ -83,8 +83,10 @@ static lv_app_dsc_t my_app_dsc = static uint8_t mem_pct[LV_APP_SYSMON_PNUM]; static uint8_t cpu_pct[LV_APP_SYSMON_PNUM]; -static lv_style_t cpu_bars; -static lv_style_t mem_bars; +static lv_style_t cpu_bar_bg; +static lv_style_t mem_bar_bg; +static lv_style_t cpu_bar_indic; +static lv_style_t mem_bar_indic; #if USE_DYN_MEM != 0 && DM_CUSTOM == 0 static dm_mon_t mem_mon; #endif @@ -109,23 +111,30 @@ const lv_app_dsc_t * lv_app_sysmon_init(void) memset(cpu_pct, 0, sizeof(cpu_pct)); /*Create bar styles for the shortcut*/ - lv_style_get(LV_STYLE_PRETTY_COLOR, &cpu_bars); + lv_style_get(LV_STYLE_PRETTY, &cpu_bar_bg); + cpu_bar_bg.ccolor = COLOR_MAKE(0x40, 0x00, 0x00); + cpu_bar_bg.font = font_get(LV_APP_FONT_MEDIUM); + cpu_bar_bg.line_space = 0; + cpu_bar_bg.txt_align = 1; + cpu_bar_bg.hpad = 0; + cpu_bar_bg.vpad = 0; - cpu_bars.gcolor = COLOR_MARRON; - cpu_bars.mcolor = COLOR_RED; - cpu_bars.bwidth = 0; + memcpy(&mem_bar_bg, &cpu_bar_bg, sizeof(lv_style_t)); + mem_bar_bg.ccolor = COLOR_MAKE(0x00, 0x40, 0x00); - cpu_bars.ccolor = COLOR_MAKE(0x40, 0x00, 0x00); - cpu_bars.font = font_get(LV_APP_FONT_MEDIUM); - cpu_bars.line_space = 0; - cpu_bars.txt_align = 1; - cpu_bars.hpad = 0; - cpu_bars.vpad = 0; + lv_style_get(LV_STYLE_PRETTY_COLOR, &cpu_bar_indic); + cpu_bar_indic.gcolor = COLOR_MARRON; + cpu_bar_indic.mcolor = COLOR_RED; + cpu_bar_indic.bcolor = COLOR_BLACK; + //cpu_bar_indic.bwidth = 1 * LV_DOWNSCALE; + cpu_bar_indic.bopa = OPA_50; + cpu_bar_indic.hpad = 0 * LV_DOWNSCALE; + cpu_bar_indic.vpad = 0 * LV_DOWNSCALE; - memcpy(&mem_bars, &cpu_bars, sizeof(cpu_bars)); - mem_bars.gcolor = COLOR_GREEN; - mem_bars.mcolor = COLOR_LIME; - mem_bars.ccolor = COLOR_MAKE(0x00, 0x40, 0x00); + + memcpy(&mem_bar_indic, &cpu_bar_indic, sizeof(lv_style_t)); + mem_bar_indic.gcolor = COLOR_GREEN; + mem_bar_indic.mcolor = COLOR_LIME; return &my_app_dsc; } @@ -186,7 +195,8 @@ static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc) sc_data->bar_cpu = lv_bar_create(sc, NULL); lv_obj_set_size(sc_data->bar_cpu, w, 5 * lv_obj_get_height(sc) / 8); lv_obj_align(sc_data->bar_cpu, NULL, LV_ALIGN_IN_BOTTOM_LEFT, w, - lv_obj_get_height(sc) / 8); - lv_bar_set_style_indic(sc_data->bar_cpu, &cpu_bars); + lv_obj_set_style(sc_data->bar_cpu, &cpu_bar_bg); + lv_bar_set_style_indic(sc_data->bar_cpu, &cpu_bar_indic); lv_obj_set_click(sc_data->bar_cpu, false); lv_bar_set_range(sc_data->bar_cpu, 0, 100); lv_obj_t * label = lv_label_create(sc_data->bar_cpu, NULL); @@ -195,7 +205,8 @@ static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc) sc_data->bar_mem = lv_bar_create(sc, sc_data->bar_cpu); lv_obj_align(sc_data->bar_mem, sc_data->bar_cpu, LV_ALIGN_OUT_RIGHT_MID, w, 0); - lv_bar_set_style_indic(sc_data->bar_mem, &mem_bars); + lv_obj_set_style(sc_data->bar_mem, &mem_bar_bg); + lv_bar_set_style_indic(sc_data->bar_mem, &mem_bar_indic); label = lv_label_create(sc_data->bar_mem, NULL); lv_label_set_text(label, "M\nE\nM"); lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0); @@ -223,6 +234,8 @@ static void my_win_open(lv_app_inst_t * app, lv_obj_t * win) { my_win_data_t * win_data = app->win_data; + lv_cont_set_layout(lv_page_get_scrl(lv_win_get_page(win)), LV_CONT_LAYOUT_PRETTY); + /*Create a chart with two data lines*/ win_data->chart = lv_chart_create(win, NULL); lv_obj_set_size(win_data->chart, LV_HOR_RES / 2, LV_VER_RES / 2); @@ -231,8 +244,8 @@ static void my_win_open(lv_app_inst_t * app, lv_obj_t * win) lv_chart_set_range(win_data->chart, 0, 100); lv_chart_set_type(win_data->chart, LV_CHART_LINE); lv_chart_set_dl_width(win_data->chart, 2 * LV_DOWNSCALE); - win_data->cpu_dl = lv_chart_add_dataline(win_data->chart, COLOR_RED); - win_data->mem_dl = lv_chart_add_dataline(win_data->chart, COLOR_BLUE); + win_data->cpu_dl = lv_chart_add_data_line(win_data->chart, COLOR_RED); + win_data->mem_dl = lv_chart_add_data_line(win_data->chart, COLOR_BLUE); uint16_t i; for(i = 0; i < LV_APP_SYSMON_PNUM; i ++) { diff --git a/lv_appx/lv_app_terminal.c b/lv_appx/lv_app_terminal.c index a22f7138b..02071a84c 100644 --- a/lv_appx/lv_app_terminal.c +++ b/lv_appx/lv_app_terminal.c @@ -31,7 +31,7 @@ /********************* * DEFINES *********************/ -#define OBJ_PAD (LV_DPI / 4) +#define OBJ_PAD (LV_DPI / 12) /********************** * TYPEDEFS @@ -144,9 +144,17 @@ static void my_app_run(lv_app_inst_t * app, void * conf) { /*Initialize the application*/ my_app_data_t * app_data = app->app_data; - app_data->com_type = LV_APP_COM_TYPE_CHAR; - app_data->format = LV_APP_TERMINAL_FORMAT_ASCII; + + if(conf != NULL) { + app_data->com_type = ((lv_app_terminal_conf_t * ) conf)->com_type; + app_data->format = ((lv_app_terminal_conf_t * ) conf)->format; + } else { + app_data->com_type = LV_APP_COM_TYPE_CHAR; + app_data->format = LV_APP_TERMINAL_FORMAT_ASCII; + } + app_data->last_sender = NULL; + memset(app_data->txt, 0, sizeof(app_data->txt)); } @@ -326,7 +334,7 @@ static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win) */ static lv_action_res_t win_ta_rel_action(lv_obj_t * ta, lv_dispi_t * dispi) { - lv_app_kb_open(ta, LV_APP_KB_MODE_TXT, NULL, win_ta_kb_ok_action); + lv_app_kb_open(ta, LV_APP_KB_MODE_TXT | LV_APP_KB_MODE_WIN_RESIZE, NULL, win_ta_kb_ok_action); return LV_ACTION_RES_OK; } diff --git a/lv_appx/lv_app_terminal.h b/lv_appx/lv_app_terminal.h index 70c32d91d..b2bda2f18 100644 --- a/lv_appx/lv_app_terminal.h +++ b/lv_appx/lv_app_terminal.h @@ -28,7 +28,8 @@ typedef enum typedef struct { - + lv_app_terminal_format_t format; /*Data display format*/ + lv_app_com_type_t com_type; /*The listened communication type (channel) */ }lv_app_terminal_conf_t; /********************** diff --git a/lv_draw/lv_draw.c b/lv_draw/lv_draw.c index 761b6c52d..b3e9ce856 100644 --- a/lv_draw/lv_draw.c +++ b/lv_draw/lv_draw.c @@ -347,7 +347,6 @@ void lv_draw_img(const area_t * cords_p, const area_t * mask_p, cord_t row; area_t act_area; - area_t mask_sub; bool union_ok; union_ok = area_union(&mask_sub, mask_p, cords_p); diff --git a/lv_obj/lv_obj.c b/lv_obj/lv_obj.c index 51ab851a3..0b171afe5 100644 --- a/lv_obj/lv_obj.c +++ b/lv_obj/lv_obj.c @@ -1234,7 +1234,7 @@ cord_t lv_obj_get_height(lv_obj_t * obj) * @param obj pointer to an object * @return the extended size attribute */ -cord_t lv_obj_getext_size(lv_obj_t * obj) +cord_t lv_obj_get_ext_size(lv_obj_t * obj) { return obj->ext_size; } diff --git a/lv_obj/lv_obj.h b/lv_obj/lv_obj.h index 5985c1d8d..f4ddee676 100644 --- a/lv_obj/lv_obj.h +++ b/lv_obj/lv_obj.h @@ -551,7 +551,7 @@ cord_t lv_obj_get_height(lv_obj_t * obj); * @param obj pointer to an object * @return the extended size attribute */ -cord_t lv_obj_getext_size(lv_obj_t * obj); +cord_t lv_obj_get_ext_size(lv_obj_t * obj); /** * Get the style pointer of an object diff --git a/lv_obj/lv_style.c b/lv_obj/lv_style.c index 3caa1adba..cc12e7d03 100644 --- a/lv_obj/lv_style.c +++ b/lv_obj/lv_style.c @@ -51,120 +51,115 @@ static lv_style_t lv_style_btn_ina; */ void lv_style_init (void) { - /* Not White/Black/Gray colors are created by HSV model with * HUE = 210*/ /*Screen style*/ - lv_style_set_ccolor(&lv_style_scr, COLOR_MAKE(0x20, 0x20, 0x20)); - lv_style_set_opa(&lv_style_scr, OPA_COVER); + lv_style_scr.ccolor = COLOR_MAKE(0x20, 0x20, 0x20); + lv_style_scr.opa = OPA_COVER; - lv_style_set_mcolor(&lv_style_scr, COLOR_WHITE);//MAKE(0xc9, 0xdb, 0xee)); - lv_style_set_gcolor(&lv_style_scr, COLOR_WHITE);//MAKE(0x4d, 0x91, 0xd5)); - lv_style_set_bcolor(&lv_style_scr, COLOR_BLACK); - lv_style_set_scolor(&lv_style_scr, COLOR_GRAY); - lv_style_set_radius(&lv_style_scr, 0); - lv_style_set_bwidth(&lv_style_scr, 0); - lv_style_set_swidth(&lv_style_scr, 0); - lv_style_set_vpad(&lv_style_scr, LV_DPI / 12); - lv_style_set_hpad(&lv_style_scr, LV_DPI / 12); - lv_style_set_opad(&lv_style_scr, LV_DPI / 12); - lv_style_set_bopa(&lv_style_scr, OPA_COVER); - lv_style_set_empty(&lv_style_scr, false); - lv_style_set_stype(&lv_style_scr, LV_STYPE_FULL); + lv_style_scr.mcolor = COLOR_MAKE(0xc9, 0xdb, 0xee); + lv_style_scr.gcolor = COLOR_MAKE(0x4d, 0x91, 0xd5); + lv_style_scr.bcolor = COLOR_BLACK; + lv_style_scr.scolor = COLOR_GRAY; + lv_style_scr.radius = 0; + lv_style_scr.bwidth = 0; + lv_style_scr.swidth = 0; + lv_style_scr.stype = LV_STYPE_FULL; + lv_style_scr.vpad = LV_DPI / 12; + lv_style_scr.hpad = LV_DPI / 12; + lv_style_scr.opad = LV_DPI / 12; + lv_style_scr.bopa = OPA_COVER; + lv_style_scr.empty = 0; lv_style_scr.glass = 0; - lv_style_set_font(&lv_style_scr, font_get(FONT_DEFAULT)); - lv_style_set_letter_space(&lv_style_scr, 1 * LV_DOWNSCALE); - lv_style_set_line_space(&lv_style_scr, 3 * LV_DOWNSCALE); - lv_style_set_txt_align(&lv_style_scr, 0); - - lv_style_set_img_recolor(&lv_style_scr, OPA_TRANSP); - - lv_style_set_line_width(&lv_style_scr, 1 * LV_DOWNSCALE); + lv_style_scr.font = font_get(FONT_DEFAULT); + lv_style_scr.letter_space = 1 * LV_DOWNSCALE; + lv_style_scr.line_space = 3 * LV_DOWNSCALE; + lv_style_scr.txt_align = 0; + lv_style_scr.img_recolor = OPA_TRANSP; + lv_style_scr.line_width = 1 * LV_DOWNSCALE; /*Plain style (by default near the same as the screen style)*/ memcpy(&lv_style_plain, &lv_style_scr, sizeof(lv_style_t)); - lv_style_set_mcolor(&lv_style_plain, COLOR_WHITE); - lv_style_set_gcolor(&lv_style_plain, COLOR_WHITE); - lv_style_set_bcolor(&lv_style_plain, COLOR_WHITE); + lv_style_plain.mcolor = COLOR_WHITE; + lv_style_plain.gcolor = COLOR_WHITE; + lv_style_plain.bcolor = COLOR_WHITE; /*Plain color style*/ memcpy(&lv_style_plain_color, &lv_style_plain, sizeof(lv_style_t)); - lv_style_set_ccolor(&lv_style_plain_color, COLOR_MAKE(0xf0, 0xf0, 0xf0)); - lv_style_set_mcolor(&lv_style_plain_color, COLOR_MAKE(0x55, 0x96, 0xd8)); - lv_style_set_gcolor(&lv_style_plain_color, lv_style_plain_color.mcolor); + lv_style_plain_color.ccolor = COLOR_MAKE(0xf0, 0xf0, 0xf0); + lv_style_plain_color.mcolor = COLOR_MAKE(0x55, 0x96, 0xd8); + lv_style_plain_color.gcolor = lv_style_plain_color.mcolor; /*Pretty style */ memcpy(&lv_style_pretty, &lv_style_plain, sizeof(lv_style_t)); - lv_style_set_ccolor(&lv_style_pretty, COLOR_MAKE(0x20, 0x20, 0x20)); - lv_style_set_mcolor(&lv_style_pretty, COLOR_WHITE); - lv_style_set_gcolor(&lv_style_pretty, COLOR_SILVER); - lv_style_set_bcolor(&lv_style_pretty, COLOR_MAKE(0x40, 0x40, 0x40)); - lv_style_set_radius(&lv_style_pretty, LV_DPI / 12); - lv_style_set_bwidth(&lv_style_pretty, LV_DPI / 40 >= 1 ? LV_DPI / 40 : 1); - lv_style_set_bopa(&lv_style_pretty, OPA_50); + lv_style_pretty.ccolor = COLOR_MAKE(0x20, 0x20, 0x20); + lv_style_pretty.mcolor = COLOR_WHITE; + lv_style_pretty.gcolor = COLOR_SILVER; + lv_style_pretty.bcolor = COLOR_MAKE(0x40, 0x40, 0x40); + lv_style_pretty.radius = LV_DPI / 15; + lv_style_pretty.bwidth = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1; + lv_style_pretty.bopa = OPA_50; /*Pretty color style*/ memcpy(&lv_style_pretty_color, &lv_style_pretty, sizeof(lv_style_t)); - lv_style_set_ccolor(&lv_style_pretty_color, COLOR_MAKE(0xe0, 0xe0, 0xe0)); - lv_style_set_mcolor(&lv_style_pretty_color, COLOR_MAKE(0x6b, 0x9a, 0xc7)); - lv_style_set_gcolor(&lv_style_pretty_color, COLOR_MAKE(0x2b, 0x59, 0x8b)); - lv_style_set_bcolor(&lv_style_pretty_color, COLOR_MAKE(0x15, 0x2c, 0x42)); - lv_style_set_scolor(&lv_style_pretty_color, COLOR_GRAY); - lv_style_set_swidth(&lv_style_pretty_color, 0); + lv_style_pretty_color.ccolor = COLOR_MAKE(0xe0, 0xe0, 0xe0); + lv_style_pretty_color.mcolor = COLOR_MAKE(0x6b, 0x9a, 0xc7); + lv_style_pretty_color.gcolor = COLOR_MAKE(0x2b, 0x59, 0x8b); + lv_style_pretty_color.bcolor = COLOR_MAKE(0x15, 0x2c, 0x42); /*Transparent style*/ memcpy(&lv_style_transp, &lv_style_plain, sizeof(lv_style_t)); - lv_style_set_empty(&lv_style_transp, true); - lv_style_set_bwidth(&lv_style_transp, 0); + lv_style_transp.empty = 1; + lv_style_transp.bwidth = 0; lv_style_transp.glass = 1; /*Transparent tight style*/ memcpy(&lv_style_transp_tight, &lv_style_transp, sizeof(lv_style_t)); - lv_style_set_hpad(&lv_style_transp_tight, 0); - lv_style_set_vpad(&lv_style_transp_tight, 0); + lv_style_transp_tight.hpad = 0; + lv_style_transp_tight.vpad = 0; /*Button released style*/ memcpy(&lv_style_btn_rel, &lv_style_plain, sizeof(lv_style_t)); - lv_style_set_mcolor(&lv_style_btn_rel, COLOR_MAKE(0x76, 0xa2, 0xd0)); - lv_style_set_gcolor(&lv_style_btn_rel, COLOR_MAKE(0x19, 0x3a, 0x5d)); - lv_style_set_bcolor(&lv_style_btn_rel, COLOR_MAKE(0x0b, 0x19, 0x28)); - lv_style_set_ccolor(&lv_style_btn_rel, COLOR_MAKE(0xff, 0xff, 0xff)); - lv_style_set_bwidth(&lv_style_btn_rel, LV_DPI / 40 >= 1 ? LV_DPI / 40 : 1); - lv_style_set_radius(&lv_style_btn_rel, LV_DPI / 12); - lv_style_set_bopa(&lv_style_btn_rel, OPA_70); - lv_style_set_scolor(&lv_style_btn_rel, COLOR_GRAY); - lv_style_set_swidth(&lv_style_btn_rel, 0); - lv_style_set_hpad(&lv_style_btn_rel, LV_DPI / 4); - lv_style_set_vpad(&lv_style_btn_rel, LV_DPI / 6); - lv_style_set_opad(&lv_style_btn_rel, LV_DPI / 10); + lv_style_btn_rel.mcolor = COLOR_MAKE(0x76, 0xa2, 0xd0); + lv_style_btn_rel.gcolor = COLOR_MAKE(0x19, 0x3a, 0x5d); + lv_style_btn_rel.bcolor = COLOR_MAKE(0x0b, 0x19, 0x28); + lv_style_btn_rel.ccolor = COLOR_MAKE(0xff, 0xff, 0xff); + lv_style_btn_rel.bwidth = LV_DPI / 50 >= 1 ? LV_DPI / 50 : 1; + lv_style_btn_rel.radius = LV_DPI / 15; + lv_style_btn_rel.bopa = OPA_70; + lv_style_btn_rel.scolor = COLOR_GRAY; + lv_style_btn_rel.swidth = 0; + lv_style_btn_rel.hpad = LV_DPI / 4; + lv_style_btn_rel.vpad = LV_DPI / 6; + lv_style_btn_rel.opad = LV_DPI / 10; /*Button pressed style*/ memcpy(&lv_style_btn_pr, &lv_style_btn_rel, sizeof(lv_style_t)); - lv_style_set_mcolor(&lv_style_btn_pr, COLOR_MAKE(0x33, 0x62, 0x94)); - lv_style_set_gcolor(&lv_style_btn_pr, COLOR_MAKE(0x10, 0x26, 0x3c)); - lv_style_set_ccolor(&lv_style_btn_pr, COLOR_MAKE(0xa4, 0xb5, 0xc6)); + lv_style_btn_pr.mcolor = COLOR_MAKE(0x33, 0x62, 0x94); + lv_style_btn_pr.gcolor = COLOR_MAKE(0x10, 0x26, 0x3c); + lv_style_btn_pr.ccolor = COLOR_MAKE(0xa4, 0xb5, 0xc6); /*Button toggle released style*/ memcpy(&lv_style_btn_trel, &lv_style_btn_rel, sizeof(lv_style_t)); - lv_style_set_mcolor(&lv_style_btn_trel, COLOR_MAKE(0x0a, 0x11, 0x22)); - lv_style_set_gcolor(&lv_style_btn_trel, COLOR_MAKE(0x37, 0x62, 0x90)); - lv_style_set_bcolor(&lv_style_btn_trel, COLOR_MAKE(0x01, 0x07, 0x0d)); - lv_style_set_ccolor(&lv_style_btn_trel, COLOR_MAKE(0xc8, 0xdd, 0xf4)); + lv_style_btn_trel.mcolor = COLOR_MAKE(0x0a, 0x11, 0x22); + lv_style_btn_trel.gcolor = COLOR_MAKE(0x37, 0x62, 0x90); + lv_style_btn_trel.bcolor = COLOR_MAKE(0x01, 0x07, 0x0d); + lv_style_btn_trel.ccolor = COLOR_MAKE(0xc8, 0xdd, 0xf4); /*Button toggle pressed style*/ memcpy(&lv_style_btn_tpr, &lv_style_btn_rel, sizeof(lv_style_t)); - lv_style_set_mcolor(&lv_style_btn_tpr, COLOR_MAKE(0x02, 0x14, 0x27)); - lv_style_set_gcolor(&lv_style_btn_tpr, COLOR_MAKE(0x2b, 0x4c, 0x70)); - lv_style_set_ccolor(&lv_style_btn_tpr, COLOR_MAKE(0xa4, 0xb5, 0xc6)); + lv_style_btn_tpr.mcolor = COLOR_MAKE(0x02, 0x14, 0x27); + lv_style_btn_tpr.gcolor = COLOR_MAKE(0x2b, 0x4c, 0x70); + lv_style_btn_tpr.ccolor = COLOR_MAKE(0xa4, 0xb5, 0xc6); /*Button inactive style*/ memcpy(&lv_style_btn_ina, &lv_style_btn_rel, sizeof(lv_style_t)); - lv_style_set_mcolor(&lv_style_btn_ina, COLOR_MAKE(0xd8, 0xd8, 0xd8)); - lv_style_set_gcolor(&lv_style_btn_ina, COLOR_MAKE(0xd8, 0xd8, 0xd8)); - lv_style_set_bcolor(&lv_style_btn_ina, COLOR_MAKE(0x90, 0x90, 0x90)); - lv_style_set_ccolor(&lv_style_btn_ina, COLOR_MAKE(0x70, 0x70, 0x70)); + lv_style_btn_ina.mcolor = COLOR_MAKE(0xd8, 0xd8, 0xd8); + lv_style_btn_ina.gcolor = COLOR_MAKE(0xd8, 0xd8, 0xd8); + lv_style_btn_ina.bcolor = COLOR_MAKE(0x90, 0x90, 0x90); + lv_style_btn_ina.ccolor = COLOR_MAKE(0x70, 0x70, 0x70); } @@ -223,453 +218,6 @@ lv_style_t * lv_style_get(lv_style_name_t style_name, lv_style_t * copy) return style; } -/** - * Set the content color of a style - * @param style pointer to style - * @param ccolor content color - */ -void lv_style_set_ccolor(lv_style_t * style, color_t ccolor) -{ - style->ccolor = ccolor; -} - -/** - * Set the opacity of a style - * @param style pointer to style - * @param opa opacity (OPA_COVER, OPA_TRANSP, OPA_10, OPA_20 ... OPA_90) - */ -void lv_style_set_opa(lv_style_t * style, opa_t opa) -{ - style->opa = opa; -} - - -/** - * Set the container main color of a style - * @param style pointer to style - * @param mcolor main color of the background - */ -void lv_style_set_mcolor(lv_style_t * style, color_t mcolor) -{ - style->mcolor = mcolor; -} - - -/** - * Set the container gradient color of a style - * @param style pointer to style - * @param gcolor gradient color of the background - */ -void lv_style_set_gcolor(lv_style_t * style, color_t gcolor) -{ - style->gcolor = gcolor; -} - -/** - * Set the container border color of a style - * @param style pointer to style - * @param bcolor border color of the background - */ -void lv_style_set_bcolor(lv_style_t * style, color_t bcolor) -{ - style->bcolor = bcolor; -} - - -/** - * Set the container shadow color of a style - * @param style pointer to style - * @param scolor shadow color of the background - */ -void lv_style_set_scolor(lv_style_t * style, color_t scolor) -{ - style->scolor = scolor; -} - -/** - * Set the container corner radius of a style - * @param style pointer to style - * @param radius corner radius of the background (>= 0) - */ -void lv_style_set_radius(lv_style_t * style, cord_t radius) -{ - style->radius = radius; -} - - -/** - * Set the container border width of a style - * @param style pointer to style - * @param bwidth border width of the background (>= 0, 0 means no border) - */ -void lv_style_set_bwidth(lv_style_t * style, cord_t bwidth) -{ - style->bwidth = bwidth; -} - - -/** - * Set the container shadow width of a style - * @param style pointer to style - * @param swidth shadow width of the background (>= 0, 0 means no shadow) - */ -void lv_style_set_swidth(lv_style_t * style, cord_t swidth) -{ - style->swidth = swidth; -} - - -/** - * Set the container vertical padding of a style - * @param style pointer to style - * @param vpad vertical padding on the background - */ -void lv_style_set_vpad(lv_style_t * style, cord_t vpad) -{ - style->vpad = vpad; -} - - -/** - * Set the container horizontal padding of a style - * @param style pointer to style - * @param hpad horizontal padding on the background - */ -void lv_style_set_hpad(lv_style_t * style, cord_t hpad) -{ - style->hpad = hpad; -} - -/** - * Set the container object padding of a style - * @param style pointer to style - * @param opad padding between objects on the background - */ -void lv_style_set_opad(lv_style_t * style, cord_t opad) -{ - style->opad = opad; -} - -/** - * Set the container border opacity of a style (relative to the object opacity) - * @param style pointer to style - * @param bopa border opacity of the background (OPA_COVER, OPA_TRANSP, OPA_10, OPA_20 ... OPA_90) - */ -void lv_style_set_bopa(lv_style_t * style, opa_t bopa) -{ - style->bopa = bopa; -} - - -/** - * Set container empty attribute of a style (transparent background but border drawn) - * @param style pointer to style - * @param empty true: empty enable, false: empty disable - */ -void lv_style_set_empty(lv_style_t * style, bool empty) -{ - style->empty = empty == false ? 0 : 1; -} - -/** - * Set the shadow type (position) of a style - * @param style pointer to style - * @param stype shadow type from 'lv_shadow_type_t' enum - */ -void lv_style_set_stype(lv_style_t * style, lv_stype_t stype) -{ - style->stype = stype; -} - -/** - * Set the font of a style - * @param style pointer to style - * @param font pointer to a fint - */ -void lv_style_set_font(lv_style_t * style, const font_t * font) -{ - style->font = font; -} - - -/** - * Set the letter space of a style - * @param style pointer to style - * @param letter_space new letter space - */ -void lv_style_set_letter_space(lv_style_t * style, cord_t letter_space) -{ - style->letter_space = letter_space; -} - - -/** - * Set the line space of a style - * @param style pointer to style - * @param line_space new letter space - */ -void lv_style_set_line_space(lv_style_t * style, cord_t line_space) -{ - style->line_space = line_space; -} - -/** - * Set the text align of a style - * @param style pointer to style - * @param align type of text alignment from 'lv_txt_align_t' - */ -void lv_style_set_txt_align(lv_style_t * style, lv_txt_align_t align) -{ - style->txt_align = align; -} - - -/** - * Set the image re-color intensity of a style - * @param style pointer to style - * @param recolor re-coloring intensity (OPA_TRANSP: do nothing, OPA_COVER: fully re-color, OPA_10: little re-color) - */ -void lv_style_set_img_recolor(lv_style_t * style, opa_t recolor) -{ - style->img_recolor = recolor; -} - - -/** - * Set the line width of a style - * @param style pointer to style - * @param width new line width (>=0) - */ -void lv_style_set_line_width(lv_style_t * style, cord_t width) -{ - style->line_width = width; -} - -/************************* - * GET FUNTIONS - *************************/ -/** - * Get the content color of a style - * @param style pointer to style - * @return content color - */ -color_t lv_style_get_ccolor(lv_style_t * style) -{ - return style->ccolor; -} - -/** - * Get the opacity of a style - * @param style pointer to style - * @return opacity (OPA_COVER, OPA_TRANSP, OPA_10, OPA_20 ... OPA_90) - */ -opa_t lv_style_get_opa(lv_style_t * style) -{ - return style->opa; -} - -/** - * Get the container main color of a style - * @param style pointer to style - * @return main color of the background - */ -color_t lv_style_get_mcolor(lv_style_t * style) -{ - return style->mcolor; -} - - -/** - * Get the container gradient color of a style - * @param style pointer to style - * @return gradient color of the background - */ -color_t lv_style_get_gcolor(lv_style_t * style) -{ - return style->gcolor; -} - -/** - * Get the container border color of a style - * @param style pointer to style - * @return border color of the background - */ -color_t lv_style_get_bcolor(lv_style_t * style) -{ - return style->bcolor; -} - - -/** - * Get the container shadow color of a style - * @param style pointer to style - * @return shadow color of the background - */ -color_t lv_style_get_Scolor(lv_style_t * style) -{ - return style->scolor; -} - -/** - * Get the container corner radius of a style - * @param style pointer to style - * @return corner radius of the background (>= 0) - */ - cord_t lv_style_get_radius(lv_style_t * style) -{ - return style->radius; -} - - -/** - * Get the container border width of a style - * @param style pointer to style - * @return border width of the background (>= 0, 0 means no border) - */ -cord_t lv_style_get_bwidth(lv_style_t * style) -{ - return style->bwidth; -} - - -/** - * Get the container shadow width of a style - * @param style pointer to style - * @return shadow width of the background (>= 0, 0 means no shadow) - */ -cord_t lv_style_get_swidth(lv_style_t * style) -{ - return style->swidth; -} - - -/** - * Get the container vertical padding of a style - * @param style pointer to style - * @return vertical padding on the background - */ -cord_t lv_style_get_vpad(lv_style_t * style) -{ - return style->vpad; -} - - -/** - * Get the container horizontal padding of a style - * @param style pointer to style - * @return horizontal padding on the background - */ -cord_t lv_style_get_hpad(lv_style_t * style) -{ - return style->hpad; -} - -/** - * Get the container object padding of a style - * @param style pointer to style - * @return padding between objects on the background - */ -cord_t lv_style_get_opad(lv_style_t * style) -{ - return style->opad; -} - -/** - * Get the container border opacity of a style (relative to the object opacity) - * @param style pointer to style - * @return border opacity of the background (OPA_COVER, OPA_TRANSP, OPA_10, OPA_20 ... OPA_90) - */ -opa_t lv_style_get_bopa(lv_style_t * style) -{ - return style->bopa; -} - - -/** - * Get container empty attribute of a style (transparent background but border drawn) - * @param style pointer to style - * @return true: empty enable, false: empty disable - */ -bool lv_style_get_empty(lv_style_t * style, bool empty) -{ - return style->empty == false ? 0 : 1; -} - -/** - * Get the shadow type attribute - * @param style pointer to style - * @return shadow type from 'lv_stype_t' enum - */ -bool lv_style_get_stype(lv_style_t * style, bool empty) -{ - return style->stype; -} - -/** - * Get the font of a style - * @param style pointer to style - * @return pointer to a fint - */ -const font_t * lv_style_get_font(lv_style_t * style) -{ - return style->font; -} - - -/** - * Get the letter space of a style - * @param style pointer to style - * @return new letter space - */ -cord_t lv_style_get_letter_space(lv_style_t * style) -{ - return style->letter_space; -} - - -/** - * Get the line space of a style - * @param style pointer to style - * @return new letter space - */ -cord_t lv_style_get_line_space(lv_style_t * style) -{ - return style->line_space; -} - -/** - * Get the text align of a style - * @param style pointer to style - * @return type of text alignment from 'lv_txt_align_t' - */ -lv_txt_align_t lv_style_get_txt_align(lv_style_t * style) -{ - return style->txt_align; -} - - -/** - * Get the image re-color intensity of a style - * @param style pointer to style - * @return re-coloring intensity (OPA_TRANSP: do nothing, OPA_COVER: fully re-color, OPA_10: little re-color) - */ -opa_t lv_style_get_img_recolor(lv_style_t * style) -{ - return style->img_recolor; -} - - -/** - * Get the line width of a style - * @param style pointer to style - * @return new line width (>=0) - */ -cord_t lv_style_get_line_width(lv_style_t * style) -{ - return style->line_width; -} - - /********************** * STATIC FUNCTIONS **********************/ diff --git a/lv_obj/lv_style.h b/lv_obj/lv_style.h index 4191005cc..b1400dd8e 100644 --- a/lv_obj/lv_style.h +++ b/lv_obj/lv_style.h @@ -43,7 +43,8 @@ typedef struct opa_t opa; /*Opacity of the object*/ uint8_t glass :1; /*1: Do not inherit this style*/ uint8_t empty :1; /*Transparent background (border drawn)*/ - uint8_t stype :3; /*Shadow type from 'lv_shadow_type_t'*/ + uint8_t stype :2; /*Shadow type from 'lv_shadow_type_t'*/ + uint8_t txt_align:2; color_t mcolor; /*Main color of background*/ color_t gcolor; /*Gradient color of background*/ color_t bcolor; /*Border color of background*/ @@ -58,7 +59,6 @@ typedef struct const font_t * font; cord_t letter_space; cord_t line_space; - uint8_t txt_align; opa_t img_recolor; cord_t line_width; }lv_style_t; diff --git a/lv_objx/lv_bar.c b/lv_objx/lv_bar.c index 0c1b37d5c..bbd68ef08 100644 --- a/lv_objx/lv_bar.c +++ b/lv_objx/lv_bar.c @@ -244,8 +244,6 @@ static bool lv_bar_design(lv_obj_t * bar, const area_t * mask, lv_design_mode_t lv_bar_ext_t * ext = lv_obj_get_ext(bar); - - lv_style_t * style_indic = lv_bar_get_style_indic(bar); area_t indic_area; area_cpy(&indic_area, &bar->cords); diff --git a/lv_objx/lv_btnm.c b/lv_objx/lv_btnm.c index 4afb1a8ab..d51bd7510 100644 --- a/lv_objx/lv_btnm.c +++ b/lv_objx/lv_btnm.c @@ -396,7 +396,6 @@ static bool lv_btnm_design(lv_obj_t * btnm, const area_t * mask, lv_design_mode_ ancestor_design_f(btnm, mask, mode); lv_btnm_ext_t * ext = lv_obj_get_ext(btnm); - lv_style_t * style = lv_obj_get_style(btnm); lv_style_t * btn_style; area_t area_btnm; diff --git a/lv_objx/lv_cb.h b/lv_objx/lv_cb.h index 307737b58..e1d169b3a 100644 --- a/lv_objx/lv_cb.h +++ b/lv_objx/lv_cb.h @@ -76,7 +76,13 @@ void lv_cb_set_text(lv_obj_t * cb, const char * txt); */ const char * lv_cb_get_text(lv_obj_t * cb); +/** + * Get the bullet (lv_btn) of a check box + * @param cb pointer to check box object + * @return pointer to the bullet of the check box (lv_btn) + */ lv_obj_t * lv_cb_get_bullet(lv_obj_t * cb); + /********************** * MACROS **********************/ diff --git a/lv_objx/lv_chart.c b/lv_objx/lv_chart.c index 37aff871a..fa0a7fefc 100644 --- a/lv_objx/lv_chart.c +++ b/lv_objx/lv_chart.c @@ -139,7 +139,7 @@ bool lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param) * @param color color of the data line * @return pointer to the allocated data line ( */ -lv_chart_dl_t * lv_chart_add_dataline(lv_obj_t * chart, color_t color) +lv_chart_dl_t * lv_chart_add_data_line(lv_obj_t * chart, color_t color) { lv_chart_ext_t * ext = lv_obj_get_ext(chart); lv_chart_dl_t * dl = ll_ins_head(&ext->dl_ll); diff --git a/lv_objx/lv_chart.h b/lv_objx/lv_chart.h index aaf3b5fd0..ab2f54762 100644 --- a/lv_objx/lv_chart.h +++ b/lv_objx/lv_chart.h @@ -18,7 +18,6 @@ /********************* * DEFINES *********************/ -#define LV_CHART_DL_NUM 8 /*Max data line number. Used in the style.*/ /********************** * TYPEDEFS @@ -83,7 +82,7 @@ bool lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param); * @param color color of the data line * @return pointer to the allocated data line ( */ -lv_chart_dl_t * lv_chart_add_dataline(lv_obj_t * chart, color_t color); +lv_chart_dl_t * lv_chart_add_data_line(lv_obj_t * chart, color_t color); /** * Refresh a chart if its data line has changed diff --git a/lv_objx/lv_cont.h b/lv_objx/lv_cont.h index 0166ad7c3..57f205592 100644 --- a/lv_objx/lv_cont.h +++ b/lv_objx/lv_cont.h @@ -30,9 +30,9 @@ typedef enum LV_CONT_LAYOUT_COL_L, /*Column left align*/ LV_CONT_LAYOUT_COL_M, /*Column middle align*/ LV_CONT_LAYOUT_COL_R, /*Column right align*/ - LV_CONT_LAYOUT_ROW_T, /*Row left align*/ + LV_CONT_LAYOUT_ROW_T, /*Row top align*/ LV_CONT_LAYOUT_ROW_M, /*Row middle align*/ - LV_CONT_LAYOUT_ROW_B, /*Row right align*/ + LV_CONT_LAYOUT_ROW_B, /*Row bottom align*/ LV_CONT_LAYOUT_PRETTY, /*Put as many object as possible in row and begin a new row*/ LV_CONT_LAYOUT_GRID, /*Align same-sized object into a grid*/ }lv_cont_layout_t; diff --git a/lv_objx/lv_ddlist.c b/lv_objx/lv_ddlist.c index db8b04e63..47068daf3 100644 --- a/lv_objx/lv_ddlist.c +++ b/lv_objx/lv_ddlist.c @@ -36,8 +36,7 @@ static void lv_ddlist_pos_act_option(lv_obj_t * ddlist); * STATIC VARIABLES **********************/ static lv_design_f_t ancestor_design_f; -static const char * def_options[] = {"Option 1", "Option 2", "Option 3","Option 4", "Option 5", "Option 6", - "Option 7", "Option 8", "Option 9","Option 10", "Option 11", "Option 12",""}; +static const char * def_options[] = {"Option 1", "Option 2", "Option 3", ""}; /********************** * MACROS **********************/ @@ -87,7 +86,6 @@ lv_obj_t * lv_ddlist_create(lv_obj_t * par, lv_obj_t * copy) lv_obj_set_style(scrl, lv_style_get(LV_STYLE_TRANSP, NULL)); ext->opt_label = lv_label_create(new_ddlist, NULL); - lv_obj_set_style(ext->opt_label, lv_style_get(LV_STYLE_PRETTY, NULL)); lv_cont_set_fit(new_ddlist, true, false); lv_page_set_rel_action(new_ddlist, lv_ddlist_rel_action); lv_page_set_sb_mode(new_ddlist, LV_PAGE_SB_MODE_DRAG); @@ -258,7 +256,7 @@ bool lv_ddlist_get_auto_size(lv_obj_t * ddlist, bool auto_size) * @param ddlist pointer to a drop down list object * @return pointer the style of the select rectangle */ -lv_style_t * lv_dlist_get_style_select(lv_obj_t * ddlist) +lv_style_t * lv_ddlist_get_style_select(lv_obj_t * ddlist) { lv_ddlist_ext_t * ext = lv_obj_get_ext(ddlist); if(ext->style_sel == NULL) return lv_obj_get_style(ddlist); diff --git a/lv_objx/lv_ddlist.h b/lv_objx/lv_ddlist.h index 11aa06590..f503cec71 100644 --- a/lv_objx/lv_ddlist.h +++ b/lv_objx/lv_ddlist.h @@ -132,7 +132,7 @@ bool lv_ddlist_get_auto_size(lv_obj_t * ddlist, bool auto_size); * @param ddlist pointer to a drop down list object * @return pointer the style of the select rectangle */ -lv_style_t * lv_dlist_get_style_select(lv_obj_t * ddlist); +lv_style_t * lv_ddlist_get_style_select(lv_obj_t * ddlist); /********************** * MACROS diff --git a/lv_objx/lv_gauge.c b/lv_objx/lv_gauge.c index ae8bda8c0..2eeaa2fa3 100644 --- a/lv_objx/lv_gauge.c +++ b/lv_objx/lv_gauge.c @@ -189,6 +189,9 @@ void lv_gauge_set_value(lv_obj_t * gauge, uint8_t needle, int16_t value) ext->values[needle] = value; + /*To be consistent with bar set the first needle's value for the bar*/ + if(needle == 0) lv_bar_set_value(gauge, value); + lv_obj_inv(gauge); } @@ -309,6 +312,11 @@ static bool lv_gauge_design(lv_obj_t * gauge, const area_t * mask, lv_design_mod int16_t min = lv_bar_get_min_value(gauge); int16_t max = lv_bar_get_max_value(gauge); + /*To be consistent with bar use the bar value as the first needle*/ + if(ext->needle_num != 0) { + ext->values[0] = lv_bar_get_value(gauge); + } + int16_t critical_val = ext->low_critical == 0 ? min : max; uint8_t i; @@ -327,7 +335,8 @@ static bool lv_gauge_design(lv_obj_t * gauge, const area_t * mask, lv_design_mod style_bg.gcolor = color_mix(style_critical->gcolor, style_base->gcolor, ratio); style_bg.bcolor = color_mix(style_critical->bcolor, style_base->bcolor, ratio); style_bg.scolor = color_mix(style_critical->scolor, style_base->scolor, ratio); - style_bg.swidth = (cord_t)((cord_t)(style_critical->swidth + style_base->swidth) * ratio) >> 8; + style_bg.swidth = (cord_t)(((cord_t)style_critical->swidth * ratio) + ((cord_t)style_base->swidth * (OPA_COVER - ratio))) >> 8; + style_bg.opa = (cord_t)(((uint16_t)style_critical->opa * ratio) + ((uint16_t)style_base->opa * (OPA_COVER - ratio))) >> 8; lv_draw_rect(&gauge->cords, mask, &style_bg); diff --git a/lv_objx/lv_img.c b/lv_objx/lv_img.c index b7a1cf52a..a97ed6db0 100644 --- a/lv_objx/lv_img.c +++ b/lv_objx/lv_img.c @@ -68,6 +68,7 @@ lv_obj_t * lv_img_create(lv_obj_t * par, lv_obj_t * copy) ext->h = lv_obj_get_height(new_img); ext->transp = 0; ext->upscale = 0; + ext->auto_size = 1; /*Init the new object*/ lv_obj_set_signal_f(new_img, lv_img_signal); diff --git a/lv_objx/lv_label.h b/lv_objx/lv_label.h index c5b6f7db3..94fd1315c 100644 --- a/lv_objx/lv_label.h +++ b/lv_objx/lv_label.h @@ -29,8 +29,8 @@ typedef enum { LV_LABEL_LONG_EXPAND, /*Expand the object size to the text size*/ - LV_LABEL_LONG_BREAK, /*Keep the width and break the text and expand the object height*/ - LV_LABEL_LONG_DOTS, /*Keep the size, break the text and write dots in the last line*/ + LV_LABEL_LONG_BREAK, /*Keep the object width, break the too long lines and expand the object height*/ + LV_LABEL_LONG_DOTS, /*Keep the object size, break the text and write dots in the last line*/ LV_LABEL_LONG_SCROLL, /*Expand the object size and scroll the text on the parent (move the label object)*/ }lv_label_long_mode_t; diff --git a/lv_objx/lv_list.c b/lv_objx/lv_list.c index b18718d09..9282a741e 100644 --- a/lv_objx/lv_list.c +++ b/lv_objx/lv_list.c @@ -291,7 +291,7 @@ void lv_list_set_style_img(lv_obj_t * list, lv_style_t * style) * @param liste pointer to list element * @return pointer to the text */ -const char * lv_list_element_get_txt(lv_obj_t * liste) +const char * lv_list_get_element_text(lv_obj_t * liste) { /*The last child is the label*/ lv_obj_t * label = lv_obj_get_child(liste, NULL); diff --git a/lv_objx/lv_list.h b/lv_objx/lv_list.h index 3dc1ee78e..b33c2e1ed 100644 --- a/lv_objx/lv_list.h +++ b/lv_objx/lv_list.h @@ -108,8 +108,8 @@ void lv_list_set_sb_out(lv_obj_t * list, bool out); * @param ina pointer to a style for inactive state */ void lv_list_set_styles_btn(lv_obj_t * list, lv_style_t * rel, lv_style_t * pr, -lv_style_t * trel, lv_style_t * tpr, -lv_style_t * ina); + lv_style_t * trel, lv_style_t * tpr, + lv_style_t * ina); /** * Set the styles of the list element image (typically to set symbol font) @@ -123,7 +123,7 @@ void lv_list_set_style_img(lv_obj_t * list, lv_style_t * style); * @param liste pointer to list element * @return pointer to the text */ -const char * lv_list_element_get_txt(lv_obj_t * liste); +const char * lv_list_get_element_text(lv_obj_t * liste); /** * Get the scroll bar outside attribute diff --git a/lv_objx/lv_ta.c b/lv_objx/lv_ta.c index 4f32419fb..837d0f967 100644 --- a/lv_objx/lv_ta.c +++ b/lv_objx/lv_ta.c @@ -518,7 +518,7 @@ static bool lv_ta_scrling_design(lv_obj_t * scrling, const area_t * mask, lv_des /*Draw the cursor too*/ lv_obj_t * ta = lv_obj_get_parent(scrling); lv_ta_ext_t * ta_ext = lv_obj_get_ext(ta); - lv_style_t * ta_style = lv_obj_get_style(ta); + lv_style_t * scrl_style = lv_obj_get_style(lv_page_get_scrl(ta)); if(ta_ext->cursor_show != 0 && ta_ext->cursor_state == 0) { uint16_t cur_pos = lv_ta_get_cursor_pos(ta); @@ -529,15 +529,15 @@ static bool lv_ta_scrling_design(lv_obj_t * scrling, const area_t * mask, lv_des lv_style_t * labels_p = lv_obj_get_style(ta_ext->label); cur_area.x1 = letter_pos.x + ta_ext->label->cords.x1; cur_area.y1 = letter_pos.y + ta_ext->label->cords.y1; - cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + LV_DOWNSCALE ; + cur_area.x2 = letter_pos.x + ta_ext->label->cords.x1 + scrl_style->line_width ; cur_area.y2 = letter_pos.y + ta_ext->label->cords.y1 + (font_get_height(labels_p->font) >> FONT_ANTIALIAS); lv_style_t cur_rects; lv_style_get(LV_STYLE_PLAIN, &cur_rects); cur_rects.radius = 0; cur_rects.bwidth = 0; - cur_rects.mcolor = ta_style->ccolor; - cur_rects.gcolor = ta_style->ccolor; + cur_rects.mcolor = scrl_style->ccolor; + cur_rects.gcolor = scrl_style->ccolor; lv_draw_rect(&cur_area, mask, &cur_rects); } } diff --git a/lv_objx/lv_win.c b/lv_objx/lv_win.c index 02e982793..09b1e73a8 100644 --- a/lv_objx/lv_win.c +++ b/lv_objx/lv_win.c @@ -208,7 +208,7 @@ bool lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param) * @param rel_action a function pointer to call when the button is released * @return pointer to the created button object */ -lv_obj_t * lv_win_add_ctrl_btn(lv_obj_t * win, const char * img_path, lv_action_t rel_action) +lv_obj_t * lv_win_add_cbtn(lv_obj_t * win, const char * img_path, lv_action_t rel_action) { lv_win_ext_t * ext = lv_obj_get_ext(win); @@ -235,7 +235,7 @@ lv_obj_t * lv_win_add_ctrl_btn(lv_obj_t * win, const char * img_path, lv_action_ */ lv_action_res_t lv_win_close_action(lv_obj_t * btn, lv_dispi_t * dispi) { - lv_obj_t * win = lv_win_get_from_ctrl_btn(btn); + lv_obj_t * win = lv_win_get_from_cbtn(btn); lv_obj_del(win); @@ -269,12 +269,12 @@ void lv_win_set_cbtn_size(lv_obj_t * win, cord_t size) } /** - * Set the style of the window control buttons in a given state + * Set the styles of the window control buttons in a given state * @param win pointer to a window object * @param rel spointer to the style in released state * @param pr pointer to the style in pressed state */ -void lv_win_set_style_cbtn(lv_obj_t * win, lv_style_t * rel, lv_style_t * pr) +void lv_win_set_styles_cbtn(lv_obj_t * win, lv_style_t * rel, lv_style_t * pr) { lv_win_ext_t * ext = lv_obj_get_ext(win); ext->style_cbtn_rel = rel; @@ -356,7 +356,7 @@ cord_t lv_win_get_width(lv_obj_t * win) * @param ctrl_btn pointer to a control button of a window * @return pointer to the window of 'ctrl_btn' */ -lv_obj_t * lv_win_get_from_ctrl_btn(lv_obj_t * ctrl_btn) +lv_obj_t * lv_win_get_from_cbtn(lv_obj_t * ctrl_btn) { lv_obj_t * ctrl_holder = lv_obj_get_parent(ctrl_btn); lv_obj_t * header = lv_obj_get_parent(ctrl_holder); diff --git a/lv_objx/lv_win.h b/lv_objx/lv_win.h index 710beea12..c94b97502 100644 --- a/lv_objx/lv_win.h +++ b/lv_objx/lv_win.h @@ -88,7 +88,7 @@ bool lv_win_signal(lv_obj_t * win, lv_signal_t sign, void * param); * @param rel_action a function pointer to call when the button is released * @return pointer to the created button object */ -lv_obj_t * lv_win_add_ctrl_btn(lv_obj_t * win, const char * img_path, lv_action_t rel_action); +lv_obj_t * lv_win_add_cbtn(lv_obj_t * win, const char * img_path, lv_action_t rel_action); /** * A release action which can be assigned to a window control button to close it @@ -113,12 +113,12 @@ void lv_win_set_title(lv_obj_t * win, const char * title); void lv_win_set_cbtn_size(lv_obj_t * win, cord_t size); /** - * Set the style of the window control buttons in a given state + * Set the styles of the window control buttons in a given state * @param win pointer to a window object * @param rel spointer to the style in released state * @param pr pointer to the style in pressed state */ -void lv_win_set_style_cbtn(lv_obj_t * win, lv_style_t * rel, lv_style_t * pr); +void lv_win_set_styles_cbtn(lv_obj_t * win, lv_style_t * rel, lv_style_t * pr); /** * Get the title of a window @@ -158,10 +158,10 @@ cord_t lv_win_get_width(lv_obj_t * win); /** * Get the pointer of a widow from one of its control button. * It is useful in the action of the control buttons where only button is known. - * @param ctrl_btn pointer to a control button of a window - * @return pointer to the window of 'ctrl_btn' + * @param cbtn pointer to a control button of a window + * @return pointer to the window of 'cbtn' */ -lv_obj_t * lv_win_get_from_ctrl_btn(lv_obj_t * ctrl_btn); +lv_obj_t * lv_win_get_from_cbtn(lv_obj_t * cbtn); /********************** * MACROS diff --git a/lvgl.h b/lvgl.h index 5e85b1f42..4f3aead70 100644 --- a/lvgl.h +++ b/lvgl.h @@ -34,7 +34,7 @@ #include "lv_objx/lv_label.h" #include "lv_objx/lv_line.h" #include "lv_objx/lv_page.h" -#include +#include "lv_objx/lv_cont.h" #include "lv_objx/lv_list.h" #include "lv_objx/lv_chart.h" #include "lv_objx/lv_cb.h"