feat: remove unimplemented features.
This commit is contained in:
@@ -73,15 +73,5 @@
|
|||||||
<u:Avatar Classes="Square Large Green" />
|
<u:Avatar Classes="Square Large Green" />
|
||||||
<u:Avatar Classes="Square ExtraLarge Green" />
|
<u:Avatar Classes="Square ExtraLarge Green" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<u:AvatarGroup MaxCount="3">
|
|
||||||
<u:Avatar Classes="Red" Content="LL" />
|
|
||||||
<u:Avatar Classes="" Content="CX" />
|
|
||||||
<u:Avatar Classes="Amber" Content="RM" />
|
|
||||||
<u:Avatar Background="#FDE3CF" Foreground="#F56A00" Content="ZL" />
|
|
||||||
<u:Avatar Background="#87D068" Classes="" Content="YZ" />
|
|
||||||
</u:AvatarGroup>
|
|
||||||
<u:Avatar />
|
|
||||||
</StackPanel>
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -33,17 +33,13 @@
|
|||||||
HorizontalContentAlignment="Center"
|
HorizontalContentAlignment="Center"
|
||||||
VerticalContentAlignment="Center" />
|
VerticalContentAlignment="Center" />
|
||||||
<ContentPresenter
|
<ContentPresenter
|
||||||
Name="{x:Static u:Avatar.PART_HoverMask}"
|
Name="PART_HoverMask"
|
||||||
IsVisible="False"
|
IsVisible="False"
|
||||||
Content="{TemplateBinding HoverMask}"
|
Content="{TemplateBinding HoverMask}"
|
||||||
CornerRadius="{TemplateBinding CornerRadius}"
|
CornerRadius="{TemplateBinding CornerRadius}"
|
||||||
HorizontalContentAlignment="Center"
|
HorizontalContentAlignment="Center"
|
||||||
VerticalContentAlignment="Center" />
|
VerticalContentAlignment="Center" />
|
||||||
<Image Source="{TemplateBinding Source}" />
|
<Image Source="{TemplateBinding Source}" />
|
||||||
<DockPanel>
|
|
||||||
<ContentPresenter DockPanel.Dock="Top" />
|
|
||||||
<ContentPresenter DockPanel.Dock="Bottom" />
|
|
||||||
</DockPanel>
|
|
||||||
</Panel>
|
</Panel>
|
||||||
</Border>
|
</Border>
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
@@ -141,12 +137,4 @@
|
|||||||
</Style>
|
</Style>
|
||||||
</Style>
|
</Style>
|
||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
<ControlTheme x:Key="{x:Type u:AvatarGroup}" TargetType="{x:Type u:AvatarGroup}">
|
|
||||||
<Setter Property="Template">
|
|
||||||
<ControlTemplate TargetType="u:AvatarGroup">
|
|
||||||
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" />
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter>
|
|
||||||
</ControlTheme>
|
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
@@ -1,42 +1,17 @@
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.Metadata;
|
|
||||||
using Avalonia.Controls.Presenters;
|
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
|
|
||||||
namespace Ursa.Controls;
|
namespace Ursa.Controls;
|
||||||
|
|
||||||
[TemplatePart(PART_HoverMask, typeof(ContentPresenter))]
|
|
||||||
public class Avatar : Button
|
public class Avatar : Button
|
||||||
{
|
{
|
||||||
public const string PART_TopPresenter = "PART_TopPresenter";
|
|
||||||
public const string PART_BottomPresenter = "PART_BottomPresenter";
|
|
||||||
public const string PART_HoverMask = "PART_HoverMask";
|
|
||||||
|
|
||||||
public static readonly StyledProperty<bool> ContentMotionProperty = AvaloniaProperty.Register<Avatar, bool>(
|
|
||||||
nameof(ContentMotion));
|
|
||||||
|
|
||||||
public static readonly StyledProperty<double> GapProperty = AvaloniaProperty.Register<Avatar, double>(
|
|
||||||
nameof(Gap));
|
|
||||||
|
|
||||||
public static readonly StyledProperty<IImage?> SourceProperty = AvaloniaProperty.Register<Avatar, IImage?>(
|
public static readonly StyledProperty<IImage?> SourceProperty = AvaloniaProperty.Register<Avatar, IImage?>(
|
||||||
nameof(Source));
|
nameof(Source));
|
||||||
|
|
||||||
public static readonly StyledProperty<object?> HoverMaskProperty = AvaloniaProperty.Register<Avatar, object?>(
|
public static readonly StyledProperty<object?> HoverMaskProperty = AvaloniaProperty.Register<Avatar, object?>(
|
||||||
nameof(HoverMask));
|
nameof(HoverMask));
|
||||||
|
|
||||||
public bool ContentMotion
|
|
||||||
{
|
|
||||||
get => GetValue(ContentMotionProperty);
|
|
||||||
set => SetValue(ContentMotionProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public double Gap
|
|
||||||
{
|
|
||||||
get => GetValue(GapProperty);
|
|
||||||
set => SetValue(GapProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IImage? Source
|
public IImage? Source
|
||||||
{
|
{
|
||||||
get => GetValue(SourceProperty);
|
get => GetValue(SourceProperty);
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.Controls.Templates;
|
|
||||||
|
|
||||||
namespace Ursa.Controls;
|
|
||||||
|
|
||||||
public class AvatarGroup : ItemsControl
|
|
||||||
{
|
|
||||||
public const string PART_RenderMore = "PART_RenderMore";
|
|
||||||
|
|
||||||
private static readonly FuncTemplate<Panel?> DefaultPanel = new(() => new AvatarGroupPanel());
|
|
||||||
|
|
||||||
public static readonly StyledProperty<int?> MaxCountProperty = AvaloniaProperty.Register<AvatarGroup, int?>(
|
|
||||||
nameof(MaxCount));
|
|
||||||
|
|
||||||
public static readonly StyledProperty<OverlapFromType> OverlapFromProperty =
|
|
||||||
AvaloniaProperty.Register<AvatarGroup, OverlapFromType>(
|
|
||||||
nameof(OverlapFrom), defaultValue: OverlapFromType.Start);
|
|
||||||
|
|
||||||
public int? MaxCount
|
|
||||||
{
|
|
||||||
get => GetValue(MaxCountProperty);
|
|
||||||
set => SetValue(MaxCountProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public OverlapFromType OverlapFrom
|
|
||||||
{
|
|
||||||
get => GetValue(OverlapFromProperty);
|
|
||||||
set => SetValue(OverlapFromProperty, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
static AvatarGroup()
|
|
||||||
{
|
|
||||||
ItemsPanelProperty.OverrideDefaultValue<AvatarGroup>(DefaultPanel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum OverlapFromType
|
|
||||||
{
|
|
||||||
Start,
|
|
||||||
End
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
using Avalonia;
|
|
||||||
using Avalonia.Controls;
|
|
||||||
using Avalonia.LogicalTree;
|
|
||||||
|
|
||||||
namespace Ursa.Controls;
|
|
||||||
|
|
||||||
public class AvatarGroupPanel : Panel
|
|
||||||
{
|
|
||||||
protected override Size MeasureOverride(Size availableSize)
|
|
||||||
{
|
|
||||||
var children = Children;
|
|
||||||
if (children.Count <= 0) return new Size();
|
|
||||||
|
|
||||||
availableSize = availableSize.WithWidth(double.PositiveInfinity);
|
|
||||||
children[0].Measure(availableSize);
|
|
||||||
Size first = children[0].DesiredSize;
|
|
||||||
var group = this.GetLogicalAncestors().OfType<AvatarGroup>().FirstOrDefault();
|
|
||||||
var maxCount = group?.MaxCount;
|
|
||||||
var count = children.Count;
|
|
||||||
if (maxCount >= 0 && maxCount < count)
|
|
||||||
{
|
|
||||||
count = maxCount.Value + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
var width = first.Width + first.Width * (count - 1) * 0.75;
|
|
||||||
return new Size(width, first.Height);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override Size ArrangeOverride(Size finalSize)
|
|
||||||
{
|
|
||||||
Rect rect = new Rect(finalSize);
|
|
||||||
double num = 0d;
|
|
||||||
var children = Children;
|
|
||||||
var group = this.GetLogicalAncestors().OfType<AvatarGroup>().FirstOrDefault();
|
|
||||||
var overlapFrom = group?.OverlapFrom;
|
|
||||||
var maxCount = group?.MaxCount;
|
|
||||||
var childrenCount = children.Count;
|
|
||||||
var count = maxCount < childrenCount ? maxCount.Value : childrenCount;
|
|
||||||
for (var i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
if (overlapFrom is OverlapFromType.Start)
|
|
||||||
{
|
|
||||||
children[i].ZIndex = childrenCount - i;
|
|
||||||
}
|
|
||||||
|
|
||||||
children[i].Measure(finalSize);
|
|
||||||
Size desiredSize = children[i].DesiredSize;
|
|
||||||
double width = desiredSize.Width;
|
|
||||||
double height = Math.Max(desiredSize.Height, finalSize.Height);
|
|
||||||
rect = rect.WithX(rect.X + num);
|
|
||||||
rect = rect.WithWidth(width);
|
|
||||||
rect = rect.WithHeight(height);
|
|
||||||
num = width * 0.75;
|
|
||||||
children[i].Arrange(rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxCount is not null)
|
|
||||||
{
|
|
||||||
//TODO: RenderMore
|
|
||||||
}
|
|
||||||
|
|
||||||
return finalSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user