-
Notifications
You must be signed in to change notification settings - Fork 724
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(effectiveviewport): Move the UIElement's layout properties to th…
…e LayoutInformation This gives us the ability to also use the LayoutSlot on native elements (Like the ScrollContentPresenter). There is still backing field on the UIElement for perf considerations, but it's almost readonly from the element perspective (we used custom interface implementation in order to encourage the use the unified solution of the LayoutInformation).
- Loading branch information
Showing
10 changed files
with
145 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 71 additions & 3 deletions
74
src/Uno.UI/UI/Xaml/Controls/Primitives/LayoutInformation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,83 @@ | ||
using Windows.Foundation; | ||
using Uno.Collections; | ||
|
||
namespace Windows.UI.Xaml.Controls.Primitives | ||
{ | ||
partial class LayoutInformation | ||
{ | ||
private static readonly UnsafeWeakAttachedDictionary<object, string> _layoutProperties = new UnsafeWeakAttachedDictionary<object, string>(); | ||
|
||
#region AvailableSize | ||
public static Size GetAvailableSize(UIElement element) | ||
=> element.LastAvailableSize; | ||
|
||
internal static Size GetAvailableSize(object view) | ||
=> view is IUIElementInternal iue | ||
? iue.LastAvailableSize | ||
: _layoutProperties.GetValue(view, "availablesize", () => default(Size)); | ||
|
||
internal static void SetAvailableSize(object view, Size value) | ||
{ | ||
if (view is IUIElementInternal iue) | ||
{ | ||
iue.LastAvailableSize = value; | ||
} | ||
else | ||
{ | ||
_layoutProperties.SetValue(view, "availablesize", value); | ||
} | ||
} | ||
#endregion | ||
|
||
#region LayoutSlot | ||
public static Rect GetLayoutSlot(FrameworkElement element) | ||
=> element.LayoutSlot; | ||
|
||
internal static Rect GetLayoutSlot(object view) | ||
=> view is IUIElementInternal iue | ||
? iue.LayoutSlot | ||
: _layoutProperties.GetValue(view, "layoutslot", () => default(Rect)); | ||
|
||
internal static void SetLayoutSlot(object view, Rect value) | ||
{ | ||
return element.LayoutSlot; | ||
if (view is IUIElementInternal iue) | ||
{ | ||
iue.LayoutSlot = value; | ||
} | ||
else | ||
{ | ||
_layoutProperties.SetValue(view, "layoutslot", value); | ||
} | ||
} | ||
#endregion | ||
|
||
public static Size GetAvailableSize(UIElement element) | ||
=> element.LastAvailableSize; | ||
#region DesiredSize | ||
internal static Size GetDesiredSize(UIElement element) | ||
=> element.DesiredSize; | ||
|
||
internal static Size GetDesiredSize(object view) | ||
{ | ||
switch (view) | ||
{ | ||
case IUIElementInternal iue: | ||
return iue.DesiredSize; | ||
default: | ||
return _layoutProperties.GetValue(view, "desiredSize", () => default(Size)); | ||
} | ||
} | ||
|
||
internal static void SetDesiredSize(object view, Size desiredSize) | ||
{ | ||
switch (view) | ||
{ | ||
case IUIElementInternal iue: | ||
iue.DesiredSize = desiredSize; | ||
break; | ||
default: | ||
_layoutProperties.GetValue(view, "desiredSize", () => default(Size)); | ||
break; | ||
} | ||
} | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using System; | ||
using Windows.Foundation; | ||
using Windows.UI.Xaml.Controls.Primitives; | ||
|
||
namespace Windows.UI.Xaml | ||
{ | ||
internal interface IUIElementInternal : IUIElement | ||
{ | ||
/// <summary> | ||
/// The 'availableSize' provided for the last Measure | ||
/// </summary> | ||
/// <remarks>This is the backing flied for <see cref="LayoutInformation.GetAvailableSize"/></remarks> | ||
Size LastAvailableSize { get; set; } | ||
|
||
/// <summary> | ||
/// The 'return' size produced by the last Measure | ||
/// </summary> | ||
/// <remarks>This is the backing flied for the **internal** <see cref="LayoutInformation.GetDesiredSize"/></remarks> | ||
Size DesiredSize { get; set; } | ||
|
||
/// <summary> | ||
/// The 'finalSize' provided for the last Arrange | ||
/// </summary> | ||
/// <remarks>This is the backing flied for <see cref="LayoutInformation.GetLayoutSlot"/></remarks> | ||
Rect LayoutSlot { get; set; } | ||
} | ||
} | ||
|
Oops, something went wrong.