Skip to content

Commit

Permalink
[Maui.Widaget] try when double to int, add 0.5 to fix FitGridTest inf…
Browse files Browse the repository at this point in the history
…inity loop
  • Loading branch information
xtuzy committed Apr 22, 2023
1 parent a816e75 commit 5afb519
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions SharpConstraintLayout.Maui/Widget/ConstraintLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@ public int ConstrainWidth
throw new InvalidOperationException(errorStr);
}

int availableWidth = (int)availableSize.Width;
int availableHeight = (int)availableSize.Height;
int availableWidth = (int)(availableSize.Width + 0.5);
int availableHeight = (int)(availableSize.Height + 0.5);

if (isInfinityAvailabelWidth)
{
Expand Down
6 changes: 3 additions & 3 deletions SharpConstraintLayout.Maui/Widget/UIElementExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ public static void SetViewVisibility(this UIElement element, int ConstraintSetVi
public static (int Width, int Height) GetWrapContentSize(this UIElement element)
{
#if __MAUI__
return ((int)element.DesiredSize.Width, (int)element.DesiredSize.Height);
return ((int)(element.DesiredSize.Width + 0.5), (int)(element.DesiredSize.Height + 0.5));
#elif WINDOWS
return ((int)element.DesiredSize.Width, (int)element.DesiredSize.Height);
#elif __IOS__
Expand Down Expand Up @@ -273,8 +273,8 @@ public static (int measuredWidth, int measureWidth) MeasureSelf(this UIElement e
w = MeasureSpec.GetSize(horizontalSpec);
h = MeasureSpec.GetSize(verticalSpec);
sizeRequest = (element as IView).Measure(w, h);
w = GetDefaultSize((int)(sizeRequest.Width + 1), horizontalSpec);
h = GetDefaultSize((int)(sizeRequest.Height + 1), verticalSpec);
w = GetDefaultSize((int)(sizeRequest.Width + 0.5), horizontalSpec);
h = GetDefaultSize((int)(sizeRequest.Height + 0.5), verticalSpec);
#elif WINDOWS
w = MeasureSpec.GetSize(horizontalSpec);
h = MeasureSpec.GetSize(verticalSpec);
Expand Down

0 comments on commit 5afb519

Please sign in to comment.