summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitor Sousa <vitorsousasilva@gmail.com>2015-06-17 10:17:19 +0100
committerTom Hacohen <tom@stosb.com>2015-06-17 10:17:19 +0100
commitc9a36897b14e1674d9b7b7024bbdfcce9a5313e4 (patch)
treee3b9cc770d35b0c3deb5b2ca081178d58d39a502
parent6a47667680d5928e949a8fe8dd7769a4856a2801 (diff)
elm_image: Solve clash on the meaning of "animated"
Summary: Both Elm_Image and its base interface Efl.Image have a property named "animated". The meaning for Efl.Image is whether or not the image has animation. On the other hand, Elm_Image use it to set whether an image, which supports animation, is to animate itself or not. Thus Elm_Image have another property (animated_available) to tell whether the image have animation or not, making it even more confusing. Renamed the "animated" property of Elm_Image to "animated_enable" to make the intended meaning clearer. Also replaced the "animated_available" property with the "animated" property from the Efl.Image interface, since both refers to the same thing, in order to reduce the API. Added implementations of the legacy methods for backward compatibility. Address the issue: - Elm image and the image interface clash because of the meaning of "animated". Specified in the page: https://phab.enlightenment.org/w/efl_interfaces/ Reviewers: felipealmeida, tasn Subscribers: raster Differential Revision: https://phab.enlightenment.org/D2354
-rw-r--r--src/lib/elm_image.c72
-rw-r--r--src/lib/elm_image.eo105
-rw-r--r--src/lib/elm_image_legacy.h100
3 files changed, 168 insertions, 109 deletions
diff --git a/src/lib/elm_image.c b/src/lib/elm_image.c
index 3926f40e0..229dedff0 100644
--- a/src/lib/elm_image.c
+++ b/src/lib/elm_image.c
@@ -1468,16 +1468,24 @@ _elm_image_aspect_fixed_get(Eo *obj EINA_UNUSED, Elm_Image_Data *sd)
1468 return sd->aspect_fixed; 1468 return sd->aspect_fixed;
1469} 1469}
1470 1470
1471EAPI Eina_Bool
1472elm_image_animated_available_get(const Evas_Object *obj)
1473{
1474 Eina_Bool ret;
1475 eo_do(obj, ret = efl_player_playable_get());
1476 return ret;
1477}
1478
1471EOLIAN static Eina_Bool 1479EOLIAN static Eina_Bool
1472_elm_image_animated_available_get(Eo *obj, Elm_Image_Data *sd) 1480_elm_image_efl_player_playable_get(Eo *obj, Elm_Image_Data *sd)
1473{ 1481{
1474 if (sd->edje) return EINA_FALSE; 1482 if (sd->edje) return EINA_FALSE;
1475 1483
1476 return evas_object_image_animated_get(elm_image_object_get(obj)); 1484 return evas_object_image_animated_get(elm_image_object_get(obj));
1477} 1485}
1478 1486
1479EOLIAN static void 1487static void
1480_elm_image_animated_set(Eo *obj, Elm_Image_Data *sd, Eina_Bool anim) 1488_elm_image_animated_set_internal(Eo *obj, Elm_Image_Data *sd, Eina_Bool anim)
1481{ 1489{
1482 anim = !!anim; 1490 anim = !!anim;
1483 if (sd->anim == anim) return; 1491 if (sd->anim == anim) return;
@@ -1511,16 +1519,32 @@ _elm_image_animated_set(Eo *obj, Elm_Image_Data *sd, Eina_Bool anim)
1511 return; 1519 return;
1512} 1520}
1513 1521
1514EOLIAN static Eina_Bool 1522static Eina_Bool
1515_elm_image_animated_get(Eo *obj EINA_UNUSED, Elm_Image_Data *sd) 1523_elm_image_animated_get_internal(const Eo *obj EINA_UNUSED, Elm_Image_Data *sd)
1516{ 1524{
1517 if (sd->edje) 1525 if (sd->edje)
1518 return edje_object_animation_get(sd->img); 1526 return edje_object_animation_get(sd->img);
1519 return sd->anim; 1527 return sd->anim;
1520} 1528}
1521 1529
1522EOLIAN static void 1530EAPI void
1523_elm_image_animated_play_set(Eo *obj, Elm_Image_Data *sd, Eina_Bool play) 1531elm_image_animated_set(Evas_Object *obj, Eina_Bool anim)
1532{
1533 Elm_Image_Data *sd = eo_data_scope_get(obj, MY_CLASS);
1534 if (!sd) return;
1535 _elm_image_animated_set_internal(obj, sd, anim);
1536}
1537
1538EAPI Eina_Bool
1539elm_image_animated_get(const Evas_Object *obj)
1540{
1541 Elm_Image_Data *sd = eo_data_scope_get(obj, MY_CLASS);
1542 if (!sd) return EINA_FALSE;
1543 return _elm_image_animated_get_internal(obj, sd);
1544}
1545
1546static void
1547_elm_image_animated_play_set_internal(Eo *obj, Elm_Image_Data *sd, Eina_Bool play)
1524{ 1548{
1525 if (!sd->anim) return; 1549 if (!sd->anim) return;
1526 if (sd->play == play) return; 1550 if (sd->play == play) return;
@@ -1541,14 +1565,44 @@ _elm_image_animated_play_set(Eo *obj, Elm_Image_Data *sd, Eina_Bool play)
1541 } 1565 }
1542} 1566}
1543 1567
1544EOLIAN static Eina_Bool 1568static Eina_Bool
1545_elm_image_animated_play_get(Eo *obj EINA_UNUSED, Elm_Image_Data *sd) 1569_elm_image_animated_play_get_internal(const Eo *obj EINA_UNUSED, Elm_Image_Data *sd)
1546{ 1570{
1547 if (sd->edje) 1571 if (sd->edje)
1548 return edje_object_play_get(sd->img); 1572 return edje_object_play_get(sd->img);
1549 return sd->play; 1573 return sd->play;
1550} 1574}
1551 1575
1576EAPI void
1577elm_image_animated_play_set(Elm_Image *obj, Eina_Bool play)
1578{
1579 Elm_Image_Data *sd = eo_data_scope_get(obj, MY_CLASS);
1580 if (!sd) return;
1581 _elm_image_animated_play_set_internal(obj, sd, play);
1582}
1583
1584EAPI Eina_Bool
1585elm_image_animated_play_get(const Elm_Image *obj)
1586{
1587 Elm_Image_Data *sd = eo_data_scope_get(obj, MY_CLASS);
1588 if (!sd) return EINA_FALSE;
1589 return _elm_image_animated_play_get_internal(obj, sd);
1590}
1591
1592EOLIAN static void
1593_elm_image_efl_player_play_set(Eo *obj, Elm_Image_Data *sd, Eina_Bool play)
1594{
1595 if (play && !_elm_image_animated_get_internal(obj, sd))
1596 _elm_image_animated_set_internal(obj, sd, play);
1597 _elm_image_animated_play_set_internal(obj, sd, play);
1598}
1599
1600EOLIAN static Eina_Bool
1601_elm_image_efl_player_play_get(Eo *obj, Elm_Image_Data *sd)
1602{
1603 return _elm_image_animated_play_get_internal(obj, sd);
1604}
1605
1552static void 1606static void
1553_elm_image_class_constructor(Eo_Class *klass) 1607_elm_image_class_constructor(Eo_Class *klass)
1554{ 1608{
diff --git a/src/lib/elm_image.eo b/src/lib/elm_image.eo
index 19abcce5c..ec330f93b 100644
--- a/src/lib/elm_image.eo
+++ b/src/lib/elm_image.eo
@@ -1,6 +1,7 @@
1class Elm.Image (Elm.Widget, Efl.File, Efl.Image, Evas.Clickable_Interface, 1class Elm.Image (Elm.Widget, Efl.File, Efl.Image, Evas.Clickable_Interface,
2 Edje.Object, 2 Edje.Object,
3 Elm_Interface_Atspi_Image, Elm_Interface_Atspi_Widget_Action) 3 Elm_Interface_Atspi_Image, Elm_Interface_Atspi_Widget_Action,
4 Efl.Player)
4{ 5{
5 eo_prefix: elm_obj_image; 6 eo_prefix: elm_obj_image;
6 methods { 7 methods {
@@ -52,50 +53,6 @@ class Elm.Image (Elm.Widget, Efl.File, Efl.Image, Evas.Clickable_Interface,
52 resize_down: bool; /*@ whether resizing down is allowed */ 53 resize_down: bool; /*@ whether resizing down is allowed */
53 } 54 }
54 } 55 }
55 @property animated_play {
56 set {
57 /*@
58 Start or stop an image object's animation.
59
60 To actually start playing any image object's animation, if it
61 supports it, one must do something like:
62
63 @code
64 if (elm_image_animated_available_get(img))
65 {
66 elm_image_animated_set(img, EINA_TRUE);
67 elm_image_animated_play_set(img, EINA_TRUE);
68 }
69 @endcode
70
71 elm_image_animated_set() will enable animation on the image, <b>but
72 not start it yet</b>. This is the function one uses to start and
73 stop animations on image objects.
74
75 @see elm_image_animated_available_get()
76 @see elm_image_animated_set()
77 @see elm_image_animated_play_get()
78
79 @ingroup Image
80 @since 1.7 */
81 }
82 get {
83 /*@
84 Get whether an image object is under animation or not.
85
86 @return @c EINA_TRUE, if the image is being animated, @c EINA_FALSE
87 otherwise.
88
89 @see elm_image_animated_play_get()
90
91 @ingroup Image
92 @since 1.7 */
93 }
94 values {
95 play: bool; /*@ @c EINA_TRUE to start the animation, @c EINA_FALSE
96 otherwise. Default is @c EINA_FALSE. */
97 }
98 }
99 @property resize_up { 56 @property resize_up {
100 set { 57 set {
101 /*@ 58 /*@
@@ -182,41 +139,6 @@ class Elm.Image (Elm.Widget, Efl.File, Efl.Image, Evas.Clickable_Interface,
182 otherwise. Default is @c EINA_FALSE. */ 139 otherwise. Default is @c EINA_FALSE. */
183 } 140 }
184 } 141 }
185 @property animated {
186 set {
187 /*@
188 Set whether an image object (which supports animation) is to
189 animate itself or not.
190
191 An image object, even if it supports animation, will be displayed
192 by default without animation. Call this function with @a animated
193 set to @c EINA_TRUE to enable its animation. To start or stop the
194 animation, actually, use elm_image_animated_play_set().
195
196 @see elm_image_animated_get()
197 @see elm_image_animated_available_get()
198 @see elm_image_animated_play_set()
199
200 @ingroup Image
201 @since 1.7 */
202 }
203 get {
204 /*@
205 Get whether an image object has animation enabled or not.
206
207 @return @c EINA_TRUE if the image has animation enabled,
208 @c EINA_FALSE otherwise.
209
210 @see elm_image_animated_set()
211
212 @ingroup Image
213 @since 1.7 */
214 }
215 values {
216 anim: bool; /*@ @c EINA_TRUE if the object is to animate itself,
217 @c EINA_FALSE otherwise. Default is @c EINA_FALSE. */
218 }
219 }
220 @property scale { 142 @property scale {
221 set { 143 set {
222 /*@ 144 /*@
@@ -470,26 +392,6 @@ class Elm.Image (Elm.Widget, Efl.File, Efl.Image, Evas.Clickable_Interface,
470 image loader (eg. if @p img is a memory-mapped EET file) */ 392 image loader (eg. if @p img is a memory-mapped EET file) */
471 } 393 }
472 } 394 }
473 @property animated_available {
474 get {
475 /*@
476 Get whether an image object supports animation or not.
477
478 @return @c EINA_TRUE if the image supports animation,
479 @c EINA_FALSE otherwise.
480
481 This function returns if this Elementary image object's internal
482 image can be animated. Currently Evas only supports GIF
483 animation. If the return value is @b EINA_FALSE, other
484 @c elm_image_animated_xxx API calls won't work.
485
486 @see elm_image_animated_set()
487
488 @ingroup Image
489 @since 1.7 */
490 return: bool;
491 }
492 }
493 @property object { 395 @property object {
494 get { 396 get {
495 /*@ 397 /*@
@@ -544,6 +446,9 @@ class Elm.Image (Elm.Widget, Efl.File, Efl.Image, Evas.Clickable_Interface,
544 Efl.Image.load_size.get; 446 Efl.Image.load_size.get;
545 Efl.Image.smooth_scale.set; 447 Efl.Image.smooth_scale.set;
546 Efl.Image.smooth_scale.get; 448 Efl.Image.smooth_scale.get;
449 Efl.Player.playable.get;
450 Efl.Player.play.set;
451 Efl.Player.play.get;
547 Edje.Object.signal_emit; 452 Edje.Object.signal_emit;
548 Edje.Object.size_min.get; 453 Edje.Object.size_min.get;
549 Edje.Object.size_max.get; 454 Edje.Object.size_max.get;
diff --git a/src/lib/elm_image_legacy.h b/src/lib/elm_image_legacy.h
index 55923c253..5d6a06f90 100644
--- a/src/lib/elm_image_legacy.h
+++ b/src/lib/elm_image_legacy.h
@@ -112,4 +112,104 @@ EAPI int elm_image_prescale_get(const Evas_Object *obj);
112 */ 112 */
113EAPI Eina_Bool elm_image_mmap_set(Evas_Object *obj, const Eina_File *file, const char *group); 113EAPI Eina_Bool elm_image_mmap_set(Evas_Object *obj, const Eina_File *file, const char *group);
114 114
115/**
116 * Start or stop an image object's animation.
117 *
118 * To actually start playing any image object's animation, if it
119 * supports it, one must do something like:
120 *
121 * @code
122 * if (elm_image_animated_available_get(img))
123 * {
124 * elm_image_animated_set(img, EINA_TRUE);
125 * elm_image_animated_play_set(img, EINA_TRUE);
126 * }
127 * @endcode
128 *
129 * elm_image_animated_set() will enable animation on the image, <b>but
130 * not start it yet</b>. This is the function one uses to start and
131 * stop animations on image objects.
132 *
133 * @see elm_image_animated_available_get()
134 * @see elm_image_animated_set()
135 * @see elm_image_animated_play_get()
136 *
137 * @ingroup Image
138 * @since 1.7
139 *
140 * @param[in] play @c EINA_TRUE to start the animation, @c EINA_FALSE
141otherwise. Default is @c EINA_FALSE.
142 */
143EAPI void elm_image_animated_play_set(Evas_Object *obj, Eina_Bool play);
144
145/**
146 * Get whether an image object is under animation or not.
147 *
148 * @return @c EINA_TRUE, if the image is being animated, @c EINA_FALSE
149 * otherwise.
150 *
151 * @see elm_image_animated_play_get()
152 *
153 * @ingroup Image
154 * @since 1.7
155 */
156EAPI Eina_Bool elm_image_animated_play_get(const Evas_Object *obj);
157
158/**
159 *
160 * Set whether an image object (which supports animation) is to
161 * animate itself or not.
162 *
163 * An image object, even if it supports animation, will be displayed
164 * by default without animation. Call this function with @a animated
165 * set to @c EINA_TRUE to enable its animation. To start or stop the
166 * animation, actually, use elm_image_animated_play_set().
167 *
168 * @see elm_image_animated_get()
169 * @see elm_image_animated_available_get()
170 * @see elm_image_animated_play_set()
171 *
172 * @ingroup Image
173 * @since 1.7
174 *
175 * @param[in] anim @c EINA_TRUE if the object is to animate itself,
176 * @c EINA_FALSE otherwise. Default is @c EINA_FALSE.
177 */
178EAPI void elm_image_animated_set(Evas_Object *obj, Eina_Bool anim);
179
180/**
181 *
182 * Get whether an image object has animation enabled or not.
183 *
184 * @return @c EINA_TRUE if the image has animation enabled,
185 * @c EINA_FALSE otherwise.
186 *
187 * @see elm_image_animated_set()
188 *
189 * @ingroup Image
190 * @since 1.7
191 *
192 */
193EAPI Eina_Bool elm_image_animated_get(const Evas_Object *obj);
194
195/**
196 *
197 * Get whether an image object supports animation or not.
198 *
199 * @return @c EINA_TRUE if the image supports animation,
200 * @c EINA_FALSE otherwise.
201 *
202 * This function returns if this Elementary image object's internal
203 * image can be animated. Currently Evas only supports GIF
204 * animation. If the return value is @b EINA_FALSE, other
205 * @c elm_image_animated_xxx API calls won't work.
206 *
207 * @see elm_image_animated_set()
208 *
209 * @ingroup Image
210 * @since 1.7
211 *
212 */
213EAPI Eina_Bool elm_image_animated_available_get(const Evas_Object *obj);
214
115#include "elm_image.eo.legacy.h" 215#include "elm_image.eo.legacy.h"