diff --git a/legacy/elementary/src/lib/elm_image.c b/legacy/elementary/src/lib/elm_image.c index 3926f40e02..229dedff0b 100644 --- a/legacy/elementary/src/lib/elm_image.c +++ b/legacy/elementary/src/lib/elm_image.c @@ -1468,16 +1468,24 @@ _elm_image_aspect_fixed_get(Eo *obj EINA_UNUSED, Elm_Image_Data *sd) return sd->aspect_fixed; } +EAPI Eina_Bool +elm_image_animated_available_get(const Evas_Object *obj) +{ + Eina_Bool ret; + eo_do(obj, ret = efl_player_playable_get()); + return ret; +} + EOLIAN static Eina_Bool -_elm_image_animated_available_get(Eo *obj, Elm_Image_Data *sd) +_elm_image_efl_player_playable_get(Eo *obj, Elm_Image_Data *sd) { if (sd->edje) return EINA_FALSE; return evas_object_image_animated_get(elm_image_object_get(obj)); } -EOLIAN static void -_elm_image_animated_set(Eo *obj, Elm_Image_Data *sd, Eina_Bool anim) +static void +_elm_image_animated_set_internal(Eo *obj, Elm_Image_Data *sd, Eina_Bool anim) { anim = !!anim; if (sd->anim == anim) return; @@ -1511,16 +1519,32 @@ _elm_image_animated_set(Eo *obj, Elm_Image_Data *sd, Eina_Bool anim) return; } -EOLIAN static Eina_Bool -_elm_image_animated_get(Eo *obj EINA_UNUSED, Elm_Image_Data *sd) +static Eina_Bool +_elm_image_animated_get_internal(const Eo *obj EINA_UNUSED, Elm_Image_Data *sd) { if (sd->edje) return edje_object_animation_get(sd->img); return sd->anim; } -EOLIAN static void -_elm_image_animated_play_set(Eo *obj, Elm_Image_Data *sd, Eina_Bool play) +EAPI void +elm_image_animated_set(Evas_Object *obj, Eina_Bool anim) +{ + Elm_Image_Data *sd = eo_data_scope_get(obj, MY_CLASS); + if (!sd) return; + _elm_image_animated_set_internal(obj, sd, anim); +} + +EAPI Eina_Bool +elm_image_animated_get(const Evas_Object *obj) +{ + Elm_Image_Data *sd = eo_data_scope_get(obj, MY_CLASS); + if (!sd) return EINA_FALSE; + return _elm_image_animated_get_internal(obj, sd); +} + +static void +_elm_image_animated_play_set_internal(Eo *obj, Elm_Image_Data *sd, Eina_Bool play) { if (!sd->anim) return; if (sd->play == play) return; @@ -1541,14 +1565,44 @@ _elm_image_animated_play_set(Eo *obj, Elm_Image_Data *sd, Eina_Bool play) } } -EOLIAN static Eina_Bool -_elm_image_animated_play_get(Eo *obj EINA_UNUSED, Elm_Image_Data *sd) +static Eina_Bool +_elm_image_animated_play_get_internal(const Eo *obj EINA_UNUSED, Elm_Image_Data *sd) { if (sd->edje) return edje_object_play_get(sd->img); return sd->play; } +EAPI void +elm_image_animated_play_set(Elm_Image *obj, Eina_Bool play) +{ + Elm_Image_Data *sd = eo_data_scope_get(obj, MY_CLASS); + if (!sd) return; + _elm_image_animated_play_set_internal(obj, sd, play); +} + +EAPI Eina_Bool +elm_image_animated_play_get(const Elm_Image *obj) +{ + Elm_Image_Data *sd = eo_data_scope_get(obj, MY_CLASS); + if (!sd) return EINA_FALSE; + return _elm_image_animated_play_get_internal(obj, sd); +} + +EOLIAN static void +_elm_image_efl_player_play_set(Eo *obj, Elm_Image_Data *sd, Eina_Bool play) +{ + if (play && !_elm_image_animated_get_internal(obj, sd)) + _elm_image_animated_set_internal(obj, sd, play); + _elm_image_animated_play_set_internal(obj, sd, play); +} + +EOLIAN static Eina_Bool +_elm_image_efl_player_play_get(Eo *obj, Elm_Image_Data *sd) +{ + return _elm_image_animated_play_get_internal(obj, sd); +} + static void _elm_image_class_constructor(Eo_Class *klass) { diff --git a/legacy/elementary/src/lib/elm_image.eo b/legacy/elementary/src/lib/elm_image.eo index 19abcce5c7..ec330f93b3 100644 --- a/legacy/elementary/src/lib/elm_image.eo +++ b/legacy/elementary/src/lib/elm_image.eo @@ -1,6 +1,7 @@ class Elm.Image (Elm.Widget, Efl.File, Efl.Image, Evas.Clickable_Interface, Edje.Object, - Elm_Interface_Atspi_Image, Elm_Interface_Atspi_Widget_Action) + Elm_Interface_Atspi_Image, Elm_Interface_Atspi_Widget_Action, + Efl.Player) { eo_prefix: elm_obj_image; methods { @@ -52,50 +53,6 @@ class Elm.Image (Elm.Widget, Efl.File, Efl.Image, Evas.Clickable_Interface, resize_down: bool; /*@ whether resizing down is allowed */ } } - @property animated_play { - set { - /*@ - Start or stop an image object's animation. - - To actually start playing any image object's animation, if it - supports it, one must do something like: - - @code - if (elm_image_animated_available_get(img)) - { - elm_image_animated_set(img, EINA_TRUE); - elm_image_animated_play_set(img, EINA_TRUE); - } - @endcode - - elm_image_animated_set() will enable animation on the image, but - not start it yet. This is the function one uses to start and - stop animations on image objects. - - @see elm_image_animated_available_get() - @see elm_image_animated_set() - @see elm_image_animated_play_get() - - @ingroup Image - @since 1.7 */ - } - get { - /*@ - Get whether an image object is under animation or not. - - @return @c EINA_TRUE, if the image is being animated, @c EINA_FALSE - otherwise. - - @see elm_image_animated_play_get() - - @ingroup Image - @since 1.7 */ - } - values { - play: bool; /*@ @c EINA_TRUE to start the animation, @c EINA_FALSE - otherwise. Default is @c EINA_FALSE. */ - } - } @property resize_up { set { /*@ @@ -182,41 +139,6 @@ class Elm.Image (Elm.Widget, Efl.File, Efl.Image, Evas.Clickable_Interface, otherwise. Default is @c EINA_FALSE. */ } } - @property animated { - set { - /*@ - Set whether an image object (which supports animation) is to - animate itself or not. - - An image object, even if it supports animation, will be displayed - by default without animation. Call this function with @a animated - set to @c EINA_TRUE to enable its animation. To start or stop the - animation, actually, use elm_image_animated_play_set(). - - @see elm_image_animated_get() - @see elm_image_animated_available_get() - @see elm_image_animated_play_set() - - @ingroup Image - @since 1.7 */ - } - get { - /*@ - Get whether an image object has animation enabled or not. - - @return @c EINA_TRUE if the image has animation enabled, - @c EINA_FALSE otherwise. - - @see elm_image_animated_set() - - @ingroup Image - @since 1.7 */ - } - values { - anim: bool; /*@ @c EINA_TRUE if the object is to animate itself, - @c EINA_FALSE otherwise. Default is @c EINA_FALSE. */ - } - } @property scale { set { /*@ @@ -470,26 +392,6 @@ class Elm.Image (Elm.Widget, Efl.File, Efl.Image, Evas.Clickable_Interface, image loader (eg. if @p img is a memory-mapped EET file) */ } } - @property animated_available { - get { - /*@ - Get whether an image object supports animation or not. - - @return @c EINA_TRUE if the image supports animation, - @c EINA_FALSE otherwise. - - This function returns if this Elementary image object's internal - image can be animated. Currently Evas only supports GIF - animation. If the return value is @b EINA_FALSE, other - @c elm_image_animated_xxx API calls won't work. - - @see elm_image_animated_set() - - @ingroup Image - @since 1.7 */ - return: bool; - } - } @property object { get { /*@ @@ -544,6 +446,9 @@ class Elm.Image (Elm.Widget, Efl.File, Efl.Image, Evas.Clickable_Interface, Efl.Image.load_size.get; Efl.Image.smooth_scale.set; Efl.Image.smooth_scale.get; + Efl.Player.playable.get; + Efl.Player.play.set; + Efl.Player.play.get; Edje.Object.signal_emit; Edje.Object.size_min.get; Edje.Object.size_max.get; diff --git a/legacy/elementary/src/lib/elm_image_legacy.h b/legacy/elementary/src/lib/elm_image_legacy.h index 55923c253c..5d6a06f90c 100644 --- a/legacy/elementary/src/lib/elm_image_legacy.h +++ b/legacy/elementary/src/lib/elm_image_legacy.h @@ -112,4 +112,104 @@ EAPI int elm_image_prescale_get(const Evas_Object *obj); */ EAPI Eina_Bool elm_image_mmap_set(Evas_Object *obj, const Eina_File *file, const char *group); +/** + * Start or stop an image object's animation. + * + * To actually start playing any image object's animation, if it + * supports it, one must do something like: + * + * @code + * if (elm_image_animated_available_get(img)) + * { + * elm_image_animated_set(img, EINA_TRUE); + * elm_image_animated_play_set(img, EINA_TRUE); + * } + * @endcode + * + * elm_image_animated_set() will enable animation on the image, but + * not start it yet. This is the function one uses to start and + * stop animations on image objects. + * + * @see elm_image_animated_available_get() + * @see elm_image_animated_set() + * @see elm_image_animated_play_get() + * + * @ingroup Image + * @since 1.7 + * + * @param[in] play @c EINA_TRUE to start the animation, @c EINA_FALSE +otherwise. Default is @c EINA_FALSE. + */ +EAPI void elm_image_animated_play_set(Evas_Object *obj, Eina_Bool play); + +/** + * Get whether an image object is under animation or not. + * + * @return @c EINA_TRUE, if the image is being animated, @c EINA_FALSE + * otherwise. + * + * @see elm_image_animated_play_get() + * + * @ingroup Image + * @since 1.7 + */ +EAPI Eina_Bool elm_image_animated_play_get(const Evas_Object *obj); + +/** + * + * Set whether an image object (which supports animation) is to + * animate itself or not. + * + * An image object, even if it supports animation, will be displayed + * by default without animation. Call this function with @a animated + * set to @c EINA_TRUE to enable its animation. To start or stop the + * animation, actually, use elm_image_animated_play_set(). + * + * @see elm_image_animated_get() + * @see elm_image_animated_available_get() + * @see elm_image_animated_play_set() + * + * @ingroup Image + * @since 1.7 + * + * @param[in] anim @c EINA_TRUE if the object is to animate itself, + * @c EINA_FALSE otherwise. Default is @c EINA_FALSE. + */ +EAPI void elm_image_animated_set(Evas_Object *obj, Eina_Bool anim); + +/** + * + * Get whether an image object has animation enabled or not. + * + * @return @c EINA_TRUE if the image has animation enabled, + * @c EINA_FALSE otherwise. + * + * @see elm_image_animated_set() + * + * @ingroup Image + * @since 1.7 + * + */ +EAPI Eina_Bool elm_image_animated_get(const Evas_Object *obj); + +/** + * + * Get whether an image object supports animation or not. + * + * @return @c EINA_TRUE if the image supports animation, + * @c EINA_FALSE otherwise. + * + * This function returns if this Elementary image object's internal + * image can be animated. Currently Evas only supports GIF + * animation. If the return value is @b EINA_FALSE, other + * @c elm_image_animated_xxx API calls won't work. + * + * @see elm_image_animated_set() + * + * @ingroup Image + * @since 1.7 + * + */ +EAPI Eina_Bool elm_image_animated_available_get(const Evas_Object *obj); + #include "elm_image.eo.legacy.h"