aboutsummaryrefslogtreecommitdiffstats
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
parentEfl.Gfx.Fill: Remove fill_spread (diff)
downloadefl-2d10127524b50ba5fbfbf4615295ac1c46ebb4e5.tar.gz
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.
-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 @@
interface Efl.Gfx.Fill {
legacy_prefix: null;
methods {
+ @property filled {
+ [[Binds the object's @.fill property to its actual geometry.
+
+ If $true, then every time the object is resized, it will
+ automatically trigger a call to @Efl.Gfx.Fill.fill.set
+ with the new size (and 0, 0 as source image's origin),
+ so the bound image will fill the whole object's area.
+
+ This property takes precedence over @.fill.
+
+ This flag is $true by default (used to be $false with the old APIs).
+ ]]
+ set {}
+ get {}
+ values {
+ filled: bool; [[$true to make the fill property follow
+ object size or $false otherwise.]]
+ }
+ }
@property fill {
- /* FIXME: bad defaults, bad doc */
[[Specifies how to tile an image to fill its rectangle geometry.
Note that if $w or $h are smaller than the dimensions of the object,
@@ -11,15 +29,7 @@ interface Efl.Gfx.Fill {
$w and $h need to be the exact width and height of the image object
itself, respectively.
- Warning: The default values for the fill parameters are $x = 0,
- $y = 0, $w = 0 and $h = 0. Thus, if you're not using the
- evas_object_image_filled_add() helper and want your image
- displayed, you'll have to set valid values with this function on
- your object.
-
- Note: evas_object_image_filled_set() is a helper function which
- will override the values set here automatically, for you, in a
- given way.
+ Note that this property has no effect if @.filled is $true.
]]
/* FIXME-doc
* 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.
EAPI void evas_object_image_fill_get(const Evas_Object *obj, Evas_Coord *x, Evas_Coord *y, Evas_Coord *w, Evas_Coord *h);
/**
+ * @brief Set whether the image object's fill property should track the
+ * object's size.
+ *
+ * If @c setting is @c true, then every @ref evas_object_resize will
+ * automatically trigger a call to @ref evas_object_image_fill_set with the
+ * that new size (and 0, 0 as source image's origin), so the bound image will
+ * fill the whole object's area.
+ *
+ * @param[in] filled @c true to make the fill property follow object size or
+ * @c false otherwise.
+ *
+ * @ingroup Evas_Image
+ */
+EAPI void evas_object_image_filled_set(Evas_Object *obj, Eina_Bool filled);
+
+/**
+ * @brief Retrieve whether the image object's fill property should track the
+ * object's size.
+ *
+ * Returns @c true if it is tracking, @c false if not (and @ref
+ * evas_object_fill_set must be called manually).
+ *
+ * @return @c true to make the fill property follow object size or @c false
+ * otherwise.
+ *
+ * @ingroup Evas_Image
+ */
+EAPI Eina_Bool evas_object_image_filled_get(const Evas_Object *obj);
+
+/**
*
* Sets the size of the given image object.
*
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,
src: Evas.Object *; [[Source object to use for the proxy.]]
}
}
- @property filled {
- set {
- [[Set whether the image object's fill property should track the
- object's size.
-
- If $setting is $true, then every \@ref evas_object_resize will
- automatically trigger a call to \@ref evas_object_image_fill_set
- with the that new size (and 0, 0 as source image's origin),
- so the bound image will fill the whole object's area.
- ]]
- }
- get {
- [[Retrieve whether the image object's fill property should track
- the object's size.
-
- Returns $true if it is tracking, $false if not (and
- \@ref evas_object_fill_set must be called manually).
- ]]
- }
- values {
- filled: bool; [[$true to make the fill property follow
- object size or $false otherwise.]]
- }
- }
@property content_hint {
set {
[[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,
in @Evas.Border_Fill_Mode. By center we mean the complementary
part of that defined by @.border.set. This one is very useful
for making frames and decorations. You would most probably
- also be using a filled image (as in @.filled.set) to use as
- a frame.
+ also be using a filled image (as in @Efl.Gfx.Fill.filled) to use
+ as a frame.
]]
}
get {
@@ -768,6 +744,7 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image, Efl.Gfx.Fill, Efl.Gfx.View,
Eo.Base.constructor;
Eo.Base.destructor;
Eo.Base.dbg_info_get;
+ Eo.Base.finalize;
Efl.File.file.set;
Efl.File.file.get;
Efl.File.mmap.set;
@@ -780,6 +757,8 @@ class Evas.Image (Evas.Object, Efl.File, Efl.Image, Efl.Gfx.Fill, Efl.Gfx.View,
Efl.Image.smooth_scale.get;
Efl.Gfx.Fill.fill.set;
Efl.Gfx.Fill.fill.get;
+ Efl.Gfx.Fill.filled.get;
+ Efl.Gfx.Fill.filled.set;
Efl.Gfx.View.size.set;
Efl.Gfx.View.size.get;
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
Eina_Bool changed : 1;
Eina_Bool dirty_pixels : 1;
Eina_Bool filled : 1;
+ Eina_Bool filled_set : 1;
Eina_Bool proxyrendering : 1;
Eina_Bool preloading : 1;
Eina_Bool video_surface : 1;
@@ -372,26 +373,27 @@ _evas_image_eo_base_constructor(Eo *eo_obj, Evas_Image_Data *o)
return eo_obj;
}
+EOLIAN static Eo *
+_evas_image_eo_base_finalize(Eo *eo_obj, Evas_Image_Data *o)
+{
+ if (!o->filled_set)
+ efl_gfx_fill_filled_set(eo_obj, EINA_TRUE);
+ return eo_finalize(eo_super(eo_obj, MY_CLASS));
+}
+
EAPI Evas_Object *
evas_object_image_add(Evas *eo_e)
{
- MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS);
- return NULL;
- MAGIC_CHECK_END();
- Evas_Public_Data *e = eo_data_scope_get(eo_e, EVAS_CANVAS_CLASS);
- EINA_SAFETY_ON_NULL_RETURN_VAL(e, NULL);
- EINA_SAFETY_ON_NULL_RETURN_VAL(e->engine.func, NULL);
- Evas_Object *eo_obj = eo_add(EVAS_IMAGE_CLASS, eo_e);
- return eo_obj;
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(eo_isa(eo_e, EVAS_CANVAS_CLASS), NULL);
+ return eo_add(EVAS_IMAGE_CLASS, eo_e,
+ efl_gfx_fill_filled_set(eo_obj, EINA_FALSE));
}
EAPI Evas_Object *
evas_object_image_filled_add(Evas *eo_e)
{
- Evas_Object *eo_obj;
- eo_obj = evas_object_image_add(eo_e);
- evas_object_image_filled_set(eo_obj, 1);
- return eo_obj;
+ EINA_SAFETY_ON_FALSE_RETURN_VAL(eo_isa(eo_e, EVAS_CANVAS_CLASS), NULL);
+ return eo_add(EVAS_IMAGE_CLASS, eo_e);
}
EAPI void
@@ -927,11 +929,12 @@ _evas_image_border_center_fill_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o)
return o->cur->border.fill;
}
-static void
-_evas_image_filled_set(Eo *eo_obj, Evas_Image_Data* o, Eina_Bool setting)
+EOLIAN static void
+_evas_image_efl_gfx_fill_filled_set(Eo *eo_obj, Evas_Image_Data* o, Eina_Bool setting)
{
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
setting = !!setting;
+ o->filled_set = 1;
if (o->filled == setting) return;
evas_object_async_block(obj);
@@ -953,11 +956,23 @@ _evas_image_filled_set(Eo *eo_obj, Evas_Image_Data* o, Eina_Bool setting)
}
EOLIAN static Eina_Bool
-_evas_image_filled_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o)
+_evas_image_efl_gfx_fill_filled_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o)
{
return o->filled;
}
+EAPI void
+evas_object_image_filled_set(Evas_Object *eo_obj, Eina_Bool value)
+{
+ efl_gfx_fill_filled_set(eo_obj, value);
+}
+
+EAPI Eina_Bool
+evas_object_image_filled_get(const Evas_Object *eo_obj)
+{
+ return efl_gfx_fill_filled_get(eo_obj);
+}
+
EOLIAN static void
_evas_image_border_scale_set(Eo *eo_obj, Evas_Image_Data *o, double scale)
{
@@ -4914,14 +4929,12 @@ evas_object_image_mmap_get(const Evas_Image *obj, const Eina_File **f, const cha
EAPI Eina_Bool
evas_object_image_save(const Eo *obj, const char *file, const char *key, const char *flags)
{
- Eina_Bool ret;
return efl_file_save((Eo *) obj, file, key, flags);
}
EAPI Eina_Bool
evas_object_image_animated_get(const Eo *obj)
{
- Eina_Bool ret;
return efl_image_animated_get((Eo *) obj);
}
@@ -4946,7 +4959,6 @@ evas_object_image_smooth_scale_set(Eo *obj, Eina_Bool smooth_scale)
EAPI Eina_Bool
evas_object_image_smooth_scale_get(const Eo *obj)
{
- Eina_Bool ret;
return efl_image_smooth_scale_get((Eo *) obj);
}
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)
}
END_TEST
+START_TEST(evas_object_image_defaults)
+{
+ Evas *e = _setup_evas();
+ Evas_Object *o;
+ int x, y, w, h, iw, ih;
+ Eina_Bool b;
+
+ /* test legacy defaults */
+ o = evas_object_image_add(e);
+ fail_if(evas_object_image_filled_get(o));
+ evas_object_image_fill_get(o, &x, &y, &w, &h);
+ fail_if(x || y || w || h);
+ eo_del(o);
+
+ o = evas_object_image_filled_add(e);
+ fail_if(!evas_object_image_filled_get(o));
+ eo_del(o);
+
+ /* test eo defaults */
+ eo_add(&o, EVAS_IMAGE_CLASS, e);
+ fail_if(!efl_gfx_fill_filled_get(o));
+ eo_del(o);
+
+ evas_free(e);
+ evas_shutdown();
+}
+END_TEST
+
void evas_test_image_object(TCase *tc)
{
+ tcase_add_test(tc, evas_object_image_defaults);
tcase_add_test(tc, evas_object_image_loader);
tcase_add_test(tc, evas_object_image_loader_orientation);
tcase_add_test(tc, evas_object_image_orient);