summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2016-03-02 15:44:12 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2016-03-15 11:11:59 +0900
commit2d10127524b50ba5fbfbf4615295ac1c46ebb4e5 (patch)
treee8ad7b73ce051a0736a425533eed3b66106fcda9
parente9508ea80e6d333ad89645a1e03c084a7589e1f6 (diff)
Evas image: Move filled property to Efl.Gfx.Fill and set as default
The filled property should be set to true by default since it makes more sense. Legacy APIs behaviour is preserved by setting the default to false.
Diffstat (limited to '')
-rw-r--r--src/lib/efl/interfaces/efl_gfx_fill.eo30
-rw-r--r--src/lib/evas/Evas_Legacy.h30
-rw-r--r--src/lib/evas/canvas/evas_image.eo31
-rw-r--r--src/lib/evas/canvas/evas_object_image.c48
-rw-r--r--src/tests/evas/evas_test_image.c29
5 files changed, 114 insertions, 54 deletions
diff --git a/src/lib/efl/interfaces/efl_gfx_fill.eo b/src/lib/efl/interfaces/efl_gfx_fill.eo
index 74aff4cb6b..0dde45c17e 100644
--- a/src/lib/efl/interfaces/efl_gfx_fill.eo
+++ b/src/lib/efl/interfaces/efl_gfx_fill.eo
@@ -1,8 +1,26 @@
1interface Efl.Gfx.Fill { 1interface Efl.Gfx.Fill {
2 legacy_prefix: null; 2 legacy_prefix: null;
3 methods { 3 methods {
4 @property filled {
5 [[Binds the object's @.fill property to its actual geometry.
6
7 If $true, then every time the object is resized, it will
8 automatically trigger a call to @Efl.Gfx.Fill.fill.set
9 with the new size (and 0, 0 as source image's origin),
10 so the bound image will fill the whole object's area.
11
12 This property takes precedence over @.fill.
13
14 This flag is $true by default (used to be $false with the old APIs).
15 ]]
16 set {}
17 get {}
18 values {
19 filled: bool; [[$true to make the fill property follow
20 object size or $false otherwise.]]
21 }
22 }
4 @property fill { 23 @property fill {
5 /* FIXME: bad defaults, bad doc */
6 [[Specifies how to tile an image to fill its rectangle geometry. 24 [[Specifies how to tile an image to fill its rectangle geometry.
7 25
8 Note that if $w or $h are smaller than the dimensions of the object, 26 Note that if $w or $h are smaller than the dimensions of the object,
@@ -11,15 +29,7 @@ interface Efl.Gfx.Fill {
11 $w and $h need to be the exact width and height of the image object 29 $w and $h need to be the exact width and height of the image object
12 itself, respectively. 30 itself, respectively.
13 31
14 Warning: The default values for the fill parameters are $x = 0, 32 Note that this property has no effect if @.filled is $true.
15 $y = 0, $w = 0 and $h = 0. Thus, if you're not using the
16 evas_object_image_filled_add() helper and want your image
17 displayed, you'll have to set valid values with this function on
18 your object.
19
20 Note: evas_object_image_filled_set() is a helper function which
21 will override the values set here automatically, for you, in a
22 given way.
23 ]] 33 ]]
24 /* FIXME-doc 34 /* FIXME-doc
25 * See the following image to better understand the effects of this 35 * See the following image to better understand the effects of this
diff --git a/src/lib/evas/Evas_Legacy.h b/src/lib/evas/Evas_Legacy.h
index 91c9d73457..472b2ae25f 100644
--- a/src/lib/evas/Evas_Legacy.h
+++ b/src/lib/evas/Evas_Legacy.h
@@ -2898,6 +2898,36 @@ image) to start drawing from.
2898EAPI void evas_object_image_fill_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h); 2898EAPI void evas_object_image_fill_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
2899 2899
2900/** 2900/**
2901 * @brief Set whether the image object's fill property should track the
2902 * object's size.
2903 *
2904 * If @c setting is @c true, then every @ref evas_object_resize will
2905 * automatically trigger a call to @ref evas_object_image_fill_set with the
2906 * that new size (and 0, 0 as source image's origin), so the bound image will
2907 * fill the whole object's area.
2908 *
2909 * @param[in] filled @c true to make the fill property follow object size or
2910 * @c false otherwise.
2911 *
2912 * @ingroup Evas_Image
2913 */
2914EAPI void evas_object_image_filled_set(Evas_Object *obj, Eina_Bool filled);
2915
2916/**
2917 * @brief Retrieve whether the image object's fill property should track the
2918 * object's size.
2919 *
2920 * Returns @c true if it is tracking, @c false if not (and @ref
2921 * evas_object_fill_set must be called manually).
2922 *
2923 * @return @c true to make the fill property follow object size or @c false
2924 * otherwise.
2925 *
2926 * @ingroup Evas_Image
2927 */
2928EAPI Eina_Bool evas_object_image_filled_get(const Evas_Object *obj);
2929
2930/**
2901 * 2931 *
2902 * Sets the size of the given image object. 2932 * Sets the size of the given image object.
2903 * 2933 *
diff --git a/src/lib/evas/canvas/evas_image.eo b/src/lib/evas/canvas/evas_image.eo
index beb066bb3c..f78a471530 100644
--- a/src/lib/evas/canvas/evas_image.eo
+++ b/src/lib/evas/canvas/evas_image.eo
@@ -71,30 +71,6 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image, Efl.Gfx.Fill, Efl.Gfx.View,
71 src: Evas.Object *; [[Source object to use for the proxy.]] 71 src: Evas.Object *; [[Source object to use for the proxy.]]
72 } 72 }
73 } 73 }
74 @property filled {
75 set {
76 [[Set whether the image object's fill property should track the
77 object's size.
78
79 If $setting is $true, then every \@ref evas_object_resize will
80 automatically trigger a call to \@ref evas_object_image_fill_set
81 with the that new size (and 0, 0 as source image's origin),
82 so the bound image will fill the whole object's area.
83 ]]
84 }
85 get {
86 [[Retrieve whether the image object's fill property should track
87 the object's size.
88
89 Returns $true if it is tracking, $false if not (and
90 \@ref evas_object_fill_set must be called manually).
91 ]]
92 }
93 values {
94 filled: bool; [[$true to make the fill property follow
95 object size or $false otherwise.]]
96 }
97 }
98 @property content_hint { 74 @property content_hint {
99 set { 75 set {
100 [[Set the content hint setting of a given image object of the 76 [[Set the content hint setting of a given image object of the
@@ -320,8 +296,8 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image, Efl.Gfx.Fill, Efl.Gfx.View,
320 in @Evas.Border_Fill_Mode. By center we mean the complementary 296 in @Evas.Border_Fill_Mode. By center we mean the complementary
321 part of that defined by @.border.set. This one is very useful 297 part of that defined by @.border.set. This one is very useful
322 for making frames and decorations. You would most probably 298 for making frames and decorations. You would most probably
323 also be using a filled image (as in @.filled.set) to use as 299 also be using a filled image (as in @Efl.Gfx.Fill.filled) to use
324 a frame. 300 as a frame.
325 ]] 301 ]]
326 } 302 }
327 get { 303 get {
@@ -768,6 +744,7 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image, Efl.Gfx.Fill, Efl.Gfx.View,
768 Eo.Base.constructor; 744 Eo.Base.constructor;
769 Eo.Base.destructor; 745 Eo.Base.destructor;
770 Eo.Base.dbg_info_get; 746 Eo.Base.dbg_info_get;
747 Eo.Base.finalize;
771 Efl.File.file.set; 748 Efl.File.file.set;
772 Efl.File.file.get; 749 Efl.File.file.get;
773 Efl.File.mmap.set; 750 Efl.File.mmap.set;
@@ -780,6 +757,8 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image, Efl.Gfx.Fill, Efl.Gfx.View,
780 Efl.Image.smooth_scale.get; 757 Efl.Image.smooth_scale.get;
781 Efl.Gfx.Fill.fill.set; 758 Efl.Gfx.Fill.fill.set;
782 Efl.Gfx.Fill.fill.get; 759 Efl.Gfx.Fill.fill.get;
760 Efl.Gfx.Fill.filled.get;
761 Efl.Gfx.Fill.filled.set;
783 Efl.Gfx.View.size.set; 762 Efl.Gfx.View.size.set;
784 Efl.Gfx.View.size.get; 763 Efl.Gfx.View.size.get;
785 Efl.Gfx.Filter.filter_program.set; 764 Efl.Gfx.Filter.filter_program.set;
diff --git a/src/lib/evas/canvas/evas_object_image.c b/src/lib/evas/canvas/evas_object_image.c
index 351c481502..747a269088 100644
--- a/src/lib/evas/canvas/evas_object_image.c
+++ b/src/lib/evas/canvas/evas_object_image.c
@@ -124,6 +124,7 @@ struct _Evas_Object_Image
124 Eina_Bool changed : 1; 124 Eina_Bool changed : 1;
125 Eina_Bool dirty_pixels : 1; 125 Eina_Bool dirty_pixels : 1;
126 Eina_Bool filled : 1; 126 Eina_Bool filled : 1;
127 Eina_Bool filled_set : 1;
127 Eina_Bool proxyrendering : 1; 128 Eina_Bool proxyrendering : 1;
128 Eina_Bool preloading : 1; 129 Eina_Bool preloading : 1;
129 Eina_Bool video_surface : 1; 130 Eina_Bool video_surface : 1;
@@ -372,26 +373,27 @@ _evas_image_eo_base_constructor(Eo *eo_obj, Evas_Image_Data *o)
372 return eo_obj; 373 return eo_obj;
373} 374}
374 375
376EOLIAN static Eo *
377_evas_image_eo_base_finalize(Eo *eo_obj, Evas_Image_Data *o)
378{
379 if (!o->filled_set)
380 efl_gfx_fill_filled_set(eo_obj, EINA_TRUE);
381 return eo_finalize(eo_super(eo_obj, MY_CLASS));
382}
383
375EAPI Evas_Object * 384EAPI Evas_Object *
376evas_object_image_add(Evas *eo_e) 385evas_object_image_add(Evas *eo_e)
377{ 386{
378 MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS); 387 EINA_SAFETY_ON_FALSE_RETURN_VAL(eo_isa(eo_e, EVAS_CANVAS_CLASS), NULL);
379 return NULL; 388 return eo_add(EVAS_IMAGE_CLASS, eo_e,
380 MAGIC_CHECK_END(); 389 efl_gfx_fill_filled_set(eo_obj, EINA_FALSE));
381 Evas_Public_Data *e = eo_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
382 EINA_SAFETY_ON_NULL_RETURN_VAL(e, NULL);
383 EINA_SAFETY_ON_NULL_RETURN_VAL(e->engine.func, NULL);
384 Evas_Object *eo_obj = eo_add(EVAS_IMAGE_CLASS, eo_e);
385 return eo_obj;
386} 390}
387 391
388EAPI Evas_Object * 392EAPI Evas_Object *
389evas_object_image_filled_add(Evas *eo_e) 393evas_object_image_filled_add(Evas *eo_e)
390{ 394{
391 Evas_Object *eo_obj; 395 EINA_SAFETY_ON_FALSE_RETURN_VAL(eo_isa(eo_e, EVAS_CANVAS_CLASS), NULL);
392 eo_obj = evas_object_image_add(eo_e); 396 return eo_add(EVAS_IMAGE_CLASS, eo_e);
393 evas_object_image_filled_set(eo_obj, 1);
394 return eo_obj;
395} 397}
396 398
397EAPI void 399EAPI void
@@ -927,11 +929,12 @@ _evas_image_border_center_fill_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o)
927 return o->cur->border.fill; 929 return o->cur->border.fill;
928} 930}
929 931
930static void 932EOLIAN static void
931_evas_image_filled_set(Eo *eo_obj, Evas_Image_Data* o, Eina_Bool setting) 933_evas_image_efl_gfx_fill_filled_set(Eo *eo_obj, Evas_Image_Data* o, Eina_Bool setting)
932{ 934{
933 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS); 935 Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
934 setting = !!setting; 936 setting = !!setting;
937 o->filled_set = 1;
935 if (o->filled == setting) return; 938 if (o->filled == setting) return;
936 939
937 evas_object_async_block(obj); 940 evas_object_async_block(obj);
@@ -953,11 +956,23 @@ _evas_image_filled_set(Eo *eo_obj, Evas_Image_Data* o, Eina_Bool setting)
953} 956}
954 957
955EOLIAN static Eina_Bool 958EOLIAN static Eina_Bool
956_evas_image_filled_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o) 959_evas_image_efl_gfx_fill_filled_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o)
957{ 960{
958 return o->filled; 961 return o->filled;
959} 962}
960 963
964EAPI void
965evas_object_image_filled_set(Evas_Object *eo_obj, Eina_Bool value)
966{
967 efl_gfx_fill_filled_set(eo_obj, value);
968}
969
970EAPI Eina_Bool
971evas_object_image_filled_get(const Evas_Object *eo_obj)
972{
973 return efl_gfx_fill_filled_get(eo_obj);
974}
975
961EOLIAN static void 976EOLIAN static void
962_evas_image_border_scale_set(Eo *eo_obj, Evas_Image_Data *o, double scale) 977_evas_image_border_scale_set(Eo *eo_obj, Evas_Image_Data *o, double scale)
963{ 978{
@@ -4914,14 +4929,12 @@ evas_object_image_mmap_get(const Evas_Image *obj, const Eina_File **f, const cha
4914EAPI Eina_Bool 4929EAPI Eina_Bool
4915evas_object_image_save(const Eo *obj, const char *file, const char *key, const char *flags) 4930evas_object_image_save(const Eo *obj, const char *file, const char *key, const char *flags)
4916{ 4931{
4917 Eina_Bool ret;
4918 return efl_file_save((Eo *) obj, file, key, flags); 4932 return efl_file_save((Eo *) obj, file, key, flags);
4919} 4933}
4920 4934
4921EAPI Eina_Bool 4935EAPI Eina_Bool
4922evas_object_image_animated_get(const Eo *obj) 4936evas_object_image_animated_get(const Eo *obj)
4923{ 4937{
4924 Eina_Bool ret;
4925 return efl_image_animated_get((Eo *) obj); 4938 return efl_image_animated_get((Eo *) obj);
4926} 4939}
4927 4940
@@ -4946,7 +4959,6 @@ evas_object_image_smooth_scale_set(Eo *obj, Eina_Bool smooth_scale)
4946EAPI Eina_Bool 4959EAPI Eina_Bool
4947evas_object_image_smooth_scale_get(const Eo *obj) 4960evas_object_image_smooth_scale_get(const Eo *obj)
4948{ 4961{
4949 Eina_Bool ret;
4950 return efl_image_smooth_scale_get((Eo *) obj); 4962 return efl_image_smooth_scale_get((Eo *) obj);
4951} 4963}
4952 4964
diff --git a/src/tests/evas/evas_test_image.c b/src/tests/evas/evas_test_image.c
index aa7debbfa9..0f7514c3a0 100644
--- a/src/tests/evas/evas_test_image.c
+++ b/src/tests/evas/evas_test_image.c
@@ -627,8 +627,37 @@ START_TEST(evas_object_image_partially_load_orientation)
627} 627}
628END_TEST 628END_TEST
629 629
630START_TEST(evas_object_image_defaults)
631{
632 Evas *e = _setup_evas();
633 Evas_Object *o;
634 int x, y, w, h, iw, ih;
635 Eina_Bool b;
636
637 /* test legacy defaults */
638 o = evas_object_image_add(e);
639 fail_if(evas_object_image_filled_get(o));
640 evas_object_image_fill_get(o, &x, &y, &w, &h);
641 fail_if(x || y || w || h);
642 eo_del(o);
643
644 o = evas_object_image_filled_add(e);
645 fail_if(!evas_object_image_filled_get(o));
646 eo_del(o);
647
648 /* test eo defaults */
649 eo_add(&o, EVAS_IMAGE_CLASS, e);
650 fail_if(!efl_gfx_fill_filled_get(o));
651 eo_del(o);
652
653 evas_free(e);
654 evas_shutdown();
655}
656END_TEST
657
630void evas_test_image_object(TCase *tc) 658void evas_test_image_object(TCase *tc)
631{ 659{
660 tcase_add_test(tc, evas_object_image_defaults);
632 tcase_add_test(tc, evas_object_image_loader); 661 tcase_add_test(tc, evas_object_image_loader);
633 tcase_add_test(tc, evas_object_image_loader_orientation); 662 tcase_add_test(tc, evas_object_image_loader_orientation);
634 tcase_add_test(tc, evas_object_image_orient); 663 tcase_add_test(tc, evas_object_image_orient);