elementary anim_view: settle up sizing policy. 62/193162/5
authorHermet Park <hermetpark@gmail.com>
Thu, 15 Nov 2018 11:48:35 +0000 (20:48 +0900)
committerJunsuChoi <jsuya.choi@samsung.com>
Mon, 29 Apr 2019 07:20:00 +0000 (16:20 +0900)
If anim_view is not expandable (size_hint_weight => 0, 0),
it keeps default size of vg resource as a min size.

If anim_view is expandable (size_hint_weight => 1, 1),
It resizes vg object as it's object size.

Change-Id: If20e88220e0f9f00ed133d5e844eff3c8adb2104

src/lib/elm_animation_view.c
src/lib/elm_animation_view_legacy.h

index 2fa945d157291bdfef7e6180f157b0d1e8cb3f1d..4a317b87151bd7d751c00cff8971f2860326e54b 100644 (file)
@@ -36,6 +36,32 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
    {NULL, NULL}
 };
 
+static void
+_sizing_eval(void *data)
+{
+   Elm_Animation_View_Data *pd = data;
+   if (!pd->file) return;
+
+   double hw,hh;
+   evas_object_size_hint_weight_get(pd->obj, &hw, &hh);
+
+   int sizew, sizeh;
+   eo_do(pd->vg, evas_obj_vg_default_size_get(&sizew, &sizeh));
+
+   int minw = -1;
+   int minh = -1;
+   if (hw == 0) minw = sizew;
+   if (hh == 0) minh = sizeh;
+
+   evas_object_size_hint_min_set(pd->obj, minw, minh);
+}
+
+static void
+_size_hint_event_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *ev EINA_UNUSED)
+{
+   _sizing_eval(data);
+}
+
 static void
 _transit_go_facade(Elm_Animation_View_Data *pd)
 {
@@ -168,6 +194,7 @@ _elm_animation_view_evas_object_smart_add(Eo *obj, Elm_Animation_View_Data *priv
    // Create vg to render vector animation
    Eo *vg = evas_object_vg_add(evas_object_evas_get(obj));
    elm_widget_resize_object_set(obj, vg, EINA_TRUE);
+   evas_object_event_callback_add(obj, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _size_hint_event_cb, priv);
 
    priv->vg = vg;
    priv->speed = 1;
@@ -244,6 +271,8 @@ _elm_animation_view_efl_file_file_set(Eo *obj EINA_UNUSED, Elm_Animation_View_Da
    pd->file = eina_stringshare_add(file);
    pd->keyframe = 0;
 
+   _sizing_eval(pd);
+
    if (!pd->file)
      {
         pd->state = ELM_ANIMATION_VIEW_STATE_NOT_READY;
@@ -293,7 +322,11 @@ _elm_animation_view_evas_object_smart_show(Eo *obj,
                                             Elm_Animation_View_Data *pd)
 {
    eo_do_super(obj, MY_CLASS, evas_obj_smart_show());
+
+   _sizing_eval(pd);
+
    _auto_play(pd, _visible_check(obj));
+
 }
 
 EOLIAN static void
@@ -489,6 +522,19 @@ _elm_animation_view_duration_time_get(Eo *obj EINA_UNUSED, Elm_Animation_View_Da
    return pd->frame_duration;
 }
 
+EAPI Eina_Size2D
+elm_animation_view_default_size_get(const Elm_Animation_View *obj)
+{
+   Eina_Size2D size = {0, 0};
+
+   ELM_ANIMATION_VIEW_DATA_GET(obj, pd);
+   if (!pd) return size;
+
+   eo_do(pd->vg, evas_obj_vg_default_size_get(&size.w, &size.h));
+
+   return size;
+}
+
 EAPI Elm_Animation_View*
 elm_animation_view_add(Evas_Object *parent)
 {
index 81b585131cbd06441945732ef18042db5eb3e141..4614d6f10f53a6c66b680c879d2654f36794b1ca 100644 (file)
@@ -68,4 +68,18 @@ EAPI Elm_Animation_View_State elm_animation_view_state_get(const Elm_Animation_V
  */
 EAPI Eina_Bool         elm_animation_view_is_playing_back(const Elm_Animation_View *obj);
 
+/**
+ * @brief Get the default view size that specified from vector resource.
+ *
+ * @return default size.
+ *
+ * @since 1.22
+ *
+ * @ingroup Elm_Animation_View
+ */
+
+EAPI Eina_Size2D
+elm_animation_view_default_size_get(const Elm_Animation_View *obj);
+
+
 #include "elm_animation_view.eo.legacy.h"