add elm_genlist_item_count(), change (int)wd->count to (uint)wd->item_count, fix...
authordiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 21 Feb 2012 23:59:25 +0000 (23:59 +0000)
committerdiscomfitor <discomfitor@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 21 Feb 2012 23:59:25 +0000 (23:59 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@68240 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/elm_gen_common.h
src/lib/elm_gengrid.c
src/lib/elm_genlist.c
src/lib/elm_genlist.h

index 28f8b1d..f01754d 100644 (file)
@@ -98,7 +98,7 @@ struct _Widget_Data
    int                            item_width, item_height;
    int                            group_item_width, group_item_height;
    int                            minw, minh;
-   long                           count;
+   unsigned int                   item_count;
    Evas_Coord                     pan_x, pan_y;
    Eina_Bool                      reorder_mode : 1; /* a flag for reorder mode enable/disable */
    Eina_Bool                      on_hold : 1;
index ae3a39e..93af724 100644 (file)
@@ -1073,18 +1073,18 @@ static Eina_Bool
 _reorder_item_moving_effect_timer_cb(void *data)
 {
    Elm_Gen_Item *it = data;
-   double time, t;
+   double tt, t;
    Evas_Coord dx, dy;
 
-   time = REORDER_EFFECT_TIME;
+   tt = REORDER_EFFECT_TIME;
    t = ((0.0 > (t = ecore_loop_time_get()-it->item->moving_effect_start_time)) ? 0.0 : t);
    dx = ((it->item->tx - it->item->ox) / 10) * _elm_config->scale;
    dy = ((it->item->ty - it->item->oy) / 10) * _elm_config->scale;
 
-   if (t <= time)
+   if (t <= tt)
      {
-        it->item->rx += (1 * sin((t / time) * (M_PI / 2)) * dx);
-        it->item->ry += (1 * sin((t / time) * (M_PI / 2)) * dy);
+        it->item->rx += (1 * sin((t / tt) * (M_PI / 2)) * dx);
+        it->item->ry += (1 * sin((t / tt) * (M_PI / 2)) * dy);
      }
    else
      {
@@ -1186,7 +1186,7 @@ _item_place(Elm_Gen_Item *it,
    alignh = 0;
    alignw = 0;
 
-   items_count = it->wd->count - eina_list_count(it->wd->group_items) + it->wd->items_lost;
+   items_count = it->wd->item_count - eina_list_count(it->wd->group_items) + it->wd->items_lost;
    if (it->wd->horizontal)
      {
         int columns, items_visible = 0, items_row;
@@ -1204,10 +1204,10 @@ _item_place(Elm_Gen_Item *it,
         alignw = (vw - tcw) * it->wd->align_x;
 
         items_row = items_visible;
-        if (items_row > it->wd->count)
-          items_row = it->wd->count;
+        if ((unsigned int)items_row > it->wd->item_count)
+          items_row = it->wd->item_count;
          if (it->wd->filled
-             && (unsigned int)it->wd->nmax > (unsigned int)it->wd->count)
+             && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
            tch = it->wd->nmax * it->wd->item_height;
          else
            tch = items_row * it->wd->item_height;
@@ -1215,7 +1215,7 @@ _item_place(Elm_Gen_Item *it,
      }
    else
      {
-        int rows, items_visible = 0, items_col;
+        unsigned int rows, items_visible = 0, items_col;
 
         if (it->wd->item_width > 0)
           items_visible = vw / it->wd->item_width;
@@ -1230,10 +1230,10 @@ _item_place(Elm_Gen_Item *it,
         alignh = (vh - tch) * it->wd->align_y;
 
         items_col = items_visible;
-        if (items_col > it->wd->count)
-          items_col = it->wd->count;
+        if (items_col > it->wd->item_count)
+          items_col = it->wd->item_count;
          if (it->wd->filled
-             && (unsigned int)it->wd->nmax > (unsigned int)it->wd->count)
+             && (unsigned int)it->wd->nmax > (unsigned int)it->wd->item_count)
            tcw = it->wd->nmax * it->wd->item_width;
          else
            tcw = items_col * it->wd->item_width;
@@ -1445,7 +1445,7 @@ _item_del(Elm_Gen_Item *it)
    evas_event_freeze(evas_object_evas_get(obj));
    it->wd->selected = eina_list_remove(it->wd->selected, it);
    if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
-   it->wd->count--;
+   it->wd->item_count--;
    _elm_genlist_item_del_serious(it);
    evas_event_thaw(evas_object_evas_get(obj));
    evas_event_thaw_eval(evas_object_evas_get(obj));
@@ -1507,7 +1507,7 @@ _calc_job(void *data)
                   count++;
                }
           }
-        count = wd->count + wd->items_lost - count_group;
+        count = wd->item_count + wd->items_lost - count_group;
         if (wd->horizontal)
           {
              minw = (ceil(count / (float)nmax) * wd->item_width) + (count_group * wd->group_item_width);
@@ -1897,7 +1897,7 @@ _item_new(Widget_Data                  *wd,
    elm_widget_item_disable_hook_set(it, _item_disable_hook);
    elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
    it->item = ELM_NEW(Elm_Gen_Item_Type);
-   wd->count++;
+   wd->item_count++;
    it->group = it->itc->item_style && (!strcmp(it->itc->item_style, "group_index"));
    ELM_GEN_ITEM_SETUP(it);
 
index ad98448..fecbbe9 100644 (file)
@@ -3372,6 +3372,7 @@ _item_new(Widget_Data                  *wd,
         if (!it2->parent->group) depth += 1;
      }
    it->item->expanded_depth = depth;
+   wd->item_count++;
    return it;
 }
 
@@ -3816,6 +3817,15 @@ _item_move_before(Elm_Gen_Item *it, Elm_Gen_Item *before)
    evas_object_smart_callback_call(WIDGET(it), SIG_MOVED, it);
 }
 
+EAPI unsigned int
+elm_genlist_item_count(const Evas_Object *obj)
+{
+   ELM_CHECK_WIDTYPE(obj, widtype) 0;
+   Widget_Data *wd = elm_widget_data_get(obj);
+   if (!wd) return 0;
+   return wd->item_count;
+}
+
 EAPI Elm_Object_Item *
 elm_genlist_item_append(Evas_Object                  *obj,
                         const Elm_Genlist_Item_Class *itc,
@@ -4133,7 +4143,6 @@ _elm_genlist_clear(Evas_Object *obj, Eina_Bool standby)
    wd->pan_y = 0;
    wd->minw = 0;
    wd->minh = 0;
-   wd->count = 0;
    if (wd->pan_smart)
      {
         evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh);
@@ -5554,4 +5563,5 @@ _elm_genlist_item_del_serious(Elm_Gen_Item *it)
    it->item = NULL;
    if (it->wd->last_selected_item == (Elm_Object_Item *) it)
      it->wd->last_selected_item = NULL;
+   it->wd->item_count--;
 }
index 85736eb..473fae8 100644 (file)
@@ -1915,5 +1915,16 @@ EAPI void elm_genlist_item_class_ref(Elm_Genlist_Item_Class *itc);
 EAPI void elm_genlist_item_class_unref(Elm_Genlist_Item_Class *itc);
 
 /**
+ * Return how many items are currently in a list
+ *
+ * @param obj The list
+ * @return The total number of list items in the list
+ *
+ * This behavior is O(1) and includes items which may or may not be realized.
+ *
+ * @ingroup Genlist
+ */
+EAPI unsigned int elm_genlist_item_count(const Evas_Object *obj);
+/**
  * @}
  */