@@ -20,7 +20,7 @@ class Launcher(mpos.apps.Activity):
2020 def onCreate (self ):
2121 print ("launcher.py onCreate()" )
2222 main_screen = lv .obj ()
23- main_screen .set_style_border_width (0 , 0 )
23+ main_screen .set_style_border_width (0 , lv . PART . MAIN )
2424 main_screen .set_style_radius (0 , 0 )
2525 main_screen .set_pos (0 , mpos .ui .topmenu .NOTIFICATION_BAR_HEIGHT ) # leave some margin for the notification bar
2626 #main_screen.set_size(lv.pct(100), lv.pct(100))
@@ -65,6 +65,10 @@ def onResume(self, screen):
6565 start = time .ticks_ms ()
6666
6767 screen .clean ()
68+ # Get the group for focusable objects
69+ focusgroup = lv .group_get_default ()
70+ if not focusgroup :
71+ print ("WARNING: could not get default focusgroup" )
6872
6973 # Sort apps alphabetically by app.name
7074 app_list .sort (key = lambda x : x [0 ].lower ()) # Case-insensitive sorting
@@ -75,9 +79,10 @@ def onResume(self, screen):
7579 # Create container for each app (icon + label)
7680 app_cont = lv .obj (screen )
7781 app_cont .set_size (iconcont_width , iconcont_height )
78- app_cont .set_style_border_width (0 , 0 )
82+ app_cont .set_style_border_width (0 , lv . PART . MAIN )
7983 app_cont .set_style_pad_all (0 , 0 )
8084 app_cont .set_style_bg_opa (lv .OPA .TRANSP ,0 ) # prevent default style from adding slight gray to this container
85+ app_cont .set_scrollbar_mode (lv .SCROLLBAR_MODE .OFF )
8186 # Load and display icon
8287 icon_path = f"{ app_dir_fullpath } /res/mipmap-mdpi/icon_64x64.png"
8388 image = lv .image (app_cont )
@@ -100,6 +105,9 @@ def onResume(self, screen):
100105 label .align (lv .ALIGN .BOTTOM_MID , 0 , 0 )
101106 label .set_style_text_align (lv .TEXT_ALIGN .CENTER , 0 )
102107 app_cont .add_event_cb (lambda e , path = app_dir_fullpath : mpos .apps .start_app (path ), lv .EVENT .CLICKED , None )
108+ app_cont .add_event_cb (lambda e , app_cont = app_cont : self .focus_app_cont (app_cont ),lv .EVENT .FOCUSED ,None )
109+ app_cont .add_event_cb (lambda e , app_cont = app_cont : self .defocus_app_cont (app_cont ),lv .EVENT .DEFOCUSED ,None )
110+ focusgroup .add_obj (app_cont )
103111
104112 end = time .ticks_ms ()
105113 print (f"Redraw icons took: { end - start } ms" )
@@ -113,3 +121,13 @@ def load_icon(icon_path):
113121 'data' : image_data
114122 })
115123 return image_dsc
124+
125+ def focus_app_cont (self , app_cont ):
126+ #print(f"app_cont {app_cont} focused, setting border...")
127+ app_cont .set_style_border_color (lv .theme_get_color_primary (None ),lv .PART .MAIN )
128+ app_cont .set_style_border_width (1 , lv .PART .MAIN )
129+ app_cont .scroll_to_view (lv .ANIM .ON ) # scroll to bring it into view
130+
131+ def defocus_app_cont (self , app_cont ):
132+ #print(f"app_cont {app_cont} defocused, unsetting border...")
133+ app_cont .set_style_border_width (0 , lv .PART .MAIN )
0 commit comments