feat: OverlapFormType.
This commit is contained in:
@@ -15,7 +15,7 @@ public class AvatarGroup : ItemsControl
|
|||||||
|
|
||||||
public static readonly StyledProperty<OverlapFromType> OverlapFromProperty =
|
public static readonly StyledProperty<OverlapFromType> OverlapFromProperty =
|
||||||
AvaloniaProperty.Register<AvatarGroup, OverlapFromType>(
|
AvaloniaProperty.Register<AvatarGroup, OverlapFromType>(
|
||||||
nameof(OverlapFrom));
|
nameof(OverlapFrom), defaultValue: OverlapFromType.Start);
|
||||||
|
|
||||||
public int MaxCount
|
public int MaxCount
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.LogicalTree;
|
||||||
|
|
||||||
namespace Ursa.Controls;
|
namespace Ursa.Controls;
|
||||||
|
|
||||||
@@ -28,18 +28,25 @@ public class AvatarGroupPanel : Panel
|
|||||||
{
|
{
|
||||||
Rect rect = new Rect(finalSize);
|
Rect rect = new Rect(finalSize);
|
||||||
double num = 0d;
|
double num = 0d;
|
||||||
|
var group = this.GetLogicalAncestors().OfType<AvatarGroup>().FirstOrDefault();
|
||||||
|
var overlapFrom = group?.OverlapFrom;
|
||||||
var children = Children;
|
var children = Children;
|
||||||
foreach (var child in children)
|
for (var i = 0; i < children.Count; i++)
|
||||||
{
|
{
|
||||||
child.Measure(finalSize);
|
if (overlapFrom is OverlapFromType.Start)
|
||||||
Size desiredSize = child.DesiredSize;
|
{
|
||||||
|
children[i].ZIndex = children.Count - i;
|
||||||
|
}
|
||||||
|
|
||||||
|
children[i].Measure(finalSize);
|
||||||
|
Size desiredSize = children[i].DesiredSize;
|
||||||
double width = desiredSize.Width;
|
double width = desiredSize.Width;
|
||||||
double height = Math.Max(desiredSize.Height, finalSize.Height);
|
double height = Math.Max(desiredSize.Height, finalSize.Height);
|
||||||
rect = rect.WithX(rect.X + num);
|
rect = rect.WithX(rect.X + num);
|
||||||
rect = rect.WithWidth(width);
|
rect = rect.WithWidth(width);
|
||||||
rect = rect.WithHeight(height);
|
rect = rect.WithHeight(height);
|
||||||
num = width * 0.75;
|
num = width * 0.75;
|
||||||
child.Arrange(rect);
|
children[i].Arrange(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
return finalSize;
|
return finalSize;
|
||||||
|
|||||||
Reference in New Issue
Block a user