Apply scalable pixel.
authorPiotr Czaja/Advanced Frameworks (PLT) /SRPOL/Engineer/Samsung Electronics <p.czaja@samsung.com>
Tue, 8 Mar 2022 11:07:25 +0000 (12:07 +0100)
committerPiotr Czaja <p.czaja@samsung.com>
Thu, 23 Jun 2022 12:37:27 +0000 (14:37 +0200)
Fitness/Fitness.csproj
Fitness/Views/DpUtils.cs [deleted file]
Fitness/Views/ExtentsInDpExtension.cs
Fitness/Views/PixelSizeInDpExtension.cs
Fitness/Views/PositionInDpExtension.cs
Fitness/Views/SizeInDpExtension.cs
Fitness/Views/SpUtils.cs [new file with mode: 0644]
Fitness/Views/Styles/BigLightButtonStyle.cs
Fitness/Views/Styles/DirectionButtonStyle.cs
Fitness/Views/Styles/NinePatchButtonStyle.cs

index 1c9d378445c763b70c3424dc5d01ebf34cdcb400..e88bbf8fa391c3dcb9c80a4767e9ca6d85e4ca5c 100644 (file)
@@ -2,7 +2,7 @@
 
   <PropertyGroup>
     <OutputType>Exe</OutputType>
-    <TargetFramework>tizen90</TargetFramework>
+    <TargetFramework>tizen10.0</TargetFramework>
     <TargetFrameworkIdentifier>Tizen</TargetFrameworkIdentifier>
     <CodeAnalysisRuleSet>Settings.StyleCop</CodeAnalysisRuleSet>
   </PropertyGroup>
@@ -21,7 +21,7 @@
 
   <ItemGroup>
     <PackageReference Include="Tizen.NET.Sdk" Version="1.1.2" />
-    <PackageReference Include="Tizen.NET" Version="9.0.0.16751" />
+    <PackageReference Include="Tizen.NET" Version="10.0.0.17007" />
     <PackageReference Include="Tizen.NUI.XamlBuild" Version="1.0.11" />
     <PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
       <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@@ -37,5 +37,9 @@
     <EmbeddedResource Include="res\layout\*.xaml" />
   </ItemGroup>
 
+  <PropertyGroup>
+      <NeedInjection>False</NeedInjection>
+  </PropertyGroup>
+
 </Project>
 
diff --git a/Fitness/Views/DpUtils.cs b/Fitness/Views/DpUtils.cs
deleted file mode 100644 (file)
index 49629e2..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-using System;
-using Tizen.NUI;
-
-namespace Fitness.Views
-{
-    /// <summary>
-    /// Utils for converting dp pixels.
-    /// </summary>
-    public static class DpUtils
-    {
-        private const float DpPixelDivider = 1.48125f;
-
-        /// <summary>
-        /// Converts dp pixels into pixels.
-        /// </summary>
-        /// <param name="pixels">The number of dp pixels.</param>
-        /// <returns>The number of pixels.</returns>
-        public static int DpToPixels(int pixels)
-        {
-            return (int)Math.Round(DpTypeConverter.Instance.ConvertToPixel(pixels / DpPixelDivider), MidpointRounding.AwayFromZero);
-        }
-
-        /// <summary>
-        /// Converts dp pixels into pixels.
-        /// </summary>
-        /// <param name="pixels">The number of dp pixels.</param>
-        /// <returns>The number of pixels.</returns>
-        public static ushort DpToPixels(ushort pixels)
-        {
-            return (ushort)Math.Round(DpTypeConverter.Instance.ConvertToPixel(pixels / DpPixelDivider), MidpointRounding.AwayFromZero);
-        }
-
-        /// <summary>
-        /// Converts dp pixels into pixels.
-        /// </summary>
-        /// <param name="pixels">The number of dp pixels.</param>
-        /// <returns>The number of pixels.</returns>
-        public static float DpToPixels(float pixels)
-        {
-            return DpTypeConverter.Instance.ConvertToPixel(pixels / DpPixelDivider);
-        }
-
-        /// <summary>
-        /// Converts dp pixels into pixels.
-        /// </summary>
-        /// <param name="size">The size to be converted to pixels.</param>
-        /// <returns>The number of pixels.</returns>
-        public static Size2D DpToPixels(Size2D size)
-        {
-            return new Size2D(DpToPixels(size.Width), DpToPixels(size.Height));
-        }
-
-        /// <summary>
-        /// Converts dp pixels into pixels.
-        /// </summary>
-        /// <param name="extents">The extents collection to be converted to pixels.</param>
-        /// <returns>The number of pixels.</returns>
-        public static Extents DpToPixels(Extents extents)
-        {
-            return new Extents(DpToPixels(extents.Start), DpToPixels(extents.End), DpToPixels(extents.Top), DpToPixels(extents.Bottom));
-        }
-    }
-}
index 173379c8793292c41b58f806ba3391dd847338c8..1f32eabe69dfacac2e565c1e2ad0f519e6216c11 100644 (file)
@@ -48,7 +48,7 @@ namespace Fitness.Views
         /// <inheritdoc/>
         public object ProvideValue(IServiceProvider serviceProvider)
         {
-            return new Extents(DpUtils.DpToPixels(Start), DpUtils.DpToPixels(End), DpUtils.DpToPixels(Top), DpUtils.DpToPixels(Bottom));
+            return new Extents(SpUtils.SpToPixels(Start), SpUtils.SpToPixels(End), SpUtils.SpToPixels(Top), SpUtils.SpToPixels(Bottom));
         }
     }
 }
