e_desk: add desk_zoom effect 13/237813/3 accepted/tizen/unified/20200709.030133 submit/tizen/20200708.063354
authorDoyoun Kang <doyoun.kang@samsung.com>
Mon, 6 Jul 2020 01:52:30 +0000 (10:52 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 6 Jul 2020 09:23:04 +0000 (09:23 +0000)
Change-Id: I07b4415de3e128f65e4f906d5ae549fcab162255

src/bin/e_config.c
src/bin/e_config.h
src/bin/e_desk.c

index 302f355d3368b6ae08f7ab4e3cf4cd4248ab9564..5a6aabcf1d1ab118d7a39655071b2077f2a0c333 100644 (file)
@@ -306,6 +306,8 @@ _e_config_edd_init(Eina_Bool old)
    E_CONFIG_VAL(D, T, global_object_not_provide.launch_effect, UCHAR);
    E_CONFIG_VAL(D, T, use_thread_max_cpu, UCHAR);
    E_CONFIG_VAL(D, T, use_desk_group, UCHAR);
+   E_CONFIG_VAL(D, T, desk_zoom_effect.enable, UCHAR);
+   E_CONFIG_VAL(D, T, desk_zoom_effect.duration, DOUBLE);
 }
 
 static Eina_Bool
@@ -544,6 +546,8 @@ e_config_load(void)
    E_CONFIG_LIMIT(e_config->global_object_not_provide.launch_effect, 0, 1);
    E_CONFIG_LIMIT(e_config->use_thread_max_cpu, 0, 1);
    E_CONFIG_LIMIT(e_config->use_desk_group, 0, 1);
+   E_CONFIG_LIMIT(e_config->desk_zoom_effect.enable, 0, 1);
+   E_CONFIG_LIMIT(e_config->desk_zoom_effect.duration, 0.0, 10.0);
 }
 
 E_API int
index 2e64fcedf2ca977ddb1bb871bb0530239568c028..475b143b7e5afc5b2060013ba4375732bff7d80a 100644 (file)
@@ -256,6 +256,12 @@ struct _E_Config
 
    Eina_Bool use_thread_max_cpu; //set cpu count to ecore thread max
    Eina_Bool use_desk_group;
+
+   struct
+   {
+      Eina_Bool enable;
+      double    duration;
+   } desk_zoom_effect;
 };
 
 struct _E_Config_Desklock_Background
index c2c0dd22b09cb195668393aaa722562b91efd6a7..f525e6b2471d83e0e7f98d9e80ad6e7c188273e3 100644 (file)
@@ -24,7 +24,10 @@ struct _E_Desk_Smart_Data
    {
       double       ratio_x, ratio_y;
       int          cord_x, cord_y;
+      double       prev_ratio_x, prev_ratio_y;
+      int          prev_cord_x,  prev_cord_y;
       Eina_Bool    enabled;
+      Ecore_Animator *animator;
    } zoom;
 };
 
@@ -917,6 +920,64 @@ e_desk_geometry_set(E_Desk *desk, int x, int y, int w, int h)
    e_comp_render_queue();
 }
 
