@@ -212,6 +212,12 @@ bool lv_indev_is_dragging(const lv_indev_t * indev)
212
212
*/
213
213
void lv_indev_get_vect (const lv_indev_t * indev , lv_point_t * point )
214
214
{
215
+ if (indev == NULL ) {
216
+ point -> x = 0 ;
217
+ point -> y = 0 ;
218
+ return ;
219
+ }
220
+
215
221
if (indev -> driver .type != LV_INDEV_TYPE_POINTER && indev -> driver .type != LV_INDEV_TYPE_BUTTON ) {
216
222
point -> x = 0 ;
217
223
point -> y = 0 ;
@@ -461,11 +467,15 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
461
467
if (focused ) focused -> signal_func (focused , LV_SIGNAL_GET_EDITABLE , & editable );
462
468
463
469
if (editable ) {
464
- lv_group_set_editing (i -> group , lv_group_get_editing (i -> group ) ? false : true); /*Toggle edit mode on long press*/
470
+ if (i -> group -> obj_ll .head != i -> group -> obj_ll .tail )
471
+ lv_group_set_editing (i -> group , lv_group_get_editing (i -> group ) ? false : true); /*Toggle edit mode on long press*/
472
+ else if (focused )
473
+ focused -> signal_func (focused , LV_SIGNAL_LONG_PRESS , indev_act );
465
474
}
466
475
/*If not editable then just send a long press signal*/
467
476
else {
468
- if (focused ) focused -> signal_func (focused , LV_SIGNAL_LONG_PRESS , indev_act );
477
+ if (focused )
478
+ focused -> signal_func (focused , LV_SIGNAL_LONG_PRESS , indev_act );
469
479
}
470
480
i -> proc .long_pr_sent = 1 ;
471
481
}
@@ -482,7 +492,8 @@ static void indev_encoder_proc(lv_indev_t * i, lv_indev_data_t * data)
482
492
}
483
493
/*An object is being edited and the button is releases. Just send enter */
484
494
else if (i -> group -> editing ) {
485
- if (!i -> proc .long_pr_sent ) lv_group_send_data (i -> group , LV_GROUP_KEY_ENTER ); /*Ignore long pressed enter release because it comes from mode switch*/
495
+ if (!i -> proc .long_pr_sent || i -> group -> obj_ll .head == i -> group -> obj_ll .tail )
496
+ lv_group_send_data (i -> group , LV_GROUP_KEY_ENTER ); /*Ignore long pressed enter release because it comes from mode switch*/
486
497
}
487
498
/*If the focused object is editable and now in navigate mode then enter edit mode*/
488
499
else if (editable && !i -> group -> editing && !i -> proc .long_pr_sent ) {
@@ -574,7 +585,10 @@ static void indev_proc_press(lv_indev_proc_t * proc)
574
585
if (proc -> reset_query != 0 ) return ;
575
586
}
576
587
577
- if (pr_obj != NULL ) {
588
+ proc -> act_obj = pr_obj ; /*Save the pressed object*/
589
+ proc -> last_obj = proc -> act_obj ; /*Refresh the last_obj*/
590
+
591
+ if (proc -> act_obj != NULL ) {
578
592
/* Save the time when the obj pressed.
579
593
* It is necessary to count the long press time.*/
580
594
proc -> pr_timestamp = lv_tick_get ();
@@ -583,9 +597,11 @@ static void indev_proc_press(lv_indev_proc_t * proc)
583
597
proc -> drag_in_prog = 0 ;
584
598
proc -> drag_sum .x = 0 ;
585
599
proc -> drag_sum .y = 0 ;
600
+ proc -> vect .x = 0 ;
601
+ proc -> vect .y = 0 ;
586
602
587
603
/*Search for 'top' attribute*/
588
- lv_obj_t * i = pr_obj ;
604
+ lv_obj_t * i = proc -> act_obj ;
589
605
lv_obj_t * last_top = NULL ;
590
606
while (i != NULL ) {
591
607
if (i -> top != 0 ) last_top = i ;
@@ -601,14 +617,11 @@ static void indev_proc_press(lv_indev_proc_t * proc)
601
617
}
602
618
603
619
/*Send a signal about the press*/
604
- pr_obj -> signal_func (pr_obj , LV_SIGNAL_PRESSED , indev_act );
620
+ proc -> act_obj -> signal_func (proc -> act_obj , LV_SIGNAL_PRESSED , indev_act );
605
621
if (proc -> reset_query != 0 ) return ;
606
622
}
607
623
}
608
624
609
- proc -> act_obj = pr_obj ; /*Save the pressed object*/
610
- proc -> last_obj = proc -> act_obj ; /*Refresh the last_obj*/
611
-
612
625
/*Calculate the vector*/
613
626
proc -> vect .x = proc -> act_point .x - proc -> last_point .x ;
614
627
proc -> vect .y = proc -> act_point .y - proc -> last_point .y ;
@@ -885,14 +898,19 @@ static void indev_drag_throw(lv_indev_proc_t * state)
885
898
886
899
if (state -> vect .x != 0 ||
887
900
state -> vect .y != 0 ) {
888
- /*Get the coordinates and modify them*/
901
+ /*Get the coordinates and modify them*/
902
+ lv_area_t coords_ori ;
903
+ lv_obj_get_coords (drag_obj , & coords_ori );
889
904
lv_coord_t act_x = lv_obj_get_x (drag_obj ) + state -> vect .x ;
890
905
lv_coord_t act_y = lv_obj_get_y (drag_obj ) + state -> vect .y ;
891
906
lv_obj_set_pos (drag_obj , act_x , act_y );
892
907
908
+ lv_area_t coord_new ;
909
+ lv_obj_get_coords (drag_obj , & coord_new );
910
+
893
911
/*If non of the coordinates are changed then do not continue throwing*/
894
- if ((lv_obj_get_x ( drag_obj ) != act_x || state -> vect .x == 0 ) &&
895
- (lv_obj_get_y ( drag_obj ) != act_y || state -> vect .y == 0 )) {
912
+ if ((coords_ori . x1 == coord_new . x1 || state -> vect .x == 0 ) &&
913
+ (coords_ori . y1 == coord_new . y1 || state -> vect .y == 0 )) {
896
914
state -> drag_in_prog = 0 ;
897
915
state -> vect .x = 0 ;
898
916
state -> vect .y = 0 ;
0 commit comments