index dae28cf81fc2daeaa95aef6f692875ca08e62ff5..81c85f476bce9b55d9fff739a2e11ffdc66ce0f5 100644 (file)
@@ -45,7 +45,7 @@ namespace Fitness.Views
         /// <inheritdoc/>
         public object ProvideValue(IServiceProvider serviceProvider)
         {
-            return DpUtils.DpToPixels(DpSize);
+            return SpUtils.SpToPixels(DpSize);
         }
     }
 }
index 333cc678dd2bfcfe073119c3ee02d9113f579bfa..e0c76e1af95d1c10dcd77b0dc75ac61fe1122946 100644 (file)
@@ -54,7 +54,7 @@ namespace Fitness.Views
         /// <inheritdoc/>
         public object ProvideValue(IServiceProvider serviceProvider)
         {
-            return new Position(DpUtils.DpToPixels(X), DpUtils.DpToPixels(Y));
+            return new Position(SpUtils.SpToPixels(X), SpUtils.SpToPixels(Y));
         }
     }
 }
index d6bf1618d82d398c182ff32936925d010570a651..94af72ec156e0747767b89dabcd1ec647de1704c 100644 (file)
@@ -51,7 +51,7 @@ namespace Fitness.Views
         /// <inheritdoc/>
         public object ProvideValue(IServiceProvider serviceProvider)
         {
-            return new Size2D(DpUtils.DpToPixels(Width), DpUtils.DpToPixels(Height));
+            return new Size2D(SpUtils.SpToPixels(Width), SpUtils.SpToPixels(Height));
         }
     }
 }
