Fix bubble corner and theme hook issues

SVN revision: 54466
This commit is contained in:
Bruno Dilly 2010-11-11 18:04:08 +00:00
parent 1ed3e906c9
commit ed6cd22ddf
2 changed files with 39 additions and 13 deletions

View File

@ -1232,6 +1232,7 @@ extern "C" {
EAPI Evas_Object *elm_bubble_icon_get(const Evas_Object *obj); EAPI Evas_Object *elm_bubble_icon_get(const Evas_Object *obj);
EAPI Evas_Object *elm_bubble_icon_unset(Evas_Object *obj); EAPI Evas_Object *elm_bubble_icon_unset(Evas_Object *obj);
EAPI void elm_bubble_corner_set(Evas_Object *obj, const char *corner); EAPI void elm_bubble_corner_set(Evas_Object *obj, const char *corner);
EAPI const char* elm_bubble_corner_get(const Evas_Object *obj);
/* smart callbacks called: /* smart callbacks called:
*/ */

View File

@ -14,7 +14,7 @@ struct _Widget_Data
{ {
Evas_Object *bbl; Evas_Object *bbl;
Evas_Object *content, *icon; Evas_Object *content, *icon;
const char *label, *info; const char *label, *info, *corner;
}; };
static const char *widtype = NULL; static const char *widtype = NULL;
@ -31,6 +31,7 @@ _del_hook(Evas_Object *obj)
if (!wd) return; if (!wd) return;
if (wd->label) eina_stringshare_del(wd->label); if (wd->label) eina_stringshare_del(wd->label);
if (wd->info) eina_stringshare_del(wd->info); if (wd->info) eina_stringshare_del(wd->info);
if (wd->corner) eina_stringshare_del(wd->corner);
free(wd); free(wd);
} }
@ -39,18 +40,21 @@ _theme_hook(Evas_Object *obj)
{ {
Widget_Data *wd = elm_widget_data_get(obj); Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return; if (!wd) return;
_elm_theme_object_set(obj, wd->bbl, "bubble", "base", elm_widget_style_get(obj)); _elm_theme_object_set(obj, wd->bbl, "bubble", wd->corner,
elm_widget_style_get(obj));
edje_object_part_text_set(wd->bbl, "elm.text", wd->label); edje_object_part_text_set(wd->bbl, "elm.text", wd->label);
edje_object_part_text_set(wd->bbl, "elm.info", wd->info); edje_object_part_text_set(wd->bbl, "elm.info", wd->info);
if (wd->content) if (wd->content)
{ {
edje_object_part_swallow(wd->bbl, "elm.swallow.content", wd->content); edje_object_part_swallow(wd->bbl, "elm.swallow.content", wd->content);
edje_object_signal_emit(wd->bbl, "elm,state,icon,visible", "elm");
edje_object_message_signal_process(wd->bbl); edje_object_message_signal_process(wd->bbl);
} }
if (wd->icon)
edje_object_signal_emit(wd->bbl, "elm,state,icon,visible", "elm");
else else
edje_object_signal_emit(wd->bbl, "elm,state,icon,hidden", "elm"); edje_object_signal_emit(wd->bbl, "elm,state,icon,hidden", "elm");
edje_object_scale_set(wd->bbl, elm_widget_scale_get(obj) * _elm_config->scale); edje_object_scale_set(wd->bbl,
elm_widget_scale_get(obj) * _elm_config->scale);
_sizing_eval(obj); _sizing_eval(obj);
} }
@ -135,6 +139,8 @@ elm_bubble_add(Evas_Object *parent)
elm_widget_focus_next_hook_set(obj, _elm_bubble_focus_next_hook); elm_widget_focus_next_hook_set(obj, _elm_bubble_focus_next_hook);
elm_widget_can_focus_set(obj, EINA_FALSE); elm_widget_can_focus_set(obj, EINA_FALSE);
wd->corner = eina_stringshare_add("base");
wd->bbl = edje_object_add(e); wd->bbl = edje_object_add(e);
_elm_theme_object_set(obj, wd->bbl, "bubble", "base", "default"); _elm_theme_object_set(obj, wd->bbl, "bubble", "base", "default");
elm_widget_resize_object_set(obj, wd->bbl); elm_widget_resize_object_set(obj, wd->bbl);
@ -396,6 +402,11 @@ elm_bubble_icon_unset(Evas_Object *obj)
* @param corner The given corner for the bubble. * @param corner The given corner for the bubble.
* *
* This function sets the corner of the bubble. * This function sets the corner of the bubble.
* The corner will be used to find the group in the theme
* For example, if you set the corner to "bottom_right",
* the following group will be searched:
* "elm/bubble/bottom_right/default",
* considering default style.
* *
* @ingroup Bubble * @ingroup Bubble
*/ */
@ -404,12 +415,26 @@ elm_bubble_corner_set(Evas_Object *obj, const char *corner)
{ {
ELM_CHECK_WIDTYPE(obj, widtype); ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj); Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return; if ((!wd) || (!corner)) return;
_elm_theme_object_set(obj, wd->bbl, "bubble", corner, elm_widget_style_get(obj)); eina_stringshare_replace(&wd->corner, corner);
if (wd->icon) _theme_hook(obj);
edje_object_part_swallow(wd->bbl, "elm.swallow.icon", wd->icon); }
if (wd->content)
edje_object_part_swallow(wd->bbl, "elm.swallow.content", wd->content); /**
// FIXME: fix label etc. * Get the corner of the bubble
_sizing_eval(obj); *
* @param obj The bubble object.
* @return The given corner for the bubble.
*
* This function gets the corner of the bubble.
*
* @ingroup Bubble
*/
EAPI const char*
elm_bubble_corner_get(const Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
return wd->corner;
} }