1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

Apply the new style system on the applications too

This commit is contained in:
Gabor 2017-04-13 13:34:57 +02:00
parent 6116e83815
commit f431f262be
22 changed files with 361 additions and 438 deletions

View File

@ -78,14 +78,14 @@ 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 * sys_apph; /*Holder of the system app. buttons*/
static lv_obj_t * sc_page; /*A page for the shortcuts */
#endif
static lv_obj_t * app_list; /*A list which is opened on 'app_btn' release*/
static lv_app_inst_t * con_send; /*The sender application in connection mode. Not NLL means connection mode is active*/
static lv_app_style_t app_style; /*Styles for application related things*/
static lv_wins_t wins_anim; /*Used when the window is animated. (Do not use scrollbar during the anim.)*/
/*Declare icons*/
#if USE_IMG_CLOSE != 0
LV_IMG_DECLARE(img_close);
@ -255,7 +255,7 @@ lv_obj_t * lv_app_sc_open(lv_app_inst_t * app)
app->sc = lv_btn_create(app_scr, NULL);
#endif
lv_obj_set_free_p(app->sc, app);
lv_obj_set_style(app->sc, &app_style.sc_bg);
lv_btn_set_styles(app->sc, &app_style.sc_rel, &app_style.sc_pr, NULL, NULL, NULL);
lv_obj_set_size(app->sc, LV_APP_SC_WIDTH, LV_APP_SC_HEIGHT);
lv_rect_set_layout(app->sc, LV_RECT_LAYOUT_OFF);
lv_btn_set_rel_action(app->sc, lv_app_sc_rel_action);
@ -264,7 +264,7 @@ lv_obj_t * lv_app_sc_open(lv_app_inst_t * app)
if((app->dsc->mode & LV_APP_MODE_NO_SC_TITLE) == 0) {
/*Create a title on top of the shortcut*/
app->sc_title = lv_label_create(app->sc, NULL);
lv_obj_set_style(app->sc_title, &app_style.sc_title_style);
lv_obj_set_style(app->sc_title, &app_style.sc_title);
#if LV_APP_EFFECT_ANIM != 0
lv_label_set_long_mode(app->sc_title, LV_LABEL_LONG_SCROLL);
#else
@ -272,7 +272,7 @@ lv_obj_t * lv_app_sc_open(lv_app_inst_t * app)
lv_label_set_long_mode(app->sc_title, LV_LABEL_LONG_DOTS);
#endif
lv_label_set_text(app->sc_title, app->name);
lv_obj_align_us(app->sc_title, NULL, LV_ALIGN_IN_TOP_MID, 0, app_style.sc_title_margin);
lv_obj_align_us(app->sc_title, NULL, LV_ALIGN_IN_TOP_MID, 0, LV_DPI / 20);
} else {
app->sc_title = NULL;
}
@ -321,7 +321,7 @@ lv_obj_t * lv_app_win_open(lv_app_inst_t * app)
app->win = lv_win_create(lv_scr_act(), NULL);
lv_obj_set_free_p(app->win, app);
lv_obj_set_style(app->win, &app_style.win);
lv_obj_set_style(lv_win_get_header(app->win), &app_style.win_header);
lv_win_set_title(app->win, app->dsc->name);
if(app->dsc->conf_open != NULL) {
@ -524,22 +524,6 @@ lv_app_dsc_t ** lv_app_dsc_get_next(lv_app_dsc_t ** prev)
return next;
}
/**
* Refresh the style of the applications
* */
void lv_app_style_refr(void)
{
lv_style_refr_all(NULL);
#if LV_APP_DESKTOP != 0
lv_obj_set_width(lv_page_get_scrl(sc_page), LV_HOR_RES - 2 * (app_style.sc_page.bg.hpad));
#endif
app_style.win_useful_w = LV_HOR_RES - 2 * (app_style.win.page.bg.hpad + app_style.win.page.scrl.hpad);
app_style.win_useful_h = LV_VER_RES - 2 * (app_style.win.page.bg.vpad + app_style.win.page.scrl.vpad);
}
/**
* Get a pointer to the application style structure. If modified then 'lv_app_refr_style' should be called
@ -560,44 +544,46 @@ lv_app_style_t * lv_app_style_get(void)
*/
static void lv_app_init_desktop(void)
{
/*Shortcut area*/
sc_page = lv_page_create(lv_scr_act(), NULL);
lv_obj_set_style(sc_page, &app_style.sc_page);
lv_obj_set_size(sc_page, LV_HOR_RES, LV_VER_RES);
lv_obj_set_pos(sc_page, 0, 0);
lv_rect_set_fit(lv_page_get_scrl(sc_page), false, true);
lv_rect_set_layout(lv_page_get_scrl(sc_page), LV_RECT_LAYOUT_GRID);
lv_page_set_rel_action(sc_page, lv_app_sc_page_rel_action);
/*Menu on the top*/
menuh = lv_rect_create(lv_scr_act(), NULL);
lv_obj_set_size(menuh, LV_HOR_RES, app_style.menu_h);
lv_obj_set_pos(menuh, 0, 0);
lv_obj_set_style(menuh, &app_style.menu_bg);
lv_obj_set_width(menuh, LV_HOR_RES);
lv_rect_set_fit(menuh, false, true);
lv_obj_set_style(menuh, &app_style.menu);
app_btn = lv_btn_create(menuh, NULL);
lv_obj_set_style(app_btn, &app_style.menu_btn);
lv_obj_set_height(app_btn, app_style.menu_h);
lv_rect_set_fit(app_btn, true, false);
lv_btn_set_styles(app_btn, &app_style.menu_btn_rel, &app_style.menu_btn_pr, NULL, NULL, NULL);
lv_rect_set_fit(app_btn, true, true);
lv_btn_set_rel_action(app_btn, lv_app_menu_rel_action);
lv_obj_t * app_label = lv_label_create(app_btn, NULL);
lv_obj_set_style(app_label, &app_style.menu_btn_label);
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_rect_create(menuh, NULL);
lv_rect_set_layout(sys_apph, LV_RECT_LAYOUT_ROW_M);
lv_rect_set_fit(sys_apph, true, false);
lv_obj_set_height(sys_apph, app_style.menu_h);
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);
lv_obj_align(sys_apph, NULL, LV_ALIGN_IN_RIGHT_MID, 0, 0);*/
/*Shortcut area*/
sc_page = lv_page_create(lv_scr_act(), NULL);
lv_obj_set_style(sc_page, lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
lv_obj_set_style(lv_page_get_scrl(sc_page), lv_style_get(LV_STYLE_TRANSP, NULL));
lv_obj_set_size(sc_page, LV_HOR_RES, LV_VER_RES - lv_obj_get_height(menuh));
lv_obj_set_pos(sc_page, 0, lv_obj_get_height(menuh));
lv_obj_set_width(lv_page_get_scrl(sc_page), LV_HOR_RES - 20);
lv_rect_set_fit(lv_page_get_scrl(sc_page), false, true);
lv_rect_set_layout(lv_page_get_scrl(sc_page), LV_RECT_LAYOUT_GRID);
lv_page_set_rel_action(sc_page, lv_app_sc_page_rel_action);
lv_page_set_sb_mode(sc_page, LV_PAGE_SB_MODE_AUTO);
lv_app_style_refr();
}
#endif
/*-----------------------
@ -606,7 +592,7 @@ static void lv_app_init_desktop(void)
#if LV_APP_DESKTOP != 0
/**
* CAlled when the "Apps" button is released to open or close the app. list
* Called when the "Apps" button is released to open or close the app. list
* @param app_btn pointer to the "Apps" button
* @param dispi pointer to the caller display input
* @return LV_ACTION_RES_OK because the "Apps" button is never deleted
@ -621,9 +607,11 @@ static lv_action_res_t lv_app_menu_rel_action(lv_obj_t * app_btn, lv_dispi_t * d
/*Create the app. list*/
else {
app_list = lv_list_create(lv_scr_act(), NULL);
lv_obj_set_style(app_list, &app_style.app_list);
lv_obj_set_size(app_list, app_style.app_list_w, app_style.app_list_h);
lv_obj_set_y(app_list, app_style.menu_h);
lv_obj_t * scrl = lv_page_get_scrl(app_list);
lv_obj_set_style(scrl, &app_style.menu);
lv_obj_set_size(app_list, LV_HOR_RES / 3, (LV_VER_RES * 3) / 4);
lv_obj_align(app_list, menuh, LV_ALIGN_OUT_BOTTOM_LEFT, 0, 0);
lv_list_set_styles_liste(app_list, &app_style.menu_btn_rel, &app_style.menu_btn_pr, NULL, NULL, NULL);
lv_app_dsc_t ** dsc;
lv_obj_t * elem;
@ -681,7 +669,7 @@ static lv_action_res_t lv_app_sc_page_rel_action(lv_obj_t * page, lv_dispi_t * d
if(con_send != NULL) {
lv_app_inst_t * i;
LL_READ(app_inst_ll, i) {
if(i->sc != NULL) lv_obj_set_style(i->sc, &app_style.sc_bg);
if(i->sc != NULL) lv_btn_set_styles(i->sc, &app_style.sc_rel, &app_style.sc_pr, NULL, NULL, NULL);
}
con_send = NULL;
}
@ -726,13 +714,13 @@ static lv_action_res_t lv_app_sc_rel_action(lv_obj_t * sc, lv_dispi_t * dispi)
else {
lv_app_inst_t * app = lv_obj_get_free_p(sc);
if(app != con_send) { /*Do nothing with the sender*/
lv_btns_t * style = lv_obj_get_style(sc);
lv_style_t * style = lv_obj_get_style(sc);
/*Add connection to this application*/
if(style == &app_style.sc_bg) {
lv_obj_set_style(sc, &app_style.sc_rec_bg);
if(style == &app_style.sc_rel) {
lv_btn_set_styles(sc, &app_style.sc_rec_rel, &app_style.sc_rec_pr, NULL, NULL, NULL);
lv_app_con_set(con_send, app);
} else { /*Remove the applications connection*/
lv_obj_set_style(sc, &app_style.sc_bg);
lv_btn_set_styles(sc, &app_style.sc_rel, &app_style.sc_pr, NULL, NULL, NULL);
lv_app_con_del(con_send, app);
}
}
@ -754,23 +742,23 @@ static lv_action_res_t lv_app_sc_lpr_action(lv_obj_t * sc, lv_dispi_t * dispi)
if(con_send == app_send) {
lv_app_inst_t * i;
LL_READ(app_inst_ll, i) {
if(i->sc != NULL) lv_obj_set_style(i->sc, &app_style.sc_bg);
if(i->sc != NULL) lv_btn_set_styles(i->sc, &app_style.sc_rel, &app_style.sc_pr, NULL, NULL, NULL);
}
con_send = NULL;
} else {
if(con_send != NULL) {
lv_app_inst_t * i;
LL_READ(app_inst_ll, i) {
if(i->sc != NULL) lv_obj_set_style(i->sc, &app_style.sc_bg);
if(i->sc != NULL) lv_btn_set_styles(i->sc, &app_style.sc_rel, &app_style.sc_pr, NULL, NULL, NULL);
}
}
con_send = app_send;
lv_obj_set_style(sc, &app_style.sc_send_bg);
lv_btn_set_styles(sc, &app_style.sc_send_rel, &app_style.sc_send_pr, NULL, NULL, NULL);
lv_app_inst_t * i;
LL_READ(app_inst_ll, i) {
if(i->sc != NULL && lv_app_con_check(con_send, i) != false) {
lv_obj_set_style(i->sc, &app_style.sc_rec_bg);
lv_btn_set_styles(i->sc, &app_style.sc_rec_rel, &app_style.sc_rec_pr, NULL, NULL, NULL);
}
}
}
@ -797,23 +785,13 @@ static lv_action_res_t lv_app_win_close_action(lv_obj_t * close_btn, lv_dispi_t
#if LV_APP_EFFECT_ANIM != 0 && LV_APP_EFFECT_OPA != 0 && LV_APP_ANIM_WIN != 0
/*Temporally set a simpler style for the window during the animation*/
memcpy(&wins_anim, lv_obj_get_style(app->win), sizeof(lv_wins_t));
wins_anim.page.sb_mode = LV_PAGE_SB_MODE_OFF;
/*Mix a new color for the header instead of using opacity */
wins_anim.header.base.opa = OPA_COVER;
wins_anim.header.gcolor = color_mix(wins_anim.header.gcolor,
app_style.win.page.bg.gcolor,
app_style.win.header.base.opa);
lv_obj_t * win_page = lv_win_get_page(win);
lv_page_set_sb_mode(win_page, LV_PAGE_SB_MODE_OFF);
wins_anim.header.base.color = color_mix(wins_anim.header.base.color,
app_style.win.page.bg.base.color,
app_style.win.header.base.opa);
lv_obj_set_style(app->win, &wins_anim);
/*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_win_ext_t *)app->win->ext)->page.scrl, true);
lv_obj_set_hidden(lv_page_get_scrl(win_page), true);
lv_obj_anim(app->win, LV_ANIM_FLOAT_BOTTOM | ANIM_OUT, LV_APP_ANIM_WIN, 0, NULL);
lv_obj_anim(app->win, LV_ANIM_FLOAT_LEFT | ANIM_OUT, LV_APP_ANIM_WIN, 0, lv_app_win_close_anim_cb);
@ -866,14 +844,12 @@ static lv_action_res_t lv_app_win_conf_action(lv_obj_t * set_btn, lv_dispi_t * d
app->conf_win = lv_win_create(lv_scr_act(), NULL);
lv_obj_set_free_p(app->conf_win, app);
lv_obj_set_style(app->conf_win, &app_style.win);
char buf[256];
sprintf(buf, "%s settings", app->dsc->name);
lv_win_set_title(app->conf_win, buf);
lv_obj_t * scrl = lv_page_get_scrl(app->conf_win);
lv_rect_set_fit(scrl, false, true);
lv_rect_set_layout(scrl, LV_RECT_LAYOUT_COL_L);
lv_obj_set_width(scrl, LV_HOR_RES - 2 * app_style.win.page.bg.hpad);
lv_win_add_ctrl_btn(app->conf_win, "U:/icon_close" ,lv_win_close_action);
@ -905,24 +881,17 @@ 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*/
memcpy(&wins_anim, lv_obj_get_style(app->win), sizeof(lv_wins_t));
wins_anim.page.sb_mode = LV_PAGE_SB_MODE_OFF;
/*Mix a new color for the header instead of using opacity */
wins_anim.header.base.opa = OPA_COVER;
wins_anim.header.gcolor = color_mix(wins_anim.header.gcolor,
app_style.win.page.bg.gcolor,
app_style.win.header.base.opa);
wins_anim.header.base.color = color_mix(wins_anim.header.base.color,
app_style.win.page.bg.base.color,
app_style.win.header.base.opa);
lv_obj_set_style(app->win, &wins_anim);
/*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);
/*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_win_ext_t *)app->win->ext)->page.scrl, true);
lv_obj_set_hidden(lv_page_get_scrl(win_page), true);
anim_t a;
a.act_time = 0;
@ -986,23 +955,19 @@ static lv_action_res_t lv_app_win_minim_anim_create(lv_app_inst_t * app)
}
/*Temporally set a simpler style for the window during the animation*/
memcpy(&wins_anim, lv_obj_get_style(app->win), sizeof(lv_wins_t));
wins_anim.page.sb_mode = LV_PAGE_SB_MODE_OFF;
/*Mix a new color for the header instead of using opacity */
wins_anim.header.base.opa = OPA_COVER;
wins_anim.header.gcolor = color_mix(wins_anim.header.gcolor,
app_style.win.page.bg.gcolor,
app_style.win.header.base.opa);
wins_anim.header.base.color = color_mix(wins_anim.header.base.color,
app_style.win.page.bg.base.color,
app_style.win.header.base.opa);
lv_obj_set_style(app->win, &wins_anim);
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_win_ext_t *)app->win->ext)->page.scrl, 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);
lv_obj_set_hidden(lv_page_get_scrl(win_page), true);
anim_t a;
a.act_time = 0;
@ -1051,13 +1016,12 @@ static lv_action_res_t lv_app_win_minim_anim_create(lv_app_inst_t * app)
*/
static void lv_app_win_open_anim_cb(lv_obj_t * app_win)
{
lv_obj_t * win_page = lv_win_get_page(app_win);
/*Unhide the the elements*/
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_win_ext_t *)app_win->ext)->page.scrl, false);
/*Restore the style*/
lv_obj_set_style(app_win, &app_style.win);
lv_obj_set_hidden(lv_page_get_scrl(win_page), false);
}
/**
@ -1087,148 +1051,102 @@ static void lv_app_win_minim_anim_cb(lv_obj_t * app_win)
*/
static void lv_app_init_style(void)
{
/*Coordinates*/
#if LV_APP_DESKTOP != 0
app_style.menu_h = 4 * LV_DPI / 5;
app_style.app_list_w = LV_HOR_RES / 3;
app_style.app_list_h = (3 * LV_VER_RES) / 4;
#else
app_style.menu_h = 0;
app_style.app_list_w = 0;
app_style.app_list_h = 0;
#endif
app_style.sc_title_margin = 2 * LV_DOWNSCALE;
/*Menu style*/
lv_rects_get(LV_RECTS_PLAIN,&app_style.menu_bg);
app_style.menu_bg.base.color = COLOR_BLACK;
app_style.menu_bg.gcolor = COLOR_BLACK;
app_style.menu_bg.base.opa = OPA_80;
app_style.menu_bg.radius = 0;
app_style.menu_bg.bwidth = 0;
app_style.menu_bg.swidth = 0;
app_style.menu_bg.vpad = LV_DPI / 10;
app_style.menu_bg.hpad = LV_DPI / 10;
app_style.menu_bg.opad = LV_DPI / 10;
lv_style_get(LV_STYLE_PLAIN,&app_style.menu);
app_style.menu.ccolor = COLOR_WHITE;
app_style.menu.mcolor = COLOR_BLACK;
app_style.menu.gcolor = COLOR_BLACK;
app_style.menu.opa = OPA_80;
app_style.menu.radius = 0;
app_style.menu.bwidth = 0;
app_style.menu.swidth = 0;
app_style.menu.vpad = LV_DPI / 10;
app_style.menu.hpad = LV_DPI / 10;
app_style.menu.opad = LV_DPI / 10;
lv_btns_get(LV_BTNS_DEF,&app_style.menu_btn);
app_style.menu_btn.state_style[LV_BTN_STATE_REL].base.color = COLOR_BLACK;
app_style.menu_btn.state_style[LV_BTN_STATE_REL].gcolor = COLOR_BLACK;
app_style.menu_btn.state_style[LV_BTN_STATE_REL].bwidth = 0;
app_style.menu_btn.state_style[LV_BTN_STATE_REL].radius = 0;
app_style.menu_btn.state_style[LV_BTN_STATE_REL].swidth = 0;
app_style.menu_btn.state_style[LV_BTN_STATE_REL].empty = 1;
lv_style_get(LV_STYLE_BTN_REL,&app_style.menu_btn_rel);
app_style.menu_btn_rel.ccolor = COLOR_MAKE(0xd0, 0xe0, 0xf0);
app_style.menu_btn_rel.mcolor = COLOR_BLACK;
app_style.menu_btn_rel.gcolor = COLOR_BLACK;
app_style.menu_btn_rel.bwidth = 0;
app_style.menu_btn_rel.radius = 0;
app_style.menu_btn_rel.swidth = 0;
app_style.menu_btn_rel.empty = 1;
app_style.menu_btn_rel.font = font_get(LV_APP_FONT_LARGE);
app_style.menu_btn_rel.img_recolor = OPA_90;
app_style.menu_btn.state_style[LV_BTN_STATE_PR].base.color = COLOR_GRAY;
app_style.menu_btn.state_style[LV_BTN_STATE_PR].gcolor = COLOR_GRAY;
app_style.menu_btn.state_style[LV_BTN_STATE_PR].bwidth = 0;
app_style.menu_btn.state_style[LV_BTN_STATE_PR].radius = 0;
app_style.menu_btn.state_style[LV_BTN_STATE_PR].empty = 0;
app_style.menu_btn.state_style[LV_BTN_STATE_PR].swidth = 0;
lv_labels_get(LV_LABELS_BTN,&app_style.menu_btn_label);
app_style.menu_btn_label.font = font_get(LV_APP_FONT_LARGE);
app_style.menu_btn_label.base.color = COLOR_MAKE(0xd0, 0xe0, 0xf0);
lv_imgs_get(LV_IMGS_DEF,&app_style.menu_btn_img);
app_style.menu_btn_img.base.color = COLOR_WHITE;
app_style.menu_btn_img.recolor_opa = OPA_90;
/*App list styles*/
lv_lists_get(LV_LISTS_DEF,&app_style.app_list);
app_style.app_list.width_sb = 0; /*Do not keep place for the scrollbar*/
memcpy(&app_style.app_list.page.scrl, &app_style.menu_bg, sizeof(lv_rects_t));
app_style.app_list.page.bg.hpad = 0 * LV_DOWNSCALE;
app_style.app_list.page.bg.hpad = 0 * LV_DOWNSCALE;
app_style.app_list.page.bg.vpad = 0 * LV_DOWNSCALE;
app_style.app_list.page.bg.opad = 0 * LV_DOWNSCALE;
app_style.app_list.page.scrl.hpad = 0 * LV_DOWNSCALE;
app_style.app_list.page.scrl.vpad = 0 * LV_DOWNSCALE;
app_style.app_list.page.scrl.opad = 0 * LV_DOWNSCALE;
memcpy(&app_style.app_list.liste_label, &app_style.menu_btn_label, sizeof(lv_labels_t));
memcpy(&app_style.app_list.liste_btn, &app_style.menu_btn, sizeof(lv_btns_t));
app_style.app_list.page.sb.base.color = COLOR_GRAY;
app_style.app_list.page.sb.gcolor = COLOR_GRAY;
app_style.app_list.page.sb_width = 8 * LV_DOWNSCALE;
/*Shortcut page styles*/
lv_pages_get(LV_PAGES_TRANSP,&app_style.sc_page);
app_style.sc_page.bg.vpad = app_style.menu_h;
app_style.sc_page.bg.hpad = 0;
app_style.sc_page.bg.opad = 0;
app_style.sc_page.scrl.hpad = 10 * LV_DOWNSCALE;
app_style.sc_page.scrl.vpad = 10 * LV_DOWNSCALE;
app_style.sc_page.scrl.opad = 15 * LV_DOWNSCALE;
memcpy(&app_style.menu_btn_pr, &app_style.menu_btn_rel, sizeof(lv_style_t));
app_style.menu_btn_pr.mcolor = COLOR_GRAY;
app_style.menu_btn_pr.gcolor = COLOR_GRAY;
app_style.menu_btn_pr.bwidth = 0;
app_style.menu_btn_pr.radius = 0;
app_style.menu_btn_pr.empty = 0;
app_style.menu_btn_pr.swidth = 0;
/*Shortcut styles*/
lv_btns_get(LV_BTNS_DEF,&app_style.sc_bg);
app_style.sc_bg.state_style[LV_BTN_STATE_REL].base.opa = OPA_80;
app_style.sc_bg.state_style[LV_BTN_STATE_REL].base.color = COLOR_WHITE;
app_style.sc_bg.state_style[LV_BTN_STATE_REL].gcolor = COLOR_MAKE(0x20, 0x30, 0x40);
app_style.sc_bg.state_style[LV_BTN_STATE_REL].bcolor = COLOR_MAKE(0x40, 0x60, 0x80);
app_style.sc_bg.state_style[LV_BTN_STATE_REL].bopa = OPA_70;
app_style.sc_bg.state_style[LV_BTN_STATE_REL].bwidth = 1 * LV_DOWNSCALE;
app_style.sc_bg.state_style[LV_BTN_STATE_REL].swidth = 0 * LV_DOWNSCALE;
app_style.sc_bg.state_style[LV_BTN_STATE_PR].base.opa = OPA_80;
app_style.sc_bg.state_style[LV_BTN_STATE_PR].base.color = COLOR_MAKE(0xB0, 0xD0, 0xF0);
app_style.sc_bg.state_style[LV_BTN_STATE_PR].gcolor = COLOR_MAKE(0x00, 0x00, 0x00);
app_style.sc_bg.state_style[LV_BTN_STATE_PR].bcolor = COLOR_MAKE(0xB0, 0xD0, 0xF0);
app_style.sc_bg.state_style[LV_BTN_STATE_PR].bopa = OPA_70;
app_style.sc_bg.state_style[LV_BTN_STATE_PR].bwidth = 1 * LV_DOWNSCALE;
app_style.sc_bg.state_style[LV_BTN_STATE_PR].swidth = 0 * LV_DOWNSCALE;
lv_style_get(LV_STYLE_BTN_REL,&app_style.sc_rel);
app_style.sc_rel.ccolor = COLOR_MAKE(0x10, 0x18, 0x20);
app_style.sc_rel.opa = OPA_80;
app_style.sc_rel.mcolor = COLOR_WHITE;
app_style.sc_rel.gcolor = COLOR_MAKE(0x20, 0x30, 0x40);
app_style.sc_rel.bcolor = COLOR_MAKE(0x40, 0x60, 0x80);
app_style.sc_rel.bopa = OPA_70;
app_style.sc_rel.bwidth = 1 * LV_DOWNSCALE;
app_style.sc_rel.swidth = 0 * LV_DOWNSCALE;
app_style.sc_rel.font = font_get(LV_APP_FONT_MEDIUM);
app_style.sc_rel.txt_align = 1;
memcpy(&app_style.sc_send_bg, &app_style.sc_bg, sizeof(lv_btns_t));
app_style.sc_send_bg.state_style[LV_BTN_STATE_REL].base.color = COLOR_MAKE(0xFF, 0xE0, 0xE0);
app_style.sc_send_bg.state_style[LV_BTN_STATE_REL].gcolor = COLOR_MAKE(0x50, 0x20, 0x00);
app_style.sc_send_bg.state_style[LV_BTN_STATE_REL].bcolor = COLOR_BLACK;
app_style.sc_send_bg.state_style[LV_BTN_STATE_REL].bopa = OPA_30;
app_style.sc_send_bg.state_style[LV_BTN_STATE_REL].bwidth = 3 * LV_DOWNSCALE;
app_style.sc_send_bg.state_style[LV_BTN_STATE_PR].base.color = COLOR_MAKE(0xFF, 0xB0, 0xB0);
app_style.sc_send_bg.state_style[LV_BTN_STATE_PR].gcolor = COLOR_MAKE(0x20, 0x10, 0x00);
app_style.sc_send_bg.state_style[LV_BTN_STATE_PR].gcolor = COLOR_BLACK;
app_style.sc_send_bg.state_style[LV_BTN_STATE_PR].bopa = OPA_30;
app_style.sc_send_bg.state_style[LV_BTN_STATE_PR].bwidth = 3 * LV_DOWNSCALE;
memcpy(&app_style.sc_pr, &app_style.sc_rel, sizeof(lv_style_t));
app_style.sc_pr.opa = OPA_80;
app_style.sc_pr.mcolor = COLOR_MAKE(0xB0, 0xD0, 0xF0);
app_style.sc_pr.gcolor = COLOR_MAKE(0x00, 0x00, 0x00);
app_style.sc_pr.bcolor = COLOR_MAKE(0xB0, 0xD0, 0xF0);
app_style.sc_pr.bopa = OPA_70;
app_style.sc_pr.bwidth = 1 * LV_DOWNSCALE;
app_style.sc_pr.swidth = 0 * LV_DOWNSCALE;
memcpy(&app_style.sc_rec_bg, &app_style.sc_bg, sizeof(lv_btns_t));
app_style.sc_rec_bg.state_style[LV_BTN_STATE_REL].base.color = COLOR_MAKE(0xE0, 0xFF, 0xE0);
app_style.sc_rec_bg.state_style[LV_BTN_STATE_REL].gcolor = COLOR_MAKE(0x20, 0x50, 0x20);
app_style.sc_rec_bg.state_style[LV_BTN_STATE_REL].bcolor = COLOR_BLACK;
app_style.sc_rec_bg.state_style[LV_BTN_STATE_REL].bopa = OPA_30;
app_style.sc_rec_bg.state_style[LV_BTN_STATE_REL].bwidth = 3 * LV_DOWNSCALE;
app_style.sc_rec_bg.state_style[LV_BTN_STATE_PR].base.color = COLOR_MAKE(0xB0, 0xFF, 0xB0);
app_style.sc_rec_bg.state_style[LV_BTN_STATE_PR].gcolor = COLOR_MAKE(0x20, 0x20, 0x10);
app_style.sc_rec_bg.state_style[LV_BTN_STATE_PR].bcolor = COLOR_BLACK;
app_style.sc_rec_bg.state_style[LV_BTN_STATE_PR].bopa = OPA_30;
app_style.sc_rec_bg.state_style[LV_BTN_STATE_PR].bwidth = 3 * LV_DOWNSCALE;
memcpy(&app_style.sc_send_rel, &app_style.sc_rel, sizeof(lv_style_t));
app_style.sc_send_rel.mcolor = COLOR_MAKE(0xFF, 0xE0, 0xE0);
app_style.sc_send_rel.gcolor = COLOR_MAKE(0x50, 0x20, 0x00);
app_style.sc_send_rel.bcolor = COLOR_BLACK;
app_style.sc_send_rel.bopa = OPA_30;
app_style.sc_send_rel.bwidth = 3 * LV_DOWNSCALE;
lv_labels_get(LV_LABELS_TITLE,&app_style.sc_title_style);
app_style.sc_title_style.font = font_get(LV_APP_FONT_SMALL);
app_style.sc_title_style.base.color = COLOR_MAKE(0x10, 0x18, 0x20);
app_style.sc_title_style.mid = 1;
memcpy(&app_style.sc_send_pr, &app_style.sc_pr, sizeof(lv_style_t));
app_style.sc_send_pr.mcolor = COLOR_MAKE(0xFF, 0xB0, 0xB0);
app_style.sc_send_pr.gcolor = COLOR_MAKE(0x20, 0x10, 0x00);
app_style.sc_send_pr.gcolor = COLOR_BLACK;
app_style.sc_send_pr.bopa = OPA_30;
app_style.sc_send_pr.bwidth = 3 * LV_DOWNSCALE;
lv_labels_get(LV_LABELS_TXT, &app_style.sc_txt_style);
app_style.sc_txt_style.font = font_get(LV_APP_FONT_MEDIUM);
app_style.sc_txt_style.base.color = COLOR_MAKE(0x10, 0x18, 0x20);
app_style.sc_txt_style.mid = 1;
memcpy(&app_style.sc_rec_rel, &app_style.sc_send_rel, sizeof(lv_style_t));
app_style.sc_rec_rel.mcolor = COLOR_MAKE(0xE0, 0xFF, 0xE0);
app_style.sc_rec_rel.gcolor = COLOR_MAKE(0x20, 0x50, 0x20);
app_style.sc_rec_rel.bcolor = COLOR_BLACK;
app_style.sc_rec_rel.bopa = OPA_30;
app_style.sc_rec_rel.bwidth = 3 * LV_DOWNSCALE;
/*Window styles*/
lv_wins_get(LV_WINS_DEF,&app_style.win);
app_style.win.page.bg.vpad = app_style.win.ctrl_btn_h + 2 * app_style.win.header.vpad;
app_style.win.page.sb_mode = LV_PAGE_SB_MODE_AUTO;
memcpy(&app_style.win.header, &app_style.menu_bg, sizeof(lv_rects_t));
app_style.win.header.base.opa = app_style.menu_bg.base.opa;
memcpy(&app_style.win.title, &app_style.menu_btn_label, sizeof(lv_labels_t));
memcpy(&app_style.win.ctrl_btn, &app_style.menu_btn, sizeof(lv_btns_t));
app_style.win.ctrl_btn.state_style[LV_BTN_STATE_REL].base.opa = app_style.menu_btn.state_style[LV_BTN_STATE_REL].base.opa;
app_style.win.ctrl_btn.state_style[LV_BTN_STATE_PR].base.opa = app_style.menu_btn.state_style[LV_BTN_STATE_REL].base.opa;
memcpy(&app_style.win.ctrl_img, &app_style.menu_btn_img, sizeof(lv_imgs_t));
memcpy(&app_style.sc_rec_pr, &app_style.sc_send_pr, sizeof(lv_style_t));
app_style.sc_rec_pr.mcolor = COLOR_MAKE(0xB0, 0xFF, 0xB0);
app_style.sc_rec_pr.gcolor = COLOR_MAKE(0x20, 0x20, 0x10);
app_style.sc_rec_pr.bcolor = COLOR_BLACK;
app_style.sc_rec_pr.bopa = OPA_30;
app_style.sc_rec_pr.bwidth = 3 * LV_DOWNSCALE;
lv_labels_get(LV_LABELS_TXT,&app_style.win_txt_style);
app_style.win_txt_style.font = font_get(LV_APP_FONT_MEDIUM);
app_style.win_txt_style.base.color = COLOR_MAKE(0x20, 0x20, 0x20);
app_style.win_txt_style.mid = 0;
app_style.win_txt_style.letter_space = 1 * LV_DOWNSCALE;
memcpy(&app_style.sc_title, &app_style.sc_rel, sizeof(lv_style_t));
app_style.sc_title.font = font_get(LV_APP_FONT_SMALL);
/*Window*/
lv_style_get(LV_STYLE_PLAIN_COLOR, &app_style.win_header);
app_style.win_header.font = font_get(LV_APP_FONT_LARGE);
lv_style_get(LV_STYLE_TRANSP, &app_style.win_scrl);
lv_style_get(LV_STYLE_BTN_REL, &app_style.win_cbtn_rel);
app_style.win_cbtn_rel.font = font_get(LV_IMG_DEF_SYMBOL_FONT);
memcpy(&app_style.win_cbtn_pr, &app_style.win_cbtn_rel, sizeof(lv_style_t));
}
/**

View File

@ -71,28 +71,20 @@ typedef struct __LV_APP_DSC_T
}lv_app_dsc_t;
typedef struct {
lv_rects_t menu_bg;
lv_btns_t menu_btn;
lv_labels_t menu_btn_label;
lv_imgs_t menu_btn_img;
lv_lists_t app_list;
lv_pages_t sc_page;
lv_labels_t win_txt_style;
lv_wins_t win;
lv_btns_t sc_bg;
lv_btns_t sc_send_bg;
lv_btns_t sc_rec_bg;
lv_labels_t sc_title_style;
lv_labels_t sc_txt_style;
cord_t menu_h;
cord_t app_list_w;
cord_t app_list_h;
cord_t sc_title_margin;
/*Calculated values, do not set them!*/
cord_t win_useful_w;
cord_t win_useful_h;
lv_style_t menu;
lv_style_t menu_btn_rel;
lv_style_t menu_btn_pr;
lv_style_t sc_rel;
lv_style_t sc_pr;
lv_style_t sc_send_rel;
lv_style_t sc_send_pr;
lv_style_t sc_rec_rel;
lv_style_t sc_rec_pr;
lv_style_t sc_title;
lv_style_t win_header;
lv_style_t win_scrl;
lv_style_t win_cbtn_rel;
lv_style_t win_cbtn_pr;
}lv_app_style_t;
@ -213,10 +205,6 @@ lv_app_inst_t * lv_app_get_next(lv_app_inst_t * prev, lv_app_dsc_t * dsc);
*/
lv_app_dsc_t ** lv_app_dsc_get_next(lv_app_dsc_t ** prev);
/**
* Refresh the style of the applications
* */
void lv_app_style_refr(void);
/**
* Get a pointer to the application style structure. If modified then 'lv_app_refr_style' should be called

View File

@ -45,7 +45,6 @@ static char fsel_path[LV_APP_FSEL_PATH_MAX_LEN];
static uint16_t fsel_file_cnt;
static lv_obj_t * fsel_win;
static lv_obj_t * fsel_list;
static lv_lists_t fsel_lists;
static void * fsel_param;
static void (*fsel_ok_action)(void *, const char *);
@ -62,7 +61,7 @@ static void (*fsel_ok_action)(void *, const char *);
*/
void lv_app_fsel_init(void)
{
lv_lists_get(LV_LISTS_TRANSP, &fsel_lists);
//TODO lv_lists_get(LV_LISTS_TRANSP, &fsel_lists);
}
/**
@ -95,7 +94,6 @@ void lv_app_fsel_open(const char * path, const char * filter, void * param, void
lv_app_style_t * app_style = lv_app_style_get();
fsel_win = lv_win_create(lv_scr_act(), NULL);
lv_obj_set_size(fsel_win, LV_HOR_RES, LV_VER_RES);
lv_obj_set_style(fsel_win, &app_style->win);
lv_win_add_ctrl_btn(fsel_win, "U:/icon_close", fsel_close_action);
@ -139,10 +137,9 @@ static void fsel_refr(void)
lv_win_set_title(fsel_win, fsel_path);
/*Create a new list*/
lv_app_style_t * app_style = lv_app_style_get();
fsel_list = lv_list_create(fsel_win, NULL);
lv_obj_set_width(fsel_list, app_style->win_useful_w);
lv_obj_set_style(fsel_list, lv_lists_get(LV_LISTS_TRANSP, 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_obj_set_drag_parent(fsel_list, true);
lv_obj_set_drag_parent(lv_page_get_scrl(fsel_list), true);
lv_rect_set_fit(fsel_list, false, true);

View File

@ -63,8 +63,8 @@ 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_btnms_t kb_btnms;
static lv_style_t style_btn_rel;
static lv_style_t style_btn_pr;
/**********************
* MACROS
**********************/
@ -78,18 +78,8 @@ static lv_btnms_t kb_btnms;
*/
void lv_app_kb_init(void)
{
lv_app_style_t * app_style = lv_app_style_get();
lv_btnms_get(LV_BTNMS_DEF, &kb_btnms);
memcpy(&kb_btnms.bg, &app_style->menu_bg, sizeof(lv_rects_t));
kb_btnms.bg.hpad = 0;
kb_btnms.bg.vpad = 0;
kb_btnms.bg.opad = 0;
memcpy(&kb_btnms.btn, &app_style->menu_btn, sizeof(lv_btns_t));
kb_btnms.btn.state_style[LV_BTN_STATE_REL].bwidth = 1 * LV_DOWNSCALE;
kb_btnms.btn.state_style[LV_BTN_STATE_REL].bcolor = COLOR_GRAY;
memcpy(&kb_btnms.label, &app_style->menu_btn_label, sizeof(lv_labels_t));
lv_style_get(LV_STYLE_BTN_REL, &style_btn_rel);
lv_style_get(LV_STYLE_BTN_PR, &style_btn_pr);
}
/**
@ -118,14 +108,16 @@ void lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t
lv_obj_align(kb_btnm, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0);
lv_btnm_set_action(kb_btnm, lv_app_kb_action);
if(mode & LV_APP_KB_MODE_TXT) {
kb_btnms.label.font = font_get(LV_APP_FONT_MEDIUM);
style_btn_rel.font = font_get(LV_APP_FONT_MEDIUM);
style_btn_pr.font = font_get(LV_APP_FONT_MEDIUM);
lv_btnm_set_map(kb_btnm, kb_map_lc);
}
else if(mode & LV_APP_KB_MODE_NUM) {
kb_btnms.label.font = font_get(LV_APP_FONT_LARGE);
style_btn_rel.font = font_get(LV_APP_FONT_LARGE);
style_btn_pr.font = font_get(LV_APP_FONT_LARGE);
lv_btnm_set_map(kb_btnm, kb_map_num);
}
lv_obj_set_style(kb_btnm, &kb_btnms);
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);
@ -133,8 +125,7 @@ void lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t
lv_obj_set_y(kb_win, 0);
/*If the text area is higher then the new size of the window reduce its size too*/
lv_app_style_t * app_style = lv_app_style_get();
cord_t win_h = lv_obj_get_height(kb_win) - 2 * app_style->win.page.bg.vpad;
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);
@ -145,7 +136,7 @@ void lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t
#if LV_APP_ANIM_LEVEL != 0
lv_page_focus(lv_win_get_content(kb_win), kb_ta, true);
#else
lv_page_focus(kb_win, kb_ta, false);
lv_page_focus(lv_win_get_page(kb_win), kb_ta, false);
#endif
}
@ -241,7 +232,7 @@ static lv_action_res_t lv_app_kb_action(lv_obj_t * btnm, uint16_t i)
#if LV_APP_ANIM_LEVEL != 0
lv_page_focus(lv_win_get_content(kb_win), kb_ta, true);
#else
lv_page_focus(kb_win, kb_ta, false);
lv_page_focus(lv_win_get_page(kb_win), kb_ta, false);
#endif
return LV_ACTION_RES_OK;
}

