Fix window position and size issue in low resolution. 82/313882/2 accepted/tizen/unified/20240704.075707 accepted/tizen/unified/dev/20240708.001712 accepted/tizen/unified/x/20240705.012415
authorMd. Farhan Mahtab/NC eXperience Group /SRBD/Engineer/Samsung Electronics <farhan.m1@samsung.com>
Wed, 3 Jul 2024 06:16:06 +0000 (12:16 +0600)
committerMd. Farhan Mahtab/NC eXperience Group /SRBD/Engineer/Samsung Electronics <farhan.m1@samsung.com>
Wed, 3 Jul 2024 06:48:47 +0000 (12:48 +0600)
[Problem] When opening in low resolution the window border is positioned on the left side not centered and window size is not properly adjusted according to resolution.

[Cause & Measure]
 Cause : Window size and position isn't properly initialized and inside CustomBorder Constructor, MinSize is set to default value.
 Measure : Window size, position and  MinSize is properly calculated according to screen size.

Change-Id: Ife04002276ae819f8314dcdc3b740f5f606ed9db
Signed-off-by: Md. Farhan Mahtab/NC eXperience Group /SRBD/Engineer/Samsung Electronics <farhan.m1@samsung.com>
Notifications/Common/AppConstants.cs
Notifications/CustomBorder.cs
Notifications/Notifications.cs
Notifications/core/WindowManager.cs
packaging/org.tizen.notifications-1.0.1.tpk

index 1801f06b39e6da45cc3c129d4e8dae649041fe3b..618eb3341a87fb7acdcb07d1a67ba169b370ebc4 100644 (file)
@@ -40,6 +40,6 @@ namespace Notifications.Common
         public static Extents DetailContentMargin = new Extents(64, 64, 8, 8);
 
         public static float windowHeightRatio = 540f / 1080;
-        public static float windowWidthRation = 960f / 1920;
+        public static float windowWidthRatio = 960f / 1920;
     }
 }
index 26619089d886873a9250500cf25b66cc6956b9f2..c2625d5f15560951ba3e8d1dfa1ed20eba6a3cea 100644 (file)
@@ -38,6 +38,15 @@ namespace Notifications
             MinSize = new Size2D(704, 436);
         }
 
+        public CustomBorder(Size2D screenSize)
+        {
+            ResizePolicy = Window.BorderResizePolicyType.Free;
+            float minWidthRatio = 704.0f / 1920;
+            float minHeightRatio = 436.0f / 1080;
+            int minWidth = (int)(screenSize.Width * minWidthRatio);
+            int minHeight = (int)(screenSize.Height * minHeightRatio);
+            MinSize = new Size2D(minWidth, minHeight);
+        }
         private void OnThemeChanged(object sender, ThemeChangedEventArgs e)
         {
             if (e.IsPlatformThemeChanged)
index 03709e316233502bab7d339bf671a39df02d43c1..857b146f86b424673bbe4be37f9f55bbbc5b2758 100644 (file)
@@ -20,6 +20,7 @@ using System.Globalization;
 using Tizen.NUI;
 using Notifications.Common;
 using Notifications.Core;
+using Tizen.System;
 
 namespace Notifications
 {
@@ -28,7 +29,7 @@ namespace Notifications
         private Window window;
         private ViewManager viewManager;
 
-        public Program() : base(AppConstants.DefaultWindowSize, AppConstants.DefaultWindowPosition, ThemeOptions.PlatformThemeEnabled, new CustomBorder())
+        public Program(Size2D windowSize, Position2D windowPosition, CustomBorder appBorder) : base(windowSize, windowPosition, ThemeOptions.PlatformThemeEnabled, appBorder)
         {
         }
 
@@ -100,7 +101,27 @@ namespace Notifications
 
         static void Main(string[] args)
         {
-            var app = new Program();
+            int positionX, positionY;
+            int width, height;
+
+            _ = Information.TryGetValue("http://tizen.org/feature/screen.width", out int screenWidth);
+            _ = Information.TryGetValue("http://tizen.org/feature/screen.height", out int screenHeight);
+
+            Tizen.Log.Debug(AppConstants.LogTag, "screen width : " + screenWidth);
+            Tizen.Log.Debug(AppConstants.LogTag, "screen height : " + screenHeight);
+
+            Size2D displaySize = new Size2D(screenWidth, screenHeight);
+
+            width = (int)(displaySize.Width * AppConstants.windowWidthRatio);
+            height = (int)(displaySize.Height * AppConstants.windowHeightRatio);
+
+            positionX = (displaySize.Width - width) / 2;
+            positionY = (displaySize.Height - height) / 2;
+
+
+            CustomBorder appBorder = new CustomBorder(displaySize);
+            var app = new Program(new Size2D(width, height), new Position2D(positionX, positionY), appBorder);
+
             app.Run(args);
         }
     }
index f39f18f0ce4b9258023abbc3b46084bd1e95c7f8..e082828755b5035db0a29a8da438b554d4d79d31 100644 (file)
@@ -35,7 +35,7 @@ namespace Notifications.Core
             int positionX, positionY;
             int width, height;
 
-            width = (int)(DeviceInfo.DisplayWidth * AppConstants.windowWidthRation);
+            width = (int)(DeviceInfo.DisplayWidth * AppConstants.windowWidthRatio);
             height = (int)(DeviceInfo.DisplayHeight * AppConstants.windowHeightRatio);
 
             positionX = ((DeviceInfo.IsPortrait ? DeviceInfo.DisplayHeight : DeviceInfo.DisplayWidth) - width) / 2;
index c975e98b279bbf0c33b9c1848ab9b97f05e0ca9c..10bb2f924a5acc2727c45f20d6dce5cb1fa10092 100644 (file)
Binary files a/packaging/org.tizen.notifications-1.0.1.tpk and b/packaging/org.tizen.notifications-1.0.1.tpk differ