add elm_genlist_item_count(), change (int)wd->count to (uint)wd->item_count, fix a shadow var

SVN revision: 68240
This commit is contained in:
Mike Blumenkrantz 2012-02-21 23:59:25 +00:00
parent 8b6d86f565
commit 8fb0f58c98
4 changed files with 39 additions and 18 deletions

View File

@ -98,7 +98,7 @@ struct _Widget_Data
int item_width, item_height; int item_width, item_height;
int group_item_width, group_item_height; int group_item_width, group_item_height;
int minw, minh; int minw, minh;
long count; unsigned int item_count;
Evas_Coord pan_x, pan_y; Evas_Coord pan_x, pan_y;
Eina_Bool reorder_mode : 1; /* a flag for reorder mode enable/disable */ Eina_Bool reorder_mode : 1; /* a flag for reorder mode enable/disable */
Eina_Bool on_hold : 1; Eina_Bool on_hold : 1;

View File

@ -1073,18 +1073,18 @@ static Eina_Bool
_reorder_item_moving_effect_timer_cb(void *data) _reorder_item_moving_effect_timer_cb(void *data)
{ {
Elm_Gen_Item *it = data; Elm_Gen_Item *it = data;
double time, t; double tt, t;
Evas_Coord dx, dy; 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); 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; dx = ((it->item->tx - it->item->ox) / 10) * _elm_config->scale;
dy = ((it->item->ty - it->item->oy) / 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->rx += (1 * sin((t / tt) * (M_PI / 2)) * dx);
it->item->ry += (1 * sin((t / time) * (M_PI / 2)) * dy); it->item->ry += (1 * sin((t / tt) * (M_PI / 2)) * dy);
} }
else else
{ {
@ -1186,7 +1186,7 @@ _item_place(Elm_Gen_Item *it,
alignh = 0; alignh = 0;
alignw = 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) if (it->wd->horizontal)
{ {
int columns, items_visible = 0, items_row; int columns, items_visible = 0, items_row;
@ -1204,10 +1204,10 @@ _item_place(Elm_Gen_Item *it,
alignw = (vw - tcw) * it->wd->align_x; alignw = (vw - tcw) * it->wd->align_x;
items_row = items_visible; items_row = items_visible;
if (items_row > it->wd->count) if ((unsigned int)items_row > it->wd->item_count)
items_row = it->wd->count; items_row = it->wd->item_count;
if (it->wd->filled 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; tch = it->wd->nmax * it->wd->item_height;
else else
tch = items_row * it->wd->item_height; tch = items_row * it->wd->item_height;
@ -1215,7 +1215,7 @@ _item_place(Elm_Gen_Item *it,
} }
else else
{ {
int rows, items_visible = 0, items_col; unsigned int rows, items_visible = 0, items_col;
if (it->wd->item_width > 0) if (it->wd->item_width > 0)
items_visible = vw / it->wd->item_width; items_visible = vw / it->wd->item_width;
@ -1230,10 +1230,10 @@ _item_place(Elm_Gen_Item *it,
alignh = (vh - tch) * it->wd->align_y; alignh = (vh - tch) * it->wd->align_y;
items_col = items_visible; items_col = items_visible;
if (items_col > it->wd->count) if (items_col > it->wd->item_count)
items_col = it->wd->count; items_col = it->wd->item_count;
if (it->wd->filled 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; tcw = it->wd->nmax * it->wd->item_width;
else else
tcw = items_col * it->wd->item_width; 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)); evas_event_freeze(evas_object_evas_get(obj));
it->wd->selected = eina_list_remove(it->wd->selected, it); it->wd->selected = eina_list_remove(it->wd->selected, it);
if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE); if (it->realized) _elm_genlist_item_unrealize(it, EINA_FALSE);
it->wd->count--; it->wd->item_count--;
_elm_genlist_item_del_serious(it); _elm_genlist_item_del_serious(it);
evas_event_thaw(evas_object_evas_get(obj)); evas_event_thaw(evas_object_evas_get(obj));
evas_event_thaw_eval(evas_object_evas_get(obj)); evas_event_thaw_eval(evas_object_evas_get(obj));
@ -1507,7 +1507,7 @@ _calc_job(void *data)
count++; count++;
} }
} }
count = wd->count + wd->items_lost - count_group; count = wd->item_count + wd->items_lost - count_group;
if (wd->horizontal) if (wd->horizontal)
{ {
minw = (ceil(count / (float)nmax) * wd->item_width) + (count_group * wd->group_item_width); 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_disable_hook_set(it, _item_disable_hook);
elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook); elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
it->item = ELM_NEW(Elm_Gen_Item_Type); 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")); it->group = it->itc->item_style && (!strcmp(it->itc->item_style, "group_index"));
ELM_GEN_ITEM_SETUP(it); ELM_GEN_ITEM_SETUP(it);

View File

@ -3372,6 +3372,7 @@ _item_new(Widget_Data *wd,
if (!it2->parent->group) depth += 1; if (!it2->parent->group) depth += 1;
} }
it->item->expanded_depth = depth; it->item->expanded_depth = depth;
wd->item_count++;
return it; 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); 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 * EAPI Elm_Object_Item *
elm_genlist_item_append(Evas_Object *obj, elm_genlist_item_append(Evas_Object *obj,
const Elm_Genlist_Item_Class *itc, const Elm_Genlist_Item_Class *itc,
@ -4133,7 +4143,6 @@ _elm_genlist_clear(Evas_Object *obj, Eina_Bool standby)
wd->pan_y = 0; wd->pan_y = 0;
wd->minw = 0; wd->minw = 0;
wd->minh = 0; wd->minh = 0;
wd->count = 0;
if (wd->pan_smart) if (wd->pan_smart)
{ {
evas_object_size_hint_min_set(wd->pan_smart, wd->minw, wd->minh); 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; it->item = NULL;
if (it->wd->last_selected_item == (Elm_Object_Item *) it) if (it->wd->last_selected_item == (Elm_Object_Item *) it)
it->wd->last_selected_item = NULL; it->wd->last_selected_item = NULL;
it->wd->item_count--;
} }

View File

@ -1914,6 +1914,17 @@ EAPI void elm_genlist_item_class_ref(Elm_Genlist_Item_Class *itc);
*/ */
EAPI void elm_genlist_item_class_unref(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);
/** /**
* @} * @}
*/ */