From 375c33049c7562600159a0e51953b2f2a3d3ce44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=8A=B9=EA=B7=BC/Common=20Platform=20Lab=28SR?= =?UTF-8?q?=29/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Wed, 22 Jun 2022 18:27:48 +0900 Subject: [PATCH] Fix ShapeView (#511) --- .../Handlers/Shapes/Path/PathHandler.Tizen.cs | 21 +++++++++++++++++++ .../Shapes/Polygon/PolygonHandler.Tizen.cs | 2 +- .../Shapes/Polyline/PolylineHandler.Tizen.cs | 2 +- .../PublicAPI/net-tizen/PublicAPI.Shipped.txt | 1 + .../Handlers/ViewHandlerExtensions.Tizen.cs | 10 +++------ src/Core/src/Platform/Tizen/MauiShapeView.cs | 9 +++----- .../PublicAPI/net-tizen/PublicAPI.Shipped.txt | 1 - 7 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/Controls/src/Core/Handlers/Shapes/Path/PathHandler.Tizen.cs b/src/Controls/src/Core/Handlers/Shapes/Path/PathHandler.Tizen.cs index 9becec1401db..ef20de8b8249 100644 --- a/src/Controls/src/Core/Handlers/Shapes/Path/PathHandler.Tizen.cs +++ b/src/Controls/src/Core/Handlers/Shapes/Path/PathHandler.Tizen.cs @@ -1,9 +1,15 @@ using Microsoft.Maui.Controls.Shapes; +using Microsoft.Maui.Graphics; namespace Microsoft.Maui.Controls.Handlers { public partial class PathHandler { + public static void MapShape(IShapeViewHandler handler, Path path) + { + handler.PlatformView?.UpdateShape(path); + } + public static void MapData(IShapeViewHandler handler, Path path) { handler.PlatformView?.InvalidateShape(path); @@ -11,6 +17,21 @@ public static void MapData(IShapeViewHandler handler, Path path) public static void MapRenderTransform(IShapeViewHandler handler, Path path) { + IDrawable drawable = handler.PlatformView?.Drawable; + + if (drawable == null) + return; + + if (drawable is ShapeDrawable shapeDrawable) + { + Matrix? matrix = path.RenderTransform?.Value; + + if (matrix != null) + { + shapeDrawable.UpdateRenderTransform(matrix.Value.ToMatrix3X2()); + } + } + handler.PlatformView?.InvalidateShape(path); } } diff --git a/src/Controls/src/Core/Handlers/Shapes/Polygon/PolygonHandler.Tizen.cs b/src/Controls/src/Core/Handlers/Shapes/Polygon/PolygonHandler.Tizen.cs index 51635c23a19c..f2fb0ae9f918 100644 --- a/src/Controls/src/Core/Handlers/Shapes/Polygon/PolygonHandler.Tizen.cs +++ b/src/Controls/src/Core/Handlers/Shapes/Polygon/PolygonHandler.Tizen.cs @@ -39,7 +39,7 @@ public static void MapFillRule(IShapeViewHandler handler, Polygon polygon) return; if (drawable is ShapeDrawable shapeDrawable) - shapeDrawable.WindingMode = polygon.FillRule == FillRule.EvenOdd ? Graphics.WindingMode.EvenOdd : Graphics.WindingMode.NonZero; + shapeDrawable.UpdateWindingMode(polygon.FillRule == FillRule.EvenOdd ? WindingMode.EvenOdd : WindingMode.NonZero); handler.PlatformView?.InvalidateShape(polygon); } diff --git a/src/Controls/src/Core/Handlers/Shapes/Polyline/PolylineHandler.Tizen.cs b/src/Controls/src/Core/Handlers/Shapes/Polyline/PolylineHandler.Tizen.cs index 69fa54c1a024..bd487627036d 100644 --- a/src/Controls/src/Core/Handlers/Shapes/Polyline/PolylineHandler.Tizen.cs +++ b/src/Controls/src/Core/Handlers/Shapes/Polyline/PolylineHandler.Tizen.cs @@ -39,7 +39,7 @@ public static void MapFillRule(IShapeViewHandler handler, Polyline polyline) return; if (drawable is ShapeDrawable shapeDrawable) - shapeDrawable.WindingMode = polyline.FillRule == FillRule.EvenOdd ? Graphics.WindingMode.EvenOdd : Graphics.WindingMode.NonZero; + shapeDrawable.UpdateWindingMode(polyline.FillRule == FillRule.EvenOdd ? WindingMode.EvenOdd : WindingMode.NonZero); handler.PlatformView?.InvalidateShape(polyline); } diff --git a/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Shipped.txt b/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Shipped.txt index 89aacfaa4051..5a0bf85827b5 100644 --- a/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Shipped.txt +++ b/src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Shipped.txt @@ -5534,6 +5534,7 @@ Microsoft.Maui.Controls.TappedEventArgs.TappedEventArgs(object? parameter) -> vo ~static Microsoft.Maui.Controls.Handlers.LineHandler.MapY1(Microsoft.Maui.Handlers.IShapeViewHandler handler, Microsoft.Maui.Controls.Shapes.Line line) -> void ~static Microsoft.Maui.Controls.Handlers.LineHandler.MapY2(Microsoft.Maui.Handlers.IShapeViewHandler handler, Microsoft.Maui.Controls.Shapes.Line line) -> void ~static Microsoft.Maui.Controls.Handlers.PathHandler.MapData(Microsoft.Maui.Handlers.IShapeViewHandler handler, Microsoft.Maui.Controls.Shapes.Path path) -> void +~static Microsoft.Maui.Controls.Handlers.PathHandler.MapShape(Microsoft.Maui.Handlers.IShapeViewHandler handler, Microsoft.Maui.Controls.Shapes.Path path) -> void ~static Microsoft.Maui.Controls.Handlers.PathHandler.Mapper -> Microsoft.Maui.IPropertyMapper ~static Microsoft.Maui.Controls.Handlers.PathHandler.MapRenderTransform(Microsoft.Maui.Handlers.IShapeViewHandler handler, Microsoft.Maui.Controls.Shapes.Path path) -> void ~static Microsoft.Maui.Controls.Handlers.PolygonHandler.MapFillRule(Microsoft.Maui.Handlers.IShapeViewHandler handler, Microsoft.Maui.Controls.Shapes.Polygon polygon) -> void diff --git a/src/Core/src/Handlers/ViewHandlerExtensions.Tizen.cs b/src/Core/src/Handlers/ViewHandlerExtensions.Tizen.cs index 9110cd4ec8e4..81c84bd42348 100644 --- a/src/Core/src/Handlers/ViewHandlerExtensions.Tizen.cs +++ b/src/Core/src/Handlers/ViewHandlerExtensions.Tizen.cs @@ -1,7 +1,6 @@ using System; using Microsoft.Maui.Graphics; using Tizen.UIExtensions.NUI; -using NView = Tizen.NUI.BaseComponents.View; using IMeasurable = Tizen.UIExtensions.Common.IMeasurable; namespace Microsoft.Maui @@ -60,10 +59,8 @@ internal static Size GetDesiredSizeFromHandler(this IViewHandler viewHandler, do double availableWidth = (availableWidthAsInt < 0 || availableWidthAsInt == int.MaxValue) ? double.PositiveInfinity : availableWidthAsInt; double availableHeight = (availableHeightAsInt < 0 || availableHeightAsInt == int.MaxValue) ? double.PositiveInfinity : availableHeightAsInt; - var explicitWidth = virtualView.Width; - var explicitHeight = virtualView.Height; - var hasExplicitWidth = explicitWidth >= 0; - var hasExplicitHeight = explicitHeight >= 0; + double? explicitWidth = (virtualView.Width >= 0) ? virtualView.Width : null; + double? explicitHeight = (virtualView.Height >=0) ? virtualView.Height : null; Size measured; if (platformView is IMeasurable platformViewMeasurable) @@ -75,8 +72,7 @@ internal static Size GetDesiredSizeFromHandler(this IViewHandler viewHandler, do measured = platformView.NaturalSize2D.ToCommon().ToDP(); } - return new Size(hasExplicitWidth ? explicitWidth : measured.Width, - hasExplicitHeight ? explicitHeight : measured.Height); + return new Size(explicitWidth ?? measured.Width, explicitHeight ?? measured.Height); } internal static void PlatformArrangeHandler(this IViewHandler viewHandler, Rect frame) diff --git a/src/Core/src/Platform/Tizen/MauiShapeView.cs b/src/Core/src/Platform/Tizen/MauiShapeView.cs index 6134e690d7d8..231c9701c4f8 100644 --- a/src/Core/src/Platform/Tizen/MauiShapeView.cs +++ b/src/Core/src/Platform/Tizen/MauiShapeView.cs @@ -1,16 +1,13 @@ -using Tizen.UIExtensions.NUI.GraphicsView; -using Tizen.UIExtensions.Common; -using GSize = Microsoft.Maui.Graphics.Size; +using Tizen.UIExtensions.Common; +using Tizen.UIExtensions.NUI.GraphicsView; namespace Microsoft.Maui.Platform { public class MauiShapeView : SkiaGraphicsView, IMeasurable { - protected virtual double DefaultSize => 40d; - Size IMeasurable.Measure(double availableWidth, double availableHeight) { - return new GSize(DefaultSize, DefaultSize).ToPixel(); + return new Size(0, 0); } } } \ No newline at end of file diff --git a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Shipped.txt b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Shipped.txt index 3f65d6e01dde..0afc0b7669be 100644 --- a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Shipped.txt +++ b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Shipped.txt @@ -2715,7 +2715,6 @@ virtual Microsoft.Maui.Handlers.ViewHandler.Measure virtual Microsoft.Maui.Handlers.ViewHandler.SetVirtualView(Microsoft.Maui.IView! view) -> void virtual Microsoft.Maui.Handlers.WebViewHandler.MinimumSize.get -> double virtual Microsoft.Maui.Platform.MauiImageSource.Dispose(bool disposing) -> void -virtual Microsoft.Maui.Platform.MauiShapeView.DefaultSize.get -> double virtual Microsoft.Maui.Platform.StackNavigationManager.Connect(Microsoft.Maui.IView! navigationView) -> void virtual Microsoft.Maui.Platform.StackNavigationManager.Disconnect() -> void virtual Microsoft.Maui.Platform.StackNavigationManager.RequestNavigation(Microsoft.Maui.NavigationRequest! e) -> void