summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Tizen/Renderers
diff options
context:
space:
mode:
authorSeungkeun Lee <sngn.lee@samsung.com>2017-02-08 10:17:28 +0900
committerKangho Hur <kangho.hur@samsung.com>2017-07-10 11:11:19 +0900
commitbc891e2b6160d47a9e1960c38e911773bff64b66 (patch)
treea7abb3e73052974406369757a13c478248561152 /Xamarin.Forms.Platform.Tizen/Renderers
parent6964d20afc00124fd73b540ead1e004844e944fc (diff)
downloadxamarin-forms-bc891e2b6160d47a9e1960c38e911773bff64b66.tar.gz
xamarin-forms-bc891e2b6160d47a9e1960c38e911773bff64b66.tar.bz2
xamarin-forms-bc891e2b6160d47a9e1960c38e911773bff64b66.zip
Support density independent pixel
- Support Enable/Disable of this feature - By default, it was disabled. if you want enabling DP support feature, Use Forms.Init(FormsApplication application, bool useDeviceIndependentPixel) API - Hard-coded pixel value was changed to DP units - If you deal with native coordinate, use Forms.ConvertToScaledPixel / Forms.ConvertToScaledDP - If you convert hard-coded DP to pixels, use Forms.ConvertToPixel - Update font size convert formula Change-Id: I345115551e1c37d27b8a7152af5ef847d035c9a4
Diffstat (limited to 'Xamarin.Forms.Platform.Tizen/Renderers')
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs3
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/LayoutRenderer.cs4
-rw-r--r--[-rwxr-xr-x]Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs2
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/SearchBarRenderer.cs2
-rw-r--r--Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs41
5 files changed, 24 insertions, 28 deletions
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
index 39f26b4f..456bb0d5 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ButtonRenderer.cs
@@ -1,5 +1,6 @@
using System;
using EColor = ElmSharp.Color;
+using ESize = ElmSharp.Size;
using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.VisualElement;
namespace Xamarin.Forms.Platform.Tizen
@@ -46,7 +47,7 @@ namespace Xamarin.Forms.Platform.Tizen
protected override Size MinimumSize()
{
- return new Size(Control.MinimumWidth, Control.MinimumHeight);
+ return new ESize(Control.MinimumWidth, Control.MinimumHeight).ToDP();
}
void ButtonClickedHandler(object sender, EventArgs e)
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/LayoutRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/LayoutRenderer.cs
index 61421c79..99e422e9 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/LayoutRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/LayoutRenderer.cs
@@ -23,8 +23,8 @@ namespace Xamarin.Forms.Platform.Tizen
if (scrollView != null)
{
Size size = scrollView.ContentSize;
- Control.MinimumWidth = ToNativeDimension(Math.Max(size.Width, scrollView.Content.Width));
- Control.MinimumHeight = ToNativeDimension(Math.Max(size.Height, scrollView.Content.Height));
+ Control.MinimumWidth = Forms.ConvertToScaledPixel(Math.Max(size.Width, scrollView.Content.Width));
+ Control.MinimumHeight = Forms.ConvertToScaledPixel(Math.Max(size.Height, scrollView.Content.Height));
}
base.UpdateLayout();
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs
index 11195386..f35a2753 100755..100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/ScrollViewRenderer.cs
@@ -132,7 +132,7 @@ namespace Xamarin.Forms.Platform.Tizen
y = itemPosition.Y;
}
- Rect region = new Rect(ToNativeDimension(x), ToNativeDimension(y), ToNativeDimension(Element.Width), ToNativeDimension(Element.Height));
+ Rect region = new Rectangle(x, y, Element.Width, Element.Height).ToPixel();
Control.ScrollTo(region, e.ShouldAnimate);
}
}
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/SearchBarRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/SearchBarRenderer.cs
index 798a0497..3c9734db 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/SearchBarRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/SearchBarRenderer.cs
@@ -58,7 +58,7 @@ namespace Xamarin.Forms.Platform.Tizen
protected override Size MinimumSize()
{
- return new Size(250, 120);
+ return new Size(136, 65);
}
/// <summary>
diff --git a/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs b/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs
index 4bde705c..37a5fafb 100644
--- a/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs
+++ b/Xamarin.Forms.Platform.Tizen/Renderers/VisualElementRenderer.cs
@@ -9,7 +9,6 @@ using ERect = ElmSharp.Rect;
using ERectangle = ElmSharp.Rectangle;
using Specific = Xamarin.Forms.PlatformConfiguration.TizenSpecific.VisualElement;
-
namespace Xamarin.Forms.Platform.Tizen
{
/// <summary>
@@ -138,21 +137,26 @@ namespace Xamarin.Forms.Platform.Tizen
}
else
{
- int availableWidth = ToNativeDimension(widthConstraint);
- int availableHeight = ToNativeDimension(heightConstraint);
- ESize measured;
+ int availableWidth = Forms.ConvertToScaledPixel(widthConstraint);
+ int availableHeight = Forms.ConvertToScaledPixel(heightConstraint);
+
+ if (availableWidth < 0)
+ availableWidth = int.MaxValue;
+ if (availableHeight < 0)
+ availableHeight = int.MaxValue;
+ Size measured;
var nativeViewMeasurable = NativeView as Native.IMeasurable;
if (nativeViewMeasurable != null)
{
- measured = nativeViewMeasurable.Measure(availableWidth, availableHeight);
+ measured = nativeViewMeasurable.Measure(availableWidth, availableHeight).ToDP();
}
else
{
- measured = Measure(availableWidth, availableHeight);
+ measured = Measure(availableWidth, availableHeight).ToDP();
}
- return new SizeRequest(new Size(measured.Width, measured.Height), MinimumSize());
+ return new SizeRequest(measured, MinimumSize());
}
}
@@ -203,7 +207,7 @@ namespace Xamarin.Forms.Platform.Tizen
{
var x = ComputeAbsoluteX(Element);
var y = ComputeAbsoluteY(Element);
- NativeView.Geometry = new ERect(ToNativeDimension(x), ToNativeDimension(y), ToNativeDimension(Element.Width), ToNativeDimension(Element.Height));
+ NativeView.Geometry = new Rectangle(x, y, Element.Width, Element.Height).ToPixel();
ApplyTransformation();
UpdateOpacityLayer();
}
@@ -545,7 +549,8 @@ namespace Xamarin.Forms.Platform.Tizen
protected void DoLayout(Native.LayoutEventArgs e)
{
Settings.StartIgnoringBatchCommitted();
- Element.Layout(new Rectangle(Element.X, Element.Y, e.Width, e.Height));
+
+ Element.Layout(new Rectangle(Element.X, Element.Y, Forms.ConvertToScaledDP(e.Width), Forms.ConvertToScaledDP(e.Height)));
if (e.HasChanged)
{
UpdateLayout();
@@ -579,24 +584,14 @@ namespace Xamarin.Forms.Platform.Tizen
}
}
- /// <summary>
- /// Converts provided value to native dimension.
- /// </summary>
- /// <param name="v">value to be converted.</param>
- /// <returns>converted value</returns>
- protected static int ToNativeDimension(double v)
- {
- return (int)Math.Round(v);
- }
-
static double ComputeAbsoluteX(VisualElement e)
{
- return e.X + (e.RealParent is VisualElement ? Platform.GetRenderer(e.RealParent).NativeView.Geometry.X : 0.0);
+ return e.X + (e.RealParent is VisualElement ? Forms.ConvertToScaledDP(Platform.GetRenderer(e.RealParent).NativeView.Geometry.X) : 0.0);
}
static double ComputeAbsoluteY(VisualElement e)
{
- return e.Y + (e.RealParent is VisualElement ? Platform.GetRenderer(e.RealParent).NativeView.Geometry.Y : 0.0);
+ return e.Y + (e.RealParent is VisualElement ? Forms.ConvertToScaledDP(Platform.GetRenderer(e.RealParent).NativeView.Geometry.Y) : 0.0);
}
/// <summary>
@@ -830,8 +825,8 @@ namespace Xamarin.Forms.Platform.Tizen
void ApplyTranslation(EvasMap map, ERect geometry, ref bool changed)
{
- var shiftX = ToNativeDimension(Element.TranslationX);
- var shiftY = ToNativeDimension(Element.TranslationY);
+ var shiftX = Forms.ConvertToScaledPixel(Element.TranslationX);
+ var shiftY = Forms.ConvertToScaledPixel(Element.TranslationY);
// apply translation, i.e. move/shift the object a little
if (shiftX != 0 || shiftY != 0)