+static Eina_Bool
+_animator_cb(void *data, double pos)
+{
+   E_Desk *desk;
+   E_Client *ec;
+   Eina_List *l;
+   int cx, cy;
+   double zoomx, zoomy;
+   double progress;
+   double diff_x, diff_y;
+   double cBez[4] = {0.3, 0.0, 0.15, 1.0};
+
+   desk = (E_Desk*)data;
+   if (!desk) return ECORE_CALLBACK_CANCEL;
+
+   E_DESK_SMART_DATA_GET_OR_RETURN(desk->smart_obj, sd) ECORE_CALLBACK_CANCEL;
+
+   progress = ecore_animator_pos_map_n(pos, ECORE_POS_MAP_CUBIC_BEZIER, 4, cBez);
+
+   diff_x = sd->zoom.prev_ratio_x - sd->zoom.ratio_x;
+   diff_y = sd->zoom.prev_ratio_y - sd->zoom.ratio_y;
+
+   zoomx = sd->zoom.ratio_x + (diff_x * (1-progress));
+   zoomy = sd->zoom.ratio_y + (diff_y * (1-progress));
+   cx = sd->zoom.cord_x;
+   cy = sd->zoom.cord_y;
+
+   EINA_LIST_FOREACH(sd->clients, l, ec)
+     {
+        if (ec->visibility.obscured == E_VISIBILITY_UNOBSCURED)
+          _e_desk_client_zoom(ec, zoomx, zoomy, cx, cy);
+     }
+
+   if (pos >= 1.0)
+     {
+        EINA_LIST_FOREACH(sd->clients, l, ec)
+          {
+             _e_desk_client_zoom(ec, zoomx, zoomy, cx, cy);
+          }
+
+        if ((sd->zoom.ratio_x != 1.0) ||
+            (sd->zoom.ratio_y != 1.0))
+          {
+             // Zoom enable done
+             sd->zoom.enabled = EINA_TRUE;
+          }
+        else
+          {
+             // Zoom disable done
+             _e_desk_util_comp_hwc_disable_set(EINA_FALSE);
+          }
+
+        sd->zoom.animator = NULL;
+     }
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
 E_API void
 e_desk_zoom_set(E_Desk *desk, double zoomx, double zoomy, int cx, int cy)
 {
@@ -955,19 +1016,38 @@ e_desk_zoom_set(E_Desk *desk, double zoomx, double zoomy, int cx, int cy)
         if ((sd->zoom.ratio_x != zoomx) || (sd->zoom.ratio_y != zoomy) ||
             (sd->zoom.cord_x != cx) || (sd->zoom.cord_y != cy))
           {
+             sd->zoom.prev_ratio_x = sd->zoom.ratio_x;
+             sd->zoom.prev_ratio_y = sd->zoom.ratio_y;
+             sd->zoom.prev_cord_x = sd->zoom.cord_x;
+             sd->zoom.prev_cord_y = sd->zoom.cord_y;
+
              sd->zoom.ratio_x = zoomx;
              sd->zoom.ratio_y = zoomy;
              sd->zoom.cord_x = cx;
              sd->zoom.cord_y = cy;
 
-             _e_desk_object_zoom(desk->smart_obj, zoomx, zoomy, cx, cy);
-             EINA_LIST_FOREACH(sd->clients, l, ec)
-               _e_desk_client_zoom(ec, zoomx, zoomy, cx, cy);
+             if (e_config->desk_zoom_effect.enable)
+               {
+                  sd->zoom.animator = ecore_animator_timeline_add(e_config->desk_zoom_effect.duration,
+                                                                  _animator_cb, desk);
+                  _e_desk_object_zoom(desk->smart_obj, zoomx, zoomy, cx, cy);
+               }
+             else
+               {
+                  _e_desk_object_zoom(desk->smart_obj, zoomx, zoomy, cx, cy);
+                  EINA_LIST_FOREACH(sd->clients, l, ec)
+                    {
+                       _e_desk_client_zoom(ec, zoomx, zoomy, cx, cy);
+                    }
+               }
           }
 
         if (!sd->zoom.enabled)
           {
-             sd->zoom.enabled = EINA_TRUE;
+             /* if desk_zoom_effect is enabled,
+                then sd->zoom.enabled will be set after finishing effect */
+             if (!e_config->desk_zoom_effect.enable)
+               sd->zoom.enabled = EINA_TRUE;
 
              /*
               * NOTE: evas_object_map_enable_set is called in _e_desk_client_zoom()
@@ -1113,31 +1193,46 @@ e_desk_zoom_unset(E_Desk *desk)
         if (!sd->zoom.enabled)
           goto end;
 
+        sd->zoom.prev_ratio_x = sd->zoom.ratio_x;
+        sd->zoom.prev_ratio_y = sd->zoom.ratio_y;
+        sd->zoom.prev_cord_x = sd->zoom.cord_x;
+        sd->zoom.prev_cord_y = sd->zoom.cord_y;
+
         sd->zoom.ratio_x = 1.0;
         sd->zoom.ratio_y = 1.0;
         sd->zoom.cord_x = 0;
         sd->zoom.cord_y = 0;
         sd->zoom.enabled = EINA_FALSE;
 
-        _e_desk_object_zoom(desk->smart_obj, sd->zoom.ratio_x, sd->zoom.ratio_y,
-                            sd->zoom.cord_x, sd->zoom.cord_y);
-        /*
-         * NOTE: evas_object_map_enable_set is called in _e_desk_client_zoom()
-         */
-        /*
-         * evas_object_map_enable_set(desk->smart_obj, EINA_FALSE);
-         */
-        EINA_LIST_FOREACH(sd->clients, l, ec)
+        if (e_config->desk_zoom_effect.enable)
           {
-             /* NOTE Is it really necessary?
-              * Why isn't it enough to just call evas_object_map_enable_set(false)? */
-             _e_desk_client_zoom(ec, sd->zoom.ratio_x, sd->zoom.ratio_y,
+             sd->zoom.animator = ecore_animator_timeline_add(e_config->desk_zoom_effect.duration,
+                                                             _animator_cb, desk);
+             _e_desk_object_zoom(desk->smart_obj, sd->zoom.ratio_x, sd->zoom.ratio_y,
                                  sd->zoom.cord_x, sd->zoom.cord_y);
-             //evas_object_map_enable_set(ec->frame, EINA_FALSE);
           }
+        else
+          {
+             _e_desk_object_zoom(desk->smart_obj, sd->zoom.ratio_x, sd->zoom.ratio_y,
+                                 sd->zoom.cord_x, sd->zoom.cord_y);
+             /*
+              * NOTE: evas_object_map_enable_set is called in _e_desk_client_zoom()
+              */
+             /*
+              * evas_object_map_enable_set(desk->smart_obj, EINA_FALSE);
+              */
+             EINA_LIST_FOREACH(sd->clients, l, ec)
+               {
+                  /* NOTE Is it really necessary?
+                   * Why isn't it enough to just call evas_object_map_enable_set(false)? */
+                  _e_desk_client_zoom(ec, sd->zoom.ratio_x, sd->zoom.ratio_y,
+                                      sd->zoom.cord_x, sd->zoom.cord_y);
+                  //evas_object_map_enable_set(ec->frame, EINA_FALSE);
+               }
 
-        /* FIXME TEMP enable hwc */
-        _e_desk_util_comp_hwc_disable_set(EINA_FALSE);
+             /* FIXME TEMP enable hwc */
+             _e_desk_util_comp_hwc_disable_set(EINA_FALSE);
+          }
      }
 
 end:
@@ -1441,6 +1536,9 @@ _e_desk_smart_client_cb_resize(void *data, int type, void *event)
    if (!eina_list_data_find(sd->clients, ec))
      goto end;
 
+   if (sd->zoom.animator)
+     goto end;
+
    if (sd->zoom.enabled)
      _e_desk_client_zoom(ec,
                          sd->zoom.ratio_x, sd->zoom.ratio_y,