elm elm_object: Fixed part content set hooks.

1. delete old content object
 2. check whether new content object is same as old content object
 3. added some doxygen description.

SVN revision: 69743
This commit is contained in:
Daniel Juyung Seo 2012-03-29 11:09:40 +00:00
parent 6733c92556
commit 4801d7f5c1
7 changed files with 22 additions and 24 deletions

View File

@ -774,13 +774,11 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Evas_Coord min_w = -1, min_h = -1;
Widget_Data *wd;
if ((part) && (strcmp(part, "default"))) return;
wd = elm_widget_data_get(obj);
if ((!wd) || (!content)) return;
if (content == wd->content) return;
//TODO: wd->list
if (wd->content) evas_object_del(wd->content);

View File

@ -280,6 +280,7 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
elm_object_part_content_set(wd->btn, part, content);
}

View File

@ -464,12 +464,14 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
if (part && strcmp(part, "video")) return;
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
double pos, length;
Eina_Bool seekable;
if (!_elm_video_check(content)) return;
if (wd->video == content) return;
if (wd->video) evas_object_del(wd->video);
_cleanup_callback(wd);
wd->video = content;
@ -542,6 +544,7 @@ elm_player_add(Evas_Object *parent)
elm_widget_can_focus_set(obj, EINA_TRUE);
elm_widget_event_hook_set(obj, _event_hook);
elm_widget_content_set_hook_set(obj, _content_set_hook);
/* TODO: add content_unset and content_get hook */
wd->layout = edje_object_add(e);
_elm_theme_object_set(obj, wd->layout, "player", "base", "default");

View File

@ -699,11 +699,8 @@ _title_icon_set(Evas_Object *obj, Evas_Object *icon)
if (!wd) return;
if (wd->title_icon == icon) return;
title_visibility_old = (wd->title_text) || (wd->title_icon);
if (wd->title_icon)
{
evas_object_del(wd->title_icon);
wd->title_icon = NULL;
}
if (wd->title_icon) evas_object_del(wd->title_icon);
wd->title_icon = icon;
title_visibility_current = (wd->title_text) || (wd->title_icon);
elm_object_part_content_set(wd->base, "elm.swallow.title.icon",

View File

@ -122,19 +122,16 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd;
if (part && strcmp(part, "overlay")) return;
wd = elm_widget_data_get(obj);
if (!wd) return;
if (wd->overlay)
{
evas_object_del(wd->overlay);
wd->overlay = NULL;
}
if (content == wd->overlay) return;
if (wd->overlay) evas_object_del(wd->overlay);
wd->overlay = content;
if (content)
{
wd->overlay = content;
edje_object_part_swallow(wd->base, "elm.swallow.content", content);
elm_widget_sub_object_add(obj, content);
}

View File

@ -855,6 +855,7 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
{
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *edje;
Evas_Object *prev_content;
if ((!wd) || (!content)) return;
if (wd->scroll)
@ -862,23 +863,20 @@ _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content)
else
edje = wd->ent;
/* Delete the currently swallowed object */
Evas_Object *cswallow;
if (!part || !strcmp(part, "icon"))
{
cswallow = edje_object_part_swallow_get(edje, "elm.swallow.icon");
prev_content = edje_object_part_swallow_get(edje, "elm.swallow.icon");
edje_object_signal_emit(edje, "elm,action,show,icon", "elm");
}
else if (!strcmp(part, "end"))
{
cswallow = edje_object_part_swallow_get(edje, "elm.swallow.end");
prev_content = edje_object_part_swallow_get(edje, "elm.swallow.end");
edje_object_signal_emit(edje, "elm,action,show,end", "elm");
}
else
cswallow = edje_object_part_swallow_get(edje, part);
prev_content = edje_object_part_swallow_get(edje, part);
if (cswallow) evas_object_del(cswallow);
if (prev_content) evas_object_del(prev_content);
evas_event_freeze(evas_object_evas_get(obj));
elm_widget_sub_object_add(obj, content);

View File

@ -35,6 +35,10 @@ EAPI const char *elm_object_part_text_get(const Evas_Object *ob
* @param part The content part name to set (NULL for the default content)
* @param content The new content of the object
*
* This sets a new object to a widget 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 objects may have many contents
*
* @ingroup General