bu5hm4n pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=c18327d5df1735b7d18f4d7194692079f3879c6c

commit c18327d5df1735b7d18f4d7194692079f3879c6c
Author: Mike Blumenkrantz <[email protected]>
Date:   Mon Feb 10 11:05:35 2020 -0500

    efl_ui/image: implement efl.player::autoplay for image widgets
    
    this just calls efl.player::playing_set any time autoplay is true and
    the internal image object is preloaded
    
    ref T8589
    
    Reviewed-by: Marcel Hollerbach <[email protected]>
    Differential Revision: https://phab.enlightenment.org/D11306
---
 src/bin/elementary/test_photocam.c                 |  4 +-
 src/lib/elementary/efl_ui_image.c                  | 46 ++++++++++++++++++++--
 src/lib/elementary/efl_ui_image.eo                 |  2 +-
 src/lib/elementary/efl_ui_image_zoomable.c         | 23 +++++++++++
 src/lib/elementary/efl_ui_image_zoomable.eo        |  2 +-
 src/lib/elementary/efl_ui_image_zoomable_private.h |  1 +
 src/lib/elementary/efl_ui_widget_image.h           |  1 +
 7 files changed, 71 insertions(+), 8 deletions(-)

diff --git a/src/bin/elementary/test_photocam.c 
b/src/bin/elementary/test_photocam.c
index de7b827a84..9f357d9ef0 100644
--- a/src/bin/elementary/test_photocam.c
+++ b/src/bin/elementary/test_photocam.c
@@ -153,7 +153,7 @@ my_bt_open(void *data, Evas_Object *obj EINA_UNUSED, void 
*event_info)
 
    if (file && eina_str_has_extension(file, ".gif")
        && efl_playable_get(ph))
-     efl_player_playing_set(ph, EINA_TRUE);
+     efl_player_autoplay_set(ph, EINA_TRUE);
 }
 
 static void
@@ -834,7 +834,7 @@ test_image_zoomable_animated(void *data EINA_UNUSED, 
Evas_Object *obj EINA_UNUSE
    if (efl_playable_get(zoomable))
      {
         printf("animation is available for this image.\n");
-        efl_player_playing_set(zoomable, EINA_TRUE);
+        efl_player_autoplay_set(zoomable, EINA_TRUE);
      }
 
    rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS, win,
diff --git a/src/lib/elementary/efl_ui_image.c 
b/src/lib/elementary/efl_ui_image.c
index 2684b0f364..c1e0eb80f2 100644
--- a/src/lib/elementary/efl_ui_image.c
+++ b/src/lib/elementary/efl_ui_image.c
@@ -103,7 +103,11 @@ _on_image_preloaded(void *data,
    if (sd->show) evas_object_show(obj);
    _prev_img_del(sd);
    err = evas_object_image_load_error_get(obj);
-   if (!err) evas_object_smart_callback_call(sd->self, SIG_LOAD_READY, NULL);
+   if (!err)
+     {
+        evas_object_smart_callback_call(sd->self, SIG_LOAD_READY, NULL);
+        if (sd->autoplay) efl_player_playing_set(sd->self, EINA_TRUE);
+     }
    else evas_object_smart_callback_call(sd->self, SIG_LOAD_ERROR, NULL);
 }
 
@@ -436,7 +440,11 @@ _efl_ui_image_async_open_done(void *data, Ecore_Thread 
*thread)
                               ok = 
!_efl_ui_image_smart_internal_file_set(sd->self, sd);
                          }
                     }
-                  if (ok) evas_object_smart_callback_call(sd->self, 
SIG_LOAD_OPEN, NULL);
+                  if (ok)
+                    {
+                       evas_object_smart_callback_call(sd->self, 
SIG_LOAD_OPEN, NULL);
+                       if (sd->autoplay) efl_player_playing_set(sd->self, 
EINA_TRUE);
+                    }
                   else evas_object_smart_callback_call(sd->self, 
SIG_LOAD_ERROR, NULL);
                }
           }
