feat: introduce Small class and IsReadOnly property.
This commit is contained in:
@@ -23,6 +23,18 @@
|
||||
<TextBlock Text="Avalonia" />
|
||||
<TextBlock Text="Ursa" />
|
||||
</u:Breadcrumb>
|
||||
<u:Breadcrumb Classes="Small">
|
||||
<TextBlock Text="Hello" />
|
||||
<u:BreadcrumbItem Icon="?" Separator="♥" />
|
||||
<TextBlock Text="Avalonia" />
|
||||
<TextBlock Text="Ursa" />
|
||||
</u:Breadcrumb>
|
||||
<u:Breadcrumb IsReadOnly="True">
|
||||
<TextBlock Text="Hello" />
|
||||
<u:BreadcrumbItem Icon="?" Separator="♥" />
|
||||
<TextBlock Text="Avalonia" />
|
||||
<TextBlock Text="Ursa" />
|
||||
</u:Breadcrumb>
|
||||
<u:Breadcrumb
|
||||
DisplayMemberBinding="{Binding Section}"
|
||||
IconBinding="{Binding Icon}"
|
||||
|
||||
@@ -19,17 +19,20 @@
|
||||
<ItemsPresenter ItemsPanel="{TemplateBinding ItemsPanel}" />
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^[IsReadOnly=True]">
|
||||
<Setter Property="ItemContainerTheme" Value="{DynamicResource ReadOnlyBreadcrumbItem}"></Setter>
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="{x:Type u:BreadcrumbItem}" TargetType="u:BreadcrumbItem">
|
||||
<Setter Property="Cursor" Value="Hand"></Setter>
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:BreadcrumbItem">
|
||||
<Border Background="Transparent">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ContentPresenter
|
||||
Name="PART_IconPresenter"
|
||||
Margin="0 0 4 0"
|
||||
Margin="0,0,4,0"
|
||||
VerticalAlignment="Center"
|
||||
Content="{TemplateBinding Icon}"
|
||||
ContentTemplate="{TemplateBinding IconTemplate}"
|
||||
@@ -39,14 +42,19 @@
|
||||
<ContentPresenter
|
||||
Name="PART_ContentPresenter"
|
||||
VerticalAlignment="Center"
|
||||
IsVisible="{TemplateBinding Content,
|
||||
Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||
Foreground="{DynamicResource SemiColorText2}"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}" />
|
||||
<ContentPresenter Name="Separator" VerticalAlignment="Center" Content="{TemplateBinding Separator}" Foreground="{DynamicResource SemiColorText3}" Margin="4 0">
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
Foreground="{DynamicResource SemiColorText2}"
|
||||
IsVisible="{TemplateBinding Content,
|
||||
Converter={x:Static ObjectConverters.IsNotNull}}" />
|
||||
<ContentPresenter
|
||||
Name="Separator"
|
||||
Margin="4,0 0 0"
|
||||
VerticalAlignment="Center"
|
||||
Content="{TemplateBinding Separator}"
|
||||
Foreground="{DynamicResource SemiColorText3}">
|
||||
<ContentPresenter.IsVisible>
|
||||
<TemplateBinding Property="Separator" Converter="{x:Static ObjectConverters.IsNotNull}" />
|
||||
<TemplateBinding Converter="{x:Static ObjectConverters.IsNotNull}" Property="Separator" />
|
||||
</ContentPresenter.IsVisible>
|
||||
</ContentPresenter>
|
||||
</StackPanel>
|
||||
@@ -55,30 +63,81 @@
|
||||
</Setter>
|
||||
<Style Selector="^:last">
|
||||
<Style Selector="^ /template/ ContentPresenter#PART_IconPresenter">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiColorText0}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiColorText0}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiColorText0}"/>
|
||||
<Setter Property="FontWeight" Value="Bold"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiColorText0}" />
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ ContentPresenter#Separator">
|
||||
<Setter Property="IsVisible" Value="False"/>
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
<Style Selector="^:pointerover">
|
||||
<Style Selector="^ /template/ ContentPresenter#PART_IconPresenter">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiBlue5}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiBlue5}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiBlue5}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiBlue5}" />
|
||||
</Style>
|
||||
</Style>
|
||||
</Style>
|
||||
<Style Selector="^:pointerover">
|
||||
<Style Selector="^ /template/ ContentPresenter#PART_IconPresenter">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiBlue5}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiBlue5}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiBlue5}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiBlue5}" />
|
||||
</Style>
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="ReadOnlyBreadcrumbItem" TargetType="u:BreadcrumbItem">
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:BreadcrumbItem">
|
||||
<Border Background="Transparent">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<ContentPresenter
|
||||
Name="PART_IconPresenter"
|
||||
Margin="0,0,4,0"
|
||||
VerticalAlignment="Center"
|
||||
Content="{TemplateBinding Icon}"
|
||||
ContentTemplate="{TemplateBinding IconTemplate}"
|
||||
Foreground="{DynamicResource SemiColorText2}"
|
||||
IsVisible="{TemplateBinding Icon,
|
||||
Converter={x:Static ObjectConverters.IsNotNull}}" />
|
||||
<ContentPresenter
|
||||
Name="PART_ContentPresenter"
|
||||
VerticalAlignment="Center"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
Foreground="{DynamicResource SemiColorText2}"
|
||||
IsVisible="{TemplateBinding Content,
|
||||
Converter={x:Static ObjectConverters.IsNotNull}}" />
|
||||
<ContentPresenter
|
||||
Name="Separator"
|
||||
Margin="4,0 0 0"
|
||||
VerticalAlignment="Center"
|
||||
Content="{TemplateBinding Separator}"
|
||||
Foreground="{DynamicResource SemiColorText3}">
|
||||
<ContentPresenter.IsVisible>
|
||||
<TemplateBinding Converter="{x:Static ObjectConverters.IsNotNull}" Property="Separator" />
|
||||
</ContentPresenter.IsVisible>
|
||||
</ContentPresenter>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^:last">
|
||||
<Style Selector="^ /template/ ContentPresenter#PART_IconPresenter">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiColorText0}" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
|
||||
<Setter Property="Foreground" Value="{DynamicResource SemiColorText0}" />
|
||||
<Setter Property="FontWeight" Value="Bold" />
|
||||
</Style>
|
||||
<Style Selector="^ /template/ ContentPresenter#Separator">
|
||||
<Setter Property="IsVisible" Value="False" />
|
||||
</Style>
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
20
src/Ursa.Themes.Semi/Styles/Breadcrumb.axaml
Normal file
20
src/Ursa.Themes.Semi/Styles/Breadcrumb.axaml
Normal file
@@ -0,0 +1,20 @@
|
||||
<Styles xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:u="https://irihi.tech/ursa">
|
||||
<Design.PreviewWith>
|
||||
<Border Padding="20">
|
||||
<!-- Add Controls for Previewer Here -->
|
||||
</Border>
|
||||
</Design.PreviewWith>
|
||||
|
||||
<!-- Add Styles Here -->
|
||||
<Style Selector="u|Breadcrumb.Small u|BreadcrumbItem /template/ ContentPresenter">
|
||||
<Setter Property="FontSize" Value="12"></Setter>
|
||||
</Style>
|
||||
<Style Selector="u|Breadcrumb.Small u|BreadcrumbItem /template/ ContentPresenter#PART_IconPresenter">
|
||||
<Setter Property="Margin" Value="0 0 2 0"></Setter>
|
||||
</Style>
|
||||
<Style Selector="u|Breadcrumb.Small u|BreadcrumbItem /template/ ContentPresenter#Separator">
|
||||
<Setter Property="Margin" Value="2 0 0 0"></Setter>
|
||||
</Style>
|
||||
</Styles>
|
||||
@@ -4,6 +4,7 @@
|
||||
<!-- Add Controls for Previewer Here -->
|
||||
</Border>
|
||||
</Design.PreviewWith>
|
||||
<StyleInclude Source="Breadcrumb.axaml" />
|
||||
<StyleInclude Source="ButtonGroup.axaml" />
|
||||
<StyleInclude Source="Skeleton.axaml" />
|
||||
<StyleInclude Source="ToolBar.axaml"/>
|
||||
|
||||
15
src/Ursa/Controls/BackTop/BackTop.cs
Normal file
15
src/Ursa/Controls/BackTop/BackTop.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace Ursa.Controls.BackTop;
|
||||
|
||||
public class BackTop: Control
|
||||
{
|
||||
public static readonly AttachedProperty<bool> AttachProperty =
|
||||
AvaloniaProperty.RegisterAttached<BackTop, Control, bool>("Attach");
|
||||
|
||||
public static void SetAttach(Control obj, bool value) => obj.SetValue(AttachProperty, value);
|
||||
public static bool GetAttach(Control obj) => obj.GetValue(AttachProperty);
|
||||
}
|
||||
@@ -56,6 +56,15 @@ public class Breadcrumb: ItemsControl
|
||||
get => GetValue(IconTemplateProperty);
|
||||
set => SetValue(IconTemplateProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<bool> IsReadOnlyProperty = AvaloniaProperty.Register<Breadcrumb, bool>(
|
||||
nameof(IsReadOnly));
|
||||
|
||||
public bool IsReadOnly
|
||||
{
|
||||
get => GetValue(IsReadOnlyProperty);
|
||||
set => SetValue(IsReadOnlyProperty, value);
|
||||
}
|
||||
|
||||
static Breadcrumb()
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using Avalonia.Controls;
|
||||
using Avalonia.Controls.Metadata;
|
||||
using Avalonia.Controls.Templates;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.LogicalTree;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
@@ -51,6 +52,10 @@ public class BreadcrumbItem: ContentControl
|
||||
protected override void OnPointerPressed(PointerPressedEventArgs e)
|
||||
{
|
||||
base.OnPointerPressed(e);
|
||||
Command?.Execute(null);
|
||||
var parent = this.FindLogicalAncestorOfType<Breadcrumb>();
|
||||
if (parent?.IsReadOnly != true)
|
||||
{
|
||||
Command?.Execute(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user