efl_ui/image: implement efl.player::playback_loop property

this enables the existing looping functionality only when playback_loop
is set (which is always set for legacy widgets)

fix T8589

Reviewed-by: Marcel Hollerbach <mail@marcel-hollerbach.de>
Differential Revision: https://phab.enlightenment.org/D11308
This commit is contained in:
Mike Blumenkrantz 2020-02-10 12:11:03 -05:00 committed by Marcel Hollerbach
parent df561eb725
commit 831d445cc0
7 changed files with 58 additions and 9 deletions

View File

@ -150,10 +150,6 @@ my_bt_open(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
eina_list_free(grps);
}
if (file && eina_str_has_extension(file, ".gif")
&& efl_playable_get(ph))
efl_player_autoplay_set(ph, EINA_TRUE);
}
static void
@ -835,6 +831,7 @@ test_image_zoomable_animated(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSE
{
printf("animation is available for this image.\n");
efl_player_autoplay_set(zoomable, EINA_TRUE);
efl_player_playback_loop_set(zoomable, EINA_TRUE);
}
rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS, win,

View File

@ -137,7 +137,16 @@ _efl_ui_image_animate_cb(void *data)
sd->cur_frame++;
if ((sd->frame_count > 0) && (sd->cur_frame > sd->frame_count))
sd->cur_frame = sd->cur_frame % sd->frame_count;
{
if (sd->playback_loop)
sd->cur_frame = sd->cur_frame % sd->frame_count;
else
{
sd->anim_timer = NULL;
sd->cur_frame = 0;
return EINA_FALSE;
}
}
evas_object_image_animated_frame_set(sd->img, sd->cur_frame);
@ -593,6 +602,7 @@ _efl_ui_image_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Image_Data *priv)
{
evas_object_event_callback_add
(priv->hit_rect, EVAS_CALLBACK_MOUSE_UP, _on_mouse_up, obj);
priv->playback_loop = EINA_TRUE;
}
else
{
@ -1753,6 +1763,7 @@ _efl_ui_image_animated_set_internal(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool an
{
edje_object_animation_set(sd->img, anim);
sd->anim = anim;
efl_player_playback_loop_set(sd->img, sd->playback_loop);
return EINA_TRUE;
}
sd->img = elm_image_object_get(obj);
@ -1820,6 +1831,19 @@ _efl_ui_image_efl_player_playing_get(const Eo *obj, Efl_Ui_Image_Data *sd)
return _efl_ui_image_animated_get_internal(obj, sd);
}
EOLIAN static void
_efl_ui_image_efl_player_playback_loop_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, Eina_Bool playback_loop)
{
playback_loop = !!playback_loop;
sd->playback_loop = playback_loop;
}
EOLIAN static Eina_Bool
_efl_ui_image_efl_player_playback_loop_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
{
return sd->playback_loop;
}
EOLIAN static void
_efl_ui_image_efl_player_autoplay_set(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool autoplay)
{

View File

@ -104,7 +104,7 @@ class Efl.Ui.Image extends Efl.Ui.Widget implements Efl.Input.Clickable, Efl.Ui.
Efl.Player.playback_progress { get; set; }
Efl.Player.playback_speed { get; set; }
Efl.Player.autoplay { set; get; }
@empty Efl.Player.playback_loop { set; get; }
Efl.Player.playback_loop { set; get; }
Efl.Layout.Signal.signal_emit;
Efl.Layout.Signal.message_send;
Efl.Layout.Signal.signal_callback_add;

View File

@ -1835,7 +1835,10 @@ _efl_ui_image_zoomable_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Image_Zoomable
efl_ui_scroll_manager_pan_set(priv->smanager, priv->pan_obj);
if (elm_widget_is_legacy(obj))
edje_object_part_swallow(edje, "elm.swallow.content", priv->pan_obj);
{
edje_object_part_swallow(edje, "elm.swallow.content", priv->pan_obj);
priv->playback_loop = EINA_TRUE;
}
else
edje_object_part_swallow(edje, "efl.content", priv->pan_obj);
@ -3012,7 +3015,16 @@ _efl_ui_image_zoomable_animate_cb(void *data)
sd->cur_frame++;
if ((sd->frame_count > 0) && (sd->cur_frame > sd->frame_count))
sd->cur_frame = sd->cur_frame % sd->frame_count;
{
if (sd->playback_loop)
sd->cur_frame = sd->cur_frame % sd->frame_count;
else
{
sd->anim_timer = NULL;
sd->cur_frame = 0;
return EINA_FALSE;
}
}
evas_object_image_animated_frame_set(sd->img, sd->cur_frame);
sd->frame_duration = evas_object_image_animated_frame_duration_get
@ -3034,6 +3046,7 @@ _efl_ui_image_zoomable_animated_set_internal(Eo *obj EINA_UNUSED, Efl_Ui_Image_Z
{
sd->anim = anim;
edje_object_animation_set(sd->edje, anim);
efl_player_playback_loop_set(sd->edje, sd->playback_loop);
return EINA_TRUE;
}
@ -3103,6 +3116,19 @@ _efl_ui_image_zoomable_efl_player_playing_get(const Eo *obj, Efl_Ui_Image_Zoomab
return _efl_ui_image_zoomable_animated_get_internal(obj, sd);
}
EOLIAN static void
_efl_ui_image_zoomable_efl_player_playback_loop_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd, Eina_Bool playback_loop)
{
playback_loop = !!playback_loop;
sd->playback_loop = playback_loop;
}
EOLIAN static Eina_Bool
_efl_ui_image_zoomable_efl_player_playback_loop_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Zoomable_Data *sd)
{
return sd->playback_loop;
}
EOLIAN static void
_efl_ui_image_zoomable_efl_player_autoplay_set(Eo *obj, Efl_Ui_Image_Zoomable_Data *sd, Eina_Bool autoplay)
{

View File

@ -53,7 +53,7 @@ class Efl.Ui.Image_Zoomable extends Efl.Ui.Image implements Efl.Ui.Zoom
Efl.Player.playback_progress { get; set; }
Efl.Player.playback_speed { get; set; }
Efl.Player.autoplay { set; get; }
@empty Efl.Player.playback_loop { set; get; }
Efl.Player.playback_loop { set; get; }
Efl.Ui.Zoom.zoom_animation { set; get; }
Efl.Ui.Zoom.zoom_level { set; get; }
Efl.Ui.Zoom.zoom_mode { set; get; }

View File

@ -143,6 +143,7 @@ struct _Efl_Ui_Image_Zoomable_Data
Eina_Bool orientation_changed : 1;
Eina_Bool anim : 1;
Eina_Bool autoplay : 1;
Eina_Bool playback_loop : 1;
Eina_Bool freeze_want : 1;
Eina_Bool show_item: 1;
};

View File

@ -98,6 +98,7 @@ struct _Efl_Ui_Image_Data
Eina_Bool edje : 1;
Eina_Bool anim : 1;
Eina_Bool autoplay : 1;
Eina_Bool playback_loop : 1;
Eina_Bool paused : 1;
Eina_Bool async_enable : 1;
Eina_Bool scale_up : 1;