diff --git a/legacy/emotion/src/examples/emotion_border_example.c b/legacy/emotion/src/examples/emotion_border_example.c index dc562b4daf..f83790a7d7 100644 --- a/legacy/emotion/src/examples/emotion_border_example.c +++ b/legacy/emotion/src/examples/emotion_border_example.c @@ -122,7 +122,8 @@ _canvas_resize_cb(Ecore_Evas *ee) em = ecore_evas_data_get(ee, "emotion"); evas_object_resize(bg, w, h); - evas_object_resize(em, w, h); + evas_object_move(em, 10, 10); + evas_object_resize(em, w - 20, h - 20); } int @@ -175,9 +176,11 @@ main(int argc, const char *argv[]) /* Creating the emotion object */ em = _create_emotion_object(e); emotion_object_file_set(em, eina_list_data_get(curfile)); - evas_object_move(em, 0, 0); + evas_object_move(em, 10, 10); evas_object_resize(em, WIDTH, HEIGHT); - emotion_object_border_set(em, -30, -30, -30, -30); + evas_object_resize(em, WIDTH - 20, HEIGHT - 20); + emotion_object_border_set(em, 0, 0, 50, 50); + emotion_object_bg_color_set(em, 0, 128, 0, 255); evas_object_show(em); ecore_evas_data_set(ee, "emotion", em); diff --git a/legacy/emotion/src/lib/Emotion.h b/legacy/emotion/src/lib/Emotion.h index af74eb84f5..ba2f15c955 100644 --- a/legacy/emotion/src/lib/Emotion.h +++ b/legacy/emotion/src/lib/Emotion.h @@ -395,11 +395,11 @@ EAPI Eina_Bool emotion_object_init (Evas_Object *obj, const * that respective side of the video will be cropped. * * It's possible to set a color for the added borders (default is transparent) - * with emotion_object_border_color_set(). By default, an Emotion object doesn't + * with emotion_object_bg_color_set(). By default, an Emotion object doesn't * have any border. * * @see emotion_object_border_get() - * @see emotion_object_border_color_set() + * @see emotion_object_bg_color_set() */ EAPI void emotion_object_border_set(Evas_Object *obj, int l, int r, int t, int b); @@ -416,6 +416,38 @@ EAPI void emotion_object_border_set(Evas_Object *obj, int l, int r, int t, int b */ EAPI void emotion_object_border_get(const Evas_Object *obj, int *l, int *r, int *t, int *b); +/** + * @brief Set a color for the background rectangle of this emotion object. + * + * @param obj The emotion object where the background color is being set. + * @param r Red component of the color. + * @param g Green component of the color. + * @param b Blue component of the color. + * @param a Alpha channel of the color. + * + * This is useful when a border is added to any side of the Emotion object. The + * area between the edge of the video and the edge of the object will be filled + * with the specified color. + * + * The default color is 0, 0, 0, 0 (transparent). + * + * @see emotion_object_bg_color_get() + */ +EAPI void emotion_object_bg_color_set(Evas_Object *obj, int r, int g, int b, int a); + +/** + * @brief Get the background color set for the emotion object. + * + * @param obj The emotion object from which the background color is being retrieved. + * @param r Red component of the color. + * @param g Green component of the color. + * @param b Blue component of the color. + * @param a AAlpha channel of the color. + * + * @see emotion_object_bg_color_set() + */ +EAPI void emotion_object_bg_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a); + /** * @brief Set the file to be played in the Emotion object. * diff --git a/legacy/emotion/src/lib/emotion_smart.c b/legacy/emotion/src/lib/emotion_smart.c index 59ffb2a0a4..f9882b096c 100644 --- a/legacy/emotion/src/lib/emotion_smart.c +++ b/legacy/emotion/src/lib/emotion_smart.c @@ -55,6 +55,7 @@ struct _Smart_Data const char *file; Evas_Object *obj; + Evas_Object *bg; Ecore_Job *job; @@ -492,7 +493,7 @@ emotion_object_border_set(Evas_Object *obj, int l, int r, int t, int b) } EAPI void -emotion_object_border_get(Evas_Object *obj, int *l, int *r, int *t, int *b) +emotion_object_border_get(const Evas_Object *obj, int *l, int *r, int *t, int *b) { Smart_Data *sd; @@ -503,6 +504,33 @@ emotion_object_border_get(Evas_Object *obj, int *l, int *r, int *t, int *b) *b = -sd->crop.b; } +EAPI void +emotion_object_bg_color_set(Evas_Object *obj, int r, int g, int b, int a) +{ + Smart_Data *sd; + + E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME); + + evas_object_color_set(sd->bg, r, g, b, a); + + if (!evas_object_visible_get(obj)) + return; + + if (a > 0) + evas_object_show(sd->bg); + else + evas_object_hide(sd->bg); +} + +EAPI void +emotion_object_bg_color_get(const Evas_Object *obj, int *r, int *g, int *b, int *a) +{ + Smart_Data *sd; + + E_SMART_OBJ_GET(sd, obj, E_OBJ_NAME); + evas_object_color_get(sd->bg, r, g, b, a); +} + EAPI void emotion_object_play_set(Evas_Object *obj, Eina_Bool play) { @@ -1679,10 +1707,14 @@ _smart_add(Evas_Object * obj) EINA_REFCOUNT_INIT(sd); sd->state = EMOTION_WAKEUP; sd->obj = evas_object_image_add(evas_object_evas_get(obj)); + sd->bg = evas_object_rectangle_add(evas_object_evas_get(obj)); + evas_object_color_set(sd->bg, 0, 0, 0, 0); evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_MOUSE_MOVE, _mouse_move, sd); evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, sd); evas_object_image_pixels_get_callback_set(sd->obj, _pixels_get, sd); evas_object_smart_member_add(sd->obj, obj); + evas_object_smart_member_add(sd->bg, obj); + evas_object_lower(sd->bg); sd->ratio = 1.0; sd->spu.button = -1; evas_object_image_alpha_set(sd->obj, 0); @@ -1719,6 +1751,7 @@ _smart_move(Evas_Object * obj, Evas_Coord x, Evas_Coord y) int vid_w, vid_h, w, h; sd->module->video_data_size_get(sd->video, &vid_w, &vid_h); _clipper_position_size_update(obj, vid_w, vid_h); + evas_object_move(sd->bg, x, y); } static void @@ -1733,18 +1766,24 @@ _smart_resize(Evas_Object * obj, Evas_Coord w, Evas_Coord h) sd->module->video_data_size_get(sd->video, &vid_w, &vid_h); _clipper_position_size_update(obj, vid_w, vid_h); + evas_object_resize(sd->bg, w, h); } static void _smart_show(Evas_Object * obj) { Smart_Data *sd; + int a; sd = evas_object_smart_data_get(obj); if (!sd) return; evas_object_show(sd->obj); if (sd->crop.clipper) evas_object_show(sd->crop.clipper); + + evas_object_color_get(sd->bg, NULL, NULL, NULL, &a); + if (a > 0) + evas_object_show(sd->bg); } static void @@ -1757,6 +1796,7 @@ _smart_hide(Evas_Object * obj) evas_object_hide(sd->obj); if (sd->crop.clipper) evas_object_hide(sd->crop.clipper); + evas_object_hide(sd->bg); } static void @@ -1781,6 +1821,7 @@ _smart_clip_set(Evas_Object * obj, Evas_Object * clip) evas_object_clip_set(sd->crop.clipper, clip); else evas_object_clip_set(sd->obj, clip); + evas_object_clip_set(sd->bg, clip); } static void @@ -1794,5 +1835,6 @@ _smart_clip_unset(Evas_Object * obj) evas_object_clip_unset(sd->crop.clipper); else evas_object_clip_unset(sd->obj); + evas_object_clip_unset(sd->bg); }