forked from enlightenment/efl
Elm Segment Control Item: Migrate to Eo
This commit is contained in:
parent
4f67061872
commit
a6d6a7beeb
|
@ -607,7 +607,8 @@ elm_win.eo \
|
|||
elm_widget_item.eo \
|
||||
elm_color_item.eo \
|
||||
elm_dayselector_item.eo \
|
||||
elm_hoversel_item.eo
|
||||
elm_hoversel_item.eo \
|
||||
elm_segment_control_item.eo
|
||||
|
||||
elm_eolian_c = $(elm_eolian_files:%.eo=%.eo.c)
|
||||
elm_eolian_h = $(elm_eolian_files:%.eo=%.eo.h)
|
||||
|
@ -722,7 +723,9 @@ elementaryeolianfiles_DATA = \
|
|||
elm_widget_item.eo \
|
||||
elm_color_item.eo \
|
||||
elm_dayselector_item.eo \
|
||||
elm_hoversel_item.eo
|
||||
elm_hoversel_item.eo \
|
||||
elm_segment_control_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"
|
||||
|
@ -25,11 +26,11 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
|||
EOLIAN static Eina_Bool
|
||||
_elm_segment_control_elm_widget_translate(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *sd)
|
||||
{
|
||||
Elm_Segment_Item *it;
|
||||
Elm_Object_Item *it;
|
||||
Eina_List *l;
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
elm_widget_item_translate(it);
|
||||
eo_do((Eo *)it, elm_wdg_item_translate());
|
||||
|
||||
eo_do_super(obj, MY_CLASS, elm_obj_widget_translate());
|
||||
|
||||
|
@ -61,12 +62,12 @@ _elm_segment_control_elm_layout_sizing_eval(Eo *obj, Elm_Segment_Control_Data *s
|
|||
}
|
||||
|
||||
static void
|
||||
_item_free(Elm_Segment_Item *it)
|
||||
_item_free(Elm_Segment_Control_Item_Data *it)
|
||||
{
|
||||
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
|
||||
|
||||
if (sd->selected_item == it) sd->selected_item = NULL;
|
||||
if (sd->items) sd->items = eina_list_remove(sd->items, it);
|
||||
if (sd->items) sd->items = eina_list_remove(sd->items, EO_OBJ(it));
|
||||
|
||||
evas_object_del(it->icon);
|
||||
eina_stringshare_del(it->label);
|
||||
|
@ -78,7 +79,7 @@ _position_items(Elm_Segment_Control_Data *sd)
|
|||
Eina_List *l;
|
||||
Eina_Bool rtl;
|
||||
int item_count;
|
||||
Elm_Segment_Item *it;
|
||||
Elm_Object_Item *eo_item;
|
||||
int bx, by, bw, bh, pos;
|
||||
ELM_WIDGET_DATA_GET_OR_RETURN(sd->obj, wd);
|
||||
|
||||
|
@ -93,8 +94,9 @@ _position_items(Elm_Segment_Control_Data *sd)
|
|||
if (rtl) pos = bx + bw - sd->item_width;
|
||||
else pos = bx;
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
||||
{
|
||||
ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
|
||||
evas_object_move(VIEW(it), pos, by);
|
||||
evas_object_resize(VIEW(it), sd->item_width, bh);
|
||||
if (rtl) pos -= sd->item_width;
|
||||
|
@ -105,7 +107,7 @@ _position_items(Elm_Segment_Control_Data *sd)
|
|||
}
|
||||
|
||||
static void
|
||||
_swallow_item_objects(Elm_Segment_Item *it)
|
||||
_swallow_item_objects(Elm_Segment_Control_Item_Data *it)
|
||||
{
|
||||
if (!it) return;
|
||||
|
||||
|
@ -134,7 +136,7 @@ _update_list(Elm_Segment_Control_Data *sd)
|
|||
Eina_List *l;
|
||||
Eina_Bool rtl;
|
||||
int item_count;
|
||||
Elm_Segment_Item *it;
|
||||
Elm_Object_Item *eo_it;
|
||||
|
||||
_position_items(sd);
|
||||
|
||||
|
@ -142,7 +144,9 @@ _update_list(Elm_Segment_Control_Data *sd)
|
|||
|
||||
if (item_count == 1)
|
||||
{
|
||||
it = eina_list_nth(sd->items, 0);
|
||||
eo_it = eina_list_nth(sd->items, 0);
|
||||
ELM_SEGMENT_ITEM_DATA_GET(eo_it, it);
|
||||
|
||||
it->seg_index = 0;
|
||||
|
||||
//Set the segment type
|
||||
|
@ -165,8 +169,9 @@ _update_list(Elm_Segment_Control_Data *sd)
|
|||
}
|
||||
|
||||
rtl = elm_widget_mirrored_get(sd->obj);
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_it)
|
||||
{
|
||||
ELM_SEGMENT_ITEM_DATA_GET(eo_it, it);
|
||||
it->seg_index = idx;
|
||||
|
||||
//Set the segment type
|
||||
|
@ -213,7 +218,7 @@ _elm_segment_control_elm_widget_theme_apply(Eo *obj, Elm_Segment_Control_Data *s
|
|||
{
|
||||
Eina_List *l;
|
||||
Eina_Bool rtl;
|
||||
Elm_Segment_Item *it;
|
||||
Elm_Object_Item *eo_item;
|
||||
|
||||
Eina_Bool int_ret = EINA_FALSE;
|
||||
eo_do_super(obj, MY_CLASS, int_ret = elm_obj_widget_theme_apply());
|
||||
|
@ -221,8 +226,9 @@ _elm_segment_control_elm_widget_theme_apply(Eo *obj, Elm_Segment_Control_Data *s
|
|||
|
||||
rtl = elm_widget_mirrored_get(obj);
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
||||
{
|
||||
ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
|
||||
elm_widget_theme_object_set
|
||||
(obj, VIEW(it), "segment_control", "item",
|
||||
elm_widget_style_get(obj));
|
||||
|
@ -255,10 +261,11 @@ _elm_segment_control_elm_widget_disable(Eo *obj, Elm_Segment_Control_Data *sd)
|
|||
static void *
|
||||
_elm_list_data_get(const Eina_List *list)
|
||||
{
|
||||
Elm_Segment_Item *it = eina_list_data_get(list);
|
||||
Elm_Object_Item *eo_item = eina_list_data_get(list);
|
||||
|
||||
if (it) return NULL;
|
||||
if (eo_item) return NULL;
|
||||
|
||||
ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
|
||||
edje_object_signal_emit(VIEW(it), "elm,state,segment,selected", "elm");
|
||||
|
||||
return VIEW(it);
|
||||
|
@ -287,7 +294,7 @@ _elm_segment_control_elm_widget_focus_next(Eo *obj, Elm_Segment_Control_Data *sd
|
|||
#endif
|
||||
|
||||
static void
|
||||
_segment_off(Elm_Segment_Item *it)
|
||||
_segment_off(Elm_Segment_Control_Item_Data *it)
|
||||
{
|
||||
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
|
||||
|
||||
|
@ -297,7 +304,7 @@ _segment_off(Elm_Segment_Item *it)
|
|||
}
|
||||
|
||||
static void
|
||||
_segment_on(Elm_Segment_Item *it)
|
||||
_segment_on(Elm_Segment_Control_Item_Data *it)
|
||||
{
|
||||
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
|
||||
|
||||
|
@ -308,7 +315,7 @@ _segment_on(Elm_Segment_Item *it)
|
|||
edje_object_signal_emit(VIEW(it), "elm,state,segment,selected", "elm");
|
||||
|
||||
sd->selected_item = it;
|
||||
evas_object_smart_callback_call(sd->obj, SIG_CHANGED, it);
|
||||
evas_object_smart_callback_call(sd->obj, SIG_CHANGED, EO_OBJ(it));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -327,7 +334,7 @@ _on_mouse_up(void *data,
|
|||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Elm_Segment_Item *it = data;
|
||||
Elm_Segment_Control_Item_Data *it = data;
|
||||
Evas_Event_Mouse_Up *ev = event_info;
|
||||
Evas_Coord x, y, w, h;
|
||||
|
||||
|
@ -355,7 +362,7 @@ _on_mouse_down(void *data,
|
|||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Elm_Segment_Item *it = data;
|
||||
Elm_Segment_Control_Item_Data *it = data;
|
||||
Evas_Event_Mouse_Down *ev = event_info;
|
||||
|
||||
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
|
||||
|
@ -368,26 +375,26 @@ _on_mouse_down(void *data,
|
|||
edje_object_signal_emit(VIEW(it), "elm,state,segment,pressed", "elm");
|
||||
}
|
||||
|
||||
static Elm_Segment_Item *
|
||||
static Elm_Segment_Control_Item_Data *
|
||||
_item_find(const Evas_Object *obj,
|
||||
int idx)
|
||||
{
|
||||
Elm_Segment_Item *it;
|
||||
Elm_Object_Item *eo_it;
|
||||
|
||||
ELM_SEGMENT_CONTROL_DATA_GET(obj, sd);
|
||||
|
||||
it = eina_list_nth(sd->items, idx);
|
||||
eo_it = eina_list_nth(sd->items, idx);
|
||||
ELM_SEGMENT_ITEM_DATA_GET(eo_it, it);
|
||||
return it;
|
||||
}
|
||||
|
||||
static void
|
||||
_item_text_set_hook(Elm_Object_Item *it,
|
||||
const char *part,
|
||||
const char *label)
|
||||
EOLIAN static void
|
||||
_elm_segment_control_item_elm_widget_item_part_text_set(Eo *eo_item EINA_UNUSED,
|
||||
Elm_Segment_Control_Item_Data *item,
|
||||
const char *part,
|
||||
const char *label)
|
||||
{
|
||||
Elm_Segment_Item *item;
|
||||
char buf[1024];
|
||||
item = (Elm_Segment_Item *)it;
|
||||
|
||||
if ((!part) || (!strcmp(part, "default")) ||
|
||||
(!strcmp(part, "elm.text")))
|
||||
|
@ -417,9 +424,10 @@ _item_text_set_hook(Elm_Object_Item *it,
|
|||
edje_object_part_text_escaped_set(VIEW(item), part, label);
|
||||
}
|
||||
|
||||
static const char *
|
||||
_item_text_get_hook(const Elm_Object_Item *it,
|
||||
const char *part)
|
||||
EOLIAN static const char *
|
||||
_elm_segment_control_item_elm_widget_item_part_text_get(Eo *eo_item EINA_UNUSED,
|
||||
Elm_Segment_Control_Item_Data *it,
|
||||
const char *part)
|
||||
{
|
||||
char buf[1024];
|
||||
|
||||
|
@ -431,14 +439,13 @@ _item_text_get_hook(const Elm_Object_Item *it,
|
|||
return edje_object_part_text_get(VIEW(it), buf);
|
||||
}
|
||||
|
||||
static void
|
||||
_item_content_set_hook(Elm_Object_Item *it,
|
||||
const char *part,
|
||||
Evas_Object *content)
|
||||
EOLIAN static void
|
||||
_elm_segment_control_item_elm_widget_item_part_content_set(Eo *eo_item EINA_UNUSED,
|
||||
Elm_Segment_Control_Item_Data *item,
|
||||
const char *part,
|
||||
Evas_Object *content)
|
||||
{
|
||||
Elm_Segment_Item *item;
|
||||
char buf[1024];
|
||||
item = (Elm_Segment_Item *)it;
|
||||
|
||||
if (!part || !strcmp("icon", part))
|
||||
{
|
||||
|
@ -459,7 +466,7 @@ _item_content_set_hook(Elm_Object_Item *it,
|
|||
{
|
||||
if (content)
|
||||
{
|
||||
edje_object_part_swallow(VIEW(it), part, content);
|
||||
edje_object_part_swallow(VIEW(item), part, content);
|
||||
snprintf(buf, sizeof(buf), "elm,state,%s,visible", part);
|
||||
edje_object_signal_emit(VIEW(item), buf, "elm");
|
||||
}
|
||||
|
@ -471,13 +478,11 @@ _item_content_set_hook(Elm_Object_Item *it,
|
|||
}
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_item_content_get_hook(const Elm_Object_Item *it,
|
||||
const char *part)
|
||||
EOLIAN static Evas_Object *
|
||||
_elm_segment_control_item_elm_widget_item_part_content_get(Eo *eo_item EINA_UNUSED,
|
||||
Elm_Segment_Control_Item_Data *item,
|
||||
const char *part)
|
||||
{
|
||||
Elm_Segment_Item *item;
|
||||
item = (Elm_Segment_Item *)it;
|
||||
|
||||
if (part && !strcmp(part, "icon"))
|
||||
return item->icon;
|
||||
else
|
||||
|
@ -485,10 +490,9 @@ _item_content_get_hook(const Elm_Object_Item *it,
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_item_del_pre_hook(Elm_Object_Item *it)
|
||||
_elm_segment_control_item_elm_widget_item_del_pre(Eo *eo_item EINA_UNUSED, Elm_Segment_Control_Item_Data *item)
|
||||
{
|
||||
Elm_Segment_Item *item = (Elm_Segment_Item *)it;
|
||||
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
|
||||
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(item), sd);
|
||||
|
||||
_item_free(item);
|
||||
_update_list(sd);
|
||||
|
@ -500,7 +504,7 @@ static char *
|
|||
_access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
|
||||
{
|
||||
const char *txt = NULL;
|
||||
Elm_Segment_Item *it = (Elm_Segment_Item *)data;
|
||||
Elm_Segment_Control_Item_Data *it = (Elm_Segment_Control_Item_Data *)data;
|
||||
ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, NULL);
|
||||
|
||||
if (!txt) txt = it->label;
|
||||
|
@ -512,7 +516,7 @@ _access_info_cb(void *data, Evas_Object *obj EINA_UNUSED)
|
|||
static char *
|
||||
_access_state_cb(void *data, Evas_Object *obj EINA_UNUSED)
|
||||
{
|
||||
Elm_Segment_Item *it = (Elm_Segment_Item *)data;
|
||||
Elm_Segment_Control_Item_Data *it = (Elm_Segment_Control_Item_Data *)data;
|
||||
ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, NULL);
|
||||
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
|
||||
ELM_WIDGET_DATA_GET_OR_RETURN(WIDGET(it), wd, NULL);
|
||||
|
@ -526,45 +530,35 @@ _access_state_cb(void *data, Evas_Object *obj EINA_UNUSED)
|
|||
return strdup(E_("State: Unselected"));
|
||||
}
|
||||
|
||||
static void
|
||||
_access_widget_item_register(Elm_Segment_Item *it)
|
||||
static Evas_Object*
|
||||
_elm_segment_control_item_elm_widget_item_access_register(Eo *eo_it EINA_UNUSED,
|
||||
Elm_Segment_Control_Item_Data *it)
|
||||
{
|
||||
Elm_Access_Info *ai;
|
||||
Evas_Object *ret;
|
||||
|
||||
_elm_access_widget_item_register((Elm_Widget_Item_Data *)it);
|
||||
eo_do_super(eo_it, ELM_SEGMENT_CONTROL_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_("Segment Control Item"));
|
||||
_elm_access_callback_set(ai, ELM_ACCESS_INFO, _access_info_cb, it);
|
||||
_elm_access_callback_set(ai, ELM_ACCESS_STATE, _access_state_cb, it);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static Elm_Segment_Item *
|
||||
static Elm_Object_Item *
|
||||
_item_new(Evas_Object *obj,
|
||||
Evas_Object *icon,
|
||||
const char *label)
|
||||
{
|
||||
Elm_Segment_Item *it;
|
||||
Eo *eo_item;
|
||||
|
||||
it = elm_widget_item_new(obj, Elm_Segment_Item);
|
||||
if (!it) return NULL;
|
||||
eo_item = eo_add(ELM_SEGMENT_CONTROL_ITEM_CLASS, obj);
|
||||
if (!eo_item) return NULL;
|
||||
|
||||
elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
|
||||
elm_widget_item_text_set_hook_set(it, _item_text_set_hook);
|
||||
elm_widget_item_text_get_hook_set(it, _item_text_get_hook);
|
||||
elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
|
||||
elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
|
||||
|
||||
VIEW(it) = edje_object_add(evas_object_evas_get(obj));
|
||||
edje_object_scale_set(VIEW(it),elm_widget_scale_get(WIDGET(it)) *
|
||||
elm_config_scale_get());
|
||||
evas_object_smart_member_add(VIEW(it), obj);
|
||||
|
||||
elm_widget_sub_object_add(obj, VIEW(it));
|
||||
elm_widget_theme_object_set
|
||||
(obj, VIEW(it), "segment_control", "item", elm_object_style_get(obj));
|
||||
edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
|
||||
ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
|
||||
|
||||
if (label) eina_stringshare_replace(&it->label, label);
|
||||
if (it->label)
|
||||
|
@ -584,9 +578,29 @@ _item_new(Evas_Object *obj,
|
|||
|
||||
// ACCESS
|
||||
if (_elm_config->access_mode == ELM_ACCESS_MODE_ON)
|
||||
_access_widget_item_register(it);
|
||||
eo_do(eo_item, elm_wdg_item_access_register());
|
||||
|
||||
return it;
|
||||
return (Elm_Object_Item *)eo_item;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_segment_control_item_eo_base_constructor(Eo *obj, Elm_Segment_Control_Item_Data *it)
|
||||
{
|
||||
eo_do_super(obj, ELM_SEGMENT_CONTROL_ITEM_CLASS, eo_constructor());
|
||||
it->base = eo_data_scope_get(obj, ELM_WIDGET_ITEM_CLASS);
|
||||
|
||||
Evas_Object *parent;
|
||||
eo_do (obj, parent = eo_parent_get());
|
||||
|
||||
VIEW(it) = edje_object_add(evas_object_evas_get(parent));
|
||||
edje_object_scale_set(VIEW(it),elm_widget_scale_get(WIDGET(it)) *
|
||||
elm_config_scale_get());
|
||||
evas_object_smart_member_add(VIEW(it), parent);
|
||||
|
||||
elm_widget_sub_object_add(parent, VIEW(it));
|
||||
elm_widget_theme_object_set
|
||||
(parent, VIEW(it), "segment_control", "item", elm_object_style_get(parent));
|
||||
edje_object_mirrored_set(VIEW(it), elm_widget_mirrored_get(WIDGET(it)));
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
|
@ -610,12 +624,13 @@ _elm_segment_control_evas_object_smart_add(Eo *obj, Elm_Segment_Control_Data *_p
|
|||
EOLIAN static void
|
||||
_elm_segment_control_evas_object_smart_del(Eo *obj, Elm_Segment_Control_Data *sd)
|
||||
{
|
||||
Elm_Segment_Item *it;
|
||||
Elm_Object_Item *eo_it;
|
||||
|
||||
EINA_LIST_FREE(sd->items, it)
|
||||
EINA_LIST_FREE(sd->items, eo_it)
|
||||
{
|
||||
ELM_SEGMENT_ITEM_DATA_GET(eo_it, it);
|
||||
_item_free(it);
|
||||
elm_widget_item_free(it);
|
||||
eo_del((Eo *)eo_it);
|
||||
}
|
||||
|
||||
eo_do_super(obj, MY_CLASS, evas_obj_smart_del());
|
||||
|
@ -634,12 +649,15 @@ _elm_segment_control_elm_widget_focus_next(Eo *obj, Elm_Segment_Control_Data *sd
|
|||
{
|
||||
Eina_List *items = NULL;
|
||||
Eina_List *l;
|
||||
Elm_Segment_Item *it;
|
||||
Elm_Object_Item *eo_item;
|
||||
|
||||
ELM_SEGMENT_CONTROL_CHECK(obj) EINA_FALSE;
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
items = eina_list_append(items, it->base.access_obj);
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
||||
{
|
||||
ELM_SEGMENT_ITEM_DATA_GET(eo_item, it);
|
||||
items = eina_list_append(items, it->base->access_obj);
|
||||
}
|
||||
|
||||
return elm_widget_focus_list_next_get
|
||||
(obj, items, eina_list_data_get, dir, next);
|
||||
|
@ -655,13 +673,13 @@ static void
|
|||
_access_obj_process(Elm_Segment_Control_Data *sd, Eina_Bool is_access)
|
||||
{
|
||||
Eina_List *l;
|
||||
Elm_Segment_Item *it;
|
||||
Eo *eo_item;
|
||||
|
||||
EINA_LIST_FOREACH(sd->items, l, it)
|
||||
EINA_LIST_FOREACH(sd->items, l, eo_item)
|
||||
{
|
||||
if (is_access) _access_widget_item_register(it);
|
||||
if (is_access) eo_do(eo_item, elm_wdg_item_access_register());
|
||||
else
|
||||
_elm_access_widget_item_unregister((Elm_Widget_Item_Data *)it);
|
||||
eo_do(eo_item, elm_wdg_item_access_unregister());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -695,53 +713,53 @@ _elm_segment_control_eo_base_constructor(Eo *obj, Elm_Segment_Control_Data *sd)
|
|||
EOLIAN static Elm_Object_Item*
|
||||
_elm_segment_control_item_add(Eo *obj, Elm_Segment_Control_Data *sd, Evas_Object *icon, const char *label)
|
||||
{
|
||||
Elm_Segment_Item *it;
|
||||
Elm_Object_Item *eo_item;
|
||||
|
||||
eo_item = _item_new(obj, icon, label);
|
||||
if (!eo_item) return NULL;
|
||||
|
||||
it = _item_new(obj, icon, label);
|
||||
if (!it) return NULL;
|
||||
|
||||
sd->items = eina_list_append(sd->items, it);
|
||||
sd->items = eina_list_append(sd->items, eo_item);
|
||||
_update_list(sd);
|
||||
|
||||
return (Elm_Object_Item *)it;
|
||||
return (Elm_Object_Item *)eo_item;
|
||||
}
|
||||
|
||||
EOLIAN static Elm_Object_Item*
|
||||
_elm_segment_control_item_insert_at(Eo *obj, Elm_Segment_Control_Data *sd, Evas_Object *icon, const char *label, int idx)
|
||||
{
|
||||
Elm_Segment_Item *it, *it_rel;
|
||||
Elm_Object_Item *eo_item;
|
||||
Elm_Segment_Control_Item_Data *it_rel;
|
||||
|
||||
|
||||
if (idx < 0) idx = 0;
|
||||
|
||||
it = _item_new(obj, icon, label);
|
||||
if (!it) return NULL;
|
||||
eo_item = _item_new(obj, icon, label);
|
||||
if (!eo_item) return NULL;
|
||||
|
||||
it_rel = _item_find(obj, idx);
|
||||
if (it_rel) sd->items = eina_list_prepend_relative(sd->items, it, it_rel);
|
||||
else sd->items = eina_list_append(sd->items, it);
|
||||
if (it_rel) sd->items = eina_list_prepend_relative(sd->items, eo_item, EO_OBJ(it_rel));
|
||||
else sd->items = eina_list_append(sd->items, eo_item);
|
||||
|
||||
_update_list(sd);
|
||||
|
||||
return (Elm_Object_Item *)it;
|
||||
return (Elm_Object_Item *)eo_item;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_segment_control_item_del_at(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx)
|
||||
{
|
||||
Elm_Segment_Item *it;
|
||||
Elm_Segment_Control_Item_Data *it;
|
||||
|
||||
it = _item_find(obj, idx);
|
||||
if (!it) return;
|
||||
|
||||
elm_widget_item_del((Elm_Object_Item *)it);
|
||||
eo_do((Eo *)EO_OBJ(it), elm_wdg_item_del());
|
||||
}
|
||||
|
||||
EOLIAN static const char*
|
||||
_elm_segment_control_item_label_get(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx)
|
||||
{
|
||||
Elm_Segment_Item *it;
|
||||
Elm_Segment_Control_Item_Data *it;
|
||||
|
||||
it = _item_find(obj, idx);
|
||||
if (it) return it->label;
|
||||
|
@ -752,7 +770,7 @@ _elm_segment_control_item_label_get(Eo *obj, Elm_Segment_Control_Data *_pd EINA_
|
|||
EOLIAN static Evas_Object*
|
||||
_elm_segment_control_item_icon_get(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx)
|
||||
{
|
||||
Elm_Segment_Item *it = _item_find(obj, idx);
|
||||
Elm_Segment_Control_Item_Data *it = _item_find(obj, idx);
|
||||
if (it) return it->icon;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -766,25 +784,35 @@ _elm_segment_control_item_count_get(Eo *obj EINA_UNUSED, Elm_Segment_Control_Dat
|
|||
EAPI Evas_Object *
|
||||
elm_segment_control_item_object_get(const Elm_Object_Item *it)
|
||||
{
|
||||
ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, NULL);
|
||||
return eo_do((Eo*)it, elm_obj_segment_control_item_object_get());
|
||||
}
|
||||
|
||||
EOLIAN static Evas_Object *
|
||||
_elm_segment_control_item_object_get(Eo *eo_it EINA_UNUSED, Elm_Segment_Control_Item_Data *it)
|
||||
{
|
||||
return VIEW(it);
|
||||
}
|
||||
|
||||
EOLIAN static Elm_Object_Item*
|
||||
_elm_segment_control_item_selected_get(Eo *obj EINA_UNUSED, Elm_Segment_Control_Data *sd)
|
||||
{
|
||||
return (Elm_Object_Item *)sd->selected_item;
|
||||
return (Elm_Object_Item *)EO_OBJ(sd->selected_item);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
elm_segment_control_item_selected_set(Elm_Object_Item *it,
|
||||
Eina_Bool selected)
|
||||
{
|
||||
Elm_Segment_Item *item = (Elm_Segment_Item *)it;
|
||||
eo_do((Eo*)it, elm_obj_segment_control_item_selected_set(selected));
|
||||
}
|
||||
|
||||
ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it);
|
||||
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(it), sd);
|
||||
EOLIAN static void
|
||||
_elm_segment_control_item_selected_set(Eo *eo_item EINA_UNUSED,
|
||||
Elm_Segment_Control_Item_Data *item,
|
||||
Eina_Bool selected)
|
||||
{
|
||||
ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(item);
|
||||
ELM_SEGMENT_CONTROL_DATA_GET(WIDGET(item), sd);
|
||||
|
||||
if (item == sd->selected_item)
|
||||
{
|
||||
|
@ -801,15 +829,16 @@ elm_segment_control_item_selected_set(Elm_Object_Item *it,
|
|||
EOLIAN static Elm_Object_Item*
|
||||
_elm_segment_control_item_get(Eo *obj, Elm_Segment_Control_Data *_pd EINA_UNUSED, int idx)
|
||||
{
|
||||
return (Elm_Object_Item *)_item_find(obj, idx);
|
||||
Elm_Segment_Control_Item_Data *it = _item_find(obj, idx);
|
||||
return (Elm_Object_Item *)EO_OBJ(it);
|
||||
}
|
||||
|
||||
EAPI int
|
||||
elm_segment_control_item_index_get(const Elm_Object_Item *it)
|
||||
EOLIAN static int
|
||||
_elm_segment_control_item_index_get(Eo *eo_it EINA_UNUSED, Elm_Segment_Control_Item_Data *it)
|
||||
{
|
||||
ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, -1);
|
||||
|
||||
return ((Elm_Segment_Item *)it)->seg_index;
|
||||
return it->seg_index;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
|
@ -821,4 +850,5 @@ _elm_segment_control_class_constructor(Eo_Class *klass)
|
|||
_elm_segment_control_smart_focus_next_enable = EINA_TRUE;
|
||||
}
|
||||
|
||||
#include "elm_segment_control_item.eo.c"
|
||||
#include "elm_segment_control.eo.c"
|
||||
|
|
|
@ -1,49 +1,6 @@
|
|||
/**
|
||||
* Get the index of an item.
|
||||
*
|
||||
* @param it The segment control item.
|
||||
* @return The position of item in segment control widget.
|
||||
*
|
||||
* Index is the position of an item in segment control widget. Its
|
||||
* range is from @c 0 to <tt> count - 1 </tt>.
|
||||
* Count is the number of items, that can be get with
|
||||
* elm_segment_control_item_count_get().
|
||||
*
|
||||
* @ingroup SegmentControl
|
||||
*/
|
||||
EAPI int elm_segment_control_item_index_get(const Elm_Object_Item *it);
|
||||
|
||||
/**
|
||||
* Get the real Evas(Edje) object created to implement the view of a given
|
||||
* segment_control @p item.
|
||||
*
|
||||
* @param it The segment control item.
|
||||
* @return The base Edje object associated with @p it.
|
||||
*
|
||||
* Base object is the @c Evas_Object that represents that item.
|
||||
*
|
||||
* @ingroup SegmentControl
|
||||
*/
|
||||
EAPI Evas_Object *elm_segment_control_item_object_get(const Elm_Object_Item *it);
|
||||
|
||||
/**
|
||||
* Set the selected state of an item.
|
||||
*
|
||||
* @param it The segment control item
|
||||
* @param select 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.
|
||||
* Selected item can be got with function
|
||||
* elm_segment_control_item_selected_get().
|
||||
*
|
||||
* The selected item always will be highlighted on segment control.
|
||||
*
|
||||
* @see elm_segment_control_item_selected_get()
|
||||
*
|
||||
* @ingroup SegmentControl
|
||||
*/
|
||||
EAPI void elm_segment_control_item_selected_set(Elm_Object_Item *it, Eina_Bool select);
|
||||
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
class Elm_Segment_Control_Item(Elm_Widget_Item)
|
||||
{
|
||||
legacy_prefix: null;
|
||||
eo_prefix: elm_obj_segment_control_item;
|
||||
methods {
|
||||
index_get @const {
|
||||
/*@
|
||||
Get the index of an item.
|
||||
|
||||
Index is the position of an item in segment control widget. Its
|
||||
range is from @c 0 to <tt> count - 1 </tt>.
|
||||
Count is the number of items, that can be get with
|
||||
elm_segment_control_item_count_get().
|
||||
|
||||
@return The position of item in segment control widget.
|
||||
|
||||
@ingroup SegmentControl
|
||||
*/
|
||||
return: int;
|
||||
}
|
||||
object_get @const {
|
||||
/*@
|
||||
Get the real Evas(Edje) object created to implement the view of a given
|
||||
segment_control @p item.
|
||||
|
||||
Base object is the @c Evas_Object that represents that item.
|
||||
|
||||
@return The base Edje object associated with @p it.
|
||||
|
||||
@ingroup SegmentControl
|
||||
*/
|
||||
return: Evas_Object*;
|
||||
}
|
||||
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.
|
||||
Selected item can be got with function
|
||||
elm_segment_control_item_selected_get().
|
||||
|
||||
The selected item always will be highlighted on segment control.
|
||||
|
||||
@see elm_segment_control_item_selected_get()
|
||||
|
||||
@ingroup SegmentControl
|
||||
*/
|
||||
params {
|
||||
Eina_Bool select; /* @ The selected state. */
|
||||
}
|
||||
}
|
||||
}
|
||||
implements {
|
||||
Eo.Base.constructor;
|
||||
Elm_Widget_Item.access_register;
|
||||
Elm_Widget_Item.part_text.get;
|
||||
Elm_Widget_Item.part_text.set;
|
||||
Elm_Widget_Item.part_content.get;
|
||||
Elm_Widget_Item.part_content.set;
|
||||
Elm_Widget_Item.del_pre;
|
||||
}
|
||||
}
|
|
@ -2,6 +2,9 @@
|
|||
#define ELM_WIDGET_SEGMENT_CONTROL_H
|
||||
|
||||
#include "Elementary.h"
|
||||
#include "elm_segment_control_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
|
||||
|
@ -24,20 +27,20 @@
|
|||
* Base layout smart data extended with segment control instance data.
|
||||
*/
|
||||
typedef struct _Elm_Segment_Control_Data Elm_Segment_Control_Data;
|
||||
typedef struct _Elm_Segment_Item Elm_Segment_Item;
|
||||
typedef struct _Elm_Segment_Control_Item_Data Elm_Segment_Control_Item_Data;
|
||||
|
||||
struct _Elm_Segment_Control_Data
|
||||
{
|
||||
Evas_Object *obj;
|
||||
Eina_List *items;
|
||||
Elm_Segment_Item *selected_item;
|
||||
Elm_Segment_Control_Item_Data *selected_item;
|
||||
|
||||
int item_width;
|
||||
};
|
||||
|
||||
struct _Elm_Segment_Item
|
||||
struct _Elm_Segment_Control_Item_Data
|
||||
{
|
||||
ELM_WIDGET_ITEM;
|
||||
Elm_Widget_Item_Data *base;
|
||||
|
||||
Evas_Object *icon;
|
||||
const char *label;
|
||||
|
@ -73,12 +76,15 @@ struct _Elm_Segment_Item
|
|||
if (EINA_UNLIKELY(!eo_isa((obj), ELM_SEGMENT_CONTROL_CLASS))) \
|
||||
return
|
||||
|
||||
#define ELM_SEGMENT_CONTROL_ITEM_CHECK(it) \
|
||||
ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item_Data *)it, ); \
|
||||
ELM_SEGMENT_CONTROL_CHECK(it->base.widget);
|
||||
#define ELM_SEGMENT_ITEM_DATA_GET(o, sd) \
|
||||
Elm_Segment_Control_Item_Data *sd = eo_data_scope_get((Eo *)o, ELM_SEGMENT_CONTROL_ITEM_CLASS)
|
||||
|
||||
#define ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, ...) \
|
||||
ELM_WIDGET_ITEM_CHECK_OR_RETURN((Elm_Widget_Item_Data *)it, __VA_ARGS__); \
|
||||
ELM_SEGMENT_CONTROL_CHECK(it->base.widget) __VA_ARGS__;
|
||||
#define ELM_SEGMENT_CONTROL_ITEM_CHECK(it) \
|
||||
if (EINA_UNLIKELY(!eo_isa((it)->base->eo_obj, ELM_SEGMENT_CONTROL_ITEM_CLASS))) \
|
||||
return
|
||||
|
||||
#define ELM_SEGMENT_CONTROL_ITEM_CHECK_OR_RETURN(it, ...) \
|
||||
if (EINA_UNLIKELY(!eo_isa((it)->base->eo_obj, ELM_SEGMENT_CONTROL_ITEM_CLASS))) \
|
||||
return __VA_ARGS__;
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue