55 */
66#include "ui_wallpaper.h"
77
8- ui_wallpaper_t * ui_wallpaper_attach (lv_obj_t * parent )
8+ #include "app/assets/assets.h"
9+
10+ ui_wallpaper_t * ui_wallpaper_attach (lv_obj_t * parent )
911{
10- if (parent == NULL ) {
12+ if (parent == NULL )
13+ {
1114 return NULL ;
1215 }
1316
14- ui_wallpaper_t * wallpaper = (ui_wallpaper_t * )lv_malloc (sizeof (ui_wallpaper_t ));
15- if (wallpaper == NULL ) {
17+ ui_wallpaper_t * wallpaper = (ui_wallpaper_t * )lv_malloc (sizeof (ui_wallpaper_t ));
18+ if (wallpaper == NULL )
19+ {
1620 return NULL ;
1721 }
1822 lv_memset (wallpaper , 0 , sizeof (ui_wallpaper_t ));
1923
2024 wallpaper -> layer = lv_obj_create (parent );
21- if (wallpaper -> layer == NULL ) {
25+ if (wallpaper -> layer == NULL )
26+ {
2227 lv_free (wallpaper );
2328 return NULL ;
2429 }
@@ -27,22 +32,41 @@ ui_wallpaper_t *ui_wallpaper_attach(lv_obj_t *parent)
2732 lv_obj_set_size (wallpaper -> layer , LV_PCT (100 ), LV_PCT (100 ));
2833 lv_obj_add_flag (wallpaper -> layer , LV_OBJ_FLAG_IGNORE_LAYOUT );
2934 lv_obj_move_background (wallpaper -> layer );
30- lv_obj_set_style_bg_opa (wallpaper -> layer , LV_OPA_COVER , LV_PART_MAIN );
31- lv_obj_set_style_bg_color (wallpaper -> layer , lv_color_hex (0xfcff9e ), LV_PART_MAIN );
32- lv_obj_set_style_bg_grad_color (wallpaper -> layer , lv_color_hex (0xc67700 ), LV_PART_MAIN );
33- lv_obj_set_style_bg_grad_dir (wallpaper -> layer , LV_GRAD_DIR_HOR , LV_PART_MAIN );
35+ lv_obj_set_style_bg_opa (wallpaper -> layer , LV_OPA_TRANSP , LV_PART_MAIN );
3436 lv_obj_set_style_border_width (wallpaper -> layer , 0 , LV_PART_MAIN );
3537
38+ wallpaper -> image = lv_image_create (wallpaper -> layer );
39+ if (wallpaper -> image == NULL )
40+ {
41+ lv_obj_del (wallpaper -> layer );
42+ lv_free (wallpaper );
43+ return NULL ;
44+ }
45+
46+ lv_obj_remove_style_all (wallpaper -> image );
47+ lv_image_set_src (wallpaper -> image , & launcher_bg );
48+ lv_obj_set_align (wallpaper -> image , LV_ALIGN_CENTER );
49+ lv_obj_add_flag (wallpaper -> image , LV_OBJ_FLAG_IGNORE_LAYOUT );
50+ lv_obj_move_background (wallpaper -> image );
51+
3652 return wallpaper ;
3753}
3854
39- void ui_wallpaper_detach (ui_wallpaper_t * wallpaper )
55+ void ui_wallpaper_detach (ui_wallpaper_t * wallpaper )
4056{
41- if (wallpaper == NULL ) {
57+ if (wallpaper == NULL )
58+ {
4259 return ;
4360 }
4461
45- if (wallpaper -> layer != NULL ) {
62+ if (wallpaper -> image != NULL )
63+ {
64+ lv_obj_del (wallpaper -> image );
65+ wallpaper -> image = NULL ;
66+ }
67+
68+ if (wallpaper -> layer != NULL )
69+ {
4670 lv_obj_del (wallpaper -> layer );
4771 wallpaper -> layer = NULL ;
4872 }
0 commit comments