View File

@ -56,13 +56,11 @@ static lv_obj_t * notice_h;
*/
void lv_app_notice_init(void)
{
lv_app_style_t * app_style = lv_app_style_get();
notice_h = lv_rect_create(lv_scr_act(), NULL);
lv_obj_set_size(notice_h, LV_HOR_RES, LV_VER_RES - app_style->menu_h - LV_DPI / 8);
lv_obj_set_y(notice_h, app_style->menu_h + LV_DPI / 8);
lv_obj_set_size(notice_h, LV_HOR_RES, LV_VER_RES - LV_DPI);
lv_obj_set_y(notice_h, LV_DPI);
lv_obj_set_click(notice_h, false);
lv_obj_set_style(notice_h, lv_rects_get(LV_RECTS_TRANSP, NULL));
lv_obj_set_style(notice_h, lv_style_get(LV_STYLE_TRANSP, NULL));
lv_rect_set_layout(notice_h, LV_RECT_LAYOUT_COL_R);
}
@ -82,8 +80,7 @@ lv_obj_t * lv_app_notice_add(const char * format, ...)
lv_obj_t * mbox;
mbox = lv_mbox_create(notice_h, NULL);
lv_obj_set_style(mbox, lv_mboxs_get(LV_MBOXS_INFO, NULL));
lv_mbox_set_title(mbox, "");
// lv_obj_set_style(mbox, lv_mboxs_get(LV_MBOXS_INFO, NULL));
lv_mbox_set_text(mbox, txt);
#if LV_APP_NOTICE_SHOW_TIME != 0

