feat: add dialog CornerRadius to dynamic resource.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<Setter Property="OverlayMaskBrush" Value="{DynamicResource OverlayDialogMaskBrush}" />
|
||||
</ControlTheme>
|
||||
<ControlTheme x:Key="{x:Type u:CustomDialogControl}" TargetType="u:CustomDialogControl">
|
||||
<Setter Property="CornerRadius" Value="12" />
|
||||
<Setter Property="CornerRadius" Value="{DynamicResource DialogCornerRadius}" />
|
||||
<Setter Property="Transitions">
|
||||
<Transitions>
|
||||
<TransformOperationsTransition Duration="0.2" Property="RenderTransform"/>
|
||||
@@ -141,7 +141,7 @@
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="{x:Type u:DefaultDialogControl}" TargetType="u:DefaultDialogControl">
|
||||
<Setter Property="CornerRadius" Value="12" />
|
||||
<Setter Property="CornerRadius" Value="{DynamicResource DialogCornerRadius}" />
|
||||
<Setter Property="Transitions">
|
||||
<Transitions>
|
||||
<TransformOperationsTransition Duration="0.2" Property="RenderTransform"/>
|
||||
|
||||
@@ -1,20 +1,24 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:u="https://irihi.tech/ursa">
|
||||
xmlns:u="https://irihi.tech/ursa"
|
||||
xmlns:c="clr-namespace:Ursa.Themes.Semi.Converters">
|
||||
<ControlTheme TargetType="u:CustomDrawerControl" x:Key="{x:Type u:CustomDrawerControl}">
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"></Setter>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"></Setter>
|
||||
<Setter Property="Padding" Value="{DynamicResource DrawerMargin}"/>
|
||||
<Setter Property="BorderThickness" Value="{DynamicResource DrawerBorderThickness}"/>
|
||||
<Setter Property="CornerRadius" Value="{DynamicResource DrawerCornerRadius}"/>
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:CustomDrawerControl">
|
||||
<Border Name="PART_Root"
|
||||
Margin="8 -1 -1 -1"
|
||||
Margin="{TemplateBinding Padding, Converter={x:Static c:ThicknessTakeConverter.Left}}"
|
||||
Padding="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Classes="Shadow"
|
||||
ClipToBounds="False"
|
||||
CornerRadius="12 0 0 12"
|
||||
BorderThickness="1 0 0 0"
|
||||
CornerRadius="{TemplateBinding CornerRadius, Converter={x:Static c:CornerRadiusTakeConverter.Left}}"
|
||||
BorderThickness="{TemplateBinding BorderThickness, Converter={x:Static c:ThicknessTakeConverter.Left}}"
|
||||
IsHitTestVisible="True"
|
||||
Theme="{DynamicResource CardBorder}">
|
||||
<Border ClipToBounds="True" CornerRadius="{Binding #PART_Root.CornerRadius}">
|
||||
@@ -43,41 +47,44 @@
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^[Position=Right] /template/ Border#PART_Root">
|
||||
<Setter Property="Margin" Value="8 0 0 0" />
|
||||
<Setter Property="CornerRadius" Value="12 0 0 12" />
|
||||
<Setter Property="BorderThickness" Value="1 0 0 0" />
|
||||
<Setter Property="Margin" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Padding, Converter={x:Static c:ThicknessTakeConverter.Left}}" />
|
||||
<Setter Property="CornerRadius" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius, Converter={x:Static c:CornerRadiusTakeConverter.Left}}" />
|
||||
<Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={x:Static c:ThicknessTakeConverter.Left}}" />
|
||||
</Style>
|
||||
<Style Selector="^[Position=Left] /template/ Border#PART_Root">
|
||||
<Setter Property="Margin" Value="0 0 8 0" />
|
||||
<Setter Property="CornerRadius" Value="0 12 12 0" />
|
||||
<Setter Property="BorderThickness" Value="0 0 1 0" />
|
||||
<Setter Property="Margin" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Padding, Converter={x:Static c:ThicknessTakeConverter.Right}}" />
|
||||
<Setter Property="CornerRadius" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius, Converter={x:Static c:CornerRadiusTakeConverter.Right}}" />
|
||||
<Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={x:Static c:ThicknessTakeConverter.Right}}" />
|
||||
</Style>
|
||||
<Style Selector="^[Position=Top] /template/ Border#PART_Root">
|
||||
<Setter Property="Margin" Value="0 0 0 8" />
|
||||
<Setter Property="CornerRadius" Value="0 0 12 12" />
|
||||
<Setter Property="BorderThickness" Value="0 0 0 1" />
|
||||
<Setter Property="Margin" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Padding, Converter={x:Static c:ThicknessTakeConverter.Bottom}}" />
|
||||
<Setter Property="CornerRadius" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius, Converter={x:Static c:CornerRadiusTakeConverter.Bottom}}" />
|
||||
<Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={x:Static c:ThicknessTakeConverter.Bottom}}" />
|
||||
</Style>
|
||||
<Style Selector="^[Position=Bottom] /template/ Border#PART_Root">
|
||||
<Setter Property="Margin" Value="0 8 0 0" />
|
||||
<Setter Property="CornerRadius" Value="12 12 0 0" />
|
||||
<Setter Property="BorderThickness" Value="0 1 0 0" />
|
||||
<Setter Property="Margin" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Padding, Converter={x:Static c:ThicknessTakeConverter.Top}}" />
|
||||
<Setter Property="CornerRadius" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius, Converter={x:Static c:CornerRadiusTakeConverter.Top}}" />
|
||||
<Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={x:Static c:ThicknessTakeConverter.Top}}" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="{x:Type u:DefaultDrawerControl}" TargetType="u:DefaultDrawerControl">
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"></Setter>
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"></Setter>
|
||||
<Setter Property="Padding" Value="{DynamicResource DrawerMargin}"/>
|
||||
<Setter Property="BorderThickness" Value="{DynamicResource DrawerBorderThickness}"/>
|
||||
<Setter Property="CornerRadius" Value="{DynamicResource DrawerCornerRadius}"/>
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:DefaultDrawerControl">
|
||||
<Border Name="PART_Root"
|
||||
Margin="8 -1 -1 -1"
|
||||
Margin="{TemplateBinding Padding, Converter={x:Static c:ThicknessTakeConverter.Left}}"
|
||||
Padding="0"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Classes="Shadow"
|
||||
ClipToBounds="False"
|
||||
CornerRadius="12 0 0 12"
|
||||
BorderThickness="1 0 0 0"
|
||||
CornerRadius="{TemplateBinding CornerRadius, Converter={x:Static c:CornerRadiusTakeConverter.Left}}"
|
||||
BorderThickness="{TemplateBinding BorderThickness, Converter={x:Static c:ThicknessTakeConverter.Left}}"
|
||||
IsHitTestVisible="True"
|
||||
Theme="{DynamicResource CardBorder}">
|
||||
<Border ClipToBounds="True" CornerRadius="{Binding #PART_Root.CornerRadius}">
|
||||
@@ -143,24 +150,24 @@
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^[Position=Right] /template/ Border#PART_Root">
|
||||
<Setter Property="Margin" Value="8 0 0 0" />
|
||||
<Setter Property="CornerRadius" Value="12 0 0 12" />
|
||||
<Setter Property="BorderThickness" Value="1 0 0 0" />
|
||||
<Setter Property="Margin" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Padding, Converter={x:Static c:ThicknessTakeConverter.Left}}" />
|
||||
<Setter Property="CornerRadius" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius, Converter={x:Static c:CornerRadiusTakeConverter.Left}}" />
|
||||
<Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={x:Static c:ThicknessTakeConverter.Left}}" />
|
||||
</Style>
|
||||
<Style Selector="^[Position=Left] /template/ Border#PART_Root">
|
||||
<Setter Property="Margin" Value="0 0 8 0" />
|
||||
<Setter Property="CornerRadius" Value="0 12 12 0" />
|
||||
<Setter Property="BorderThickness" Value="0 0 1 0" />
|
||||
<Setter Property="Margin" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Padding, Converter={x:Static c:ThicknessTakeConverter.Right}}" />
|
||||
<Setter Property="CornerRadius" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius, Converter={x:Static c:CornerRadiusTakeConverter.Right}}" />
|
||||
<Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={x:Static c:ThicknessTakeConverter.Right}}" />
|
||||
</Style>
|
||||
<Style Selector="^[Position=Top] /template/ Border#PART_Root">
|
||||
<Setter Property="Margin" Value="0 0 0 8" />
|
||||
<Setter Property="CornerRadius" Value="0 0 12 12" />
|
||||
<Setter Property="BorderThickness" Value="0 0 0 1" />
|
||||
<Setter Property="Margin" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Padding, Converter={x:Static c:ThicknessTakeConverter.Bottom}}" />
|
||||
<Setter Property="CornerRadius" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius, Converter={x:Static c:CornerRadiusTakeConverter.Bottom}}" />
|
||||
<Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={x:Static c:ThicknessTakeConverter.Bottom}}" />
|
||||
</Style>
|
||||
<Style Selector="^[Position=Bottom] /template/ Border#PART_Root">
|
||||
<Setter Property="Margin" Value="0 8 0 0" />
|
||||
<Setter Property="CornerRadius" Value="12 12 0 0" />
|
||||
<Setter Property="BorderThickness" Value="0 1 0 0" />
|
||||
<Setter Property="Margin" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Padding, Converter={x:Static c:ThicknessTakeConverter.Top}}" />
|
||||
<Setter Property="CornerRadius" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CornerRadius, Converter={x:Static c:CornerRadiusTakeConverter.Top}}" />
|
||||
<Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=BorderThickness, Converter={x:Static c:ThicknessTakeConverter.Top}}" />
|
||||
</Style>
|
||||
</ControlTheme>
|
||||
</ResourceDictionary>
|
||||
|
||||
37
src/Ursa.Themes.Semi/Converters/CornerRadiusTakeConverter.cs
Normal file
37
src/Ursa.Themes.Semi/Converters/CornerRadiusTakeConverter.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Globalization;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace Ursa.Themes.Semi.Converters;
|
||||
|
||||
public class CornerRadiusTakeConverter: IValueConverter
|
||||
{
|
||||
private readonly Dock _dock;
|
||||
internal CornerRadiusTakeConverter(Dock dock)
|
||||
{
|
||||
_dock = dock;
|
||||
}
|
||||
public static CornerRadiusTakeConverter Left { get; } = new(Dock.Left);
|
||||
public static CornerRadiusTakeConverter Top { get; } = new(Dock.Top);
|
||||
public static CornerRadiusTakeConverter Right { get; } = new(Dock.Right);
|
||||
public static CornerRadiusTakeConverter Bottom { get; } = new(Dock.Bottom);
|
||||
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if(value is not CornerRadius c) return AvaloniaProperty.UnsetValue;
|
||||
return _dock switch
|
||||
{
|
||||
Dock.Left => new CornerRadius(c.TopLeft, 0, 0, c.BottomLeft),
|
||||
Dock.Top => new CornerRadius(c.TopLeft, c.TopRight, 0, 0),
|
||||
Dock.Right => new CornerRadius(0, c.TopRight, c.BottomRight, 0),
|
||||
Dock.Bottom => new CornerRadius(0, 0, c.BottomRight, c.BottomLeft),
|
||||
_ => AvaloniaProperty.UnsetValue
|
||||
};
|
||||
}
|
||||
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
36
src/Ursa.Themes.Semi/Converters/ThicknessTakeConverter.cs
Normal file
36
src/Ursa.Themes.Semi/Converters/ThicknessTakeConverter.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Globalization;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Data.Converters;
|
||||
|
||||
namespace Ursa.Themes.Semi.Converters;
|
||||
|
||||
public class ThicknessTakeConverter: IValueConverter
|
||||
{
|
||||
private readonly Dock _dock;
|
||||
internal ThicknessTakeConverter(Dock dock)
|
||||
{
|
||||
_dock = dock;
|
||||
}
|
||||
public static ThicknessTakeConverter Left { get; } = new(Dock.Left);
|
||||
public static ThicknessTakeConverter Top { get; } = new(Dock.Top);
|
||||
public static ThicknessTakeConverter Right { get; } = new(Dock.Right);
|
||||
public static ThicknessTakeConverter Bottom { get; } = new(Dock.Bottom);
|
||||
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is not Thickness t) return AvaloniaProperty.UnsetValue;
|
||||
return _dock switch
|
||||
{
|
||||
Dock.Left => new Thickness(t.Left, 0, 0, 0),
|
||||
Dock.Top => new Thickness(0, t.Top, 0, 0),
|
||||
Dock.Right => new Thickness(0, 0, t.Right, 0),
|
||||
Dock.Bottom => new Thickness(0, 0, 0, t.Bottom),
|
||||
_ => AvaloniaProperty.UnsetValue
|
||||
};
|
||||
}
|
||||
|
||||
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
@@ -5,4 +5,5 @@
|
||||
<StreamGeometry x:Key="DialogArrangeBringToFrontGlyph">M2,2H11V6H9V4H4V9H6V11H2V2M22,13V22H13V18H15V20H20V15H18V13H22M8,8H16V16H8V8Z</StreamGeometry>
|
||||
<StreamGeometry x:Key="DialogArrangeSendBackwardGlyph">M2,2H16V16H2V2M22,8V22H8V18H18V8H22M4,4V14H14V4H4Z</StreamGeometry>
|
||||
<StreamGeometry x:Key="DialogArrangeSendToBackGlyph">M2,2H11V11H2V2M9,4H4V9H9V4M22,13V22H13V13H22M15,20H20V15H15V20M16,8V11H13V8H16M11,16H8V13H11V16Z</StreamGeometry>
|
||||
<CornerRadius x:Key="DialogCornerRadius">12</CornerRadius>
|
||||
</ResourceDictionary>
|
||||
|
||||
7
src/Ursa.Themes.Semi/Themes/Shared/Drawer.axaml
Normal file
7
src/Ursa.Themes.Semi/Themes/Shared/Drawer.axaml
Normal file
@@ -0,0 +1,7 @@
|
||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<!-- Add Resources Here -->
|
||||
<CornerRadius x:Key="DrawerCornerRadius">12</CornerRadius>
|
||||
<Thickness x:Key="DrawerMargin">8</Thickness>
|
||||
<Thickness x:Key="DrawerBorderThickness">1</Thickness>
|
||||
</ResourceDictionary>
|
||||
@@ -8,6 +8,7 @@
|
||||
<MergeResourceInclude Source="Dialog.axaml" />
|
||||
<MergeResourceInclude Source="DialogShared.axaml" />
|
||||
<MergeResourceInclude Source="Divider.axaml" />
|
||||
<MergeResourceInclude Source="Drawer.axaml" />
|
||||
<MergeResourceInclude Source="DualBadge.axaml" />
|
||||
<MergeResourceInclude Source="IPv4Box.axaml" />
|
||||
<MergeResourceInclude Source="KeyGestureInput.axaml" />
|
||||
|
||||
Reference in New Issue
Block a user