elementary: make sure that our index for the maximum number of object is actually...
authorCedric BAIL <cedric.bail@free.fr>
Thu, 19 Dec 2019 18:47:57 +0000 (10:47 -0800)
committerJongmin Lee <jm105.lee@samsung.com>
Sun, 29 Dec 2019 20:46:23 +0000 (05:46 +0900)
Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D10927

src/lib/elementary/efl_ui_collection.c
src/lib/elementary/efl_ui_collection_view.c
src/lib/elementary/efl_ui_position_manager_entity.eo
src/lib/elementary/efl_ui_position_manager_grid.c
src/lib/elementary/efl_ui_position_manager_list.c

index 3f2aacc..e69e7c4 100644 (file)
@@ -1255,8 +1255,9 @@ _efl_ui_collection_focus_manager_efl_ui_focus_manager_request_move(Eo *obj, Efl_
 
    if (ITEM_IS_OUTSIDE_VISIBLE(item_id))
      {
-        int new_id = efl_ui_position_manager_entity_relative_item(collection_pd->pos_man, efl_ui_item_index_get(item), direction);
-        if (new_id == -1)
+        unsigned int new_id;
+
+        if (!efl_ui_position_manager_entity_relative_item(collection_pd->pos_man, efl_ui_item_index_get(item), direction, &new_id))
           {
              new_item = NULL;
           }
index 782b24e..99b459f 100644 (file)
@@ -2435,12 +2435,12 @@ _efl_ui_collection_view_focus_manager_efl_ui_focus_manager_request_move(Eo *obj,
 
    if (ITEM_IS_OUTSIDE_VISIBLE(item_id))
      {
-        int new_id;
+        unsigned int new_id;
 
-        new_id = efl_ui_position_manager_entity_relative_item(cpd->manager,
-                                                              item_id,
-                                                              direction);
-        if (new_id < 0)
+        if (!efl_ui_position_manager_entity_relative_item(cpd->manager,
+                                                          item_id,
+                                                          direction,
+                                                          &new_id))
           {
              new_item = NULL;
           }
index f75711f..368e7cb 100644 (file)
@@ -107,8 +107,9 @@ interface @beta Efl.Ui.Position_Manager.Entity extends Efl.Ui.Layout_Orientable
         params {
           current_id : uint; [[The id where the direction is oriented at]]
           direction : Efl.Ui.Focus.Direction; [[The direction where the new id is]]
+         @out index: uint; [[The relative item index after the translation has been applied.]]
         }
-        return : int; [[The id of the item in that direction, or -1 if there is no item in that direction]]
+        return : bool; [[$true if there is a next item, $false otherwise.]]
       }
    }
    events {
index 2cec569..59aabbe 100644 (file)
@@ -738,35 +738,34 @@ _efl_ui_position_manager_grid_efl_ui_position_manager_entity_position_single_ite
    return geom;
 }
 
-EOLIAN static int
-_efl_ui_position_manager_grid_efl_ui_position_manager_entity_relative_item(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd, unsigned int current_id, Efl_Ui_Focus_Direction direction)
+EOLIAN static Eina_Bool
+_efl_ui_position_manager_grid_efl_ui_position_manager_entity_relative_item(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_Grid_Data *pd, unsigned int current_id, Efl_Ui_Focus_Direction direction, unsigned int *index)
 {
-   int new_id = current_id;
    switch(direction)
      {
         case EFL_UI_FOCUS_DIRECTION_RIGHT:
         case EFL_UI_FOCUS_DIRECTION_NEXT:
-          new_id += 1;
-        break;
+           if (current_id + 1 >= pd->size) return EINA_FALSE;
+           current_id += 1;
+           break;
         case EFL_UI_FOCUS_DIRECTION_LEFT:
         case EFL_UI_FOCUS_DIRECTION_PREVIOUS:
-          new_id -= 1;
-        break;
+           if (current_id == 0) return EINA_FALSE;
+           current_id -= 1;
+           break;
         case EFL_UI_FOCUS_DIRECTION_UP:
-          //FIXME
-        break;
+           //FIXME
+           break;
         case EFL_UI_FOCUS_DIRECTION_DOWN:
-          //FIXME
-        break;
+           //FIXME
+           break;
         default:
-          new_id = -1;
-          ERR("Uncaught case!");
-        break;
+           ERR("Uncaught case!");
+           return EINA_FALSE;
      }
-   if (new_id < 0 || new_id > (int)pd->size)
-     return -1;
-   else
-     return new_id;
+
+   if (index) *index = current_id;
+   return EINA_TRUE;
 }
 
 EOLIAN static int
index 3980e12..6424b4b 100644 (file)
@@ -520,31 +520,30 @@ _efl_ui_position_manager_list_efl_object_invalidate(Eo *obj, Efl_Ui_Position_Man
    efl_invalidate(efl_super(obj, MY_CLASS));
 }
 
-EOLIAN static int
-_efl_ui_position_manager_list_efl_ui_position_manager_entity_relative_item(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd, unsigned int current_id, Efl_Ui_Focus_Direction direction)
+EOLIAN static Eina_Bool
+_efl_ui_position_manager_list_efl_ui_position_manager_entity_relative_item(Eo *obj EINA_UNUSED, Efl_Ui_Position_Manager_List_Data *pd, unsigned int current_id, Efl_Ui_Focus_Direction direction, unsigned int *index)
 {
-   int new_id = current_id;
    switch(direction)
      {
         case EFL_UI_FOCUS_DIRECTION_RIGHT:
         case EFL_UI_FOCUS_DIRECTION_NEXT:
         case EFL_UI_FOCUS_DIRECTION_DOWN:
-          new_id +=  1;
-        break;
+           if (current_id + 1 >= pd->size) return EINA_FALSE;
+           current_id +=  1;
+           break;
         case EFL_UI_FOCUS_DIRECTION_LEFT:
         case EFL_UI_FOCUS_DIRECTION_PREVIOUS:
         case EFL_UI_FOCUS_DIRECTION_UP:
-          new_id -=  1;
-        break;
+           if (current_id == 0) return EINA_FALSE;
+           current_id -=  1;
+           break;
         default:
-          ERR("Uncaught case!");
-          new_id = -1;
-        break;
+           ERR("Uncaught case!");
+           return EINA_FALSE;
      }
-   if (new_id < 0 || new_id > (int)pd->size)
-     return -1;
-   else
-     return new_id;
+
+   if (index) *index = current_id;
+   return EINA_TRUE;
 }
 
 EOLIAN static int