@@ -528,6 +536,7 @@ _efl_ui_image_edje_file_set(Evas_Object *obj)
      }
    else
      return _efl_ui_image_async_file_set(obj, sd);
+   if (sd->autoplay) efl_player_playing_set(sd->self, EINA_TRUE);
 
    /* FIXME: do i want to update icon on file change ? */
    efl_canvas_group_change(obj);
@@ -1036,7 +1045,10 @@ _efl_ui_image_smart_internal_file_set(Eo *obj, 
Efl_Ui_Image_Data *sd)
      }
 
    if (sd->preload_status == EFL_UI_IMAGE_PRELOAD_DISABLED)
-     _prev_img_del(sd);
+     {
+        _prev_img_del(sd);
+        if (sd->autoplay) efl_player_playing_set(sd->self, EINA_TRUE);
+     }
    else
      {
         evas_object_hide(sd->img);
@@ -1808,6 +1820,29 @@ _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_autoplay_set(Eo *obj, Efl_Ui_Image_Data *sd, 
Eina_Bool autoplay)
+{
+   autoplay = !!autoplay;
+   if (sd->autoplay == autoplay) return;
+   sd->autoplay = autoplay;
+   if (sd->img && (!sd->edje))
+     {
+        /* filter cases where we aren't going to immediately start playing */
+        if (!autoplay) return;
+        if ((sd->preload_status != EFL_UI_IMAGE_PRELOADED) &&
+            (sd->preload_status != EFL_UI_IMAGE_PRELOAD_DISABLED))
+          return;
+     }
+   efl_player_playing_set(obj, EINA_TRUE);
+}
+
+EOLIAN static Eina_Bool
+_efl_ui_image_efl_player_autoplay_get(const Eo *obj EINA_UNUSED, 
Efl_Ui_Image_Data *sd)
+{
+   return sd->autoplay;
+}
+
 EOLIAN static void
 _efl_ui_image_efl_player_playback_speed_set(Eo *obj EINA_UNUSED, 
Efl_Ui_Image_Data *sd, double factor)
 {
@@ -2427,7 +2462,10 @@ elm_image_memfile_set(Evas_Object *obj, const void *img, 
size_t size, const char
      (sd->img, (void *)img, size, (char *)format, (char *)key);
 
    if (sd->preload_status == EFL_UI_IMAGE_PRELOAD_DISABLED)
-     _prev_img_del(sd);
+     {
+        _prev_img_del(sd);
+        if (sd->autoplay) efl_player_playing_set(sd->self, EINA_TRUE);
+     }
    else
      {
         sd->preload_status = EFL_UI_IMAGE_PRELOADING;
diff --git a/src/lib/elementary/efl_ui_image.eo 
b/src/lib/elementary/efl_ui_image.eo
index 3bba17ed4b..392251e4de 100644
--- a/src/lib/elementary/efl_ui_image.eo
+++ b/src/lib/elementary/efl_ui_image.eo
@@ -103,7 +103,7 @@ class Efl.Ui.Image extends Efl.Ui.Widget implements 
Efl.Input.Clickable, Efl.Ui.
       Efl.Player.playback_position { get; set; }
       Efl.Player.playback_progress { get; set; }
       Efl.Player.playback_speed { get; set; }
-      @empty Efl.Player.autoplay { set; get; }
+      Efl.Player.autoplay { set; get; }
       @empty Efl.Player.playback_loop { set; get; }
       Efl.Layout.Signal.signal_emit;
       Efl.Layout.Signal.message_send;
diff --git a/src/lib/elementary/efl_ui_image_zoomable.c 
b/src/lib/elementary/efl_ui_image_zoomable.c
index 55c2daab41..8045ec6363 100644
--- a/src/lib/elementary/efl_ui_image_zoomable.c
+++ b/src/lib/elementary/efl_ui_image_zoomable.c
@@ -728,6 +728,7 @@ _main_img_preloaded_cb(void *data,
    ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
    evas_object_show(sd->img);
    sd->main_load_pending = 0;
+   if (sd->autoplay) efl_player_playing_set(obj, EINA_TRUE);
    g = _grid_create(obj);
    if (g)
      {
@@ -3098,6 +3099,28 @@ _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_autoplay_set(Eo *obj, 
Efl_Ui_Image_Zoomable_Data *sd, Eina_Bool autoplay)
+{
+   autoplay = !!autoplay;
+   if (sd->autoplay == autoplay) return;
+   sd->autoplay = autoplay;
+   if (!sd->edje)
+     {
+        /* filter cases where we aren't going to immediately start playing */
+        if (!autoplay) return;
+        if (sd->preload_num)
+          return;
+     }
+   efl_player_playing_set(obj, EINA_TRUE);
+}
+
+EOLIAN static Eina_Bool
+_efl_ui_image_zoomable_efl_player_autoplay_get(const Eo *obj EINA_UNUSED, 
Efl_Ui_Image_Zoomable_Data *sd)
+{
+   return sd->autoplay;
+}
+
 EOLIAN static Eina_Bool
 _efl_ui_image_zoomable_efl_player_paused_get(const Eo *obj EINA_UNUSED, 
Efl_Ui_Image_Zoomable_Data *sd)
 {
diff --git a/src/lib/elementary/efl_ui_image_zoomable.eo 
b/src/lib/elementary/efl_ui_image_zoomable.eo
index 64dc7a57b7..0cbd8424d9 100644
--- a/src/lib/elementary/efl_ui_image_zoomable.eo
+++ b/src/lib/elementary/efl_ui_image_zoomable.eo
@@ -52,7 +52,7 @@ class Efl.Ui.Image_Zoomable extends Efl.Ui.Image implements 
Efl.Ui.Zoom
       Efl.Player.playback_position { get; set; }
       Efl.Player.playback_progress { get; set; }
       Efl.Player.playback_speed { get; set; }
-      @empty Efl.Player.autoplay { set; get; }
+      Efl.Player.autoplay { set; get; }
       @empty Efl.Player.playback_loop { set; get; }
       Efl.Ui.Zoom.zoom_animation { set; get; }
       Efl.Ui.Zoom.zoom_level { set; get; }
diff --git a/src/lib/elementary/efl_ui_image_zoomable_private.h 
b/src/lib/elementary/efl_ui_image_zoomable_private.h
index e892c1f63c..c5435a27db 100644
--- a/src/lib/elementary/efl_ui_image_zoomable_private.h
+++ b/src/lib/elementary/efl_ui_image_zoomable_private.h
@@ -142,6 +142,7 @@ struct _Efl_Ui_Image_Zoomable_Data
    Eina_Bool    paused : 1;
    Eina_Bool    orientation_changed : 1;
    Eina_Bool    anim : 1;
+   Eina_Bool    autoplay : 1;
    Eina_Bool    freeze_want : 1;
    Eina_Bool    show_item: 1;
 };
diff --git a/src/lib/elementary/efl_ui_widget_image.h 
b/src/lib/elementary/efl_ui_widget_image.h
index de625b28b4..00716b18f1 100644
--- a/src/lib/elementary/efl_ui_widget_image.h
+++ b/src/lib/elementary/efl_ui_widget_image.h
@@ -97,6 +97,7 @@ struct _Efl_Ui_Image_Data
    Eina_Bool             edit : 1;
    Eina_Bool             edje : 1;
    Eina_Bool             anim : 1;
+   Eina_Bool             autoplay : 1;
    Eina_Bool             paused : 1;
    Eina_Bool             async_enable : 1;
    Eina_Bool             scale_up : 1;

-- 


Reply via email to