forked from enlightenment/efl
Elm Index item: Migrate to Eo
This commit is contained in:
parent
1db002db3a
commit
3db20f53ea
|
@ -612,7 +612,8 @@ elm_segment_control_item.eo \
|
|||
elm_slideshow_item.eo \
|
||||
elm_flipselector_item.eo \
|
||||
elm_menu_item.eo \
|
||||
elm_ctxpopup_item.eo
|
||||
elm_ctxpopup_item.eo \
|
||||
elm_index_item.eo
|
||||
|
||||
elm_eolian_c = $(elm_eolian_files:%.eo=%.eo.c)
|
||||
elm_eolian_h = $(elm_eolian_files:%.eo=%.eo.h)
|
||||
|
@ -732,7 +733,8 @@ elementaryeolianfiles_DATA = \
|
|||
elm_slideshow_item.eo \
|
||||
elm_flipselector_item.eo \
|
||||
elm_menu_item.eo \
|
||||
elm_ctxpopup_item.eo
|
||||
elm_ctxpopup_item.eo \
|
||||
elm_index_item.eo
|
||||
|
||||
EXTRA_DIST += ${elementaryeolianfiles_DATA}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#define ELM_INTERFACE_ATSPI_ACCESSIBLE_PROTECTED
|
||||
|
||||
#define ELM_WIDGET_ITEM_PROTECTED
|
||||
#include <Elementary.h>
|
||||
|
||||
#include "elm_priv.h"
|
||||
|
@ -38,11 +39,11 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
|||
};
|
||||
|
||||
static void
|
||||
_item_free(Elm_Index_Item *it)
|
||||
_item_free(Elm_Index_Item_Data *it)
|
||||
{
|
||||
ELM_INDEX_DATA_GET(WIDGET(it), sd);
|
||||
|
||||
sd->items = eina_list_remove(sd->items, it);
|
||||
sd->items = eina_list_remove(sd->items, EO_OBJ(it));
|
||||
|
||||
if (it->omitted)
|
||||
it->omitted = eina_list_free(it->omitted);
|
||||
|
@ -65,14 +66,15 @@ _index_box_clear(Evas_Object *obj,
|
|||
int level)
|
||||
{
|
||||
Eina_List *l;
|
||||
Elm_Index_Item *it;
|
||||
Elm_Object_Item *eo_item;
|
||||
|
||||
ELM_INDEX_DATA_GET(obj, sd);
|
||||
|
||||
if (!sd->level_active[level]) return;
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
||||
{
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_item, it);
|
||||
if (it->level != level) continue;
|
||||
ELM_SAFE_FREE(VIEW(it), evas_object_del);
|
||||
}
|
||||
|
@ -96,7 +98,7 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
|
|||
{
|
||||
const char *txt = NULL;
|
||||
|
||||
Elm_Index_Item *it = (Elm_Index_Item *)data;
|
||||
Elm_Index_Item_Data *it = (Elm_Index_Item_Data *)data;
|
||||
ELM_INDEX_ITEM_CHECK_OR_RETURN(it, NULL);
|
||||
|
||||
txt = elm_widget_access_info_get(obj);
|
||||
|
@ -106,17 +108,20 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_access_widget_item_register(Elm_Index_Item *it)
|
||||
EOLIAN static Evas_Object*
|
||||
_elm_index_item_elm_widget_item_access_register(Eo *eo_item, Elm_Index_Item_Data *it)
|
||||
{
|
||||
Elm_Access_Info *ai;
|
||||
|
||||
_elm_access_widget_item_register((Elm_Widget_Item_Data *)it);
|
||||
Evas_Object *ret = NULL;
|
||||
eo_do_super(eo_item, ELM_INDEX_ITEM_CLASS, ret = elm_wdg_item_access_register());
|
||||
|
||||
ai = _elm_access_info_get(it->base.access_obj);
|
||||
ai = _elm_access_info_get(it->base->access_obj);
|
||||
|
||||
_elm_access_text_set(ai, ELM_ACCESS_TYPE, E_("Index Item"));
|
||||
_elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, it);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -183,7 +188,8 @@ _index_box_auto_fill(Evas_Object *obj,
|
|||
int i = 0, max_num_of_items = 0, num_of_items = 0, g = 0, skip = 0;
|
||||
Eina_List *l;
|
||||
Eina_Bool rtl;
|
||||
Elm_Index_Item *it, *head = NULL;
|
||||
Elm_Object_Item *eo_item;
|
||||
Elm_Index_Item_Data *head = NULL;
|
||||
Evas_Coord mw, mh, ih;
|
||||
Evas_Object *o;
|
||||
Elm_Index_Omit *om;
|
||||
|
@ -201,8 +207,9 @@ _index_box_auto_fill(Evas_Object *obj,
|
|||
EINA_LIST_FREE(sd->omit, om)
|
||||
free(om);
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
||||
{
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_item, it);
|
||||
if (it->omitted)
|
||||
it->omitted = eina_list_free(it->omitted);
|
||||
if (it->head) it->head = NULL;
|
||||
|
@ -218,8 +225,11 @@ _index_box_auto_fill(Evas_Object *obj,
|
|||
|
||||
evas_object_del(o);
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
if (it->level == level) num_of_items++;
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
||||
{
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_item, it);
|
||||
if (it->level == level) num_of_items++;
|
||||
}
|
||||
|
||||
if (mh != 0)
|
||||
max_num_of_items = ih / mh;
|
||||
|
@ -228,9 +238,10 @@ _index_box_auto_fill(Evas_Object *obj,
|
|||
}
|
||||
|
||||
om = eina_list_nth(sd->omit, g);
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
||||
{
|
||||
const char *stacking;
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_item, it);
|
||||
|
||||
if (it->level != level) continue;
|
||||
|
||||
|
@ -310,7 +321,7 @@ _index_box_auto_fill(Evas_Object *obj,
|
|||
// ACCESS
|
||||
if ((it->level == 0) &&
|
||||
(_elm_config->access_mode == ELM_ACCESS_MODE_ON))
|
||||
_access_widget_item_register(it);
|
||||
eo_do((Eo *)eo_item, elm_wdg_item_access_register());
|
||||
}
|
||||
|
||||
evas_object_smart_calculate(sd->bx[level]);
|
||||
|
@ -321,7 +332,7 @@ EOLIAN static Eina_Bool
|
|||
_elm_index_elm_widget_theme_apply(Eo *obj, Elm_Index_Data *sd)
|
||||
{
|
||||
Evas_Coord minw = 0, minh = 0;
|
||||
Elm_Index_Item *it;
|
||||
Elm_Object_Item *eo_item;
|
||||
|
||||
Eina_Bool int_ret = EINA_FALSE;
|
||||
|
||||
|
@ -385,9 +396,10 @@ _elm_index_elm_widget_theme_apply(Eo *obj, Elm_Index_Data *sd)
|
|||
}
|
||||
else elm_layout_signal_emit(obj, "elm,state,inactive", "elm");
|
||||
|
||||
it = (Elm_Index_Item *)elm_index_selected_item_get(obj, sd->level);
|
||||
if (it)
|
||||
eo_item = elm_index_selected_item_get(obj, sd->level);
|
||||
if (eo_item)
|
||||
{
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_item, it);
|
||||
if (it->head)
|
||||
edje_object_signal_emit(VIEW(it->head), "elm,state,active", "elm");
|
||||
else
|
||||
|
@ -412,51 +424,61 @@ _elm_index_elm_layout_sizing_eval(Eo *obj, Elm_Index_Data *_pd EINA_UNUSED)
|
|||
evas_object_size_hint_max_set(obj, -1, -1);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_item_del_pre_hook(Elm_Object_Item *it)
|
||||
EOLIAN static Eina_Bool
|
||||
_elm_index_item_elm_widget_item_del_pre(Eo *eo_item EINA_UNUSED, Elm_Index_Item_Data *it)
|
||||
{
|
||||
ELM_INDEX_DATA_GET(WIDGET(it), sd);
|
||||
|
||||
_item_free((Elm_Index_Item *)it);
|
||||
_item_free(it);
|
||||
_index_box_clear(WIDGET(it), sd->level);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static Elm_Index_Item *
|
||||
EOLIAN static void
|
||||
_elm_index_item_eo_base_constructor(Eo *obj, Elm_Index_Item_Data *it)
|
||||
{
|
||||
eo_do_super(obj, ELM_INDEX_ITEM_CLASS, eo_constructor());
|
||||
it->base = eo_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS);
|
||||
}
|
||||
|
||||
static Elm_Object_Item *
|
||||
_item_new(Evas_Object *obj,
|
||||
const char *letter,
|
||||
Evas_Smart_Cb func,
|
||||
const void *data)
|
||||
{
|
||||
Elm_Index_Item *it;
|
||||
Eo *eo_item;
|
||||
|
||||
ELM_INDEX_DATA_GET(obj, sd);
|
||||
|
||||
it = elm_widget_item_new(obj, Elm_Index_Item);
|
||||
if (!it) return NULL;
|
||||
eo_item = eo_add (ELM_INDEX_ITEM_CLASS, obj);
|
||||
if (!eo_item) return NULL;
|
||||
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_item, it);
|
||||
|
||||
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->base->data = data;
|
||||
it->level = sd->level;
|
||||
|
||||
return it;
|
||||
return (Elm_Object_Item *)eo_item;
|
||||
}
|
||||
|
||||
static Elm_Index_Item *
|
||||
static Elm_Index_Item_Data *
|
||||
_item_find(Evas_Object *obj,
|
||||
const void *data)
|
||||
{
|
||||
Eina_List *l;
|
||||
Elm_Index_Item *it;
|
||||
Elm_Object_Item *eo_item;
|
||||
|
||||
ELM_INDEX_DATA_GET(obj, sd);
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
if (it->base.data == data) return it;
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
||||
{
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_item, it);
|
||||
if (it->base->data == data) return it;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -480,7 +502,8 @@ _sel_eval(Evas_Object *obj,
|
|||
Evas_Coord evy)
|
||||
{
|
||||
Evas_Coord x, y, w, h, bx, by, bw, bh, xx, yy;
|
||||
Elm_Index_Item *it, *it_closest, *it_last, *om_closest;
|
||||
Elm_Index_Item_Data *it, *it_closest, *it_last, *om_closest;
|
||||
Elm_Object_Item *eo_item;
|
||||
char *label = NULL, *last = NULL;
|
||||
double cdv = 0.5;
|
||||
Evas_Coord dist;
|
||||
|
@ -498,8 +521,9 @@ _sel_eval(Evas_Object *obj,
|
|||
dist = 0x7fffffff;
|
||||
evas_object_geometry_get(sd->bx[i], &bx, &by, &bw, &bh);
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
||||
{
|
||||
it = eo_data_scope_get((Eo *)eo_item, ELM_INDEX_ITEM_CLASS);
|
||||
if (it->level != i) continue;
|
||||
if (it->level != sd->level)
|
||||
{
|
||||
|
@ -621,16 +645,16 @@ _sel_eval(Evas_Object *obj,
|
|||
ret = eina_strbuf_string_steal(buf);
|
||||
eina_strbuf_free(buf);
|
||||
|
||||
_elm_access_highlight_set(it->base.access_obj);
|
||||
_elm_access_highlight_set(it->base->access_obj);
|
||||
_elm_access_say(ret);
|
||||
}
|
||||
|
||||
if (om_closest)
|
||||
evas_object_smart_callback_call
|
||||
(obj, SIG_CHANGED, om_closest);
|
||||
(obj, SIG_CHANGED, EO_OBJ(om_closest));
|
||||
else
|
||||
evas_object_smart_callback_call
|
||||
(obj, SIG_CHANGED, it);
|
||||
(obj, SIG_CHANGED, EO_OBJ(it));
|
||||
ecore_timer_del(sd->delay);
|
||||
sd->delay = ecore_timer_add(sd->delay_change_time,
|
||||
_delay_change_cb, obj);
|
||||
|
@ -711,20 +735,21 @@ _on_mouse_up(void *data,
|
|||
void *event_info)
|
||||
{
|
||||
Evas_Event_Mouse_Up *ev = event_info;
|
||||
Elm_Object_Item *item;
|
||||
Elm_Index_Item *id_item;
|
||||
Elm_Object_Item *eo_item;
|
||||
Elm_Object_Item *eo_id_item;
|
||||
|
||||
ELM_INDEX_DATA_GET(data, sd);
|
||||
|
||||
if (ev->button != 1) return;
|
||||
sd->mouse_down = EINA_FALSE;
|
||||
item = elm_index_selected_item_get(data, sd->level);
|
||||
if (item)
|
||||
eo_item = elm_index_selected_item_get(data, sd->level);
|
||||
if (eo_item)
|
||||
{
|
||||
evas_object_smart_callback_call(data, SIG_SELECTED, item);
|
||||
id_item = (Elm_Index_Item *)item;
|
||||
evas_object_smart_callback_call(data, SIG_SELECTED, eo_item);
|
||||
eo_id_item = eo_item;
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_id_item, id_item);
|
||||
if (id_item->func)
|
||||
id_item->func((void *)id_item->base.data, WIDGET(id_item), id_item);
|
||||
id_item->func((void *)id_item->base->data, WIDGET(id_item), eo_id_item);
|
||||
}
|
||||
if (!sd->autohide_disabled)
|
||||
elm_layout_signal_emit(data, "elm,state,inactive", "elm");
|
||||
|
@ -810,7 +835,8 @@ _on_mouse_move_access(void *data,
|
|||
{
|
||||
|
||||
Evas_Event_Mouse_Down *ev = event_info;
|
||||
Elm_Index_Item *it, *it_closest;
|
||||
Elm_Object_Item *eo_item;
|
||||
Elm_Index_Item_Data *it_closest;
|
||||
Eina_List *l;
|
||||
Evas_Coord dist = 0;
|
||||
Evas_Coord x, y, w, h, xx, yy;
|
||||
|
@ -820,8 +846,9 @@ _on_mouse_move_access(void *data,
|
|||
it_closest = NULL;
|
||||
dist = 0x7fffffff;
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
||||
{
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_item, it);
|
||||
evas_object_geometry_get(VIEW(it), &x, &y, &w, &h);
|
||||
xx = x + (w / 2);
|
||||
yy = y + (h / 2);
|
||||
|
@ -836,7 +863,7 @@ _on_mouse_move_access(void *data,
|
|||
}
|
||||
|
||||
if (it_closest)
|
||||
_elm_access_highlight_set(it_closest->base.access_obj);
|
||||
_elm_access_highlight_set(it_closest->base->access_obj);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -861,14 +888,15 @@ _index_resize_cb(void *data EINA_UNUSED,
|
|||
|
||||
if (!sd->omit_enabled) return;
|
||||
|
||||
Elm_Index_Item *it;
|
||||
Elm_Object_Item *eo_item;
|
||||
|
||||
_index_box_clear(obj, 0);
|
||||
_index_box_auto_fill(obj, 0);
|
||||
|
||||
it = (Elm_Index_Item *)elm_index_selected_item_get(obj, sd->level);
|
||||
if (it)
|
||||
eo_item = elm_index_selected_item_get(obj, sd->level);
|
||||
if (eo_item)
|
||||
{
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_item, it);
|
||||
if (it->head)
|
||||
edje_object_signal_emit(VIEW(it->head), "elm,state,active", "elm");
|
||||
else
|
||||
|
@ -960,7 +988,7 @@ _elm_index_evas_object_smart_del(Eo *obj, Elm_Index_Data *sd)
|
|||
Elm_Index_Omit *o;
|
||||
|
||||
while (sd->items)
|
||||
elm_widget_item_del(sd->items->data);
|
||||
eo_do (sd->items->data, elm_wdg_item_del());
|
||||
|
||||
EINA_LIST_FREE(sd->omit, o)
|
||||
free(o);
|
||||
|
@ -991,7 +1019,7 @@ _elm_index_elm_widget_focus_next(Eo *obj, Elm_Index_Data *sd, Elm_Focus_Directio
|
|||
|
||||
Eina_List *items = NULL;
|
||||
Eina_List *l = NULL;
|
||||
Elm_Index_Item *it;
|
||||
Elm_Object_Item *eo_item;
|
||||
Evas_Object *ao;
|
||||
Evas_Object *po;
|
||||
|
||||
|
@ -1003,10 +1031,11 @@ _elm_index_elm_widget_focus_next(Eo *obj, Elm_Index_Data *sd, Elm_Focus_Directio
|
|||
ao = evas_object_data_get(po, "_part_access_obj");
|
||||
items = eina_list_append(items, ao);
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
||||
{
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_item, it);
|
||||
if (it->level != 0) continue;
|
||||
items = eina_list_append(items, it->base.access_obj);
|
||||
items = eina_list_append(items, it->base->access_obj);
|
||||
}
|
||||
|
||||
int_ret = elm_widget_focus_list_next_get
|
||||
|
@ -1023,15 +1052,16 @@ static void
|
|||
_access_obj_process(Evas_Object *obj, Eina_Bool is_access)
|
||||
{
|
||||
Eina_List *l;
|
||||
Elm_Index_Item *it;
|
||||
Elm_Object_Item *eo_item;
|
||||
|
||||
ELM_INDEX_DATA_GET(obj, sd);
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
||||
{
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_item, it);
|
||||
if (it->level != 0) continue;
|
||||
if (is_access) _access_widget_item_register(it);
|
||||
else _elm_access_widget_item_unregister((Elm_Widget_Item_Data *)it);
|
||||
if (is_access) eo_do((Eo *)eo_item, elm_wdg_item_access_register());
|
||||
else eo_do((Eo *)eo_item, elm_wdg_item_access_unregister());
|
||||
}
|
||||
|
||||
if (is_access)
|
||||
|
@ -1125,25 +1155,33 @@ _elm_index_item_level_get(Eo *obj EINA_UNUSED, Elm_Index_Data *sd)
|
|||
|
||||
//FIXME: Should update indicator based on the autohidden status & indicator visibility
|
||||
EAPI void
|
||||
elm_index_item_selected_set(Elm_Object_Item *it,
|
||||
Eina_Bool selected)
|
||||
elm_index_item_selected_set(Elm_Object_Item *it, Eina_Bool selected)
|
||||
{
|
||||
Elm_Index_Item *it_sel, *it_last, *it_inactive, *it_active;
|
||||
eo_do((Eo*)it, elm_obj_index_item_selected_set(selected));
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_index_item_selected_set(Eo *eo_it,
|
||||
Elm_Index_Item_Data *it,
|
||||
Eina_Bool selected)
|
||||
{
|
||||
Elm_Index_Item_Data *it_sel, *it_inactive, *it_active;
|
||||
Evas_Object *obj = WIDGET(it);
|
||||
|
||||
ELM_INDEX_ITEM_CHECK_OR_RETURN(it);
|
||||
ELM_INDEX_DATA_GET(obj, sd);
|
||||
|
||||
selected = !!selected;
|
||||
it_sel = (Elm_Index_Item *)it;
|
||||
it_sel = it;
|
||||
if (it_sel->selected == selected) return;
|
||||
|
||||
if (selected)
|
||||
{
|
||||
it_last = (Elm_Index_Item *)elm_index_selected_item_get(obj, sd->level);
|
||||
Elm_Object_Item *eo_it_last = elm_index_selected_item_get(obj, sd->level);
|
||||
|
||||
if (it_last)
|
||||
if (eo_it_last)
|
||||
{
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_it_last, it_last);
|
||||
it_last->selected = EINA_FALSE;
|
||||
if (it_last->head)
|
||||
it_inactive = it_last->head;
|
||||
|
@ -1165,9 +1203,9 @@ elm_index_item_selected_set(Elm_Object_Item *it,
|
|||
edje_object_message_signal_process(VIEW(it_active));
|
||||
|
||||
evas_object_smart_callback_call
|
||||
(obj, SIG_CHANGED, it);
|
||||
(obj, SIG_CHANGED, eo_it);
|
||||
evas_object_smart_callback_call
|
||||
(obj, SIG_SELECTED, it);
|
||||
(obj, SIG_SELECTED, eo_it);
|
||||
ecore_timer_del(sd->delay);
|
||||
sd->delay = ecore_timer_add(sd->delay_change_time,
|
||||
_delay_change_cb, obj);
|
||||
|
@ -1192,13 +1230,14 @@ EOLIAN static Elm_Object_Item*
|
|||
_elm_index_selected_item_get(Eo *obj EINA_UNUSED, Elm_Index_Data *sd, int level)
|
||||
{
|
||||
Eina_List *l;
|
||||
Elm_Index_Item *it;
|
||||
Elm_Object_Item *eo_item;
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
||||
{
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_item, it);
|
||||
if ((it->selected) && (it->level == level))
|
||||
{
|
||||
return (Elm_Object_Item *)it;
|
||||
return (Elm_Object_Item *)eo_item;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1208,8 +1247,7 @@ _elm_index_selected_item_get(Eo *obj EINA_UNUSED, Elm_Index_Data *sd, int level)
|
|||
EOLIAN static Elm_Object_Item*
|
||||
_elm_index_item_append(Eo *obj, Elm_Index_Data *sd, const char *letter, Evas_Smart_Cb func, const void *data)
|
||||
{
|
||||
Elm_Index_Item *it;
|
||||
|
||||
Elm_Object_Item *it;
|
||||
|
||||
it = _item_new(obj, letter, func, data);
|
||||
if (!it) return NULL;
|
||||
|
@ -1223,7 +1261,7 @@ _elm_index_item_append(Eo *obj, Elm_Index_Data *sd, const char *letter, Evas_Sma
|
|||
EOLIAN static Elm_Object_Item*
|
||||
_elm_index_item_prepend(Eo *obj, Elm_Index_Data *sd, const char *letter, Evas_Smart_Cb func, const void *data)
|
||||
{
|
||||
Elm_Index_Item *it;
|
||||
Elm_Object_Item *it;
|
||||
|
||||
it = _item_new(obj, letter, func, data);
|
||||
if (!it) return NULL;
|
||||
|
@ -1247,7 +1285,7 @@ elm_index_item_prepend_relative(Evas_Object *obj,
|
|||
EOLIAN static Elm_Object_Item*
|
||||
_elm_index_item_insert_after(Eo *obj, Elm_Index_Data *sd, Elm_Object_Item *after, const char *letter, Evas_Smart_Cb func, const void *data)
|
||||
{
|
||||
Elm_Index_Item *it;
|
||||
Elm_Object_Item *it;
|
||||
|
||||
|
||||
if (!after) return elm_index_item_append(obj, letter, func, data);
|
||||
|
@ -1264,7 +1302,7 @@ _elm_index_item_insert_after(Eo *obj, Elm_Index_Data *sd, Elm_Object_Item *after
|
|||
EOLIAN static Elm_Object_Item*
|
||||
_elm_index_item_insert_before(Eo *obj, Elm_Index_Data *sd, Elm_Object_Item *before, const char *letter, Evas_Smart_Cb func, const void *data)
|
||||
{
|
||||
Elm_Index_Item *it;
|
||||
Elm_Object_Item *it;
|
||||
|
||||
if (!before) return elm_index_item_prepend(obj, letter, func, data);
|
||||
|
||||
|
@ -1280,60 +1318,64 @@ _elm_index_item_insert_before(Eo *obj, Elm_Index_Data *sd, Elm_Object_Item *befo
|
|||
EOLIAN static Elm_Object_Item*
|
||||
_elm_index_item_sorted_insert(Eo *obj, Elm_Index_Data *sd, const char *letter, Evas_Smart_Cb func, const void *data, Eina_Compare_Cb cmp_func, Eina_Compare_Cb cmp_data_func)
|
||||
{
|
||||
Elm_Index_Item *it;
|
||||
Elm_Object_Item *eo_item;
|
||||
Eina_List *lnear;
|
||||
int cmp;
|
||||
|
||||
if (!(sd->items)) return elm_index_item_append(obj, letter, func, data);
|
||||
|
||||
it = _item_new(obj, letter, func, data);
|
||||
if (!it) return NULL;
|
||||
eo_item = _item_new(obj, letter, func, data);
|
||||
if (!eo_item) return NULL;
|
||||
|
||||
lnear = eina_list_search_sorted_near_list(sd->items, cmp_func, it, &cmp);
|
||||
lnear = eina_list_search_sorted_near_list(sd->items, cmp_func, eo_item, &cmp);
|
||||
if (cmp < 0)
|
||||
sd->items = eina_list_append_relative_list(sd->items, it, lnear);
|
||||
sd->items = eina_list_append_relative_list(sd->items, eo_item, lnear);
|
||||
else if (cmp > 0)
|
||||
sd->items = eina_list_prepend_relative_list(sd->items, it, lnear);
|
||||
sd->items = eina_list_prepend_relative_list(sd->items, eo_item, lnear);
|
||||
else
|
||||
{
|
||||
/* If cmp_data_func is not provided, append a duplicated item */
|
||||
if (!cmp_data_func)
|
||||
sd->items = eina_list_append_relative_list(sd->items, it, lnear);
|
||||
sd->items = eina_list_append_relative_list(sd->items, eo_item, lnear);
|
||||
else
|
||||
{
|
||||
Elm_Index_Item *p_it = eina_list_data_get(lnear);
|
||||
if (cmp_data_func(p_it->base.data, it->base.data) >= 0)
|
||||
p_it->base.data = it->base.data;
|
||||
elm_widget_item_del(it);
|
||||
it = NULL;
|
||||
Elm_Object_Item *eo_p_it = eina_list_data_get(lnear);
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_p_it, p_it);
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_item, it);
|
||||
if (cmp_data_func(p_it->base->data, it->base->data) >= 0)
|
||||
p_it->base->data = it->base->data;
|
||||
eo_do((Eo *)eo_item, elm_wdg_item_del());
|
||||
eo_item = NULL;
|
||||
}
|
||||
}
|
||||
_index_box_clear(obj, sd->level);
|
||||
|
||||
if (!it) return NULL;
|
||||
else return (Elm_Object_Item *)it;
|
||||
if (!eo_item) return NULL;
|
||||
else return (Elm_Object_Item *)eo_item;
|
||||
}
|
||||
|
||||
EOLIAN static Elm_Object_Item*
|
||||
_elm_index_item_find(Eo *obj, Elm_Index_Data *_pd EINA_UNUSED, const void *data)
|
||||
{
|
||||
return (Elm_Object_Item *)_item_find(obj, data);
|
||||
Elm_Index_Item_Data *it = _item_find(obj, data);
|
||||
return EO_OBJ(it);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_index_item_clear(Eo *obj, Elm_Index_Data *sd)
|
||||
{
|
||||
Elm_Index_Item *it;
|
||||
Elm_Object_Item *eo_item;
|
||||
Eina_List *l, *clear = NULL;
|
||||
|
||||
_index_box_clear(obj, sd->level);
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
||||
{
|
||||
ELM_INDEX_ITEM_DATA_GET(eo_item, it);
|
||||
if (it->level != sd->level) continue;
|
||||
clear = eina_list_append(clear, it);
|
||||
clear = eina_list_append(clear, eo_item);
|
||||
}
|
||||
EINA_LIST_FREE(clear, it)
|
||||
elm_widget_item_del(it);
|
||||
EINA_LIST_FREE(clear, eo_item)
|
||||
eo_do((Eo *)eo_item, elm_wdg_item_del());
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
|
@ -1371,9 +1413,13 @@ _elm_index_indicator_disabled_get(Eo *obj EINA_UNUSED, Elm_Index_Data *sd)
|
|||
EAPI const char *
|
||||
elm_index_item_letter_get(const Elm_Object_Item *it)
|
||||
{
|
||||
ELM_INDEX_ITEM_CHECK_OR_RETURN(it, NULL);
|
||||
return eo_do((Eo *)it, elm_obj_index_item_letter_get());
|
||||
}
|
||||
|
||||
return ((Elm_Index_Item *)it)->letter;
|
||||
EOLIAN static const char *
|
||||
_elm_index_item_letter_get(Eo *item EINA_UNUSED, Elm_Index_Item_Data *it)
|
||||
{
|
||||
return it->letter;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
|
@ -1434,4 +1480,5 @@ _elm_index_class_constructor(Eo_Class *klass)
|
|||
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
|
||||
}
|
||||
|
||||
#include "elm_index_item.eo.c"
|
||||
#include "elm_index.eo.c"
|
||||
|
|
|
@ -1,21 +1,2 @@
|
|||
/**
|
||||
* Set the selected state of an item.
|
||||
*
|
||||
* @param it The index item
|
||||
* @param selected The selected state
|
||||
*
|
||||
* This sets the selected state of the given item @p it.
|
||||
* @c EINA_TRUE for selected, @c EINA_FALSE for not selected.
|
||||
*
|
||||
* If a new item is selected the previously selected will be unselected.
|
||||
* Previously selected item can be get with function
|
||||
* elm_index_selected_item_get().
|
||||
*
|
||||
* Selected items will be highlighted.
|
||||
*
|
||||
* @see elm_index_selected_item_get()
|
||||
*
|
||||
* @ingroup Index
|
||||
*/
|
||||
EAPI void elm_index_item_selected_set(Elm_Object_Item *it, Eina_Bool selected);
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
class Elm_Index_Item(Elm_Widget_Item)
|
||||
{
|
||||
legacy_prefix: null;
|
||||
eo_prefix: elm_obj_index_item;
|
||||
properties {
|
||||
selected {
|
||||
set {
|
||||
/*@
|
||||
Set the selected state of an item.
|
||||
|
||||
This sets the selected state of the given item @p it.
|
||||
@c EINA_TRUE for selected, @c EINA_FALSE for not selected.
|
||||
|
||||
If a new item is selected the previously selected will be unselected.
|
||||
Previously selected item can be get with function
|
||||
elm_index_selected_item_get().
|
||||
|
||||
Selected items will be highlighted.
|
||||
|
||||
@see elm_index_selected_item_get()
|
||||
|
||||
@ingroup Index
|
||||
*/
|
||||
}
|
||||
values {
|
||||
Eina_Bool selected; /*@ EINA_TRUE if selected EINA_FALSE otherwise */
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
methods {
|
||||
letter_get @const {
|
||||
/*@
|
||||
Get the letter (string) set on a given index widget item.
|
||||
@return The letter string set on @p item
|
||||
|
||||
@ingroup Index
|
||||
*/
|
||||
return: const (char)*;
|
||||
}
|
||||
}
|
||||
implements {
|
||||
Eo.Base.constructor;
|
||||
Elm_Widget_Item.access_register;
|
||||
Elm_Widget_Item.del_pre;
|
||||
}
|
||||
}
|
|
@ -11,14 +11,6 @@
|
|||
*/
|
||||
EAPI Evas_Object *elm_index_add(Evas_Object *parent);
|
||||
|
||||
/**
|
||||
* Get the letter (string) set on a given index widget item.
|
||||
*
|
||||
* @param item The index item handle
|
||||
* @return The letter string set on @p it
|
||||
*
|
||||
* @ingroup Index
|
||||
*/
|
||||
EAPI const char *elm_index_item_letter_get(const Elm_Object_Item *item);
|
||||
|
||||
#include "elm_index.eo.legacy.h"
|
||||
#include "elm_index.eo.legacy.h"
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
#define ELM_WIDGET_INDEX_H
|
||||
|
||||
#include "Elementary.h"
|
||||
#include "elm_index_item.eo.h"
|
||||
|
||||
#include "elm_object_item_migration_temp.h"
|
||||
|
||||
/* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
|
||||
* CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
|
||||
|
@ -48,17 +51,17 @@ struct _Elm_Index_Data
|
|||
Eina_Bool omit_enabled : 1;
|
||||
};
|
||||
|
||||
typedef struct _Elm_Index_Item Elm_Index_Item;
|
||||
struct _Elm_Index_Item
|
||||
typedef struct _Elm_Index_Item_Data Elm_Index_Item_Data;
|
||||
struct _Elm_Index_Item_Data
|
||||
{
|
||||
ELM_WIDGET_ITEM;
|
||||
Elm_Widget_Item_Data *base;
|
||||
|
||||
const char *letter;
|
||||
int level;
|
||||
Evas_Smart_Cb func;
|
||||
|
||||
Eina_List *omitted;
|
||||
Elm_Index_Item *head;
|
||||
Elm_Index_Item_Data *head;
|
||||
|
||||
Eina_Bool selected : 1; /**< a flag that remembers an item is selected. this is set true when mouse down/move occur above an item and when elm_index_item_selected_set() API is called. */
|
||||
};
|
||||
|
@ -99,11 +102,14 @@ struct _Elm_Index_Omit
|
|||
return
|
||||
|
||||
#define ELM_INDEX_ITEM_CHECK(it) \
|
||||
ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item_Data *)it, ); \
|
||||
ELM_INDEX_CHECK(it->base.widget);
|
||||
if (EINA_UNLIKELY(!eo_isa((it->base->eo_obj), ELM_INDEX_ITEM_CLASS))) \
|
||||
return
|
||||
|
||||
#define ELM_INDEX_ITEM_CHECK_OR_RETURN(it, ...) \
|
||||
ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item_Data *)it, __VA_ARGS__); \
|
||||
ELM_INDEX_CHECK(it->base.widget) __VA_ARGS__;
|
||||
if (EINA_UNLIKELY(!eo_isa((it->base->eo_obj), ELM_INDEX_ITEM_CLASS))) \
|
||||
return __VA_ARGS__;
|
||||
|
||||
#define ELM_INDEX_ITEM_DATA_GET(o, sd) \
|
||||
Elm_Index_Item_Data *sd = eo_data_scope_get((Eo *)o, ELM_INDEX_ITEM_CLASS)
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue