elementary/bg - content_set/get/unset, fixed indentation

SVN revision: 64484
This commit is contained in:
ChunEon Park 2011-10-28 08:31:42 +00:00
parent 6a2e36c5f0
commit 31678440d9
6 changed files with 126 additions and 101 deletions

View File

@ -235,7 +235,7 @@
* @until }
*
* The next callback will be used when setting the overlay (using
* elm_bg_overlay_set()):
* elm_object_content_set()):
*
* @skip _cb_overlay_changed
* @until }
@ -318,14 +318,14 @@
*
* @skipline elm_radio_value_set
*
* Then we add a checkbox for the elm_bg_overlay_set() function:
* Then we add a checkbox for the elm_object_content_set() function for the bg:
*
* @skip check_add
* @until evas_object_show
*
* Now look at the code of the @c _cb_overlay_changed again. If the checkbox
* state is checked, an overlay will be added to the background. It's done by
* creating an Edje object, and setting it with elm_bg_overlay_set() to the
* creating an Edje object, and setting it with elm_object_content_set() to the
* background object. For information about what are and how to set Edje
* object, look at the Edje documentation.
*

View File

@ -26,10 +26,10 @@ _cb_overlay_changed(void *data, Evas_Object *obj, void *event __UNUSED__)
parent = elm_object_parent_widget_get(o_bg);
over = edje_object_add(evas_object_evas_get(parent));
edje_object_file_set(over, buff, "bg_overlay");
elm_bg_overlay_set(o_bg, over);
elm_object_content_set(o_bg, over);
}
else
elm_bg_overlay_set(o_bg, NULL);
elm_object_content_set(o_bg, NULL);
}
static void

View File

@ -38,10 +38,10 @@ _cb_overlay_changed(void *data, Evas_Object *obj, void *event __UNUSED__)
parent = elm_object_parent_widget_get(o_bg);
over = edje_object_add(evas_object_evas_get(parent));
edje_object_file_set(over, buff, "bg_overlay");
elm_bg_overlay_set(o_bg, over);
elm_object_content_set(o_bg, over);
}
else
elm_bg_overlay_set(o_bg, NULL);
elm_object_content_set(o_bg, NULL);
}
static void

View File

@ -4514,6 +4514,10 @@ extern "C" {
* packing into any container object. It works just like an image, but has
* some properties useful to a background, like setting it to tiled,
* centered, scaled or stretched.
*
* Default contents parts of the bg widget that you can use for are:
*
* @li "elm.swallow.content" - overlay of the bg
*
* Here is some sample code using it:
* @li @ref bg_01_example_page
@ -4631,7 +4635,7 @@ extern "C" {
* @ingroup Bg
*/
EAPI void elm_bg_overlay_set(Evas_Object *obj, Evas_Object *overlay) EINA_ARG_NONNULL(1);
EINA_DEPRECATED EAPI void elm_bg_overlay_set(Evas_Object *obj, Evas_Object *overlay) EINA_ARG_NONNULL(1);
/**
* Get the overlay object used for the background object.
@ -4643,7 +4647,7 @@ extern "C" {
*
* @ingroup Bg
*/
EAPI Evas_Object *elm_bg_overlay_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
EINA_DEPRECATED EAPI Evas_Object *elm_bg_overlay_get(const Evas_Object *obj) EINA_ARG_NONNULL(1);
/**
* Get the overlay object used for the background object.
@ -4655,7 +4659,7 @@ extern "C" {
*
* @ingroup Bg
*/
EAPI Evas_Object *elm_bg_overlay_unset(Evas_Object *obj) EINA_ARG_NONNULL(1);
EINA_DEPRECATED EAPI Evas_Object *elm_bg_overlay_unset(Evas_Object *obj) EINA_ARG_NONNULL(1);
/**
* Set the size of the pixmap representation of the image.
@ -6162,13 +6166,13 @@ extern "C" {
*
* Default contents parts of the button widget that you can use for are:
*
* @li "elm.swallow.content" - The icon of the button
* @li "elm.swallow.content" - A icon of the button
*
* Default text parts of the button widget that you can use for are:
*
* @li "elm.text" - The title label of the button
* @li "elm.text" - Title label of the button
*
* Follow through a complete example @ref button_example_01 "here".
* Follow through a complete example @ref button_example_01 "here".
* @{
*/
/**
@ -9735,10 +9739,10 @@ extern "C" {
* Only one object can be added to the @c SWALLOW part (but you still can
* have many @c SWALLOW parts and one object on each of them). Use the @c
* elm_object_content_set/get/unset functions to set, retrieve and unset
* objects as content of the @c SWALLOW. After being set to this part, the
* object size, position, visibility, clipping and other description
* properties will be totally controled by the description of the given part
* (inside the Edje theme file).
* objects as content of the @c SWALLOW. After being set to this part, the
* object size, position, visibility, clipping and other description
* properties will be totally controled by the description of the given part
* (inside the Edje theme file).
*
* One can use @c evas_object_size_hint_* functions on the child to have some
* kind of control over its behavior, but the resulting behavior will still
@ -28145,13 +28149,13 @@ extern "C" {
*
* Default contents parts of the naviframe items that you can use for are:
*
* @li "elm.swallow.content" - The main content of the page
* @li "elm.swallow.prev_btn" - The button to go to the previous page
* @li "elm.swallow.next_btn" - The button to go to the next page
* @li "elm.swallow.content" - A main content of the page
* @li "elm.swallow.prev_btn" - A button to go to the previous page
* @li "elm.swallow.next_btn" - A button to go to the next page
*
* Default text parts of the naviframe items that you can use for are:
*
* @li "elm.text.title" - The title label in the title area
* @li "elm.text.title" - Title label in the title area
*
* @ref tutorial_naviframe gives a good overview of the usage of the API.
*/

View File

@ -10,7 +10,6 @@ struct _Widget_Data
{
Eina_Inlist *stack;
Evas_Object *base;
Evas_Object *rect;
Eina_Bool preserve: 1;
Eina_Bool auto_pushed: 1;
Eina_Bool freeze_events: 1;
@ -88,7 +87,6 @@ static void _resize(void *data,
Evas *e,
Evas_Object *obj,
void *event_info);
static void _hide(void *data, Evas *e, Evas_Object *obj, void *event_info);
static void _title_clicked(void *data, Evas_Object *obj,
const char *emission,
const char *source);
@ -184,8 +182,6 @@ _theme_hook(Evas_Object *obj)
_elm_widget_mirrored_reload(obj);
_mirrored_set(obj, elm_widget_mirrored_get(obj));
evas_object_hide(wd->rect);
}
static void _emit_hook(Evas_Object *obj,
@ -447,13 +443,6 @@ _move(void *data __UNUSED__,
Evas_Object *obj,
void *event_info __UNUSED__)
{
Evas_Coord x, y;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
evas_object_geometry_get(obj, &x, &y, NULL, NULL);
evas_object_move(wd->rect, x, y);
_sizing_eval(obj);
}
@ -463,28 +452,9 @@ _resize(void *data __UNUSED__,
Evas_Object *obj,
void *event_info __UNUSED__)
{
Evas_Coord w, h;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
evas_object_geometry_get(obj, NULL, NULL, &w, &h);
evas_object_resize(wd->rect, w, h);
_sizing_eval(obj);
}
static void
_hide(void *data __UNUSED__,
Evas *e __UNUSED__,
Evas_Object *obj,
void *event_info __UNUSED__)
{
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (wd->freeze_events)
evas_object_hide(wd->rect);
}
static void
_title_clicked(void *data,
Evas_Object *obj __UNUSED__,
@ -740,12 +710,19 @@ _pushed_finished(void *data,
const char *emission __UNUSED__,
const char *source __UNUSED__)
{
Widget_Data *wd;
Elm_Naviframe_Item *it = data;
if (!it) return;
wd = elm_widget_data_get(WIDGET(it));
if (!wd) return;
evas_object_hide(VIEW(it));
evas_object_smart_callback_call(WIDGET(it),
SIG_PUSH_FINISHED,
data);
if (wd->freeze_events)
evas_object_freeze_events_set(VIEW(it), EINA_FALSE);
}
static void
@ -780,7 +757,7 @@ _show_finished(void *data,
SIG_TRANSITION_FINISHED,
data);
if (wd->freeze_events)
evas_object_hide(wd->rect);
evas_object_freeze_events_set(VIEW(it), EINA_FALSE);
}
static void
@ -883,8 +860,10 @@ _item_style_set(Elm_Naviframe_Item *navi_it, const char *item_style)
_item_sizing_eval(navi_it);
wd = elm_widget_data_get(WIDGET(navi_it));
if (wd && wd->freeze_events)
evas_object_hide(wd->rect);
if (!wd) return;
if (wd->freeze_events)
evas_object_freeze_events_set(VIEW(navi_it), EINA_FALSE);
}
EAPI Evas_Object *
@ -910,14 +889,8 @@ elm_naviframe_add(Evas_Object *parent)
elm_widget_resize_object_set(obj, wd->base);
_elm_theme_object_set(obj, wd->base, "naviframe", "base", "default");
//rect
wd->rect = evas_object_rectangle_add(e);
evas_object_color_set(wd->rect, 0, 0, 0, 0);
elm_widget_sub_object_add(obj, wd->rect);
evas_object_event_callback_add(obj, EVAS_CALLBACK_MOVE, _move, obj);
evas_object_event_callback_add(obj, EVAS_CALLBACK_RESIZE, _resize, obj);
evas_object_event_callback_add(obj, EVAS_CALLBACK_HIDE, _hide, obj);
evas_object_smart_callbacks_descriptions_set(obj, _signals);
wd->auto_pushed = EINA_TRUE;
@ -1002,7 +975,10 @@ elm_naviframe_item_push(Evas_Object *obj,
if (prev_it)
{
if (wd->freeze_events)
evas_object_show(wd->rect);
{
evas_object_freeze_events_set(VIEW(it), EINA_TRUE);
evas_object_freeze_events_set(VIEW(prev_it), EINA_TRUE);
}
edje_object_signal_emit(VIEW(prev_it),
"elm,state,cur,pushed",
"elm");
@ -1039,7 +1015,10 @@ elm_naviframe_item_pop(Evas_Object *obj)
if (prev_it)
{
if (wd->freeze_events)
evas_object_show(wd->rect);
{
evas_object_freeze_events_set(VIEW(it), EINA_TRUE);
evas_object_freeze_events_set(VIEW(prev_it), EINA_TRUE);
}
edje_object_signal_emit(it->base.view, "elm,state,cur,popped", "elm");
evas_object_show(VIEW(prev_it));
evas_object_raise(VIEW(prev_it));
@ -1057,10 +1036,14 @@ EAPI void
elm_naviframe_item_pop_to(Elm_Object_Item *it)
{
ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
Elm_Naviframe_Item *navi_it = (Elm_Naviframe_Item *) it;
Widget_Data *wd = elm_widget_data_get(WIDGET(navi_it));
Elm_Naviframe_Item *navi_it;
Widget_Data *wd;
Eina_Inlist *l, *prev_l;
navi_it = (Elm_Naviframe_Item *) it;
wd = elm_widget_data_get(WIDGET(navi_it));
if (!wd) return;
if (it == elm_naviframe_top_item_get(WIDGET(navi_it))) return;
l = wd->stack->last->prev;
@ -1081,15 +1064,23 @@ EAPI void
elm_naviframe_item_promote(Elm_Object_Item *it)
{
ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
Elm_Naviframe_Item *navi_it = (Elm_Naviframe_Item *) it;
Elm_Naviframe_Item *prev_it = NULL;
Widget_Data *wd = elm_widget_data_get(navi_it->base.widget);
Elm_Naviframe_Item *navi_it;
Elm_Naviframe_Item *prev_it;
Widget_Data *wd;
navi_it = (Elm_Naviframe_Item *) it;
wd = elm_widget_data_get(navi_it->base.widget);
if (!wd) return;
if (it == elm_naviframe_top_item_get(navi_it->base.widget)) return;
wd->stack = eina_inlist_demote(wd->stack, EINA_INLIST_GET(navi_it));
prev_it = EINA_INLIST_CONTAINER_GET(wd->stack->last->prev,
Elm_Naviframe_Item);
if (wd->freeze_events)
evas_object_show(wd->rect);
{
evas_object_freeze_events_set(VIEW(it), EINA_TRUE);
evas_object_freeze_events_set(VIEW(prev_it), EINA_TRUE);
}
edje_object_signal_emit(prev_it->base.view,
"elm,state,cur,pushed",
"elm");
@ -1105,8 +1096,13 @@ EAPI void
elm_naviframe_item_del(Elm_Object_Item *it)
{
ELM_OBJ_ITEM_CHECK_OR_RETURN(it);
Elm_Naviframe_Item *navi_it =(Elm_Naviframe_Item *) it;
Widget_Data *wd = elm_widget_data_get(WIDGET(navi_it));
Elm_Naviframe_Item *navi_it;
Widget_Data *wd;
navi_it =(Elm_Naviframe_Item *) it;
wd = elm_widget_data_get(WIDGET(navi_it));
if (!wd) return;
if (it == elm_naviframe_top_item_get(WIDGET(navi_it)))
{
wd->stack = eina_inlist_remove(wd->stack, EINA_INLIST_GET(navi_it));

View File

@ -18,6 +18,9 @@ static const char *widtype = NULL;
static void _del_hook(Evas_Object *obj);
static void _theme_hook(Evas_Object *obj);
static void _custom_resize(void *data, Evas *a, Evas_Object *obj, void *event_info);
static void _content_set_hook(Evas_Object *obj, const char *part, Evas_Object *content);
static Evas_Object *_content_get_hook(const Evas_Object *obj, const char *part);
static Evas_Object *_content_unset_hook(Evas_Object *obj, const char *part);
static void
_del_hook(Evas_Object *obj)
@ -113,6 +116,52 @@ _custom_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void
evas_object_size_hint_max_set(wd->img, mw, mh);
}
static void
_content_set_hook(Evas_Object *obj, const char *part __UNUSED__, Evas_Object *content)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (wd->overlay)
{
evas_object_del(wd->overlay);
wd->overlay = NULL;
}
if (content)
{
wd->overlay = content;
edje_object_part_swallow(wd->base, "elm.swallow.content", content);
elm_widget_sub_object_add(obj, content);
}
_custom_resize(wd, NULL, NULL, NULL);
}
static Evas_Object *
_content_get_hook(const Evas_Object *obj, const char *part __UNUSED__)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return NULL;
return wd->overlay;
}
static Evas_Object *
_content_unset_hook(Evas_Object *obj, const char *part __UNUSED__)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *overlay;
if (!wd) return NULL;
if (!wd->overlay) return NULL;
overlay = wd->overlay;
elm_widget_sub_object_del(obj, wd->overlay);
edje_object_part_unswallow(wd->base, wd->overlay);
wd->overlay = NULL;
_custom_resize(wd, NULL, NULL, NULL);
return overlay;
}
EAPI Evas_Object *
elm_bg_add(Evas_Object *parent)
{
@ -128,6 +177,10 @@ elm_bg_add(Evas_Object *parent)
elm_widget_data_set(obj, wd);
elm_widget_del_hook_set(obj, _del_hook);
elm_widget_theme_hook_set(obj, _theme_hook);
elm_widget_content_set_hook_set(obj, _content_set_hook);
elm_widget_content_get_hook_set(obj, _content_get_hook);
elm_widget_content_unset_hook_set(obj, _content_unset_hook);
elm_widget_can_focus_set(obj, EINA_FALSE);
wd->base = edje_object_add(e);
@ -241,47 +294,19 @@ elm_bg_color_get(const Evas_Object *obj, int *r, int *g, int *b)
EAPI void
elm_bg_overlay_set(Evas_Object *obj, Evas_Object *overlay)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (wd->overlay)
{
evas_object_del(wd->overlay);
wd->overlay = NULL;
}
if (overlay)
{
wd->overlay = overlay;
edje_object_part_swallow(wd->base, "elm.swallow.content", wd->overlay);
elm_widget_sub_object_add(obj, wd->overlay);
}
_custom_resize(wd, NULL, NULL, NULL);
_content_set_hook(obj, NULL, overlay);
}
EAPI Evas_Object *
elm_bg_overlay_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->overlay;
return _content_get_hook(obj, NULL);
}
EAPI Evas_Object *
elm_bg_overlay_unset(Evas_Object *obj)
{
ELM_CHECK_WIDTYPE(obj, widtype) NULL;
Widget_Data *wd = elm_widget_data_get(obj);
Evas_Object *overlay;
if (!wd) return NULL;
if (!wd->overlay) return NULL;
overlay = wd->overlay;
elm_widget_sub_object_del(obj, wd->overlay);
edje_object_part_unswallow(wd->base, wd->overlay);
wd->overlay = NULL;
_custom_resize(wd, NULL, NULL, NULL);
return overlay;
return _content_unset_hook(obj, NULL);
}
EAPI void