Update the code becuse of protect field and lv_win inheritance changes

This commit is contained in:
Gabor
2017-01-03 17:11:44 +01:00
parent 2eaaa5b36d
commit 6884f6735c
6 changed files with 32 additions and 28 deletions

View File

@@ -71,7 +71,6 @@ static lv_obj_t * sc_page; /*A page for the shortcuts */
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*/
/*Declare icons*/
LV_IMG_DECLARE(img_add);
LV_IMG_DECLARE(img_bubble);
@@ -158,6 +157,11 @@ lv_app_inst_t * lv_app_run(const lv_app_dsc_t * app_dsc, const char * cstr, void
app->dsc = app_dsc;
app->app_data = dm_alloc(app_dsc->app_data_size);
app->name = NULL;
app->sc = NULL;
app->sc_data = NULL;
app->sc_title = NULL;
app->win = NULL;
app->win_data = NULL;
lv_app_rename(app, app_dsc->name); /*Set a default name*/
/*Call the application specific run function*/
@@ -270,9 +274,9 @@ lv_obj_t * lv_app_win_open(lv_app_inst_t * app)
lv_obj_set_free_p(app->win, app);
lv_obj_set_style(app->win, &app_style.win_style);
lv_win_set_title(app->win, app->dsc->name);
lv_obj_t * win_content = lv_page_get_scrl(lv_win_get_content(app->win));
lv_obj_t * win_content = lv_page_get_scrl(app->win);
lv_rect_set_fit(win_content, false, true);
lv_obj_set_width(win_content, LV_HOR_RES - 2 * app_style.win_style.content.bg_rects.hpad);
lv_obj_set_width(win_content, LV_HOR_RES - 2 * app_style.win_style.pages.bg_rects.hpad);
lv_win_add_ctrl_btn(app->win, "U:/icon_down", lv_app_win_minim_action);
lv_win_add_ctrl_btn(app->win, "U:/icon_close", lv_app_win_close_action);
@@ -848,23 +852,23 @@ static lv_action_res_t lv_app_win_minim_anim_create(lv_app_inst_t * app)
a.path = anim_get_path(ANIM_PATH_LIN);
a.end = lv_obj_get_width(app->sc);
a.start = LV_HOR_RES;
a.end = lv_obj_get_width(app->sc);
a.fp = (anim_fp_t) lv_obj_set_width;
anim_create(&a);
a.end = lv_obj_get_height(app->sc);
a.start = LV_VER_RES;
a.end = lv_obj_get_height(app->sc);
a.fp = (anim_fp_t) lv_obj_set_height;
anim_create(&a);
a.end = cords.x1;
a.start = 0;
a.end = cords.x1;
a.fp = (anim_fp_t) lv_obj_set_x;
anim_create(&a);
a.end = cords.y1;
a.start = 0;
a.end = cords.y1;
a.fp = (anim_fp_t) lv_obj_set_y;
a.end_cb = (void (*)(void *))lv_app_win_minim_anim_cb;
anim_create(&a);
@@ -1026,16 +1030,15 @@ static void lv_app_init_style(void)
memcpy(&app_style.win_style.title, &app_style.menu_btn_label_style, sizeof(lv_labels_t));
memcpy(&app_style.win_style.ctrl_btn, &app_style.menu_btn_style, sizeof(lv_btns_t));
memcpy(&app_style.win_style.ctrl_img, &app_style.menu_btn_img_style, sizeof(lv_imgs_t));
app_style.win_style.header_on_content = 1;
app_style.win_style.header_opa = app_style.menu_opa;
app_style.win_style.ctrl_btn_opa = app_style.menu_btn_opa;
app_style.win_style.header.vpad = 5 * LV_DOWNSCALE;
app_style.win_style.header.hpad = 5 * LV_DOWNSCALE;
app_style.win_style.header.opad = 5 * LV_DOWNSCALE;
app_style.win_style.content.bg_rects.vpad = app_style.win_style.ctrl_btn_h +
app_style.win_style.pages.bg_rects.vpad = app_style.win_style.ctrl_btn_h +
2 * app_style.win_style.header.vpad;
app_style.win_style.content.bg_rects.hpad = 5 * LV_DOWNSCALE;
app_style.win_style.content.scrl_rects.objs.transp = 1;
app_style.win_style.pages.bg_rects.hpad = 5 * LV_DOWNSCALE;
app_style.win_style.pages.scrl_rects.objs.transp = 1;
lv_labels_get(LV_LABELS_DEF,&app_style.win_txt_style);
app_style.win_txt_style.font = LV_APP_FONT_MEDIUM;

View File

@@ -146,8 +146,8 @@ static void fsel_refr(void)
/*Create a new list*/
lv_wins_t * wins = lv_obj_get_style(fsel_win);
fsel_list = lv_list_create(fsel_win, NULL);
lv_obj_set_size(fsel_list, LV_HOR_RES - 2 * (wins->content.bg_rects.hpad + wins->content.scrl_rects.hpad), LV_VER_RES -
wins->content.bg_rects.vpad - 2 * wins->content.scrl_rects.vpad);
lv_obj_set_size(fsel_list, LV_HOR_RES - 2 * (wins->pages.bg_rects.hpad + wins->pages.scrl_rects.hpad), LV_VER_RES -
wins->pages.bg_rects.vpad - 2 * wins->pages.scrl_rects.vpad);
lv_obj_align(fsel_list, NULL, LV_ALIGN_CENTER, 0, 0);
lv_obj_set_style(fsel_list, &fsel_lists);
lv_list_set_fit(fsel_list, LV_LIST_FIT_WIDTH_SB);

View File

@@ -124,10 +124,10 @@ void lv_app_kb_open(lv_obj_t * ta, lv_app_kb_mode_t mode, void (*close)(lv_obj_t
/*If the text area is higher then the new size of the window redus its size too*/
lv_app_style_t * app_style = lv_app_style_get();
cord_t win_cont_h = lv_obj_get_height(lv_win_get_content(kb_win)) - 2 * app_style->win_style.content.scrl_rects.vpad;
cord_t win_h = lv_obj_get_height(kb_win) - 2 * app_style->win_style.pages.scrl_rects.vpad;
kb_ta_ori_size = lv_obj_get_height(kb_ta);
if(lv_obj_get_height(kb_ta) > win_cont_h) {
lv_obj_set_height(kb_ta, win_cont_h);
if(lv_obj_get_height(kb_ta) > win_h) {
lv_obj_set_height(kb_ta, win_h);
}
lv_ta_set_cursor_pos(kb_ta, LV_TA_CUR_LAST);
@@ -135,7 +135,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(lv_win_get_content(kb_win), kb_ta, false);
lv_page_focus(kb_win, kb_ta, false);
#endif
}
@@ -231,7 +231,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(lv_win_get_content(kb_win), kb_ta, false);
lv_page_focus(kb_win, kb_ta, false);
#endif
return LV_ACTION_RES_OK;
}

View File

@@ -243,7 +243,7 @@ static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
}
/*Create a label for the details of Memory and CPU usage*/
cord_t opad = app_style->win_style.content.scrl_rects.opad;
cord_t opad = app_style->win_style.pages.scrl_rects.opad;
win_data->label = lv_label_create(win, NULL);
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);
@@ -360,7 +360,7 @@ static void lv_app_sysmon_refr(void)
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_style.content.scrl_rects.opad;
cord_t opad = app_style->win_style.pages.scrl_rects.opad;
lv_app_inst_t * app;
app = lv_app_get_next(NULL, &my_app_dsc);
while(app != NULL) {

View File

@@ -214,14 +214,14 @@ static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
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_style.content.scrl_rects.opad;
cord_t opad = app_style->win_style.pages.scrl_rects.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_style.content.bg_rects.hpad +
app_style->win_style.content.scrl_rects.hpad));
2 * (app_style->win_style.pages.bg_rects.hpad +
app_style->win_style.pages.scrl_rects.hpad));
lv_obj_set_style(win_data->label, &app_style->win_txt_style);
lv_label_set_text_static(win_data->label, app_data->txt); /*Use the app. data text directly*/
@@ -247,8 +247,8 @@ static void my_win_open(lv_app_inst_t * app, lv_obj_t * win)
lv_obj_align(win_data->com_type_btn, win_data->ta, LV_ALIGN_OUT_RIGHT_TOP, opad, 0);
/*Align the window to see the text area on the bottom*/
lv_obj_align(lv_page_get_scrl(lv_win_get_content(app->win)), NULL, LV_ALIGN_IN_BOTTOM_LEFT,
0, - app_style->win_style.content.scrl_rects.vpad);
lv_obj_align(lv_page_get_scrl(app->win), NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0,
- app_style->win_style.pages.scrl_rects.vpad);
}
@@ -360,11 +360,12 @@ static void add_data(lv_app_inst_t * app, const void * data, uint16_t data_len)
lv_app_style_t * app_style = lv_app_style_get();
if(win_data != NULL) {
cord_t opad = app_style->win_style.content.scrl_rects.opad;
cord_t opad = app_style->win_style.pages.scrl_rects.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, 0, opad);
lv_obj_align(win_data->com_type_btn, win_data->ta, LV_ALIGN_OUT_RIGHT_TOP, opad, 0);
lv_obj_align(lv_page_get_scrl(lv_win_get_content(app->win)), NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0, - app_style->win_style.content.scrl_rects.vpad);
lv_obj_align(lv_page_get_scrl(app->win), NULL, LV_ALIGN_IN_BOTTOM_LEFT, 0,
- app_style->win_style.pages.scrl_rects.vpad);
}
/*Set the last line on the shortcut*/

View File

@@ -118,7 +118,7 @@
/*Text area (dependencies: lv_label, lv_page)*/
#define USE_LV_TA 1
#if USE_LV_TA != 0
#define LV_TA_MAX_LENGTH 8
#define LV_TA_MAX_LENGTH 256
#define LV_TA_CUR_BLINK_TIME 400 /*ms*/
#endif