forked from enlightenment/efl
elm elm_object_item: Fixed item part content set hooks.
1. delete old content object 2. check whether new content object is same as old content object 3. rename internal content set hook function 4. elm_widget_sub_object_del will be followed by evas_object_del 5. added some doxygen description. SVN revision: 69738
This commit is contained in:
parent
2101792842
commit
3d15654faa
|
@ -1078,7 +1078,6 @@ _item_icon_set(Elm_Popup_Content_Item *item, Evas_Object *icon)
|
|||
if (item->icon == icon) return;
|
||||
if (item->icon)
|
||||
{
|
||||
elm_widget_sub_object_del(WIDGET(item), item->icon);
|
||||
evas_object_data_del(item->icon, "_popup_content_item");
|
||||
evas_object_del(item->icon);
|
||||
}
|
||||
|
|
|
@ -909,8 +909,7 @@ 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);
|
||||
if (it->icon) evas_object_del(it->icon);
|
||||
it->icon = icon;
|
||||
if (VIEW(it))
|
||||
{
|
||||
|
|
|
@ -3584,8 +3584,13 @@ _item_content_get_hook(Elm_Gen_Item *it, const char *part)
|
|||
static void
|
||||
_item_content_set_hook(Elm_Gen_Item *it, const char *part, Evas_Object *content)
|
||||
{
|
||||
Evas_Object *prev_obj;
|
||||
|
||||
if (content && part)
|
||||
{
|
||||
if (eina_list_data_find(it->content_objs, content)) return;
|
||||
prev_obj = edje_object_part_swallow_get(VIEW(it), part);
|
||||
if (prev_obj) evas_object_del(prev_obj);
|
||||
it->content_objs = eina_list_append(it->content_objs, content);
|
||||
edje_object_part_swallow(VIEW(it), part, content);
|
||||
}
|
||||
|
|
|
@ -1050,7 +1050,7 @@ _item_disable(Elm_Object_Item *it)
|
|||
}
|
||||
|
||||
static void
|
||||
_item_content_set(Elm_Object_Item *it, const char *part, Evas_Object *content)
|
||||
_item_content_set_hook(Elm_Object_Item *it, const char *part, Evas_Object *content)
|
||||
{
|
||||
Elm_List_Item *item = (Elm_List_Item *)it;
|
||||
Evas_Object **icon_p = NULL;
|
||||
|
@ -1092,7 +1092,7 @@ _item_content_set(Elm_Object_Item *it, const char *part, Evas_Object *content)
|
|||
}
|
||||
|
||||
static Evas_Object *
|
||||
_item_content_get(const Elm_Object_Item *it, const char *part)
|
||||
_item_content_get_hook(const Elm_Object_Item *it, const char *part)
|
||||
{
|
||||
Elm_List_Item *item = (Elm_List_Item *)it;
|
||||
|
||||
|
@ -1110,20 +1110,20 @@ _item_content_get(const Elm_Object_Item *it, const char *part)
|
|||
}
|
||||
|
||||
static Evas_Object *
|
||||
_item_content_unset(const Elm_Object_Item *it, const char *part)
|
||||
_item_content_unset_hook(const Elm_Object_Item *it, const char *part)
|
||||
{
|
||||
Elm_List_Item *item = (Elm_List_Item *)it;
|
||||
|
||||
if ((!part) || (!strcmp(part, "start")))
|
||||
{
|
||||
Evas_Object *obj = item->icon;
|
||||
_item_content_set((Elm_Object_Item *)it, part, NULL);
|
||||
_item_content_set_hook((Elm_Object_Item *)it, part, NULL);
|
||||
return obj;
|
||||
}
|
||||
else if (!strcmp(part, "end"))
|
||||
{
|
||||
Evas_Object *obj = item->end;
|
||||
_item_content_set((Elm_Object_Item *)it, part, NULL);
|
||||
_item_content_set_hook((Elm_Object_Item *)it, part, NULL);
|
||||
return obj;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -1214,9 +1214,9 @@ _item_new(Evas_Object *obj, const char *label, Evas_Object *icon, Evas_Object *e
|
|||
_changed_size_hints, obj);
|
||||
}
|
||||
elm_widget_item_disable_hook_set(it, _item_disable);
|
||||
elm_widget_item_content_set_hook_set(it, _item_content_set);
|
||||
elm_widget_item_content_get_hook_set(it, _item_content_get);
|
||||
elm_widget_item_content_unset_hook_set(it, _item_content_unset);
|
||||
elm_widget_item_content_set_hook_set(it, _item_content_set_hook);
|
||||
elm_widget_item_content_get_hook_set(it, _item_content_get_hook);
|
||||
elm_widget_item_content_unset_hook_set(it, _item_content_unset_hook);
|
||||
elm_widget_item_text_set_hook_set(it, _item_text_set);
|
||||
elm_widget_item_text_get_hook_set(it, _item_text_get);
|
||||
elm_widget_item_del_pre_hook_set(it, _item_del_pre_hook);
|
||||
|
|
|
@ -174,21 +174,17 @@ _item_content_set_hook(Elm_Object_Item *it,
|
|||
Evas_Object *content)
|
||||
{
|
||||
Elm_Menu_Item *item;
|
||||
|
||||
if (part && strcmp(part, "default")) return;
|
||||
|
||||
item = (Elm_Menu_Item *)it;
|
||||
if (content == item->content) return;
|
||||
|
||||
if (item->content)
|
||||
{
|
||||
elm_widget_sub_object_del(WIDGET(item), item->content);
|
||||
evas_object_del(item->content);
|
||||
}
|
||||
if (item->content) evas_object_del(item->content);
|
||||
|
||||
item->content = content;
|
||||
|
||||
elm_widget_sub_object_add(WIDGET(item), item->content);
|
||||
edje_object_part_swallow(VIEW(item), "elm.swallow.content", item->content);
|
||||
if (item->content)
|
||||
edje_object_part_swallow(VIEW(item), "elm.swallow.content", item->content);
|
||||
_sizing_eval(WIDGET(item));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,10 @@ EAPI Evas_Object *elm_object_item_widget_get(const Elm_Object_It
|
|||
* @param part The content part name to set (NULL for the default content)
|
||||
* @param content The new content of the object item
|
||||
*
|
||||
* This sets a new object to an item as a content object. If any object was
|
||||
* already set as a content object in the same part, previous object will be
|
||||
* deleted automatically.
|
||||
*
|
||||
* @note Elementary object items may have many contents
|
||||
*
|
||||
* @ingroup General
|
||||
|
|
|
@ -469,18 +469,13 @@ _item_content_set_hook(Elm_Object_Item *it,
|
|||
Evas_Object *content)
|
||||
{
|
||||
Elm_Segment_Item *item;
|
||||
|
||||
if (part && strcmp(part, "icon")) return;
|
||||
|
||||
item = (Elm_Segment_Item *)it;
|
||||
if (content == item->icon) return;
|
||||
|
||||
//Remove the existing icon
|
||||
if (item->icon)
|
||||
{
|
||||
edje_object_part_unswallow(VIEW(item), item->icon);
|
||||
evas_object_del(item->icon);
|
||||
item->icon = NULL;
|
||||
}
|
||||
if (item->icon) evas_object_del(item->icon);
|
||||
item->icon = content;
|
||||
if (item->icon)
|
||||
{
|
||||
|
|
|
@ -425,15 +425,18 @@ _item_content_set_hook(Elm_Object_Item *it,
|
|||
Evas_Object *content)
|
||||
{
|
||||
double scale;
|
||||
|
||||
if (part && strcmp(part, "object")) return;
|
||||
Elm_Toolbar_Item *item = (Elm_Toolbar_Item *) it;
|
||||
Evas_Object *obj = WIDGET(item);
|
||||
Widget_Data *wd = elm_widget_data_get(obj);
|
||||
|
||||
if (!wd || !obj) return;
|
||||
if (item->object == content) return;
|
||||
|
||||
if (item->object) evas_object_del(item->object);
|
||||
|
||||
item->object = content;
|
||||
elm_widget_sub_object_add(obj, item->object);
|
||||
if (item->object)
|
||||
elm_widget_sub_object_add(obj, item->object);
|
||||
scale = (elm_widget_scale_get(obj) * _elm_config->scale);
|
||||
_theme_hook_item(obj, item, scale, wd->icon_size);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue