Ecore_Timer *delay;
Eina_Bool level_active[2];
Eina_Bool horizontal : 1;
- Eina_Bool active : 1;
+ Eina_Bool autohide_disabled : 1;
Eina_Bool down : 1;
+ Eina_Bool indicator_disabled : 1;
};
struct _Elm_Index_Item
ELM_WIDGET_ITEM;
const char *letter;
int level;
+ Evas_Smart_Cb func;
Eina_Bool selected : 1;
};
static const char *widtype = NULL;
+
+static void _del_hook(Evas_Object *obj);
static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl);
static void _theme_hook(Evas_Object *obj);
static void _sizing_eval(Evas_Object *obj);
_del_pre_hook(Evas_Object *obj)
{
Widget_Data *wd = elm_widget_data_get(obj);
+ Elm_Index_Item *it;
if (!wd) return;
_index_box_clear(obj, wd->bx[wd->level], wd->level);
_index_box_clear(obj, wd->bx[0], 0);
- while (wd->items) _item_free(wd->items->data);
+ while (wd->items)
+ {
+ it = wd->items->data;
+ _item_free(it);
+ elm_widget_item_free(it);
+ }
if (wd->delay) ecore_timer_del(wd->delay);
}
edje_object_scale_set(wd->base, elm_widget_scale_get(obj) * _elm_config->scale);
_sizing_eval(obj);
_index_box_auto_fill(obj, wd->bx[0], 0);
- if (wd->active)
- if (wd->level == 1)
- _index_box_auto_fill(obj, wd->bx[1], 1);
+
+ if (wd->autohide_disabled)
+ {
+ if (wd->level == 1) _index_box_auto_fill(obj, wd->bx[1], 1);
+ edje_object_signal_emit(wd->base, "elm,state,active", "elm");
+ }
+ else
+ edje_object_signal_emit(wd->base, "elm,state,inactive", "elm");
}
static void
evas_object_size_hint_max_set(obj, maxw, maxh);
}
+static Eina_Bool
+_item_del_pre_hook(Elm_Object_Item *it)
+{
+ Widget_Data *wd = elm_widget_data_get(WIDGET(it));
+ if (!wd) return EINA_FALSE;
+ _item_free((Elm_Index_Item *)it);
+ _index_box_clear(WIDGET(it), wd->bx[wd->level], wd->level);
+ return EINA_TRUE;
+}
+
static Elm_Index_Item *
-_item_new(Evas_Object *obj, const char *letter, const void *item)
+_item_new(Evas_Object *obj, const char *letter, Evas_Smart_Cb func, const void *data)
{
Widget_Data *wd = elm_widget_data_get(obj);
Elm_Index_Item *it;
if (!wd) return NULL;
it = elm_widget_item_new(obj, Elm_Index_Item);
if (!it) return NULL;
- it->letter = eina_stringshare_add(letter);
- it->base.data = item;
+ elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
+ if (letter) it->letter = eina_stringshare_add(letter);
+ it->func = func;
+ it->base.data = data;
it->level = wd->level;
return it;
}
static Elm_Index_Item *
-_item_find(Evas_Object *obj, const void *item)
+_item_find(Evas_Object *obj, const void *data)
{
Widget_Data *wd = elm_widget_data_get(obj);
Eina_List *l;
Elm_Index_Item *it;
if (!wd) return NULL;
EINA_LIST_FOREACH(wd->items, l, it)
- if (it->base.data == item) return it;
+ if (it->base.data == data) return it;
return NULL;
}
Widget_Data *wd = elm_widget_data_get(WIDGET(it));
if (!wd) return;
wd->items = eina_list_remove(wd->items, it);
- elm_widget_item_pre_notify_del(it);
- eina_stringshare_del(it->letter);
- elm_widget_item_del(it);
+ if (it->letter) eina_stringshare_del(it->letter);
}
// FIXME: always have index filled
const char *stacking;
if (it->level != level) continue;
+
+//FIXME: Need to check. This cause one less items show up.
+// if(i > wd->max_supp_items_count) break;
+
o = edje_object_add(evas_object_evas_get(obj));
VIEW(it) = o;
edje_object_mirrored_set(VIEW(it), rtl);
- if (i & 0x1)
- _elm_theme_object_set(obj, o, "index", "item_odd/vertical", elm_widget_style_get(obj));
+
+ if (wd->horizontal)
+ {
+ if (i & 0x1)
+ _elm_theme_object_set(obj, o, "index", "item_odd/horizontal",
+ elm_widget_style_get(obj));
+ else
+ _elm_theme_object_set(obj, o, "index", "item/horizontal",
+ elm_widget_style_get(obj));
+ }
else
- _elm_theme_object_set(obj, o, "index", "item/vertical", elm_widget_style_get(obj));
- edje_object_part_text_set(o, "elm.text", it->letter);
+ {
+ if (i & 0x1)
+ _elm_theme_object_set(obj, o, "index", "item_odd/vertical",
+ elm_widget_style_get(obj));
+ else
+ _elm_theme_object_set(obj, o, "index", "item/vertical",
+ elm_widget_style_get(obj));
+ }
+
+ edje_object_part_text_escaped_set(o, "elm.text", it->letter);
edje_object_size_min_restricted_calc(o, &mw, &mh, 0, 0);
evas_object_size_hint_min_set(o, mw, mh);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
Elm_Object_Item *item;
if (!wd) return ECORE_CALLBACK_CANCEL;
wd->delay = NULL;
- item = elm_index_item_selected_get(data, wd->level);
+ item = elm_index_selected_item_get(data, wd->level);
if (item) evas_object_smart_callback_call(data, SIG_DELAY_CHANGED, item);
return ECORE_CALLBACK_CANCEL;
}
evas_object_geometry_get(wd->bx[i], &bx, &by, &bw, &bh);
EINA_LIST_FOREACH(wd->items, l, it)
{
- if (!((it->level == i) && (VIEW(it)))) continue;
- if ((VIEW(it)) && (it->level != wd->level))
+ if (it->level != i) continue;
+ if (it->level != wd->level)
{
if (it->selected)
{
dist = x;
}
}
- if ((!i) && (!wd->level))
+ if ((i == 0) && (wd->level == 0))
edje_object_part_drag_value_set(wd->base, "elm.dragable.index.1",
cdv, cdv);
if (it_closest) it_closest->selected = 1;
if (it_closest)
{
it = it_closest;
- if (!last)
+ if (!last && it->letter)
last = strdup(it->letter);
else
{
- if (!label) label = strdup(last);
+ if (!label && last) label = strdup(last);
else
{
- /* FIXME: realloc return NULL if the request fails */
- label = realloc(label, strlen(label) + strlen(last) + 1);
- strcat(label, last);
+ if (label && last)
+ {
+ label = realloc(label, strlen(label) +
+ strlen(last) + 1);
+ if (!label) return;
+ strcat(label, last);
+ }
}
free(last);
- last = strdup(it->letter);
+ if (it->letter) last = strdup(it->letter);
}
}
}
if (!label) label = strdup("");
if (!last) last = strdup("");
- edje_object_part_text_set(wd->base, "elm.text.body", label);
- edje_object_part_text_set(wd->base, "elm.text", last);
+ edje_object_part_text_escaped_set(wd->base, "elm.text.body", label);
+ edje_object_part_text_escaped_set(wd->base, "elm.text", last);
free(label);
free(last);
}
evas_object_geometry_get(wd->base, &x, &y, &w, NULL);
wd->dx = ev->canvas.x - x;
wd->dy = ev->canvas.y - y;
- elm_index_active_set(data, 1);
+ if (!wd->autohide_disabled)
+ {
+ _index_box_clear(data, wd->bx[1], 1);
+ _index_box_auto_fill(data, wd->bx[0], 0);
+ edje_object_signal_emit(wd->base, "elm,state,active", "elm");
+ }
_sel_eval(data, ev->canvas.x, ev->canvas.y);
edje_object_part_drag_value_set(wd->base, "elm.dragable.pointer",
(!edje_object_mirrored_get(wd->base)) ? wd->dx : (wd->dx - w), wd->dy);
- if (wd->items)
- edje_object_signal_emit(wd->base, "elm,indicator,state,active", "elm");
+ if (wd->items && !wd->indicator_disabled)
+ edje_object_signal_emit(wd->base, "elm,indicator,state,active", "elm");
}
static void
Widget_Data *wd = elm_widget_data_get(data);
Evas_Event_Mouse_Up *ev = event_info;
Elm_Object_Item *item;
+ Elm_Index_Item *id_item;
if (!wd) return;
if (ev->button != 1) return;
wd->down = 0;
- item = elm_index_item_selected_get(data, wd->level);
- if (item) evas_object_smart_callback_call(data, SIG_SELECTED, item);
- elm_index_active_set(data, 0);
+ item = elm_index_selected_item_get(data, wd->level);
+ if (item)
+ {
+ evas_object_smart_callback_call(data, SIG_SELECTED, item);
+ id_item = (Elm_Index_Item *)item;
+ if (id_item->func)
+ id_item->func((void *)id_item->base.data, WIDGET(id_item), id_item);
+ }
+ if (!wd->autohide_disabled)
+ edje_object_signal_emit(wd->base, "elm,state,inactive", "elm");
edje_object_signal_emit(wd->base, "elm,state,level,0", "elm");
- edje_object_signal_emit(wd->base, "elm,indicator,state,inactive", "elm");
+ if (wd->items && !wd->indicator_disabled)
+ edje_object_signal_emit(wd->base, "elm,indicator,state,inactive", "elm");
}
static void
elm_widget_signal_callback_del_hook_set(obj, _signal_callback_del_hook);
elm_widget_can_focus_set(obj, EINA_FALSE);
+ wd->indicator_disabled = EINA_FALSE;
wd->horizontal = EINA_FALSE;
+ wd->autohide_disabled = EINA_FALSE;
wd->base = edje_object_add(e);
_elm_theme_object_set(obj, wd->base, "index", "base/vertical", "default");
}
EAPI void
-elm_index_active_set(Evas_Object *obj, Eina_Bool active)
+elm_index_autohide_disabled_set(Evas_Object *obj, Eina_Bool disabled)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
- if (wd->active == active) return;
- wd->active = active;
+ disabled = !!disabled;
+ if (wd->autohide_disabled == disabled) return;
+ wd->autohide_disabled = disabled;
wd->level = 0;
- if (wd->active)
+ if (wd->autohide_disabled)
{
_index_box_clear(obj, wd->bx[1], 1);
_index_box_auto_fill(obj, wd->bx[0], 0);
}
else
edje_object_signal_emit(wd->base, "elm,state,inactive", "elm");
+
+ //FIXME: Should be update indicator based on the indicator visiblility
}
EAPI Eina_Bool
-elm_index_active_get(const Evas_Object *obj)
+elm_index_autohide_disabled_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return EINA_FALSE;
- return wd->active;
+ return wd->autohide_disabled;
}
EAPI void
return wd->level;
}
+EAPI void
+elm_index_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
+{
+ ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
+ Evas_Coord x, y, w, h;
+ Widget_Data *wd = elm_widget_data_get(WIDGET(it));
+ if (!wd) return;
+
+ //FIXME: Should be update indicator based on the autohidden status & indicator visiblility
+
+ if (selected)
+ {
+ evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
+ _sel_eval(WIDGET(it), x + (w/2), y + (h/2));
+ }
+ else
+ _sel_eval(WIDGET(it), -99999, -9999);
+
+}
+
EAPI Elm_Object_Item *
-elm_index_item_selected_get(const Evas_Object *obj, int level)
+elm_index_selected_item_get(const Evas_Object *obj, int level)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
EINA_LIST_FOREACH(wd->items, l, it)
{
if ((it->selected) && (it->level == level))
- return (Elm_Object_Item *) it;
+ return (Elm_Object_Item *)it;
}
return NULL;
}
-EAPI void
-elm_index_item_append(Evas_Object *obj, const char *letter, const void *item)
+EAPI Elm_Object_Item *
+elm_index_item_append(Evas_Object *obj, const char *letter, Evas_Smart_Cb func, const void *data)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Elm_Index_Item *it;
- if (!wd) return;
- it = _item_new(obj, letter, item);
- if (!it) return;
+ if (!wd) return NULL;
+ it = _item_new(obj, letter, func, data);
+ if (!it) return NULL;
wd->items = eina_list_append(wd->items, it);
_index_box_clear(obj, wd->bx[wd->level], wd->level);
+ return (Elm_Object_Item *)it;
}
-EAPI void
-elm_index_item_prepend(Evas_Object *obj, const char *letter, const void *item)
+EAPI Elm_Object_Item *
+elm_index_item_prepend(Evas_Object *obj, const char *letter, Evas_Smart_Cb func, const void *data)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Elm_Index_Item *it;
- if (!wd) return;
- it = _item_new(obj, letter, item);
- if (!it) return;
+ if (!wd) return NULL;
+ it = _item_new(obj, letter, func, data);
+ if (!it) return NULL;
wd->items = eina_list_prepend(wd->items, it);
_index_box_clear(obj, wd->bx[wd->level], wd->level);
+ return (Elm_Object_Item *)it;
}
-EAPI void
-elm_index_item_append_relative(Evas_Object *obj, const char *letter, const void *item, const Elm_Object_Item *relative)
+EINA_DEPRECATED EAPI Elm_Object_Item *
+elm_index_item_prepend_relative(Evas_Object *obj, const char *letter, const void *item, const Elm_Object_Item *relative)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
+ return elm_index_item_insert_before(obj, (Elm_Object_Item *) relative, letter, NULL, item);
+}
+
+EAPI Elm_Object_Item *
+elm_index_item_insert_after(Evas_Object *obj, Elm_Object_Item *after, const char *letter, Evas_Smart_Cb func, const void *data)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Elm_Index_Item *it;
- if (!wd) return;
- if (!relative)
- {
- elm_index_item_append(obj, letter, item);
- return;
- }
- it = _item_new(obj, letter, item);
- if (!it) return;
- wd->items = eina_list_append_relative(wd->items, it, relative);
+ if (!wd) return NULL;
+ if (!after) return elm_index_item_append(obj, letter, func, data);
+ it = _item_new(obj, letter, func, data);
+ if (!it) return NULL;
+ wd->items = eina_list_append_relative(wd->items, it, after);
_index_box_clear(obj, wd->bx[wd->level], wd->level);
+ return (Elm_Object_Item *)it;
}
-EAPI void
-elm_index_item_prepend_relative(Evas_Object *obj, const char *letter, const void *item, const Elm_Object_Item *relative)
+EAPI Elm_Object_Item *
+elm_index_item_insert_before(Evas_Object *obj, Elm_Object_Item *before, const char *letter, Evas_Smart_Cb func, const void *data)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Elm_Index_Item *it;
- if (!wd) return;
- if (!relative)
- {
- elm_index_item_prepend(obj, letter, item);
- return;
- }
- it = _item_new(obj, letter, item);
- if (!it) return;
- wd->items = eina_list_prepend_relative(wd->items, it, relative);
+ if (!wd) return NULL;
+ if (!before) return elm_index_item_prepend(obj, letter, func, data);
+ it = _item_new(obj, letter, func, data);
+ if (!it) return NULL;
+ wd->items = eina_list_prepend_relative(wd->items, it, before);
_index_box_clear(obj, wd->bx[wd->level], wd->level);
+ return (Elm_Object_Item *)it;
}
-EAPI void
-elm_index_item_sorted_insert(Evas_Object *obj, const char *letter, const void *item, Eina_Compare_Cb cmp_func, Eina_Compare_Cb cmp_data_func)
+EAPI Elm_Object_Item *
+elm_index_item_sorted_insert(Evas_Object *obj, const char *letter, Evas_Smart_Cb func, const void *data, Eina_Compare_Cb cmp_func, Eina_Compare_Cb cmp_data_func)
{
- ELM_CHECK_WIDTYPE(obj, widtype);
+ ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Eina_List *lnear;
Elm_Index_Item *it;
int cmp;
- if (!wd) return;
+ if (!wd) return NULL;
if (!(wd->items))
- {
- elm_index_item_append(obj, letter, item);
- return;
- }
+ return elm_index_item_append(obj, letter, func, data);
- it = _item_new(obj, letter, item);
- if (!it) return;
+ it = _item_new(obj, letter, func, data);
+ if (!it) return NULL;
lnear = eina_list_search_sorted_near_list(wd->items, cmp_func, it, &cmp);
if (cmp < 0)
if (cmp_data_func(p_it->base.data, it->base.data) >= 0)
p_it->base.data = it->base.data;
_item_free(it);
+ elm_widget_item_free(it);
}
}
-
- _index_box_clear(obj, wd->bx[wd->level], wd->level);
-}
-
-EAPI void
-elm_index_item_del(Evas_Object *obj, Elm_Object_Item *it)
-{
- ELM_CHECK_WIDTYPE(obj, widtype);
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
- Widget_Data *wd = elm_widget_data_get(obj);
- if (!wd) return;
- _item_free((Elm_Index_Item *) it);
_index_box_clear(obj, wd->bx[wd->level], wd->level);
+ return (Elm_Object_Item *)it;
}
EAPI Elm_Object_Item *
-elm_index_item_find(Evas_Object *obj, const void *item)
+elm_index_item_find(Evas_Object *obj, const void *data)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
- return (Elm_Object_Item *) _item_find(obj, item);
+ return (Elm_Object_Item *) _item_find(obj, data);
}
EAPI void
if (it->level != wd->level) continue;
clear = eina_list_append(clear, it);
}
- EINA_LIST_FREE(clear, it) _item_free(it);
+ EINA_LIST_FREE(clear, it)
+ {
+ _item_free(it);
+ elm_widget_item_free(it);
+ }
}
EAPI void
-elm_index_item_go(Evas_Object *obj, int level __UNUSED__)
+elm_index_level_go(Evas_Object *obj, int level __UNUSED__)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (wd->level == 1) _index_box_auto_fill(obj, wd->bx[1], 1);
}
-EAPI void *
-elm_index_item_data_get(const Elm_Object_Item *it)
-{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
- return elm_widget_item_data_get(it);
-}
-
EAPI void
-elm_index_item_data_set(Elm_Object_Item *it, const void *data)
+elm_index_indicator_disabled_set(Evas_Object *obj, Eina_Bool disabled)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
- elm_widget_item_data_set(it, data);
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+
+ disabled = !!disabled;
+ if (wd->indicator_disabled == disabled) return;
+ wd->indicator_disabled = disabled;
+ if (!wd->items) return;
+ if (disabled)
+ edje_object_signal_emit(wd->base, "elm,indicator,state,inactive", "elm");
+ else
+ edje_object_signal_emit(wd->base, "elm,indicator,state,active", "elm");
}
-EAPI void
-elm_index_item_del_cb_set(Elm_Object_Item *it, Evas_Smart_Cb func)
+EAPI Eina_Bool
+elm_index_indicator_disabled_get(const Evas_Object *obj)
{
- ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
- elm_widget_item_del_cb_set(it, func);
+ ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return EINA_FALSE;
+
+ return wd->indicator_disabled;
}
EAPI const char *
elm_index_item_letter_get(const Elm_Object_Item *it)
{
ELM_OBJ_ITEM_CHECK_OR_RETURN(it, NULL);
- return ((Elm_Index_Item *) it)->letter;
+ return ((Elm_Index_Item *)it)->letter;
+}
+
+EAPI void
+elm_index_horizontal_set(Evas_Object *obj, Eina_Bool horizontal)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype);
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return;
+
+ horizontal = !!horizontal;
+ if (horizontal == wd->horizontal) return;
+ wd->horizontal = horizontal;
+ _theme_hook(obj);
}
+EAPI Eina_Bool
+elm_index_horizontal_get(const Evas_Object *obj)
+{
+ ELM_CHECK_WIDTYPE(obj, widtype) EINA_FALSE;
+ Widget_Data *wd = elm_widget_data_get(obj);
+ if (!wd) return EINA_FALSE;
+ return wd->horizontal;
+}