diff --git a/lv_app/lv_app.c b/lv_app/lv_app.c index de4687f92..42e7f62b1 100644 --- a/lv_app/lv_app.c +++ b/lv_app/lv_app.c @@ -54,6 +54,7 @@ static lv_action_res_t lv_app_win_conf_action(lv_obj_t * set_btn, lv_dispi_t * d static lv_action_res_t lv_app_win_open_anim_create(lv_app_inst_t * app); static lv_action_res_t lv_app_win_minim_anim_create(lv_app_inst_t * app); #if LV_APP_EFFECT_ANIM != 0 && LV_APP_ANIM_WIN != 0 +static void lv_app_win_open_anim_cb(lv_obj_t * app_win); static void lv_app_win_close_anim_cb(lv_obj_t * app_win); static void lv_app_win_minim_anim_cb(lv_obj_t * app_win); #endif @@ -75,7 +76,7 @@ static lv_obj_t * app_list; /*A list which is opened on 'app_btn' release*/ 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*/ - +static lv_wins_t wins_no_sb; /*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); @@ -799,8 +800,18 @@ static lv_action_res_t lv_app_win_close_action(lv_obj_t * close_btn, lv_dispi_t lv_app_kb_close(false); #if LV_APP_EFFECT_ANIM != 0 && LV_APP_EFFECT_OPA != 0 && LV_APP_ANIM_WIN != 0 + /*Temporally set no scrollbar style for the window*/ + memcpy(&wins_no_sb, lv_obj_get_style(app->win), sizeof(lv_wins_t)); + wins_no_sb.pages.sb_mode = LV_PAGE_SB_MODE_OFF; + lv_obj_set_style(app->win, &wins_no_sb); + + /*Hide the control buttons and the title during the animation*/ + lv_obj_set_hidden(((lv_win_ext_t *)app->win->ext)->ctrl_holder, true); + lv_obj_set_hidden(((lv_win_ext_t *)app->win->ext)->title, 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); + lv_app_sc_close(app); /*The animation will close the window*/ return LV_ACTION_RES_OK; @@ -878,7 +889,7 @@ static lv_action_res_t lv_app_win_open_anim_create(lv_app_inst_t * app) /*Make an animation on window open*/ #if LV_APP_EFFECT_ANIM != 0 && LV_APP_ANIM_WIN != 0 - area_t cords; /*If no shortcut simulate one or load the its coordinates*/ + area_t cords; /*If no shortcut simulate one and load the its coordinates*/ if(app->sc == NULL) { cords.x1 = LV_HOR_RES / 2 - LV_APP_SC_WIDTH / 2; cords.y1 = LV_VER_RES / 2 - LV_APP_SC_HEIGHT / 2; @@ -888,6 +899,15 @@ 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 no scrollbar style for the window*/ + memcpy(&wins_no_sb, lv_obj_get_style(app->win), sizeof(lv_wins_t)); + wins_no_sb.pages.sb_mode = LV_PAGE_SB_MODE_OFF; + lv_obj_set_style(app->win, &wins_no_sb); + + /*Hide the control buttons and the title during the animation*/ + lv_obj_set_hidden(((lv_win_ext_t *)app->win->ext)->ctrl_holder, true); + lv_obj_set_hidden(((lv_win_ext_t *)app->win->ext)->title, true); + anim_t a; a.act_time = 0; a.time = LV_APP_ANIM_WIN; @@ -915,6 +935,7 @@ static lv_action_res_t lv_app_win_open_anim_create(lv_app_inst_t * app) a.start = cords.y1; a.end = 0; a.fp = (anim_fp_t) lv_obj_set_y; + a.end_cb = (anim_cb_t)lv_app_win_open_anim_cb; anim_create(&a); #endif /*LV_APP_EFFECT_ANIM != 0 && LV_APP_ANIM_WIN != 0*/ @@ -939,7 +960,16 @@ static lv_action_res_t lv_app_win_minim_anim_create(lv_app_inst_t * app) } else { lv_obj_get_cords(app->sc, &cords); } + + /*Temporally set no scrollbar style for the window*/ + memcpy(&wins_no_sb, lv_obj_get_style(app->win), sizeof(lv_wins_t)); + wins_no_sb.pages.sb_mode = LV_PAGE_SB_MODE_OFF; + lv_obj_set_style(app->win, &wins_no_sb); + /*Hide the control buttons and the title during the animation*/ + lv_obj_set_hidden(((lv_win_ext_t *)app->win->ext)->ctrl_holder, true); + lv_obj_set_hidden(((lv_win_ext_t *)app->win->ext)->title, true); + anim_t a; a.act_time = 0; a.time = LV_APP_ANIM_WIN; @@ -979,6 +1009,22 @@ static lv_action_res_t lv_app_win_minim_anim_create(lv_app_inst_t * app) } #if LV_APP_EFFECT_ANIM != 0 + + +/** + * Called when the window open animation is ready to close the application + * @param app_win pointer to a window + */ +static void lv_app_win_open_anim_cb(lv_obj_t * app_win) +{ + /*Unhide the title and the ctrl btn holder*/ + lv_obj_set_hidden(((lv_win_ext_t *)app_win->ext)->ctrl_holder, false); + lv_obj_set_hidden(((lv_win_ext_t *)app_win->ext)->title, false); + + /*Restore the style*/ + lv_obj_set_style(app_win, &app_style.win_style); +} + /** * Called when the window close animation is ready to close the application * @param app_win pointer to a window @@ -988,6 +1034,8 @@ static void lv_app_win_close_anim_cb(lv_obj_t * app_win) lv_app_inst_t * app = lv_obj_get_free_p(app_win); lv_app_close(app); } + + /** * Called when the window minimization animation is ready to close the window * @param app_win pointer to a window @@ -1129,7 +1177,7 @@ 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_opa = app_style.menu_opa; + app_style.win_style.header_opa = OPA_COVER; //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; diff --git a/lv_appx/lv_app_visual.c b/lv_appx/lv_app_visual.c index 52b3f4915..4abd29c3f 100644 --- a/lv_appx/lv_app_visual.c +++ b/lv_appx/lv_app_visual.c @@ -48,9 +48,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); 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); -static void kb_ok_action(lv_obj_t * ta); - /********************** * STATIC VARIABLES **********************/ @@ -184,27 +181,4 @@ static void my_win_close(lv_app_inst_t * app) * OTHER FUNCTIONS ---------------------*/ -/** - * Called when the text area on the window is released to open the app. keyboard - * @param ta pointer to the text area on the window - * @param dispi pointer to the caller display input - * @return LV_ACTION_RES_OK because the text area is not deleted - */ -static lv_action_res_t ta_rel_action(lv_obj_t * ta, lv_dispi_t * dispi) -{ - - return LV_ACTION_RES_OK; -} - -/** - * Called when the "Ok" button is pressed on the app. keyboard - * @param ta pointer to the text area assigned to the app. kexboard - */ -static void kb_ok_action(lv_obj_t * ta) -{ - lv_app_inst_t * app = lv_obj_get_free_p(ta); - const char * txt = lv_ta_get_txt(ta); - lv_app_com_send(app, LV_APP_COM_TYPE_CHAR, txt, strlen(txt)); -} - #endif /*LV_APP_ENABLE != 0 && USE_LV_APP_VISUAL != 0*/ diff --git a/lv_draw/lv_draw_vbasic.c b/lv_draw/lv_draw_vbasic.c index d7eff8ead..19cf6cf31 100644 --- a/lv_draw/lv_draw_vbasic.c +++ b/lv_draw/lv_draw_vbasic.c @@ -88,11 +88,18 @@ void lv_vfill(const area_t * cords_p, const area_t * mask_p, vdb_buf_tmp += vdb_width; } } - /*Calculate the alpha too*/ + /*Calculate with alpha too*/ else { + color_t bg_tmp = COLOR_BLACK; + color_t opa_tmp = color_mix(color, bg_tmp, opa); for(row = vdb_rel_a.y1; row <= vdb_rel_a.y2; row++) { for(col = vdb_rel_a.x1; col <= vdb_rel_a.x2; col++) { - vdb_buf_tmp[col] = color_mix(color, vdb_buf_tmp[col], opa); + /*If the bg color changed recalculate the result color*/ + if(vdb_buf_tmp[col].full != bg_tmp.full) { + bg_tmp = vdb_buf_tmp[col]; + opa_tmp = color_mix(color, bg_tmp, opa); + } + vdb_buf_tmp[col] = opa_tmp; } vdb_buf_tmp += vdb_width; } @@ -224,32 +231,8 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p, map_p -= (masked_a.x1 >> ds_shift); - if(upscale != false) { - cord_t row; - cord_t col; - color_t transp_color = LV_COLOR_TRANSP; - color_t color_tmp; - color_t prev_color = COLOR_BLACK; - cord_t map_col; - - color_tmp = color_mix(recolor, prev_color, recolor_opa); - for(row = masked_a.y1; row <= masked_a.y2; row++) { - for(col = masked_a.x1; col <= masked_a.x2; col ++) { - map_col = col >> 1; - - if(map_p[map_col].full != prev_color.full) { - prev_color.full = map_p[map_col].full; - color_tmp = color_mix(recolor, prev_color, recolor_opa); - } - if(transp == false || map_p[map_col].full != transp_color.full) { - vdb_buf_tmp[col] = color_mix( color_tmp, vdb_buf_tmp[col], opa); - } - } - if((row & 0x1) != 0) map_p += map_width; /*Next row on the map*/ - vdb_buf_tmp += vdb_width ; /*Next row on the VDB*/ - } - } - else { + /*No upscalse*/ + if(upscale == false) { if(transp == false) { /*Simply copy the pixels to the VDB*/ cord_t row; @@ -261,7 +244,7 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p, map_p += map_width; /*Next row on the map*/ vdb_buf_tmp += vdb_width; /*Next row on the VDB*/ } - } else { + } else { /*with opacity*/ cord_t col; for(row = masked_a.y1; row <= masked_a.y2; row++) { for(col = masked_a.x1; col <= masked_a.x2; col ++) { @@ -272,9 +255,11 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p, } } - /*To recolor draw simply a rectangle above the image*/ #if LV_VDB_SIZE != 0 - lv_vfill(cords_p, mask_p, recolor, recolor_opa); + /*To recolor draw simply a rectangle above the image*/ + if(recolor_opa != OPA_TRANSP) { + lv_vfill(cords_p, mask_p, recolor, recolor_opa); + } #endif } else { /*transp == true: Check all pixels */ cord_t row; @@ -290,8 +275,8 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p, } } - map_p += map_width; /*Next row on the map*/ - vdb_buf_tmp += vdb_width; /*Next row on the VDB*/ + map_p += map_width; /*Next row on the map*/ + vdb_buf_tmp += vdb_width; /*Next row on the VDB*/ } } else { for(row = masked_a.y1; row <= masked_a.y2; row++) { @@ -301,8 +286,8 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p, } } - map_p += map_width; /*Next row on the map*/ - vdb_buf_tmp += vdb_width; /*Next row on the VDB*/ + map_p += map_width; /*Next row on the map*/ + vdb_buf_tmp += vdb_width; /*Next row on the VDB*/ } } } else { /*Recolor needed*/ @@ -335,6 +320,57 @@ void lv_vmap(const area_t * cords_p, const area_t * mask_p, } } } + /*Upscalse*/ + else { + cord_t row; + cord_t col; + color_t transp_color = LV_COLOR_TRANSP; + color_t color_tmp; + color_t prev_color = COLOR_BLACK; + cord_t map_col; + + /*The most simple case (but upscale): o opacity, no recolor, no transp. pixels*/ + if(transp == false && opa == OPA_COVER && recolor_opa == OPA_TRANSP) { + for(row = masked_a.y1; row <= masked_a.y2; row++) { + for(col = masked_a.x1; col <= masked_a.x2; col ++) { + map_col = col >> 1; + vdb_buf_tmp[col].full = map_p[map_col].full; + } + if((row & 0x1) != 0) map_p += map_width; /*Next row on the map*/ + vdb_buf_tmp += vdb_width ; /*Next row on the VDB*/ + } + } + /*Handle other cases*/ + else { + color_tmp = color_mix(recolor, prev_color, recolor_opa); + for(row = masked_a.y1; row <= masked_a.y2; row++) { + for(col = masked_a.x1; col <= masked_a.x2; col ++) { + map_col = col >> 1; + + /*Handle recoloring*/ + if(recolor_opa == OPA_TRANSP) { + color_tmp.full = map_p[map_col].full; + } else { + if(map_p[map_col].full != prev_color.full) { + prev_color.full = map_p[map_col].full; + color_tmp = color_mix(recolor, prev_color, recolor_opa); + } + } + /*Put the NOT transparent pixels*/ + if(transp == false || map_p[map_col].full != transp_color.full) { + /*Handle opacity*/ + if(opa == OPA_COVER) { + vdb_buf_tmp[col] = color_tmp; + } else { + vdb_buf_tmp[col] = color_mix( color_tmp, vdb_buf_tmp[col], opa); + } + } + } + if((row & 0x1) != 0) map_p += map_width; /*Next row on the map*/ + vdb_buf_tmp += vdb_width ; /*Next row on the VDB*/ + } + } + } } diff --git a/lv_obj/lv_dispi.c b/lv_obj/lv_dispi.c index 93fe2465c..9cfdefe91 100644 --- a/lv_obj/lv_dispi.c +++ b/lv_obj/lv_dispi.c @@ -219,8 +219,8 @@ static void dispi_proc_press(lv_dispi_t * dispi_p) if(dispi_p->act_obj == NULL) { pr_obj = dispi_search_obj(dispi_p, lv_scr_act()); } - /*If there is last object but it can not be dragged also search*/ - else if(dispi_p->drag_range_out == 0) {/*Now act_obj != NULL*/ + /*If there is last object but it is not dragged also search*/ + else if(dispi_p->drag_in_prog == 0) {/*Now act_obj != NULL*/ pr_obj = dispi_search_obj(dispi_p, lv_scr_act()); } /*If a dragable object was the last then keep it*/ diff --git a/lv_obj/lv_obj.c b/lv_obj/lv_obj.c index 441f79d57..757b6ea02 100644 --- a/lv_obj/lv_obj.c +++ b/lv_obj/lv_obj.c @@ -85,6 +85,7 @@ void lv_init(void) def_scr = lv_img_create(NULL, NULL); lv_img_set_auto_size(def_scr, false); lv_img_set_file(def_scr, "U:/def_wp"); + lv_img_set_upscale(def_scr, true); #else def_scr = lv_obj_create(NULL, NULL); #endif diff --git a/lv_obj/lv_vdb.c b/lv_obj/lv_vdb.c index 4cba900a6..860ea41d1 100644 --- a/lv_obj/lv_vdb.c +++ b/lv_obj/lv_vdb.c @@ -74,20 +74,28 @@ void lv_vdb_flush(void) color_t * in2_buf = vdb.buf + w; /*Pointer to the second row*/ color_t * out_buf = vdb.buf; /*Store the result here*/ for(y = vdb.vdb_area.y1; y < vdb.vdb_area.y2; y += 2) { - for(x = vdb.vdb_area.x1; x < vdb.vdb_area.x2; x += 2) { - /*Get the average of 2x2 red*/ - out_buf->red = (in1_buf->red + (in1_buf + 1)->red + - in2_buf->red + (in2_buf+ 1)->red) >> 2; - /*Get the average of 2x2 green*/ - out_buf->green = (in1_buf->green + (in1_buf + 1)->green + - in2_buf->green + (in2_buf + 1)->green) >> 2; - /*Get the average of 2x2 blue*/ - out_buf->blue = (in1_buf->blue + (in1_buf + 1)->blue + - in2_buf->blue + (in2_buf + 1)->blue) >> 2; - - in1_buf+=2; /*Skip the next pixel because it is already used above*/ - in2_buf+=2; - out_buf++; + for(x = vdb.vdb_area.x1; x < vdb.vdb_area.x2; x += 2) { + + /*If the pixels are the same do not calculate the average */ + if(in1_buf->full == (in1_buf + 1)->full && + in1_buf->full == in2_buf->full && + in1_buf->full == (in2_buf + 1)->full) { + out_buf->full = in1_buf->full; + } else { + /*Get the average of 2x2 red*/ + out_buf->red = (in1_buf->red + (in1_buf + 1)->red + + in2_buf->red + (in2_buf+ 1)->red) >> 2; + /*Get the average of 2x2 green*/ + out_buf->green = (in1_buf->green + (in1_buf + 1)->green + + in2_buf->green + (in2_buf + 1)->green) >> 2; + /*Get the average of 2x2 blue*/ + out_buf->blue = (in1_buf->blue + (in1_buf + 1)->blue + + in2_buf->blue + (in2_buf + 1)->blue) >> 2; + } + + in1_buf += 2; /*Skip the next pixel because it is already used above*/ + in2_buf += 2; + out_buf ++; } /*2 row is ready so go the next 2*/ in1_buf += w; /*Skip the next row because it is processed from in2_buf*/ @@ -105,6 +113,4 @@ void lv_vdb_flush(void) * STATIC FUNCTIONS **********************/ - - #endif diff --git a/lv_objx/lv_img.c b/lv_objx/lv_img.c index a34433748..ca3d60b7f 100644 --- a/lv_objx/lv_img.c +++ b/lv_objx/lv_img.c @@ -217,10 +217,12 @@ void lv_img_set_file(lv_obj_t * img, const char * fn) ext->h = header.h; ext->transp = header.transp; +#if LV_ANTIALIAS != 0 if(ext->upscale != 0) { ext->w *= 2; ext->h *= 2; } +#endif } /*Handle symbol texts*/ else { @@ -240,11 +242,6 @@ void lv_img_set_file(lv_obj_t * img, const char * fn) } - if(ext->upscale != 0) { - ext->w *= LV_DOWNSCALE; - ext->h *= LV_DOWNSCALE; - } - if(fn != NULL) { ext->fn = dm_realloc(ext->fn, strlen(fn) + 1); strcpy(ext->fn, fn); @@ -283,7 +280,11 @@ void lv_img_set_auto_size(lv_obj_t * img, bool en) void lv_img_set_upscale(lv_obj_t * img, bool en) { lv_img_ext_t * ext = lv_obj_get_ext(img); - + + /*Upscale works only if antialiassing is enabled*/ +#if LV_ANTIALIAS == 0 + en = false; +#endif ext->upscale = (en == false ? 0 : 1); /*Refresh the image with the new size*/ diff --git a/lv_objx/lv_page.c b/lv_objx/lv_page.c index 5eb8596a1..400dcfd14 100644 --- a/lv_objx/lv_page.c +++ b/lv_objx/lv_page.c @@ -517,7 +517,6 @@ static bool lv_page_design(lv_obj_t * page, const area_t * mask, lv_design_mode_ ancestor_design_f(page, mask, mode); } else if(mode == LV_DESIGN_DRAW_POST) { /*Draw the scroll bars finally*/ ancestor_design_f(page, mask, mode); - lv_page_ext_t * ext = lv_obj_get_ext(page); lv_pages_t * style = lv_obj_get_style(page); opa_t sb_opa = lv_obj_get_opa(page) * style->sb_opa /100; @@ -554,6 +553,7 @@ static bool lv_page_design(lv_obj_t * page, const area_t * mask, lv_design_mode_ */ static void lv_page_sb_refresh(lv_obj_t * page) { +// return; /*Always let sb_width padding above,under, left and right to the scrollbars * else: * - horizontal and vertical scrollbars can overlap on the corners