Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions src/Controls/src/Core/ContentPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,5 @@ Size ICrossPlatformLayout.CrossPlatformArrange(Rect bounds)
this.ArrangeContent(bounds);
return bounds.Size;
}

private protected override void InvalidateMeasureLegacy(InvalidationTrigger trigger, int depth, int depthLeveltoInvalidate)
{
base.InvalidateMeasureLegacy(trigger, depth, 1);
}
}
}
8 changes: 0 additions & 8 deletions src/Controls/src/Core/InvalidationEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,7 @@ public InvalidationEventArgs(InvalidationTrigger trigger)
{
Trigger = trigger;
}
public InvalidationEventArgs(InvalidationTrigger trigger, int depth) : this(trigger)
{
CurrentInvalidationDepth = depth;
}


public InvalidationTrigger Trigger { get; private set; }


public int CurrentInvalidationDepth { set; get; }
}
}
104 changes: 23 additions & 81 deletions src/Controls/src/Core/LegacyLayouts/Layout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,12 @@ public override SizeRequest Measure(double widthConstraint, double heightConstra
SizeRequest size = base.Measure(widthConstraint - Padding.HorizontalThickness, heightConstraint - Padding.VerticalThickness, flags);
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning disable CS0618 // Type or member is obsolete
return new SizeRequest(new Size(size.Request.Width + Padding.HorizontalThickness, size.Request.Height + Padding.VerticalThickness),
new Size(size.Minimum.Width + Padding.HorizontalThickness, size.Minimum.Height + Padding.VerticalThickness));
var request = new Size(size.Request.Width + Padding.HorizontalThickness, size.Request.Height + Padding.VerticalThickness);
var minimum = new Size(size.Minimum.Width + Padding.HorizontalThickness, size.Minimum.Height + Padding.VerticalThickness);

DesiredSize = request;

return new SizeRequest(request, minimum);
#pragma warning restore CS0618 // Type or member is obsolete
}
#pragma warning restore CS0672 // Member overrides obsolete member
Expand Down Expand Up @@ -320,14 +324,19 @@ public void RaiseChild(View view)
[Obsolete("Use InvalidateMeasure depending on your scenario")]
protected virtual void InvalidateLayout()
{
_hasDoneLayout = false;
SetNeedsLayout();
InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged);
if (!_hasDoneLayout)
{
ForceLayout();
}
}

void SetNeedsLayout()
{
_hasDoneLayout = false;
}

/// <summary>
/// Positions and sizes the children of a layout.
/// </summary>
Expand All @@ -341,10 +350,18 @@ protected virtual void InvalidateLayout()
[Obsolete("Use ArrangeOverride")]
protected abstract void LayoutChildren(double x, double y, double width, double height);

internal override void OnChildMeasureInvalidatedInternal(VisualElement child, InvalidationTrigger trigger, int depth)
internal override void OnChildMeasureInvalidated(VisualElement child, InvalidationTrigger trigger)
{
// TODO: once we remove old Xamarin public signatures we can invoke `OnChildMeasureInvalidated(VisualElement, InvalidationTrigger)` directly
OnChildMeasureInvalidated(child, new InvalidationEventArgs(trigger, depth));
SetNeedsLayout();
InvalidateMeasureCache();

OnChildMeasureInvalidated(child, new InvalidationEventArgs(trigger));

var propagatedTrigger = GetPropagatedTrigger(trigger);
InvokeMeasureInvalidated(propagatedTrigger);

// Behavior of legacy layouts is to always propagate the measure invalidation to the parent
(Parent as VisualElement)?.OnChildMeasureInvalidated(this, propagatedTrigger);
}

