forked from enlightenment/efl
elementary/segment control - elm_segment_control patch
Hi, Attachment to the mail is elm_segment_control patch. Change Log: 1. Generic Text support to segment items. 2. Generic Content support to segment items. Signed-Off-By: PRINCE KUMAR DUBEY <prince.dubey>@samsung.com> Thank you, Prince SVN revision: 75719
This commit is contained in:
parent
69ad586105
commit
a42b50a495
|
@ -368,27 +368,49 @@ _item_text_set_hook(Elm_Object_Item *it,
|
||||||
const char *label)
|
const char *label)
|
||||||
{
|
{
|
||||||
Elm_Segment_Item *item;
|
Elm_Segment_Item *item;
|
||||||
|
char buf[1024];
|
||||||
if (part && strcmp(part, "default")) return;
|
|
||||||
|
|
||||||
item = (Elm_Segment_Item *)it;
|
item = (Elm_Segment_Item *)it;
|
||||||
eina_stringshare_replace(&item->label, label);
|
|
||||||
if (item->label)
|
|
||||||
edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm");
|
|
||||||
else
|
|
||||||
edje_object_signal_emit(VIEW(item), "elm,state,text,hidden", "elm");
|
|
||||||
edje_object_message_signal_process(VIEW(item));
|
|
||||||
|
|
||||||
|
if ((!part) || (!strcmp(part, "default")) ||
|
||||||
|
(!strcmp(part, "elm.text")))
|
||||||
|
{
|
||||||
|
eina_stringshare_replace(&item->label, label);
|
||||||
|
if (label)
|
||||||
|
edje_object_signal_emit(VIEW(item), "elm,state,text,visible", "elm");
|
||||||
|
else
|
||||||
|
edje_object_signal_emit(VIEW(item), "elm,state,text,hidden", "elm");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (label)
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), "elm,state,%s,visible", part);
|
||||||
|
edje_object_signal_emit(VIEW(item), buf, "elm");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), "elm,state,%s,hidden", part);
|
||||||
|
edje_object_signal_emit(VIEW(item), buf, "elm");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
edje_object_message_signal_process(VIEW(item));
|
||||||
//label can be NULL also.
|
//label can be NULL also.
|
||||||
edje_object_part_text_escaped_set(VIEW(item), "elm.text", item->label);
|
edje_object_part_text_escaped_set(VIEW(item), part, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
_item_text_get_hook(const Elm_Object_Item *it,
|
_item_text_get_hook(const Elm_Object_Item *it,
|
||||||
const char *part)
|
const char *part)
|
||||||
{
|
{
|
||||||
if (part && strcmp(part, "default")) return NULL;
|
char buf[1024];
|
||||||
return ((Elm_Segment_Item *)it)->label;
|
|
||||||
|
if (!part || !strcmp(part, "default"))
|
||||||
|
snprintf(buf, sizeof(buf), "elm.text");
|
||||||
|
else
|
||||||
|
snprintf(buf, sizeof(buf), "%s", part);
|
||||||
|
|
||||||
|
return edje_object_part_text_get(VIEW(it), buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -397,32 +419,51 @@ _item_content_set_hook(Elm_Object_Item *it,
|
||||||
Evas_Object *content)
|
Evas_Object *content)
|
||||||
{
|
{
|
||||||
Elm_Segment_Item *item;
|
Elm_Segment_Item *item;
|
||||||
|
char buf[1024];
|
||||||
if (part && strcmp(part, "icon")) return;
|
|
||||||
|
|
||||||
item = (Elm_Segment_Item *)it;
|
item = (Elm_Segment_Item *)it;
|
||||||
if (content == item->icon) return;
|
|
||||||
|
|
||||||
//Remove the existing icon
|
if (!part || !strcmp("icon", part))
|
||||||
if (item->icon) evas_object_del(item->icon);
|
|
||||||
item->icon = content;
|
|
||||||
if (item->icon)
|
|
||||||
{
|
{
|
||||||
elm_widget_sub_object_add(VIEW(item), item->icon);
|
if (content == item->icon) return;
|
||||||
edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
|
|
||||||
edje_object_signal_emit(VIEW(item), "elm,state,icon,visible", "elm");
|
if (item->icon) evas_object_del(item->icon);
|
||||||
|
item->icon = content;
|
||||||
|
if (!item->icon)
|
||||||
|
{
|
||||||
|
elm_widget_sub_object_add(VIEW(item), item->icon);
|
||||||
|
edje_object_part_swallow(VIEW(item), "elm.swallow.icon", item->icon);
|
||||||
|
edje_object_signal_emit(VIEW(item), "elm,state,icon,visible", "elm");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
edje_object_signal_emit(VIEW(item), "elm,state,icon,hidden", "elm");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
edje_object_signal_emit(VIEW(item), "elm,state,icon,hidden", "elm");
|
{
|
||||||
|
if (content)
|
||||||
|
{
|
||||||
|
edje_object_part_swallow(VIEW(it), part, content);
|
||||||
|
snprintf(buf, sizeof(buf), "elm,state,%s,visible", part);
|
||||||
|
edje_object_signal_emit(VIEW(item), buf, "elm");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), "elm,state,%s,hidden", part);
|
||||||
|
edje_object_signal_emit(VIEW(item), buf, "elm");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static Evas_Object *
|
static Evas_Object *
|
||||||
_item_content_get_hook(const Elm_Object_Item *it,
|
_item_content_get_hook(const Elm_Object_Item *it,
|
||||||
const char *part)
|
const char *part)
|
||||||
{
|
{
|
||||||
if (part && strcmp(part, "icon")) return NULL;
|
Elm_Segment_Item *item;
|
||||||
|
item = (Elm_Segment_Item *)it;
|
||||||
|
|
||||||
return ((Elm_Segment_Item *)it)->icon;
|
if (!part && !strcmp(part, "icon"))
|
||||||
|
return item->icon;
|
||||||
|
else
|
||||||
|
return edje_object_part_swallow_get(VIEW(item), part);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
|
|
Loading…
Reference in New Issue