[genlist] expandable effect rollback
authorJaehwan Kim <jae.hwan.kim@samsung.com>
Mon, 2 May 2011 02:47:43 +0000 (11:47 +0900)
committerJaehwan Kim <jae.hwan.kim@samsung.com>
Mon, 2 May 2011 02:47:43 +0000 (11:47 +0900)
src/lib/elm_genlist.c

index 806a001..18b9b31 100644 (file)
@@ -5793,6 +5793,7 @@ _item_moving_effect_timer_cb(void *data)
    double time = 0.3, t;
    int y, dy;
    Eina_Bool check, end = EINA_FALSE;
+   //   static Eina_Bool first = EINA_TRUE;
    int in = 0;
 
    t = ((0.0 > (t = current_time_get() - wd->start_time)) ? 0.0 : t) / 1000;
@@ -5800,30 +5801,6 @@ _item_moving_effect_timer_cb(void *data)
    evas_object_geometry_get(wd->pan_smart, &ox, &oy, &ow, &oh);
    evas_output_viewport_get(evas_object_evas_get(wd->pan_smart), &cvx, &cvy, &cvw, &cvh);
    if (t > time) end = EINA_TRUE;
-
-   it2 = elm_genlist_item_next_get(wd->expand_item);
-   while (it2)
-     {
-        if (wd->expand_item->expanded_depth == it2->expanded_depth) break;
-        it2 = elm_genlist_item_next_get(it2);
-     }
-   dy = 0;
-   if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
-     dy = it2->scrl_y - it2->old_scrl_y;
-   else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
-     dy = wd->expand_item_gap;
-
-   if (t <= time)
-     {
-        y = ((1 - (1 - (t / time)) * (1 - (t /time))) * dy);
-     }
-   else
-     {
-        end = EINA_TRUE;
-        y = dy;
-     }
-
-   check = EINA_FALSE;
    EINA_INLIST_FOREACH(wd->blocks, itb)
      {
         itb->w = wd->minw;
@@ -5834,11 +5811,43 @@ _item_moving_effect_timer_cb(void *data)
           {
              EINA_LIST_FOREACH(itb->items, l, it)
                {
-                  if (it == it2) check = EINA_TRUE;
-                  if (!check) continue;
+                  if (wd->move_effect_mode != ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
+                    {
+                       it2 = it;
+                       check = EINA_FALSE;
+                       do {
+                            if(it2->parent == wd->expand_item) check = EINA_TRUE;
+                            it2 = it2->parent;
+                       } while(it2);
+                       if(check) continue;
+                    }
+                  dy = 0;
+                  //printf(" s: %d %d ", oy, oh);
+                  if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
+                     dy = it->scrl_y - it->old_scrl_y;
+                  else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
+                    {
+                       //                  printf("%d %d\n", it->old_scrl_y, wd->expand_item_end);
+                       if(wd->expand_item_end < it->old_scrl_y)
+                          dy = wd->expand_item_gap;
+                    }
+                  else if (wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_DELETE)
+                    {
+                        if (wd->expand_item_end < it->old_scrl_y)
+                          dy = wd->expand_item_gap;
+                    }
+                  if (t <= time)
+                     y = (1 * sin((t / time) * (M_PI / 2)) * dy);
+                  else
+                    {
+                       end = EINA_TRUE;
+                       y = dy;
+                    }
 
                   if (!it->old_scrl_y)
                      it->old_scrl_y  = it->scrl_y;
+
+
                   if (it->old_scrl_y + y < oy + oh)
                     {
                        if (!it->realized) _item_realize(it, in, 0);
@@ -5861,46 +5870,49 @@ _item_moving_effect_timer_cb(void *data)
 
                       if (it->group_item) evas_object_raise(it->group_item->base.view);
                    }
-               }
-          }
-     }
 
-   if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
-     {
-        it = elm_genlist_item_prev_get(it2);
-        while(it)
-          {
-             if((it->scrl_y < it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
-               {
-                  if(!it->effect_done)
+                  if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
                     {
-                       edje_object_signal_emit(it->base.view, "flip_item", "");
-                       evas_object_show(it->base.view);
-                       it->effect_done = EINA_TRUE;
+                       it2 = elm_genlist_item_prev_get(it);
+                       while(it2)
+                         {
+                            if((it2->scrl_y < it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
+                              {
+                                 if(!it2->effect_done)
+                                   {
+                                      //edje_object_signal_emit(it2->base.view, "elm,state,expand_flip", "");
+                                      evas_object_move(it2->base.view, it2->scrl_x, it2->scrl_y);
+                                      evas_object_show(it2->base.view);
+                                      it2->effect_done = EINA_TRUE;
+                                   }
+                                // break;
+                              }
+                            it2 = elm_genlist_item_prev_get(it2);
+                         }
                     }
-               }
-             it = elm_genlist_item_prev_get(it);
-             if (it->expanded_depth <= it2->expanded_depth) break;
-          }
-     }
-   else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
-     {
-        it = elm_genlist_item_prev_get(it2);
-        while(it)
-          {
-             if((it->scrl_y > it2->old_scrl_y + y) && (it->expanded_depth > it2->expanded_depth))
-               {
-                  if(!it->effect_done)
+                  else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
                     {
-                       edje_object_signal_emit(it->base.view, "elm,state,hide", "");
-                       it->effect_done = EINA_TRUE;
+                       it2 = elm_genlist_item_prev_get(it);
+                       while(it2)
+                         {
+                            if((it2->scrl_y > it->old_scrl_y + y) && (it2->expanded_depth > it->expanded_depth))
+                              {
+                                 if(!it2->effect_done)
+                                   {
+                                      edje_object_signal_emit(it2->base.view, "elm,state,hide", "");
+                                      it2->effect_done = EINA_TRUE;
+                                   }
+                              }
+                            else
+                               break;
+                            it2 = elm_genlist_item_prev_get(it2);
+                         }
                     }
                }
-             else
-               break;
-             it = elm_genlist_item_prev_get(it);
           }
      }
+   //   first = EINA_FALSE;
+   //   printf("\n");
    if (end)
      {
         if (wd->item_moving_effect_timer)
@@ -5916,7 +5928,9 @@ _item_moving_effect_timer_cb(void *data)
                     }
                }
           }
+        //evas_render(evas_object_evas_get(wd->obj));
         wd->item_moving_effect_timer = NULL;
+        //        first = EINA_TRUE;
 
         _item_auto_scroll(wd);
         evas_object_lower(wd->alpha_bg);
@@ -5939,6 +5953,7 @@ _emit_contract(Elm_Genlist_Item *it)
    Elm_Genlist_Item *it2;
    Eina_List *l;
 
+   //   printf("%p is emited contract\n", it);
    edje_object_signal_emit(it->base.view, "elm,state,contract_flip", "");
    it->effect_done = EINA_FALSE;
 
@@ -5967,9 +5982,15 @@ _item_flip_effect_show(Elm_Genlist_Item *it)
         if (it2->parent && it == it2->parent)
           {
              if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_EXPAND)
-               edje_object_signal_emit(it2->base.view, "elm,state,unvisible", "");
+               {
+                  edje_object_signal_emit(it2->base.view, "flip_item", "");
+                  if(check)
+                     evas_object_move(it2->base.view, -9999, -9999);
+                  else
+                     evas_object_show(it2->base.view);
+               }
              else if(wd->move_effect_mode == ELM_GENLIST_ITEM_MOVE_EFFECT_CONTRACT)
-               _emit_contract(it2);
+                _emit_contract(it2);
           }
      }