From: cnook <kimcinoo@gmail.com>
Subject: [E-devel] [Patch] elm_diskselector, set icon to added item If the diskselector is round mode, the scroller of diskselector has additional items for its rounding(carousel) effect. Previously, elm_diskselector_item_icon_set(); did not care about theses additional items. Please review the attached patch that will care. Thanks. SVN revision: 63957
This commit is contained in:
parent
a59721b120
commit
7716a26e4a
|
@ -600,7 +600,7 @@ _move_scroller(void *data)
|
|||
{
|
||||
Evas_Object *obj = data;
|
||||
Widget_Data *wd;
|
||||
Eina_List *l;
|
||||
Eina_List *list, *l;
|
||||
Elm_Diskselector_Item *dit;
|
||||
Evas_Coord y, w, h;
|
||||
int i;
|
||||
|
@ -608,17 +608,26 @@ _move_scroller(void *data)
|
|||
wd = elm_widget_data_get(obj);
|
||||
if (!wd) return EINA_FALSE;
|
||||
|
||||
if (wd->round)
|
||||
i = 1;
|
||||
if (!wd->round)
|
||||
{
|
||||
i = 0;
|
||||
list = wd->items;
|
||||
}
|
||||
else
|
||||
i = 0;
|
||||
{
|
||||
i = 1;
|
||||
list = wd->r_items;
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH(wd->items, l, dit)
|
||||
EINA_LIST_FOREACH(list, l, dit)
|
||||
{
|
||||
if (wd->selected_item == dit)
|
||||
break;
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (wd->round) i -= CEIL(wd->display_item_num);
|
||||
|
||||
if (!dit)
|
||||
{
|
||||
wd->selected_item =
|
||||
|
@ -751,6 +760,73 @@ _round_items_add(Widget_Data *wd)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_item_icon_set(Elm_Diskselector_Item *it, Evas_Object *icon)
|
||||
{
|
||||
if (it->icon == icon) return;
|
||||
if (it->icon)
|
||||
evas_object_del(it->icon);
|
||||
it->icon = icon;
|
||||
if (it->base.view)
|
||||
{
|
||||
evas_object_size_hint_min_set(it->icon, 24, 24);
|
||||
evas_object_size_hint_max_set(it->icon, 40, 40);
|
||||
edje_object_part_swallow(it->base.view, "elm.swallow.icon", it->icon);
|
||||
evas_object_show(it->icon);
|
||||
elm_widget_sub_object_add(it->base.widget, it->icon);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_check_identical_item(Elm_Diskselector_Item *it, Evas_Object *icon)
|
||||
{
|
||||
Widget_Data *wd;
|
||||
Elm_Diskselector_Item *dit;
|
||||
Eina_List *l;
|
||||
int idx = 0;
|
||||
int ic = 0;
|
||||
int ac = 0;
|
||||
|
||||
wd = elm_widget_data_get(it->base.widget);
|
||||
if (!wd) return;
|
||||
|
||||
if (wd->round)
|
||||
{
|
||||
// Get index from indentical item from round items
|
||||
EINA_LIST_FOREACH(wd->r_items, l, dit)
|
||||
{
|
||||
if (it == dit) break;
|
||||
idx++;
|
||||
}
|
||||
|
||||
// No item to match
|
||||
ic = eina_list_count(wd->r_items);
|
||||
if (idx >= ic) return;
|
||||
dit = NULL;
|
||||
|
||||
// Number of added items: CEIL(wd->display_item_num)
|
||||
ac = CEIL(wd->display_item_num);
|
||||
|
||||
if (((idx >= 0) && (idx < ac)) ||
|
||||
((idx >= ac) && (idx < (2 * ac))))
|
||||
{
|
||||
// Selected item: under, low region
|
||||
dit = eina_list_nth(wd->r_items,
|
||||
idx + ic - (2 * ac));
|
||||
}
|
||||
else if (((idx >= (ic - ac)) && (idx < ic)) ||
|
||||
((idx >= (ic - (2 * ac))) && (idx < ic - ac)))
|
||||
{
|
||||
// Selected item: over, high region
|
||||
dit = eina_list_nth(wd->r_items,
|
||||
idx - ic + (2 * ac));
|
||||
}
|
||||
|
||||
if(dit) _item_icon_set(dit, icon);
|
||||
_sizing_eval(wd->self);
|
||||
}
|
||||
}
|
||||
|
||||
EAPI Evas_Object *
|
||||
elm_diskselector_add(Evas_Object *parent)
|
||||
{
|
||||
|
@ -1223,18 +1299,8 @@ EAPI void
|
|||
elm_diskselector_item_icon_set(Elm_Diskselector_Item *it, Evas_Object *icon)
|
||||
{
|
||||
ELM_DISKSELECTOR_ITEM_CHECK_OR_RETURN(it);
|
||||
if (it->icon == icon) return;
|
||||
if (it->icon)
|
||||
evas_object_del(it->icon);
|
||||
it->icon = icon;
|
||||
if (it->base.view)
|
||||
{
|
||||
evas_object_size_hint_min_set(it->icon, 24, 24);
|
||||
evas_object_size_hint_max_set(it->icon, 40, 40);
|
||||
edje_object_part_swallow(it->base.view, "elm.swallow.icon", it->icon);
|
||||
evas_object_show(it->icon);
|
||||
elm_widget_sub_object_add(it->base.widget, it->icon);
|
||||
}
|
||||
_item_icon_set(it, icon);
|
||||
_check_identical_item(it, icon);
|
||||
}
|
||||
|
||||
EAPI Elm_Diskselector_Item *
|
||||
|
|
|
@ -55,6 +55,7 @@ struct _Widget_Data
|
|||
Eina_Bool reorder_mode : 1;
|
||||
Eina_Bool reorder_pan_move : 1;
|
||||
Eina_Bool auto_scroll_enabled : 1;
|
||||
Eina_Bool pan_resized : 1;
|
||||
struct
|
||||
{
|
||||
Evas_Coord x, y;
|
||||
|
@ -2691,11 +2692,18 @@ _pan_resize(Evas_Object *obj,
|
|||
if ((ow == w) && (oh == h)) return;
|
||||
if ((sd->wd->height_for_width) && (ow != w))
|
||||
{
|
||||
/* fix me later */
|
||||
if (sd->resize_job) ecore_job_del(sd->resize_job);
|
||||
sd->resize_job = ecore_job_add(_pan_resize_job, sd);
|
||||
}
|
||||
sd->wd->pan_resized = EINA_TRUE;
|
||||
evas_object_smart_changed(obj);
|
||||
if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
|
||||
sd->wd->calc_job = NULL;
|
||||
/* OLD
|
||||
if (sd->wd->calc_job) ecore_job_del(sd->wd->calc_job);
|
||||
sd->wd->calc_job = ecore_job_add(_calc_job, sd->wd);
|
||||
*/
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2710,6 +2718,13 @@ _pan_calculate(Evas_Object *obj)
|
|||
|
||||
if (!sd) return;
|
||||
evas_event_freeze(evas_object_evas_get(obj));
|
||||
|
||||
if (sd->wd->pan_resized)
|
||||
{
|
||||
_calc_job(sd->wd);
|
||||
sd->wd->pan_resized = EINA_FALSE;
|
||||
}
|
||||
|
||||
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
|
||||
evas_output_viewport_get(evas_object_evas_get(obj), &cvx, &cvy, &cvw, &cvh);
|
||||
EINA_LIST_FOREACH(sd->wd->group_items, l, git)
|
||||
|
|
Loading…
Reference in New Issue