/// <summary>
Expand All @@ -356,19 +373,6 @@ internal override void OnChildMeasureInvalidatedInternal(VisualElement child, In
/// <remarks>This method has a default implementation and application developers must call the base implementation.</remarks>
protected void OnChildMeasureInvalidated(object sender, EventArgs e)
{
var depth = 0;
InvalidationTrigger trigger;
if (e is InvalidationEventArgs args)
{
trigger = args.Trigger;
depth = args.CurrentInvalidationDepth;
}
else
{
trigger = InvalidationTrigger.Undefined;
}

OnChildMeasureInvalidated((VisualElement)sender, trigger, depth);
OnChildMeasureInvalidated();
}

Expand Down Expand Up @@ -542,55 +546,6 @@ internal static void LayoutChildIntoBoundingRegion(View child, Rect region, Size
child.Layout(region);
}

internal virtual void OnChildMeasureInvalidated(VisualElement child, InvalidationTrigger trigger, int depth)
{
IReadOnlyList<Element> children = LogicalChildrenInternal;
int count = children.Count;
for (var index = 0; index < count; index++)
{
if (LogicalChildrenInternal[index] is VisualElement v && v.IsVisible && (!v.IsPlatformEnabled || !v.IsPlatformStateConsistent))
{
return;
}
}

if (child is View view)
{
// we can ignore the request if we are either fully constrained or when the size request changes and we were already fully constrained
if ((trigger == InvalidationTrigger.MeasureChanged && view.Constraint == LayoutConstraint.Fixed) ||
(trigger == InvalidationTrigger.SizeRequestChanged && view.ComputedConstraint == LayoutConstraint.Fixed))
{
return;
}
if (trigger == InvalidationTrigger.HorizontalOptionsChanged || trigger == InvalidationTrigger.VerticalOptionsChanged)
{
ComputeConstraintForView(view);
}
}

InvalidateMeasureLegacy(trigger, depth, int.MaxValue);
}

// This lets us override the rules for invalidation on MAUI controls that unfortunately still inheirt from the legacy layout
private protected virtual void InvalidateMeasureLegacy(InvalidationTrigger trigger, int depth, int depthLeveltoInvalidate)
{
if (depth <= depthLeveltoInvalidate)
{
if (trigger == InvalidationTrigger.RendererReady)
{
InvalidateMeasureInternal(new InvalidationEventArgs(InvalidationTrigger.RendererReady, depth));
}
else
{
InvalidateMeasureInternal(new InvalidationEventArgs(InvalidationTrigger.MeasureChanged, depth));
}
}
else
{
FireMeasureChanged(trigger, depth);
}
}

internal override void OnIsVisibleChanged(bool oldValue, bool newValue)
{
base.OnIsVisibleChanged(oldValue, newValue);
Expand Down Expand Up @@ -708,19 +663,6 @@ bool ShouldLayoutChildren()
return true;
}

protected override void InvalidateMeasureOverride()
{
base.InvalidateMeasureOverride();

foreach (var child in ((IElementController)this).LogicalChildren)
{
if (child is IView fe)
{
fe.InvalidateMeasure();
}
}
}

protected override Size ArrangeOverride(Rect bounds)
{
base.ArrangeOverride(bounds);
Expand Down
8 changes: 7 additions & 1 deletion src/Controls/src/Core/LegacyLayouts/StackLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,18 @@ protected override SizeRequest OnMeasure(double widthConstraint, double heightCo
return result;
}

internal override void OnChildMeasureInvalidated(VisualElement child, InvalidationTrigger trigger)
{
_layoutInformation = new LayoutInformation();
base.OnChildMeasureInvalidated(child, trigger);
}

internal override void ComputeConstraintForView(View view)
{
ComputeConstraintForView(view, false);
}

internal override void InvalidateMeasureInternal(InvalidationEventArgs trigger)
internal override void InvalidateMeasureInternal(InvalidationTrigger trigger)
{
_layoutInformation = new LayoutInformation();
base.InvalidateMeasureInternal(trigger);
Expand Down
50 changes: 4 additions & 46 deletions src/Controls/src/Core/Page/Page.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,10 +506,11 @@ protected override void OnBindingContextChanged()
}


internal override void OnChildMeasureInvalidatedInternal(VisualElement child, InvalidationTrigger trigger, int depth)
internal override void OnChildMeasureInvalidated(VisualElement child, InvalidationTrigger trigger)
{
// TODO: once we remove old Xamarin public signatures we can invoke `OnChildMeasureInvalidated(VisualElement, InvalidationTrigger)` directly
OnChildMeasureInvalidated(child, new InvalidationEventArgs(trigger, depth));
OnChildMeasureInvalidated(child, new InvalidationEventArgs(trigger));
var propagatedTrigger = GetPropagatedTrigger(trigger);
InvokeMeasureInvalidated(propagatedTrigger);
}

/// <summary>
Expand All @@ -519,19 +520,6 @@ internal override void OnChildMeasureInvalidatedInternal(VisualElement child, In
/// <param name="e">The event arguments.</param>
protected virtual void OnChildMeasureInvalidated(object sender, EventArgs e)
{
var depth = 0;
InvalidationTrigger trigger;
if (e is InvalidationEventArgs args)
{
trigger = args.Trigger;
depth = args.CurrentInvalidationDepth;
}
else
{
trigger = InvalidationTrigger.Undefined;
}

OnChildMeasureInvalidated((VisualElement)sender, trigger, depth);
}

/// <summary>
Expand Down Expand Up @@ -610,36 +598,6 @@ protected void UpdateChildrenLayout()
}
}

internal virtual void OnChildMeasureInvalidated(VisualElement child, InvalidationTrigger trigger, int depth)
{
var container = this as IPageContainer<Page>;
if (container != null)
{
Page page = container.CurrentPage;
if (page != null && page.IsVisible && (!page.IsPlatformEnabled || !page.IsPlatformStateConsistent))
return;
}
else
{
var logicalChildren = this.InternalChildren;
for (var i = 0; i < logicalChildren.Count; i++)
{
var v = logicalChildren[i] as VisualElement;
if (v != null && v.IsVisible && (!v.IsPlatformEnabled || !v.IsPlatformStateConsistent))
return;
}
}

if (depth <= 1)
{
InvalidateMeasureInternal(new InvalidationEventArgs(InvalidationTrigger.MeasureChanged, depth));
}
else
{
FireMeasureChanged(trigger, depth);
}
}

internal void OnAppearing(Action action)
{
if (_hasAppeared)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const Microsoft.Maui.Controls.TitleBar.TrailingHiddenState = "TrailingContentCol
const Microsoft.Maui.Controls.TitleBar.TrailingVisibleState = "TrailingContentVisible" -> string!
Microsoft.Maui.Controls.Embedding.EmbeddingExtensions
Microsoft.Maui.Controls.HandlerProperties
*REMOVED*override Microsoft.Maui.Controls.Compatibility.Layout.InvalidateMeasureOverride() -> void
Microsoft.Maui.Controls.HybridWebView
Microsoft.Maui.Controls.HybridWebView.DefaultFile.get -> string?
Microsoft.Maui.Controls.HybridWebView.DefaultFile.set -> void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ const Microsoft.Maui.Controls.TitleBar.TrailingHiddenState = "TrailingContentCol
const Microsoft.Maui.Controls.TitleBar.TrailingVisibleState = "TrailingContentVisible" -> string!
Microsoft.Maui.Controls.Embedding.EmbeddingExtensions
Microsoft.Maui.Controls.HandlerProperties
*REMOVED*override Microsoft.Maui.Controls.Compatibility.Layout.InvalidateMeasureOverride() -> void
*REMOVED*Microsoft.Maui.Controls.Handlers.Compatibility.ShellScrollViewTracker
*REMOVED*Microsoft.Maui.Controls.Handlers.Compatibility.ShellScrollViewTracker.Dispose() -> void
*REMOVED*Microsoft.Maui.Controls.Handlers.Compatibility.ShellScrollViewTracker.OnLayoutSubviews() -> void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ const Microsoft.Maui.Controls.TitleBar.TrailingHiddenState = "TrailingContentCol
const Microsoft.Maui.Controls.TitleBar.TrailingVisibleState = "TrailingContentVisible" -> string!
Microsoft.Maui.Controls.Embedding.EmbeddingExtensions
Microsoft.Maui.Controls.HandlerProperties
*REMOVED*override Microsoft.Maui.Controls.Compatibility.Layout.InvalidateMeasureOverride() -> void
*REMOVED*Microsoft.Maui.Controls.Handlers.Compatibility.ShellScrollViewTracker
*REMOVED*Microsoft.Maui.Controls.Handlers.Compatibility.ShellScrollViewTracker.Dispose() -> void
*REMOVED*Microsoft.Maui.Controls.Handlers.Compatibility.ShellScrollViewTracker.OnLayoutSubviews() -> void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const Microsoft.Maui.Controls.TitleBar.TitleVisibleState = "TitleVisible" -> str
const Microsoft.Maui.Controls.TitleBar.TrailingHiddenState = "TrailingContentCollapsed" -> string!
const Microsoft.Maui.Controls.TitleBar.TrailingVisibleState = "TrailingContentVisible" -> string!
Microsoft.Maui.Controls.HandlerProperties
*REMOVED*override Microsoft.Maui.Controls.Compatibility.Layout.InvalidateMeasureOverride() -> void
Microsoft.Maui.Controls.HybridWebView
Microsoft.Maui.Controls.HybridWebView.DefaultFile.get -> string?
Microsoft.Maui.Controls.HybridWebView.DefaultFile.set -> void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ const Microsoft.Maui.Controls.TitleBar.TrailingHiddenState = "TrailingContentCol
const Microsoft.Maui.Controls.TitleBar.TrailingVisibleState = "TrailingContentVisible" -> string!
Microsoft.Maui.Controls.Embedding.EmbeddingExtensions
Microsoft.Maui.Controls.HandlerProperties
*REMOVED*override Microsoft.Maui.Controls.Compatibility.Layout.InvalidateMeasureOverride() -> void
Microsoft.Maui.Controls.HybridWebView
Microsoft.Maui.Controls.HybridWebView.DefaultFile.get -> string?
Microsoft.Maui.Controls.HybridWebView.DefaultFile.set -> void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const Microsoft.Maui.Controls.TitleBar.TitleVisibleState = "TitleVisible" -> str
const Microsoft.Maui.Controls.TitleBar.TrailingHiddenState = "TrailingContentCollapsed" -> string!
const Microsoft.Maui.Controls.TitleBar.TrailingVisibleState = "TrailingContentVisible" -> string!
Microsoft.Maui.Controls.HandlerProperties
*REMOVED*override Microsoft.Maui.Controls.Compatibility.Layout.InvalidateMeasureOverride() -> void
Microsoft.Maui.Controls.HybridWebView
Microsoft.Maui.Controls.HybridWebView.DefaultFile.get -> string?
Microsoft.Maui.Controls.HybridWebView.DefaultFile.set -> void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const Microsoft.Maui.Controls.TitleBar.TitleVisibleState = "TitleVisible" -> str
const Microsoft.Maui.Controls.TitleBar.TrailingHiddenState = "TrailingContentCollapsed" -> string!
const Microsoft.Maui.Controls.TitleBar.TrailingVisibleState = "TrailingContentVisible" -> string!
Microsoft.Maui.Controls.HandlerProperties
*REMOVED*override Microsoft.Maui.Controls.Compatibility.Layout.InvalidateMeasureOverride() -> void
Microsoft.Maui.Controls.HybridWebView
Microsoft.Maui.Controls.HybridWebView.DefaultFile.get -> string?
Microsoft.Maui.Controls.HybridWebView.DefaultFile.set -> void
Expand Down
5 changes: 0 additions & 5 deletions src/Controls/src/Core/ScrollView/ScrollView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,6 @@ Size ICrossPlatformLayout.CrossPlatformArrange(Rect bounds)
return bounds.Size;
}

private protected override void InvalidateMeasureLegacy(InvalidationTrigger trigger, int depth, int depthLeveltoInvalidate)
{
base.InvalidateMeasureLegacy(trigger, depth, 1);
}

private protected override string GetDebuggerDisplay()
{
var debugText = DebuggerDisplayHelpers.GetDebugText(nameof(Content), Content);
Expand Down
5 changes: 0 additions & 5 deletions src/Controls/src/Core/TemplatedView/TemplatedView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,6 @@ Size ICrossPlatformLayout.CrossPlatformArrange(Rect bounds)
return bounds.Size;
}

private protected override void InvalidateMeasureLegacy(InvalidationTrigger trigger, int depth, int depthLeveltoInvalidate)
{
base.InvalidateMeasureLegacy(trigger, depth, 1);
}

#nullable disable

}
Expand Down
Loading
Loading