summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-04-21 12:04:13 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-04-26 11:36:23 +0900
commite1092b84eb9a196aa2cdc00dd49c1e8af9dd5a36 (patch)
tree0aed3afbf542deb8ce20e62088483ebeed32ed34 /src
parentd962705e4109860cc4dee83cebb0e432b8e69cb7 (diff)
Edje: Adapt to Efl.Container
This basically renames swallow into content.
Diffstat (limited to 'src')
-rw-r--r--src/lib/edje/Edje_Legacy.h61
-rw-r--r--src/lib/edje/edje_object.eo65
-rw-r--r--src/lib/edje/edje_util.c40
-rw-r--r--src/lib/efl/interfaces/efl_container.eo7
-rw-r--r--src/tests/edje/edje_test_edje.c40
-rw-r--r--src/tests/emotion/emotion_test_main-eo.c8
6 files changed, 149 insertions, 72 deletions
diff --git a/src/lib/edje/Edje_Legacy.h b/src/lib/edje/Edje_Legacy.h
index 8991eb2bfd..e361befc5f 100644
--- a/src/lib/edje/Edje_Legacy.h
+++ b/src/lib/edje/Edje_Legacy.h
@@ -228,6 +228,67 @@ Edje object
228 */ 228 */
229EAPI Eina_Bool edje_object_mmap_set(Edje_Object *obj, const Eina_File *file, const char *group); 229EAPI Eina_Bool edje_object_mmap_set(Edje_Object *obj, const Eina_File *file, const char *group);
230 230
231/**
232 * @brief "Swallows" an object into one of the Edje object @c SWALLOW parts.
233 *
234 * Swallowing an object into an Edje object is, for a given part of type
235 * @c SWALLOW in the EDC group which gave life to obj, to set an external
236 * object to be controlled by obj, being displayed exactly over that part's
237 * region inside the whole Edje object's viewport.
238 *
239 * From this point on, obj will have total control over obj_swallow's geometry
240 * and visibility. For instance, if obj is visible, as in @ref
241 * evas_object_show(), the swallowed object will be visible too -- if the given
242 * @c SWALLOW part it's in is also visible. Other actions on obj will also
243 * reflect on the swallowed object as well (e.g. resizing, moving,
244 * raising/lowering, etc.).
245 *
246 * Finally, all internal changes to part, specifically, will reflect on the
247 * displaying of obj_swallow, for example state changes leading to different
248 * visibility states, geometries, positions, etc.
249 *
250 * If an object has already been swallowed into this part, then it will first
251 * be unswallowed (as in edje_object_part_unswallow()) before the new object is
252 * swallowed.
253 *
254 * @note obj won't delete the swallowed object once it is deleted --
255 * obj_swallow will get to an unparented state again.
256 *
257 * For more details on EDC @c SWALLOW parts, see @ref edcref "syntax
258 * reference".
259 *
260 * @param[in] obj_swallow The object to occupy that part
261 *
262 * @ingroup Edje_Object
263 */
264EAPI Eina_Bool edje_object_part_swallow(Edje_Object *obj, const char *part, Evas_Object *obj_swallow);
265
266/**
267 * @brief Get the object currently swallowed by a part.
268 *
269 * @param[in] part The part name
270 *
271 * @return The swallowed object, or @c null if there is none.
272 *
273 * @ingroup Edje_Object
274 */
275EAPI Evas_Object *edje_object_part_swallow_get(const Edje_Object *obj, const char *part);
276
277/**
278 * @brief Unswallow an object.
279 *
280 * Causes the edje to regurgitate a previously swallowed object. :)
281 *
282 * @note obj_swallow will not be deleted or hidden. Note: obj_swallow may
283 * appear shown on the evas depending on its state when it got unswallowed.
284 * Make sure you delete it or hide it if you do not want it to.
285 *
286 * @param[in] obj_swallow The swallowed object
287 *
288 * @ingroup Edje_Object
289 */
290EAPI void edje_object_part_unswallow(Edje_Object *obj, Evas_Object *obj_swallow);
291
231 292
232#include "edje_object.eo.legacy.h" 293#include "edje_object.eo.legacy.h"
233#include "edje_edit.eo.legacy.h" 294#include "edje_edit.eo.legacy.h"
diff --git a/src/lib/edje/edje_object.eo b/src/lib/edje/edje_object.eo
index 5e5cf5bea2..8a195545e2 100644
--- a/src/lib/edje/edje_object.eo
+++ b/src/lib/edje/edje_object.eo
@@ -1,6 +1,6 @@
1import edje_types; 1import edje_types;
2 2
3class Edje.Object (Evas.Smart_Clipped, Efl.File) 3class Edje.Object (Evas.Smart_Clipped, Efl.File, Efl.Container)
4{ 4{
5 legacy_prefix: edje_object; 5 legacy_prefix: edje_object;
6 eo_prefix: edje_obj; 6 eo_prefix: edje_obj;
@@ -1408,19 +1408,6 @@ class Edje.Object (Evas.Smart_Clipped, Efl.File)
1408 @in part: const(char)*; [[The part name]] 1408 @in part: const(char)*; [[The part name]]
1409 } 1409 }
1410 } 1410 }
1411 part_unswallow {
1412 [[Unswallow an object.
1413
1414 Causes the edje to regurgitate a previously swallowed object. :)
1415
1416 Note: obj_swallow will not be deleted or hidden.
1417 Note: obj_swallow may appear shown on the evas depending on its state when
1418 it got unswallowed. Make sure you delete it or hide it if you do not want it to.]]
1419
1420 params {
1421 @in obj_swallow: Evas.Object *; [[The swallowed object]]
1422 }
1423 }
1424 part_text_prediction_allow_set { 1411 part_text_prediction_allow_set {
1425 [[Set whether the prediction is allowed or not. 1412 [[Set whether the prediction is allowed or not.
1426 1413
@@ -1543,14 +1530,6 @@ class Edje.Object (Evas.Smart_Clipped, Efl.File)
1543 1530
1544 return: int; [[The frozen state or 0 if the object is not frozen or on error.]] 1531 return: int; [[The frozen state or 0 if the object is not frozen or on error.]]
1545 } 1532 }
1546 part_swallow_get @const {
1547 [[Get the object currently swallowed by a part.]]
1548
1549 return: Evas.Object *; [[The swallowed object, or $null if there is none.]]
1550 params {
1551 @in part: const(char)*; [[The part name]]
1552 }
1553 }
1554 part_text_imf_context_reset @const { 1533 part_text_imf_context_reset @const {
1555 [[Reset the input method context if needed. 1534 [[Reset the input method context if needed.
1556 1535
@@ -2168,44 +2147,6 @@ class Edje.Object (Evas.Smart_Clipped, Efl.File)
2168 @in part: const(char)*; [[The part name]] 2147 @in part: const(char)*; [[The part name]]
2169 } 2148 }
2170 } 2149 }
2171 part_swallow {
2172 [["Swallows" an object into one of the Edje object $SWALLOW
2173 parts.
2174
2175 Swallowing an object into an Edje object is, for a given part of
2176 type $SWALLOW in the EDC group which gave life to obj, to set
2177 an external object to be controlled by obj, being displayed
2178 exactly over that part's region inside the whole Edje object's
2179 viewport.
2180
2181 From this point on, obj will have total control over
2182 obj_swallow's geometry and visibility. For instance, if obj is
2183 visible, as in \@ref evas_object_show(), the swallowed object will be
2184 visible too -- if the given $SWALLOW part it's in is also visible.
2185 Other actions on obj will also reflect on the swallowed object as
2186 well (e.g. resizing, moving, raising/lowering, etc.).
2187
2188 Finally, all internal changes to part, specifically, will
2189 reflect on the displaying of obj_swallow, for example state
2190 changes leading to different visibility states, geometries,
2191 positions, etc.
2192
2193 If an object has already been swallowed into this part, then it
2194 will first be unswallowed (as in edje_object_part_unswallow())
2195 before the new object is swallowed.
2196
2197 Note: obj won't delete the swallowed object once it is
2198 deleted -- obj_swallow will get to an unparented state again.
2199
2200 For more details on EDC $SWALLOW parts, see \@ref edcref "syntax
2201 reference".]]
2202
2203 return: bool;
2204 params {
2205 @in part: const(char)*; [[The swallow part's name]]
2206 @in obj_swallow: Evas.Object *; [[The object to occupy that part]]
2207 }
2208 }
2209 @property transition_duration_factor { 2150 @property transition_duration_factor {
2210 set { 2151 set {
2211 [[Set transition duration factor. 2152 [[Set transition duration factor.
@@ -2243,6 +2184,10 @@ class Edje.Object (Evas.Smart_Clipped, Efl.File)
2243 Efl.File.file.get; 2184 Efl.File.file.get;
2244 Efl.File.mmap.set; 2185 Efl.File.mmap.set;
2245 Efl.File.mmap.get; 2186 Efl.File.mmap.get;
2187 Efl.Container.content.set;
2188 Efl.Container.content.get;
2189 Efl.Container.content_unset; /* swallow NULL */
2190 Efl.Container.content_remove; /* unswallow */
2246 } 2191 }
2247 events { 2192 events {
2248 recalc; [[Edje re-calculated the object.]] 2193 recalc; [[Edje re-calculated the object.]]
diff --git a/src/lib/edje/edje_util.c b/src/lib/edje/edje_util.c
index a34d81c478..be6c932ffb 100644
--- a/src/lib/edje/edje_util.c
+++ b/src/lib/edje/edje_util.c
@@ -3502,7 +3502,8 @@ _edje_object_text_markup_filter_callback_del_full(Eo *obj EINA_UNUSED, Edje *ed,
3502} 3502}
3503 3503
3504EOLIAN Eina_Bool 3504EOLIAN Eina_Bool
3505_edje_object_part_swallow(Eo *obj EINA_UNUSED, Edje *ed, const char *part, Evas_Object *obj_swallow) 3505_edje_object_efl_container_content_set(Eo *obj EINA_UNUSED, Edje *ed,
3506 const char *part, Efl_Gfx_Base *obj_swallow)
3506{ 3507{
3507 Edje_Real_Part *rp, *rpcur; 3508 Edje_Real_Part *rp, *rpcur;
3508 Edje_User_Defined *eud = NULL; 3509 Edje_User_Defined *eud = NULL;
@@ -3800,7 +3801,7 @@ edje_box_layout_register(const char *name, Evas_Object_Box_Layout func, void *(*
3800} 3801}
3801 3802
3802EOLIAN void 3803EOLIAN void
3803_edje_object_part_unswallow(Eo *obj EINA_UNUSED, Edje *ed, Evas_Object *obj_swallow) 3804_edje_object_efl_container_content_remove(Eo *obj EINA_UNUSED, Edje *ed, Evas_Object *obj_swallow)
3804{ 3805{
3805 Edje_Real_Part *rp; 3806 Edje_Real_Part *rp;
3806 3807
@@ -3861,8 +3862,8 @@ _edje_object_part_unswallow(Eo *obj EINA_UNUSED, Edje *ed, Evas_Object *obj_swal
3861 } 3862 }
3862} 3863}
3863 3864
3864EOLIAN Evas_Object * 3865EOLIAN Efl_Gfx_Base *
3865_edje_object_part_swallow_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part) 3866_edje_object_efl_container_content_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part)
3866{ 3867{
3867 Edje_Real_Part *rp; 3868 Edje_Real_Part *rp;
3868 3869
@@ -3879,6 +3880,17 @@ _edje_object_part_swallow_get(Eo *obj EINA_UNUSED, Edje *ed, const char *part)
3879 return rp->typedata.swallow->swallowed_object; 3880 return rp->typedata.swallow->swallowed_object;
3880} 3881}
3881 3882
3883EOLIAN Eina_Bool
3884_edje_object_efl_container_content_unset(Eo *obj, Edje *ed EINA_UNUSED, const char *part)
3885{
3886 Efl_Gfx_Base *content;
3887
3888 content = efl_content_get(obj, part);
3889 if (!content) return EINA_TRUE;
3890
3891 return efl_content_remove(obj, content);
3892}
3893
3882EOLIAN void 3894EOLIAN void
3883_edje_object_size_min_get(Eo *obj EINA_UNUSED, Edje *ed, Evas_Coord *minw, Evas_Coord *minh) 3895_edje_object_size_min_get(Eo *obj EINA_UNUSED, Edje *ed, Evas_Coord *minw, Evas_Coord *minh)
3884{ 3896{
@@ -6670,4 +6682,24 @@ _edje_part_mask_flags_set(Edje *ed EINA_UNUSED, Edje_Real_Part *rp, Evas_Event_F
6670 rp->part->mask_flags = mask_flags; 6682 rp->part->mask_flags = mask_flags;
6671} 6683}
6672 6684
6685/* Legacy APIs */
6686
6687EAPI Eina_Bool
6688edje_object_part_swallow(Edje_Object *obj, const char *part, Evas_Object *obj_swallow)
6689{
6690 return efl_content_set(obj, part, obj_swallow);
6691}
6692
6693EAPI void
6694edje_object_part_unswallow(Edje_Object *obj, Evas_Object *obj_swallow)
6695{
6696 efl_content_remove(obj, obj_swallow);
6697}
6698
6699EAPI Evas_Object *
6700edje_object_part_swallow_get(const Edje_Object *obj, const char *part)
6701{
6702 return efl_content_get(obj, part);
6703}
6704
6673/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/ 6705/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
diff --git a/src/lib/efl/interfaces/efl_container.eo b/src/lib/efl/interfaces/efl_container.eo
index b4e0f0949a..c31e2c09f1 100644
--- a/src/lib/efl/interfaces/efl_container.eo
+++ b/src/lib/efl/interfaces/efl_container.eo
@@ -34,6 +34,13 @@ interface Efl.Container (Efl.Gfx.Base)
34 } 34 }
35 return: Efl.Gfx.Base*; 35 return: Efl.Gfx.Base*;
36 } 36 }
37 content_remove {
38 [[Unswallow an object from this container.]]
39 params {
40 @in content: Efl.Gfx.Base*;
41 }
42 return: bool; [[$false if $content was not a child or can not be removed.]]
43 }
37 content_iterate { 44 content_iterate {
38 [[Begin iterating over this object's contents.]] 45 [[Begin iterating over this object's contents.]]
39 return: free(own(iterator<Efl.Gfx.Base *> *), eina_iterator_free) @warn_unused; 46 return: free(own(iterator<Efl.Gfx.Base *> *), eina_iterator_free) @warn_unused;
diff --git a/src/tests/edje/edje_test_edje.c b/src/tests/edje/edje_test_edje.c
index a576ac3068..50fdcac3f6 100644
--- a/src/tests/edje/edje_test_edje.c
+++ b/src/tests/edje/edje_test_edje.c
@@ -362,17 +362,48 @@ START_TEST(edje_test_swallows)
362 362
363 363
364 o1 = eo_add(EDJE_OBJECT_CLASS, ly); 364 o1 = eo_add(EDJE_OBJECT_CLASS, ly);
365 fail_if(!edje_obj_part_swallow(ly, "swallow", o1)); 365 fail_if(!edje_object_part_swallow(ly, "swallow", o1));
366 ck_assert_ptr_eq(eo_parent_get(o1), ly); 366 ck_assert_ptr_eq(eo_parent_get(o1), ly);
367 367
368 edje_obj_part_unswallow(ly, o1); 368 edje_object_part_unswallow(ly, o1);
369 ck_assert_ptr_eq(eo_parent_get(o1), evas_common_evas_get(o1)); 369 ck_assert_ptr_eq(eo_parent_get(o1), evas_common_evas_get(o1));
370 370
371 fail_if(!edje_obj_part_swallow(ly, "swallow", o1)); 371 fail_if(!edje_object_part_swallow(ly, "swallow", o1));
372 ck_assert_ptr_eq(eo_parent_get(o1), ly); 372 ck_assert_ptr_eq(eo_parent_get(o1), ly);
373 373
374 o2 = eo_add(EDJE_OBJECT_CLASS, ly); 374 o2 = eo_add(EDJE_OBJECT_CLASS, ly);
375 fail_if(!edje_obj_part_swallow(ly, "swallow", o2)); 375 fail_if(!edje_object_part_swallow(ly, "swallow", o2));
376 ck_assert_ptr_eq(eo_parent_get(o2), ly);
377 /* o1 is deleted at this point. */
378 ck_assert_ptr_eq(eo_parent_get(o1), evas_common_evas_get(o1));
379
380 EDJE_TEST_FREE_EVAS();
381}
382END_TEST
383
384START_TEST(edje_test_swallows_eoapi)
385{
386 Evas *evas = EDJE_TEST_INIT_EVAS();
387 Evas_Object *ly, *o1, *o2;
388
389 ly = eo_add(EDJE_OBJECT_CLASS, evas);
390 fail_unless(edje_object_file_set(ly, test_layout_get("test_swallows.edj"), "test_group"));
391
392 fail_unless(edje_object_part_exists(ly, "swallow"));
393
394
395 o1 = eo_add(EDJE_OBJECT_CLASS, ly);
396 fail_if(!efl_content_set(ly, "swallow", o1));
397 ck_assert_ptr_eq(eo_parent_get(o1), ly);
398
399 efl_content_remove(ly, o1);
400 ck_assert_ptr_eq(eo_parent_get(o1), evas_common_evas_get(o1));
401
402 fail_if(!efl_content_set(ly, "swallow", o1));
403 ck_assert_ptr_eq(eo_parent_get(o1), ly);
404
405 o2 = eo_add(EDJE_OBJECT_CLASS, ly);
406 fail_if(!efl_content_set(ly, "swallow", o2));
376 ck_assert_ptr_eq(eo_parent_get(o2), ly); 407 ck_assert_ptr_eq(eo_parent_get(o2), ly);
377 /* o1 is deleted at this point. */ 408 /* o1 is deleted at this point. */
378 ck_assert_ptr_eq(eo_parent_get(o1), evas_common_evas_get(o1)); 409 ck_assert_ptr_eq(eo_parent_get(o1), evas_common_evas_get(o1));
@@ -434,5 +465,6 @@ void edje_test_edje(TCase *tc)
434 tcase_add_test(tc, edje_test_size_class); 465 tcase_add_test(tc, edje_test_size_class);
435 tcase_add_test(tc, edje_test_color_class); 466 tcase_add_test(tc, edje_test_color_class);
436 tcase_add_test(tc, edje_test_swallows); 467 tcase_add_test(tc, edje_test_swallows);
468 tcase_add_test(tc, edje_test_swallows_eoapi);
437 tcase_add_test(tc, edje_test_box); 469 tcase_add_test(tc, edje_test_box);
438} 470}
diff --git a/src/tests/emotion/emotion_test_main-eo.c b/src/tests/emotion/emotion_test_main-eo.c
index 8a8aad5659..c1d55a571d 100644
--- a/src/tests/emotion/emotion_test_main-eo.c
+++ b/src/tests/emotion/emotion_test_main-eo.c
@@ -353,11 +353,11 @@ video_obj_frame_resize_cb(void *data, const Eo_Event *event)
353 printf("HANDLE %ix%i @ %3.3f\n", iw, ih, ratio); 353 printf("HANDLE %ix%i @ %3.3f\n", iw, ih, ratio);
354 if (ratio > 0.0) iw = (ih * ratio) + 0.5; 354 if (ratio > 0.0) iw = (ih * ratio) + 0.5;
355 evas_object_size_hint_min_set(event->obj, iw, ih); 355 evas_object_size_hint_min_set(event->obj, iw, ih);
356 edje_obj_part_swallow(oe, "video_swallow", event->obj); 356 edje_object_part_swallow(oe, "video_swallow", event->obj);
357 edje_obj_size_min_calc(oe, &w, &h); 357 edje_obj_size_min_calc(oe, &w, &h);
358 efl_gfx_size_set(oe, w, h); 358 efl_gfx_size_set(oe, w, h);
359 evas_obj_size_hint_min_set(event->obj, 0, 0); 359 evas_object_size_hint_min_set(event->obj, 0, 0);
360 edje_obj_part_swallow(oe, "video_swallow", event->obj); 360 edje_object_part_swallow(oe, "video_swallow", event->obj);
361 361
362 return EINA_TRUE; 362 return EINA_TRUE;
363} 363}
@@ -643,7 +643,7 @@ init_video_object(const char *module_filename, const char *filename)
643 eo_event_callback_add(oe, EVAS_OBJECT_EVENT_FREE, _oe_free_cb, fd); 643 eo_event_callback_add(oe, EVAS_OBJECT_EVENT_FREE, _oe_free_cb, fd);
644 eo_key_data_set(oe, "frame_data", fd); 644 eo_key_data_set(oe, "frame_data", fd);
645 efl_file_set(oe, theme_file, reflex ? "video_controller/reflex" : "video_controller"); 645 efl_file_set(oe, theme_file, reflex ? "video_controller/reflex" : "video_controller");
646 edje_obj_part_swallow(oe, "video_swallow", o); 646 edje_object_part_swallow(oe, "video_swallow", o);
647 647
648 offset = 20 * (eina_list_count(video_objs) - 1); 648 offset = 20 * (eina_list_count(video_objs) - 1);
649 efl_gfx_position_set(oe, offset, offset); 649 efl_gfx_position_set(oe, offset, offset);