View File

@ -143,11 +143,9 @@ static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
{
my_sc_data_t * sc_data = app->sc_data;
lv_app_style_t * app_style = lv_app_style_get();
sc_data->label = lv_label_create(sc, NULL);
lv_label_set_text(sc_data->label, "Empty");
lv_obj_set_style(sc_data->label, &app_style->sc_txt_style);
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
}

View File

@ -112,7 +112,7 @@ static lv_app_dsc_t my_app_dsc =
.win_data_size = sizeof(my_win_data_t),
};
static lv_labels_t sc_labels;
static lv_style_t style_sc_label;
/**********************
@ -130,9 +130,8 @@ static lv_labels_t sc_labels;
const lv_app_dsc_t * lv_app_files_init(void)
{
lv_app_style_t * app_style = lv_app_style_get();
memcpy(&sc_labels, &app_style->sc_txt_style, sizeof(lv_labels_t));
sc_labels.font = font_get(LV_APP_FONT_LARGE);
memcpy(&style_sc_label, &app_style->sc_rec_rel, sizeof(lv_style_t));
style_sc_label.font = font_get(LV_APP_FONT_LARGE);
return &my_app_dsc;
}
@ -219,7 +218,7 @@ static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
sc_data->label = lv_label_create(sc, NULL);
lv_obj_set_style(sc_data->label, &sc_labels);
lv_obj_set_style(sc_data->label, &style_sc_label);
lv_label_set_text(sc_data->label, fs_get_last(app_data->path));
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
}
@ -298,10 +297,10 @@ static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win)
if(app_data->send_crc != 0) lv_btn_set_state(cb, LV_BTN_STATE_TREL);
else lv_btn_set_state(cb, LV_BTN_STATE_REL);
/*Create a text area the type chunk size*/
/*Create a text area to type chunk size*/
lv_obj_t * val_set_h;
val_set_h = lv_rect_create(conf_win, NULL);
lv_obj_set_style(val_set_h, lv_rects_get(LV_RECTS_TRANSP, NULL));
lv_obj_set_style(val_set_h, lv_style_get(LV_STYLE_PLAIN_COLOR, NULL));
lv_obj_set_click(val_set_h, false);
lv_rect_set_fit(val_set_h, true, true);
lv_rect_set_layout(val_set_h, LV_RECT_LAYOUT_ROW_M);
@ -313,7 +312,6 @@ static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win)
lv_obj_t * ta;
char buf[32];
ta = lv_ta_create(val_set_h, NULL);
lv_obj_set_style(ta, lv_tas_get(LV_TAS_DEF, NULL));
lv_rect_set_fit(ta, false, true);
lv_obj_set_free_num(ta, SEND_SETTINGS_CHUNK_SIZE);
lv_obj_set_free_p(ta, app);
@ -342,7 +340,6 @@ static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win)
*/
static void win_create_list(lv_app_inst_t * app)
{
lv_app_style_t * app_style = lv_app_style_get();
my_win_data_t * win_data = app->win_data;
/*Delete the previous list*/
@ -352,8 +349,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, app_style->win_useful_w);
lv_obj_set_style(win_data->file_list, lv_lists_get(LV_LISTS_TRANSP, 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_obj_set_drag_parent(win_data->file_list, true);
lv_obj_set_drag_parent(lv_page_get_scrl(win_data->file_list), true);
lv_rect_set_fit(win_data->file_list, false, true);

View File

@ -36,8 +36,8 @@ typedef struct
typedef struct
{
lv_obj_t * chart;
cord_t * cpu_dl;
cord_t * mem_dl;
lv_chart_dl_t * cpu_dl;
lv_chart_dl_t * mem_dl;
lv_obj_t * label;
}my_win_data_t;
@ -83,8 +83,8 @@ 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_bars_t cpu_bars;
static lv_bars_t mem_bars;
static lv_style_t cpu_bars;
static lv_style_t mem_bars;
#if USE_DYN_MEM != 0 && DM_CUSTOM == 0
static dm_mon_t mem_mon;
#endif
@ -109,30 +109,21 @@ const lv_app_dsc_t * lv_app_sysmon_init(void)
memset(cpu_pct, 0, sizeof(cpu_pct));
/*Create bar styles for the shortcut*/
lv_bars_get(LV_BARS_DEF, &cpu_bars);
cpu_bars.bg.gcolor = COLOR_MAKE(0xFF, 0xE0, 0xE0);
cpu_bars.bg.base.color = COLOR_MAKE(0xFF, 0xD0, 0xD0);
cpu_bars.bg.bcolor = COLOR_MAKE(0xFF, 0x20, 0x20);
cpu_bars.bg.bwidth = 1 * LV_DOWNSCALE;
lv_style_get(LV_STYLE_PRETTY_COLOR, &cpu_bars);
cpu_bars.indic.gcolor = COLOR_MARRON;
cpu_bars.indic.base.color = COLOR_RED;
cpu_bars.indic.bwidth = 0;
cpu_bars.gcolor = COLOR_MARRON;
cpu_bars.mcolor = COLOR_RED;
cpu_bars.bwidth = 0;
cpu_bars.label.base.color = COLOR_MAKE(0x40, 0x00, 0x00);
cpu_bars.label.font = font_get(LV_APP_FONT_MEDIUM);
cpu_bars.label.line_space = 0;
cpu_bars.label.mid = 1;
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;
memcpy(&mem_bars, &cpu_bars, sizeof(cpu_bars));
mem_bars.bg.gcolor = COLOR_MAKE(0xD0, 0xFF, 0xD0);
mem_bars.bg.base.color = COLOR_MAKE(0xE0, 0xFF, 0xE0);
mem_bars.bg.bcolor = COLOR_MAKE(0x20, 0xFF, 0x20);
mem_bars.indic.gcolor = COLOR_GREEN;
mem_bars.indic.base.color = COLOR_LIME;
mem_bars.label.base.color = COLOR_MAKE(0x00, 0x40, 0x00);
mem_bars.gcolor = COLOR_GREEN;
mem_bars.mcolor = COLOR_LIME;
mem_bars.ccolor = COLOR_MAKE(0x00, 0x40, 0x00);
return &my_app_dsc;
}
@ -193,14 +184,14 @@ 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_obj_set_style(sc_data->bar_cpu, &cpu_bars);
lv_bar_set_style_indic(sc_data->bar_cpu, &cpu_bars);
lv_obj_set_click(sc_data->bar_cpu, false);
lv_bar_set_range(sc_data->bar_cpu, 0, 100);
lv_bar_set_format_str(sc_data->bar_cpu, "C\nP\nU");
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_obj_set_style(sc_data->bar_mem, &mem_bars);
lv_bar_set_style_indic(sc_data->bar_mem, &mem_bars);
lv_bar_set_format_str(sc_data->bar_mem, "M\ne\nm");
lv_app_sysmon_refr();
@ -225,7 +216,6 @@ static void my_sc_close(lv_app_inst_t * app)
static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
{
my_win_data_t * win_data = app->win_data;
lv_app_style_t * app_style = lv_app_style_get();
/*Create a chart with two data lines*/
win_data->chart = lv_chart_create(win, NULL);
@ -235,21 +225,19 @@ 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);
win_data->cpu_dl = lv_chart_add_dataline(win_data->chart);
win_data->mem_dl = lv_chart_add_dataline(win_data->chart);
win_data->cpu_dl = lv_chart_add_dataline(win_data->chart, COLOR_RED, 2 * LV_DOWNSCALE);
win_data->mem_dl = lv_chart_add_dataline(win_data->chart, COLOR_BLUE, 2 * LV_DOWNSCALE);
uint16_t i;
for(i = 0; i < LV_APP_SYSMON_PNUM; i ++) {
win_data->cpu_dl[i] = cpu_pct[i];
win_data->mem_dl[i] = mem_pct[i];
win_data->cpu_dl->points[i] = cpu_pct[i];
win_data->mem_dl->points[i] = mem_pct[i];
}
/*Create a label for the details of Memory and CPU usage*/
cord_t opad = app_style->win.page.scrl.opad;
win_data->label = lv_label_create(win, NULL);
lv_label_set_recolor(win_data->label, true);
lv_obj_align(win_data->label, win_data->chart, LV_ALIGN_OUT_RIGHT_MID, opad, 0);
lv_obj_set_style(win_data->label, &app_style->win_txt_style);
lv_obj_align(win_data->label, win_data->chart, LV_ALIGN_OUT_RIGHT_MID, LV_DPI / 4, 0);
lv_app_sysmon_refr();
@ -317,7 +305,7 @@ static void sysmon_task(void * param)
if(mem_mon.size_free < LV_APP_SYSMON_MEM_WARN && mem_warn_report == false) {
mem_warn_report = true;
lv_obj_t * not = lv_app_notice_add("Critically low memory");
lv_obj_set_style(not, lv_mboxs_get(LV_MBOXS_WARN, NULL));
//TODO lv_obj_set_style(not, lv_mboxs_get(LV_MBOXS_WARN, NULL));
}
if(mem_mon.size_free > LV_APP_SYSMON_MEM_WARN) mem_warn_report = false;
@ -327,7 +315,7 @@ static void sysmon_task(void * param)
if(frag_warn_report == false) {
frag_warn_report = true;
lv_obj_t * not =lv_app_notice_add("Critical memory\nfragmentation");
lv_obj_set_style(not, lv_mboxs_get(LV_MBOXS_WARN, NULL));
//TODO lv_obj_set_style(not, lv_mboxs_get(LV_MBOXS_WARN, NULL));
dm_defrag(); /*Defrag. if the fragmentation is critical*/
}
@ -369,8 +357,6 @@ static void lv_app_sysmon_refr(void)
sprintf(buf_long, "%s%c%s MEMORY: N/A%c", buf_long, TXT_RECOLOR_CMD, MEM_LABEL_COLOR, TXT_RECOLOR_CMD);
sprintf(buf_short, "%sMem: N/A\nFrag: N/A", buf_short);
#endif
lv_app_style_t * app_style = lv_app_style_get();
cord_t opad = app_style->win.page.scrl.opad;
lv_app_inst_t * app;
app = lv_app_get_next(NULL, &my_app_dsc);
while(app != NULL) {
@ -378,7 +364,7 @@ static void lv_app_sysmon_refr(void)
my_win_data_t * win_data = app->win_data;
if(win_data != NULL) {
lv_label_set_text(win_data->label, buf_long);
lv_obj_align(win_data->label, win_data->chart, LV_ALIGN_OUT_RIGHT_TOP, opad, 0);
lv_chart_set_next(win_data->chart, win_data->mem_dl, mem_pct[LV_APP_SYSMON_PNUM - 1]);
lv_chart_set_next(win_data->chart, win_data->cpu_dl, cpu_pct[LV_APP_SYSMON_PNUM - 1]);

View File

@ -31,6 +31,7 @@
/*********************
* DEFINES
*********************/
#define OBJ_PAD (LV_DPI / 4)
/**********************
* TYPEDEFS
@ -99,11 +100,10 @@ static lv_app_dsc_t my_app_dsc =
.win_data_size = sizeof(my_win_data_t),
};
const char * com_type_list_txt[] = {"Character", "Integer", "Log", "None", ""};
lv_app_com_type_t com_type_list[] = {LV_APP_COM_TYPE_CHAR, LV_APP_COM_TYPE_INT, LV_APP_COM_TYPE_LOG, LV_APP_COM_TYPE_INV};
const char * txt_format_list_txt[] = {"ASCII", "Hexadecimal", ""};
lv_objs_t sc_txt_bgs;
lv_labels_t sc_txts;
static const char * com_type_list_txt[] = {"Character", "Integer", "Log", "None", ""};
static lv_app_com_type_t com_type_list[] = {LV_APP_COM_TYPE_CHAR, LV_APP_COM_TYPE_INT, LV_APP_COM_TYPE_LOG, LV_APP_COM_TYPE_INV};
static const char * txt_format_list_txt[] = {"ASCII", "Hexadecimal", ""};
static lv_style_t style_sc_term;
/**********************
* MACROS
@ -119,17 +119,13 @@ lv_labels_t sc_txts;
*/
const lv_app_dsc_t * lv_app_terminal_init(void)
{
lv_app_style_t * app_style = lv_app_style_get();
memcpy(&sc_txts, &app_style->sc_txt_style, sizeof(lv_labels_t));
sc_txts.line_space = 0;
sc_txts.letter_space = 0;
sc_txts.mid = 0;
sc_txts.base.color = COLOR_WHITE;
lv_objs_get(LV_OBJS_PLAIN, &sc_txt_bgs);
sc_txt_bgs.color = COLOR_MAKE(0x20, 0x20, 0x20);
lv_style_get(LV_STYLE_PLAIN, &style_sc_term);
style_sc_term.line_space = 0;
style_sc_term.letter_space = 0;
style_sc_term.txt_align = 0;
style_sc_term.ccolor = COLOR_WHITE;
style_sc_term.mcolor = COLOR_MAKE(0x20, 0x20, 0x20);
style_sc_term.gcolor = COLOR_MAKE(0x20, 0x20, 0x20);
return &my_app_dsc;
}
@ -218,13 +214,12 @@ static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
/*Create a dark background*/
lv_obj_t * txt_bg = lv_obj_create(sc, NULL);
lv_obj_set_size(txt_bg, 7 * LV_APP_SC_WIDTH / 8 , app->sc->cords.y2 - app->sc_title->cords.y2 - 10 * LV_DOWNSCALE);
lv_obj_set_style(txt_bg, &sc_txt_bgs);
lv_obj_set_style(txt_bg, &style_sc_term);
lv_obj_align(txt_bg, app->sc_title, LV_ALIGN_OUT_BOTTOM_MID, 0, 3 * LV_DOWNSCALE);
lv_obj_set_click(txt_bg, false);
/*Add a text with the text of the terminal*/
sc_data->label = lv_label_create(txt_bg, NULL);
lv_obj_set_style(sc_data->label, &sc_txts);
lv_label_set_long_mode(sc_data->label, LV_LABEL_LONG_BREAK);
lv_obj_set_width(sc_data->label, lv_obj_get_width(txt_bg) - LV_APP_SC_WIDTH / 8);
lv_label_set_text_static(sc_data->label, app_data->txt);
@ -250,18 +245,11 @@ static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
{
my_win_data_t * win_data = app->win_data;
my_app_data_t * app_data = app->app_data;
lv_app_style_t * app_style = lv_app_style_get();
cord_t opad = app_style->win.page.scrl.opad;
/*Create a label for the text of the terminal*/
win_data->label = lv_label_create(win, NULL);
lv_label_set_long_mode(win_data->label, LV_LABEL_LONG_BREAK);
lv_obj_set_width(win_data->label, LV_HOR_RES -
2 * (app_style->win.page.bg.hpad +
app_style->win.page.scrl.hpad));
lv_obj_set_style(win_data->label, &app_style->win_txt_style);
lv_obj_set_width(win_data->label, lv_win_get_width(win));
lv_label_set_text_static(win_data->label, app_data->txt); /*Use the app. data text directly*/
/*Create a text area. Text can be added to the terminal from here by app. keyboard.*/
@ -270,9 +258,8 @@ static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
lv_obj_set_free_p(win_data->ta, app);
lv_page_set_rel_action(win_data->ta, win_ta_rel_action);
lv_ta_set_text(win_data->ta, "");
lv_obj_set_style(win_data->ta, lv_tas_get(LV_TAS_DEF, NULL));
if(app_data->txt[0] != '\0') lv_obj_align(win_data->ta, win_data->label, LV_ALIGN_OUT_BOTTOM_LEFT, opad, opad);
else lv_obj_align(win_data->ta, NULL, LV_ALIGN_IN_TOP_LEFT, opad, opad);
if(app_data->txt[0] != '\0') lv_obj_align(win_data->ta, win_data->label, LV_ALIGN_OUT_BOTTOM_LEFT, OBJ_PAD, OBJ_PAD);
else lv_obj_align(win_data->ta, NULL, LV_ALIGN_IN_TOP_LEFT, OBJ_PAD, OBJ_PAD);
/*Create a clear button*/
win_data->clear_btn = lv_btn_create(win, NULL);
@ -280,13 +267,12 @@ static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
lv_obj_set_free_p(win_data->clear_btn, app);
lv_btn_set_rel_action(win_data->clear_btn, win_clear_rel_action);
lv_obj_t * btn_label = lv_label_create(win_data->clear_btn, NULL);
lv_obj_set_style(btn_label, lv_labels_get(LV_LABELS_BTN, NULL));
lv_label_set_text(btn_label, "Clear");
lv_obj_align(win_data->clear_btn, win_data->ta, LV_ALIGN_OUT_RIGHT_TOP, opad, 0);
lv_obj_align(win_data->clear_btn, win_data->ta, LV_ALIGN_OUT_RIGHT_TOP, OBJ_PAD, 0);
/*Align the window to see the text area on the bottom*/
lv_obj_align(lv_page_get_scrl(app->win), NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0,
- app_style->win.page.scrl.vpad);
lv_obj_t * page = lv_win_get_page(app->win);
lv_obj_align(lv_page_get_scrl(page), NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, - LV_VER_RES);
}
@ -308,12 +294,10 @@ static void my_win_close(lv_app_inst_t * app)
static void my_conf_open(lv_app_inst_t * app, lv_obj_t * conf_win)
{
my_app_data_t * app_data = app->app_data;
lv_app_style_t * app_style = lv_app_style_get();
lv_obj_t * label;
label = lv_label_create(conf_win, NULL);
lv_label_set_text(label, "Communication type");
lv_obj_set_style(label, &app_style->win_txt_style);
lv_obj_t * ddl;
ddl = lv_ddlist_create(conf_win, NULL);
@ -405,13 +389,11 @@ static lv_action_res_t win_clear_rel_action(lv_obj_t * btn, lv_dispi_t * dispi)
}
if(win_data != NULL) {
lv_app_style_t * app_style =lv_app_style_get();
cord_t opad = app_style->win.page.scrl.opad;
lv_label_set_text_static(win_data->label, app_data->txt);
lv_obj_align(win_data->ta, NULL, LV_ALIGN_IN_TOP_LEFT, opad, opad);
lv_obj_align(win_data->clear_btn, win_data->ta, LV_ALIGN_OUT_RIGHT_TOP, opad, 0);
lv_obj_align(lv_page_get_scrl(app->win), NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0,
- app_style->win.page.scrl.vpad);
lv_obj_align(win_data->ta, NULL, LV_ALIGN_IN_TOP_LEFT, OBJ_PAD, OBJ_PAD);
lv_obj_align(win_data->clear_btn, win_data->ta, LV_ALIGN_OUT_RIGHT_TOP, OBJ_PAD, 0);
lv_obj_t * page = lv_win_get_page(app->win);
lv_obj_align(lv_page_get_scrl(page), NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, - LV_VER_RES);
}
return LV_ACTION_RES_OK;
@ -489,15 +471,13 @@ static void add_data(lv_app_inst_t * app, const void * data, uint16_t data_len)
my_win_data_t * win_data = app->win_data;
my_sc_data_t * sc_data = app->sc_data;
lv_app_style_t * app_style = lv_app_style_get();
if(win_data != NULL) {
cord_t opad = app_style->win.page.scrl.opad;
lv_label_set_text_static(win_data->label, app_data->txt);
lv_obj_align(win_data->ta, win_data->label, LV_ALIGN_OUT_BOTTOM_LEFT, opad, opad);
lv_obj_align(win_data->clear_btn, win_data->ta, LV_ALIGN_OUT_RIGHT_TOP, opad, 0);
lv_obj_align(lv_page_get_scrl(app->win), NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0,
- app_style->win.page.scrl.vpad);
lv_obj_align(win_data->ta, win_data->label, LV_ALIGN_OUT_BOTTOM_LEFT, OBJ_PAD, OBJ_PAD);
lv_obj_align(win_data->clear_btn, win_data->ta, LV_ALIGN_OUT_RIGHT_TOP, OBJ_PAD, 0);
lv_obj_t * page = lv_win_get_page(app->win);
lv_obj_align(lv_page_get_scrl(page), NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, - LV_VER_RES);
}
/*Set the last line on the shortcut*/

View File

@ -139,11 +139,9 @@ static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
static void my_sc_open(lv_app_inst_t * app, lv_obj_t * sc)
{
my_sc_data_t * sc_data = app->sc_data;
lv_app_style_t * app_style = lv_app_style_get();
sc_data->label = lv_label_create(sc, NULL);
lv_label_set_text(sc_data->label, "Empty");
lv_obj_set_style(sc_data->label, &app_style->sc_txt_style);
lv_obj_align(sc_data->label, NULL, LV_ALIGN_CENTER, 0, 0);
}

View File

@ -33,8 +33,8 @@ static lv_style_t lv_style_plain;
static lv_style_t lv_style_plain_color;
static lv_style_t lv_style_pretty;
static lv_style_t lv_style_pretty_color;
static lv_style_t lv_style_focus;
static lv_style_t lv_style_focus_color;
//static lv_style_t lv_style_focus;
//static lv_style_t lv_style_focus_color;
static lv_style_t lv_style_btn_rel;
static lv_style_t lv_style_btn_pr;
static lv_style_t lv_style_btn_trel;
@ -64,7 +64,7 @@ void lv_style_init (void)
lv_style_set_bcolor(&lv_style_scr, COLOR_MAKE(0x20, 0x20 ,0x20));
lv_style_set_scolor(&lv_style_scr, COLOR_GRAY);
lv_style_set_radius(&lv_style_scr, 0);
lv_style_set_bwidth(&lv_style_scr, LV_DPI / 30 >= 1 ? LV_DPI / 30 >= 1 : 1);
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 / 6);
lv_style_set_hpad(&lv_style_scr, LV_DPI / 6);
@ -86,15 +86,16 @@ void lv_style_init (void)
/*Plain color style*/
memcpy(&lv_style_plain_color, &lv_style_plain, sizeof(lv_style_t));
lv_style_set_ccolor(&lv_style_plain_color, COLOR_SILVER);
lv_style_set_mcolor(&lv_style_plain_color, COLOR_CYAN);
lv_style_set_gcolor(&lv_style_plain_color, COLOR_CYAN);
lv_style_set_ccolor(&lv_style_plain_color, COLOR_MAKE(0xf0, 0xf0, 0xf0));
lv_style_set_mcolor(&lv_style_plain_color, COLOR_MAKE(0x40, 0x60, 0x80));
lv_style_set_gcolor(&lv_style_plain_color, COLOR_MAKE(0x40, 0x60, 0x80));
/*Pretty style */
memcpy(&lv_style_pretty, &lv_style_plain, sizeof(lv_style_t));
lv_style_set_mcolor(&lv_style_pretty, COLOR_WHITE);
lv_style_set_mcolor(&lv_style_pretty, COLOR_SILVER);
lv_style_set_radius(&lv_style_pretty, LV_DPI / 10);
lv_style_set_bwidth(&lv_style_pretty, LV_DPI / 20 >= 1 ? LV_DPI / 30 >= 1 : 1);
/*Pretty color style*/
memcpy(&lv_style_pretty_color, &lv_style_pretty, sizeof(lv_style_t));

View File

@ -128,8 +128,6 @@ bool lv_bar_signal(lv_obj_t * bar, lv_signal_t sign, void * param)
if(valid != false) {
lv_bar_ext_t * ext = lv_obj_get_ext(bar);
lv_style_t * style = lv_obj_get_style(bar);
point_t p;
char buf[LV_BAR_TXT_MAX_LENGTH];
switch(sign) {
case LV_SIGNAL_CLEANUP:

View File

@ -123,7 +123,6 @@ bool lv_btn_signal(lv_obj_t * btn, lv_signal_t sign, void * param)
* make the object specific signal handling */
if(valid != false) {
lv_btn_ext_t * ext = lv_obj_get_ext(btn);
lv_style_t * style = lv_obj_get_style(btn);
lv_btn_state_t state = lv_btn_get_state(btn);
bool tgl = lv_btn_get_tgl(btn);

View File

@ -294,16 +294,18 @@ void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_callback_t cb)
}
/**
* Set the style of the buttons in a given state
* Set the styles of the buttons of the button matrox
* @param btnm pointer to a button matrix object
* @param state style in this state (LV_BTN_STATE_PR or LV_BTN_STATE_REL)
* @param style pointer to style
*/
void lv_btnm_set_styles_btn(lv_obj_t * btnm, lv_btn_state_t state, lv_style_t * style)
void lv_btnm_set_styles_btn(lv_obj_t * btnm, lv_style_t * rel, lv_style_t * pr)
{
lv_btnm_ext_t * ext = lv_obj_get_ext(btnm);
if(state == LV_BTN_STATE_REL) ext->style_btn_rel = style;
if(state == LV_BTN_STATE_PR) ext->style_btn_pr = style;
ext->style_btn_rel = rel;
ext->style_btn_pr = pr;
lv_obj_inv(btnm);
}

View File

@ -94,7 +94,8 @@ void lv_btnm_set_map(lv_obj_t * btnm, const char ** map);
*/
void lv_btnm_set_action(lv_obj_t * btnm, lv_btnm_callback_t cb);
void lv_btnm_set_styles_btn(lv_obj_t * btnm, lv_btn_state_t state, lv_style_t * style);
void lv_btnm_set_styles_btn(lv_obj_t * btnm, lv_style_t * rel, lv_style_t * pr);
/**
* Get the current map of a button matrix
* @param btnm pointer to a button matrix object

View File

@ -137,9 +137,9 @@ bool lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param)
* @param chart pointer to a chart object
* @param color color of the data line
* @param width line width/point radius/column width
* @return pointer to the allocated data line (an array for the data points)
* @return pointer to the allocated data line (
*/
cord_t * lv_chart_add_dataline(lv_obj_t * chart, color_t color, cord_t width)
lv_chart_dl_t * lv_chart_add_dataline(lv_obj_t * chart, color_t color, cord_t width)
{
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
lv_chart_dl_t * dl = ll_ins_head(&ext->dl_ll);
@ -158,7 +158,7 @@ cord_t * lv_chart_add_dataline(lv_obj_t * chart, color_t color, cord_t width)
ext->dl_num++;
return dl->points;
return dl;
}
/**
@ -267,16 +267,16 @@ void lv_chart_set_drak_effect(lv_obj_t * chart, opa_t dark_eff)
* @param dl pointer to a data line on 'chart'
* @param y the new value of the most right data
*/
void lv_chart_set_next(lv_obj_t * chart, cord_t * dl, cord_t y)
void lv_chart_set_next(lv_obj_t * chart, lv_chart_dl_t * dl, cord_t y)
{
lv_chart_ext_t * ext = lv_obj_get_ext(chart);
uint16_t i;
for(i = 0; i < ext->pnum - 1; i++) {
dl[i] = dl[i + 1];
dl->points[i] = dl->points[i + 1];
}
dl[ext->pnum - 1] = y;
dl->points[ext->pnum - 1] = y;
lv_chart_refr(chart);
}

View File

@ -90,9 +90,9 @@ bool lv_chart_signal(lv_obj_t * chart, lv_signal_t sign, void * param);
/**
* Allocate and add a data line to the chart
* @param chart pointer to a chart object
* @return pointer to the allocated data lie (an array for the data points)
* @return pointer to the allocated data line
*/
cord_t * lv_chart_add_dataline(lv_obj_t * chart, color_t color, cord_t width);
lv_chart_dl_t * lv_chart_add_dataline(lv_obj_t * chart, color_t color, cord_t width);
/**
* Refresh a chart if its data line has changed
@ -142,7 +142,7 @@ void lv_chart_set_drak_effect(lv_obj_t * chart, opa_t dark_eff);
* @param dl pointer to a data line on 'chart'
* @param y the new value of the most right data
*/
void lv_chart_set_next(lv_obj_t * chart, cord_t * dl, cord_t y);
void lv_chart_set_next(lv_obj_t * chart, lv_chart_dl_t * dl, cord_t y);
/**
* Get the type of a chart

View File

@ -221,11 +221,12 @@ void lv_list_set_styles_liste(lv_obj_t * list, lv_style_t * rel, lv_style_t * pr
ext->styles_liste[LV_BTN_STATE_TPR] = tpr;
ext->styles_liste[LV_BTN_STATE_INA] = ina;
lv_obj_t * liste = lv_obj_get_child(list, NULL);
while(liste != NULL) {
lv_obj_t * scrl = lv_page_get_scrl(list);
lv_obj_t * liste = lv_obj_get_child(scrl, NULL);
while(liste != NULL)
{
lv_btn_set_styles(liste, rel, pr, trel, tpr, ina);
liste = lv_obj_get_child(list, liste);
liste = lv_obj_get_child(scrl, liste);
}
}

View File

@ -134,7 +134,6 @@ bool lv_page_signal(lv_obj_t * page, lv_signal_t sign, void * param)
* make the object specific signal handling */
if(obj_valid != false) {
lv_page_ext_t * ext = lv_obj_get_ext(page);
lv_style_t * style = lv_obj_get_style(page);
lv_obj_t * child;
switch(sign) {
case LV_SIGNAL_CHILD_CHG: /*Move children to the scrollable object*/

View File

@ -94,7 +94,9 @@ lv_obj_t * lv_ta_create(lv_obj_t * par, lv_obj_t * copy)
lv_label_set_text(ext->label, "Text area");
lv_page_glue_obj(ext->label, true);
lv_obj_set_click(ext->label, false);
lv_obj_set_style(new_ta, lv_obj_get_style(ext->page.scrl));
lv_obj_set_style(new_ta, lv_style_get(LV_STYLE_PRETTY, NULL));
lv_page_set_sb_mode(new_ta, LV_PAGE_SB_MODE_AUTO);
lv_obj_set_style(lv_page_get_scrl(new_ta), lv_style_get(LV_STYLE_TRANSP_TIGHT, NULL));
lv_obj_set_size(new_ta, LV_TA_DEF_WIDTH, LV_TA_DEF_HEIGHT);
}
/*Copy an existing object*/

View File

@ -63,12 +63,9 @@ lv_obj_t * lv_win_create(lv_obj_t * par, lv_obj_t * copy)
ext->header = NULL;
ext->title = NULL;
ext->style_header = lv_style_get(LV_STYLE_PLAIN_COLOR, NULL);
ext->styles_btn[LV_BTN_STATE_REL] = lv_style_get(LV_STYLE_BTN_REL, NULL);
ext->styles_btn[LV_BTN_STATE_PR] = lv_style_get(LV_STYLE_BTN_PR, NULL);
ext->styles_btn[LV_BTN_STATE_TREL] = lv_style_get(LV_STYLE_BTN_TREL, NULL);
ext->styles_btn[LV_BTN_STATE_TPR] = lv_style_get(LV_STYLE_BTN_TPR, NULL);
ext->styles_btn[LV_BTN_STATE_INA] = lv_style_get(LV_STYLE_BTN_INA, NULL);
ext->btn_size = LV_DPI;
ext->style_cbtn_rel = lv_style_get(LV_STYLE_BTN_REL, NULL);
ext->style_cbtn_pr = lv_style_get(LV_STYLE_BTN_PR, NULL);
ext->cbtn_size = (3 * LV_DPI) / 4;
/*Init the new window object*/
if(copy == NULL) {
@ -216,10 +213,9 @@ lv_obj_t * lv_win_add_ctrl_btn(lv_obj_t * win, const char * img_path, lv_action_
lv_win_ext_t * ext = lv_obj_get_ext(win);
lv_obj_t * btn = lv_btn_create(ext->btnh, NULL);
lv_btn_set_styles(btn, ext->styles_btn[LV_BTN_STATE_REL], ext->styles_btn[LV_BTN_STATE_PR],
ext->styles_btn[LV_BTN_STATE_TREL], ext->styles_btn[LV_BTN_STATE_TPR],
ext->styles_btn[LV_BTN_STATE_INA]);
lv_obj_set_size(btn, ext->btn_size, ext->btn_size);
lv_btn_set_styles(btn, ext->style_cbtn_rel, ext->style_cbtn_pr,
NULL, NULL, NULL);
lv_obj_set_size(btn, ext->cbtn_size, ext->cbtn_size);
lv_btn_set_rel_action(btn, rel_action);
lv_obj_t * img = lv_img_create(btn, NULL);
@ -259,6 +255,40 @@ void lv_win_set_title(lv_obj_t * win, const char * title)
lv_win_realign(win);
}
/**
* Set the control button size of a window
* @param win pointer to a window object
* @return control button size
*/
void lv_win_set_cbtn_size(lv_obj_t * win, cord_t size)
{
lv_win_ext_t * ext = lv_obj_get_ext(win);
ext->cbtn_size = size;
lv_win_realign(win);
}
/**
* Set the style of the window control buttons in a given state
* @param win pointer to a window object
* @param state style in this state (LV_BTN_STATE_PR or LV_BTN_STATE_REL)
* @param style pointer to style
*/
void lv_win_set_style_cbtn(lv_obj_t * win, lv_btn_state_t state, lv_style_t * style)
{
lv_win_ext_t * ext = lv_obj_get_ext(win);
if(state == LV_BTN_STATE_REL) ext->style_cbtn_rel = style;
if(state == LV_BTN_STATE_PR) ext->style_cbtn_pr = style;
lv_obj_t * cbtn;
cbtn = lv_obj_get_child(ext->btnh, NULL);
while(cbtn != NULL) {
lv_btn_set_styles(cbtn, ext->style_cbtn_rel, ext->style_cbtn_pr, NULL, NULL, NULL);
cbtn = lv_obj_get_child(ext->btnh, cbtn);
}
}
/*=====================
* Getter functions
*====================*/
@ -285,6 +315,42 @@ lv_obj_t * lv_win_get_page(lv_obj_t * win)
return ext->page;
}
/**
* Get the s window header
* @param win pointer to a window object
* @return pointer to the window header object (lv_rect)
*/
lv_obj_t * lv_win_get_header(lv_obj_t * win)
{
lv_win_ext_t * ext = lv_obj_get_ext(win);
return ext->header;
}
/**
* Get the control button size of a window
* @param win pointer to a window object
* @return control button size
*/
cord_t lv_win_get_cbtn_size(lv_obj_t * win)
{
lv_win_ext_t * ext = lv_obj_get_ext(win);
return ext->cbtn_size;
}
/**
* Get width of the content area (page scrollable) of the window
* @param win pointer to a window object
* @return the width of the contetn area
*/
cord_t lv_win_get_width(lv_obj_t * win)
{
lv_win_ext_t * ext = lv_obj_get_ext(win);
lv_obj_t * scrl = lv_page_get_scrl(ext->page);
lv_style_t * style_scrl = lv_obj_get_style(scrl);
return lv_obj_get_width(scrl) - 2 * style_scrl->hpad;
}
/**
* 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.
@ -341,7 +407,6 @@ static bool lv_win_design(lv_obj_t * win, const area_t * mask, lv_design_mode_t
static void lv_win_realign(lv_obj_t * win)
{
lv_win_ext_t * ext = lv_obj_get_ext(win);
lv_style_t * style = lv_obj_get_style(win);
if(ext->page == NULL || ext->btnh == NULL || ext->header == NULL || ext->title == NULL) return;
@ -349,12 +414,12 @@ static void lv_win_realign(lv_obj_t * win)
/*Refresh the style of all control buttons*/
cbtn = lv_obj_get_child(ext->btnh, NULL);
while(cbtn != NULL) {
lv_obj_set_size(cbtn, ext->btn_size, ext->btn_size);
lv_obj_set_size(cbtn, ext->cbtn_size, ext->cbtn_size);
cbtn = lv_obj_get_child(ext->btnh, cbtn);
}
lv_style_t * btnh_style = lv_obj_get_style(ext->btnh);
lv_obj_set_height(ext->btnh, ext->btn_size + 2 * btnh_style->vpad * 2);
lv_obj_set_height(ext->btnh, ext->cbtn_size + 2 * btnh_style->vpad * 2);
lv_obj_set_width(ext->header, lv_obj_get_width(win));
/*Align the higher object first to make the correct header size first*/

View File

@ -62,8 +62,9 @@ typedef struct
lv_obj_t * title; /*Pointer to the title label of the window*/
lv_obj_t * btnh; /*Pointer to the control button holder rectangle of the window*/
lv_style_t * style_header; /*Style of the header rectangle*/
lv_style_t * styles_btn[LV_BTN_STATE_NUM]; /*Style of the control buttons*/
cord_t btn_size; /*Size of the control buttons (square)*/
lv_style_t * style_cbtn_rel; /*Control button releases style*/
lv_style_t * style_cbtn_pr; /*Control button pressed style*/
cord_t cbtn_size; /*Size of the control buttons (square)*/
}lv_win_ext_t;
/**********************
@ -120,6 +121,10 @@ const char * lv_win_get_title(lv_obj_t * win);
lv_obj_t * lv_win_get_page(lv_obj_t * win);
lv_obj_t * lv_win_get_header(lv_obj_t * win);
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.