@@ -297,25 +297,20 @@ void ViewMain::onCancel()
297297
298298void ViewMain::refreshWidgetSelectTimer ()
299299{
300- if (!widget_select_timer) {
301- widget_select_timer = lv_timer_create (ViewMain::ws_timer, 10 * 1000 , this );
302- } else {
303- lv_timer_reset (widget_select_timer);
304- }
300+ widgetSelectCancelTime = get_tmr10ms () + 1000 ; // 10 seconds
305301}
306302
307- bool ViewMain::enableWidgetSelect (bool enable)
303+ void ViewMain::enableWidgetSelect (bool enable)
308304{
309305 TRACE (" enableWidgetSelect(%d)" , enable);
310- // TODO: start timer
311- if (widget_select == enable) return false ;
306+ if (widget_select == enable) return ;
312307 widget_select = enable;
313308
314309 lv_obj_t * tile = lv_tileview_get_tile_act (tile_view);
315- if (!tile) return true ;
310+ if (!tile) return ;
316311
317312 auto cont_obj = lv_obj_get_child (tile, 0 );
318- if (!cont_obj) return true ;
313+ if (!cont_obj) return ;
319314
320315 auto cont = (WidgetsContainer*)lv_obj_get_user_data (cont_obj);
321316
@@ -329,30 +324,33 @@ bool ViewMain::enableWidgetSelect(bool enable)
329324 lv_obj_clear_flag (tile_view, LV_OBJ_FLAG_SCROLLABLE );
330325 lv_obj_clear_flag (tile_view, LV_OBJ_FLAG_SCROLL_CHAIN_HOR );
331326 lv_obj_clear_flag (tile_view, LV_OBJ_FLAG_SCROLL_CHAIN_VER );
327+
328+ refreshWidgetSelectTimer ();
332329 } else {
333330 lv_obj_add_flag (tile_view, LV_OBJ_FLAG_SCROLLABLE );
334331 lv_obj_add_flag (tile_view, LV_OBJ_FLAG_SCROLL_CHAIN_HOR );
335332 lv_obj_add_flag (tile_view, LV_OBJ_FLAG_SCROLL_CHAIN_VER );
336333
337- if (widget_select_timer) {
338- lv_timer_del (widget_select_timer);
339- widget_select_timer = nullptr ;
340- }
334+ widgetSelectCancelTime = 0 ;
341335 }
342-
343- return true ;
344336}
345337
346338void ViewMain::openMenu ()
347339{
348340 viewMainMenu = new ViewMainMenu (this , [=]() { viewMainMenu = nullptr ; });
349341}
350342
351- void ViewMain::ws_timer ( lv_timer_t * t )
343+ void ViewMain::checkWidgetSelectTimeout ( )
352344{
353- ViewMain* view = (ViewMain*)t->user_data ;
354- if (!view) return ;
355- view->enableWidgetSelect (false );
345+ if (_instance) _instance->_checkWidgetSelectTimeout ();
346+ }
347+
348+ void ViewMain::_checkWidgetSelectTimeout ()
349+ {
350+ if (deleted ()) return ;
351+
352+ if (widget_select && widgetSelectCancelTime < get_tmr10ms ())
353+ enableWidgetSelect (false );
356354}
357355
358356bool ViewMain::onLongPress ()
0 commit comments