diff --git a/Fitness/Views/SpUtils.cs b/Fitness/Views/SpUtils.cs
new file mode 100644 (file)
index 0000000..7e78dc5
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Tizen.NUI;
+
+namespace Fitness.Views
+{
+    /// <summary>
+    /// Utils for converting sp pixels.
+    /// </summary>
+    public static class SpUtils
+    {
+        private const float SpPixelDivider = 1.48125f;
+
+        /// <summary>
+        /// Converts sp pixels into pixels.
+        /// </summary>
+        /// <param name="pixels">The number of sp pixels.</param>
+        /// <returns>The number of pixels.</returns>
+        public static int SpToPixels(int pixels)
+        {
+            return (int)Math.Round(SpTypeConverter.Instance.ConvertToPixel(pixels / SpPixelDivider), MidpointRounding.AwayFromZero);
+        }
+
+        /// <summary>
+        /// Converts sp pixels into pixels.
+        /// </summary>
+        /// <param name="pixels">The number of sp pixels.</param>
+        /// <returns>The number of pixels.</returns>
+        public static ushort SpToPixels(ushort pixels)
+        {
+            return (ushort)Math.Round(SpTypeConverter.Instance.ConvertToPixel(pixels / SpPixelDivider), MidpointRounding.AwayFromZero);
+        }
+
+        /// <summary>
+        /// Converts sp pixels into pixels.
+        /// </summary>
+        /// <param name="pixels">The number of sp pixels.</param>
+        /// <returns>The number of pixels.</returns>
+        public static float SpToPixels(float pixels)
+        {
+            return SpTypeConverter.Instance.ConvertToPixel(pixels / SpPixelDivider);
+        }
+
+        /// <summary>
+        /// Converts sp pixels into pixels.
+        /// </summary>
+        /// <param name="size">The size to be converted to pixels.</param>
+        /// <returns>The number of pixels.</returns>
+        public static Size2D SpToPixels(Size2D size)
+        {
+            return new Size2D(SpToPixels(size.Width), SpToPixels(size.Height));
+        }
+
+        /// <summary>
+        /// Converts sp pixels into pixels.
+        /// </summary>
+        /// <param name="extents">The extents collection to be converted to pixels.</param>
+        /// <returns>The number of pixels.</returns>
+        public static Extents SpToPixels(Extents extents)
+        {
+            return new Extents(SpToPixels(extents.Start), SpToPixels(extents.End), SpToPixels(extents.Top), SpToPixels(extents.Bottom));
+        }
+    }
+}
index 5eb9804b12a466a69db1d821aaa00aaca63b98f0..16d7144d0001213938bf748e123cf6520336fdbc 100644 (file)
@@ -20,7 +20,7 @@ namespace Fitness.Views.Styles
     {
         public BigLightButtonStyle()
         {
-            Text.PixelSize = DpUtils.DpToPixels(40.0f);
+            Text.PixelSize = SpUtils.SpToPixels(40.0f);
         }
     }
 }
index 7b0d3d87c170a069737c4959b8933a6160702403..4a0402172c638fb2ce6d7c8599afaccead6c5b3f 100644 (file)
@@ -52,7 +52,7 @@ namespace Fitness.Views.Styles
         public DirectionButtonStyle(Direction direction)
         {
             Text.TextColor.Disabled = new Color("#C3CAD2");
-            Text.PixelSize = DpUtils.DpToPixels(24.0f);
+            Text.PixelSize = SpUtils.SpToPixels(24.0f);
 
             NinePatchBackgroundColor.Disabled = NinePatchBackgroundColor.Normal;
             NinePatchFrameColor.Disabled = NinePatchFrameColor.Normal;
@@ -61,13 +61,13 @@ namespace Fitness.Views.Styles
             {
                 case Direction.Previous:
                     Text.HorizontalAlignment = HorizontalAlignment.Begin;
-                    TextPadding = new Extents(DpUtils.DpToPixels((ushort)20), 0, 0, 0);
+                    TextPadding = new Extents(SpUtils.SpToPixels((ushort)20), 0, 0, 0);
                     IconRelativeOrientation = Button.IconOrientation.Left;
                     break;
 
                 case Direction.Next:
                     Text.HorizontalAlignment = HorizontalAlignment.End;
-                    IconPadding = new Extents(DpUtils.DpToPixels((ushort)20), 0, 0, 0);
+                    IconPadding = new Extents(SpUtils.SpToPixels((ushort)20), 0, 0, 0);
                     IconRelativeOrientation = Button.IconOrientation.Right;
                     break;
 
@@ -78,7 +78,7 @@ namespace Fitness.Views.Styles
             Icon = new ImageViewStyle
             {
                 ResourceUrl = GetArrowIconPaths(direction),
-                Size = new Size2D(DpUtils.DpToPixels(80), DpUtils.DpToPixels(80)),
+                Size = new Size2D(SpUtils.SpToPixels(80), SpUtils.SpToPixels(80)),
             };
         }
 
index fbc7f881c49c7f7594596182930ed5696909d9c1..1751c8e0f0bc149fb3b567afe1f877459785f477 100644 (file)
@@ -29,7 +29,7 @@ namespace Fitness.Views.Styles
 
             Text = new TextLabelStyle
             {
-                PixelSize = DpUtils.DpToPixels(32.0f),
+                PixelSize = SpUtils.SpToPixels(32.0f),
                 FontFamily = "BreezeSans",
             };