e_client: added resize aspect ratio 09/275209/1
authorJunseok Kim <juns.kim@samsung.com>
Fri, 29 Apr 2022 07:39:02 +0000 (16:39 +0900)
committerJunseok Kim <juns.kim@samsung.com>
Wed, 18 May 2022 07:17:58 +0000 (16:17 +0900)
added values for resize aspect ratio and adjust to resize handle

Change-Id: I88f218cb4ebb01c7b5c1d5f785560abcccea92cb
Signed-off-by: Junseok Kim <juns.kim@samsung.com>
src/bin/e_client.c
src/bin/e_client.h

index 96716b4..e8f4768 100644 (file)
@@ -1798,15 +1798,16 @@ _e_client_resize_handle(E_Client *ec)
         else
           h = ec->moveinfo.down.h + (ec->mouse.current.my - ec->moveinfo.down.my);
      }
-
    tw = ec->w;
    th = ec->h;
 
-   if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
+   if ((ec->resize_mode == E_POINTER_RESIZE_T) ||
+       (ec->resize_mode == E_POINTER_RESIZE_TL) ||
        (ec->resize_mode == E_POINTER_RESIZE_L) ||
        (ec->resize_mode == E_POINTER_RESIZE_BL))
      x += (tw - w);
-   if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
+   if ((ec->resize_mode == E_POINTER_RESIZE_L) ||
+       (ec->resize_mode == E_POINTER_RESIZE_TL) ||
        (ec->resize_mode == E_POINTER_RESIZE_T) ||
        (ec->resize_mode == E_POINTER_RESIZE_TR))
      y += (th - h);
@@ -1829,11 +1830,32 @@ _e_client_resize_handle(E_Client *ec)
           }
      }
    e_client_resize_limit(ec, &new_w, &new_h);
-   if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
+
+   if (ec->manage_resize.enable_aspect_ratio)
+     {
+        if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
+            (ec->resize_mode == E_POINTER_RESIZE_L) ||
+            (ec->resize_mode == E_POINTER_RESIZE_BL) ||
+            (ec->resize_mode == E_POINTER_RESIZE_TR) ||
+            (ec->resize_mode == E_POINTER_RESIZE_R) ||
+            (ec->resize_mode == E_POINTER_RESIZE_BR))
+          {
+             new_h = (int) ec->manage_resize.ah / ec->manage_resize.aw * new_w;
+          }
+        else if ((ec->resize_mode == E_POINTER_RESIZE_T) ||
+                 (ec->resize_mode == E_POINTER_RESIZE_B))
+          {
+             new_w = (int) ec->manage_resize.aw / ec->manage_resize.ah * new_h;
+          }
+     }
+
+   if ((ec->resize_mode == E_POINTER_RESIZE_T) ||
+       (ec->resize_mode == E_POINTER_RESIZE_TL) ||
        (ec->resize_mode == E_POINTER_RESIZE_L) ||
        (ec->resize_mode == E_POINTER_RESIZE_BL))
      new_x += (w - new_w);
-   if ((ec->resize_mode == E_POINTER_RESIZE_TL) ||
+   if ((ec->resize_mode == E_POINTER_RESIZE_L) ||
+       (ec->resize_mode == E_POINTER_RESIZE_TL) ||
        (ec->resize_mode == E_POINTER_RESIZE_T) ||
        (ec->resize_mode == E_POINTER_RESIZE_TR))
      new_y += (h - new_h);
@@ -4581,6 +4603,8 @@ e_client_new(E_Pixmap *cp, int first_map, int internal)
 
    ec->manage_resize.resize_obj = NULL;
    ec->manage_resize.x = ec->manage_resize.y = ec->manage_resize.w = ec->manage_resize.h = 0;
+   ec->manage_resize.enable_aspect_ratio = EINA_FALSE;
+   ec->manage_resize.aw = ec->manage_resize.ah = 0;
 
    return ec;
 }
index ddf8a86..d576a7c 100644 (file)
@@ -1029,7 +1029,9 @@ struct E_Client
    struct
    {
       int x, y, w, h;
+      Eina_Bool enable_aspect_ratio;
       Evas_Object *resize_obj;
+      float aw, ah;
    } manage_resize;
 };