From 4989192d3622abf32867585151050c1dc35bb255 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Sat, 24 Aug 2024 19:23:36 +0800 Subject: [PATCH] feat: 1. add InnerRightContent to NumericUpDown 2. Add Small/Large size classes. 3. Use shared close button theme in Semi.Avalonia. --- demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml | 20 +++++++++++ .../ViewModels/NumericUpDownDemoViewModel.cs | 1 + .../Controls/KeyGestureInput.axaml | 3 +- .../Controls/NumericUpDown.axaml | 33 +++++++------------ .../NumericUpDown/NumericUpDownBase.cs | 17 ++++++++-- 5 files changed, 48 insertions(+), 26 deletions(-) diff --git a/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml b/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml index 610c37a..d854971 100644 --- a/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml +++ b/demo/Ursa.Demo/Pages/NumericUpDownDemo.axaml @@ -6,6 +6,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:u="https://irihi.tech/ursa" xmlns:vm="using:Ursa.Demo.ViewModels" + xmlns:system="clr-namespace:System;assembly=System.Runtime" d:DesignHeight="450" d:DesignWidth="800" x:CompileBindings="True" @@ -34,6 +35,7 @@ FontFamily="{Binding FontFamily, Mode=OneWay}" FormatString="{Binding FormatString}" InnerLeftContent="{Binding InnerLeftContent}" + InnerRightContent="{Binding InnerRightContent}" IsEnabled="{Binding IsEnable}" IsReadOnly="{Binding IsReadOnly}" Maximum="{Binding Maximum}" @@ -125,6 +127,24 @@ Step="1" Watermark="AllowHexSpecifier" Value="2" /> + + + + + + + + + diff --git a/demo/Ursa.Demo/ViewModels/NumericUpDownDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/NumericUpDownDemoViewModel.cs index a4f4435..d7873bf 100644 --- a/demo/Ursa.Demo/ViewModels/NumericUpDownDemoViewModel.cs +++ b/demo/Ursa.Demo/ViewModels/NumericUpDownDemoViewModel.cs @@ -24,6 +24,7 @@ public partial class NumericUpDownDemoViewModel : ObservableObject [ObservableProperty] private Array _arrayHorizontalContentAlignment; [ObservableProperty] private HorizontalAlignment _horizontalContentAlignment = HorizontalAlignment.Center; [ObservableProperty] private object? _innerLeftContent = "obj:0x"; + [ObservableProperty] private object? _innerRightContent = "%"; [ObservableProperty] private string _watermark = "Water mark showed"; [ObservableProperty] private string _formatString = "X8"; [ObservableProperty] private Array _arrayParsingNumberStyle; diff --git a/src/Ursa.Themes.Semi/Controls/KeyGestureInput.axaml b/src/Ursa.Themes.Semi/Controls/KeyGestureInput.axaml index 3adc90d..9548bd9 100644 --- a/src/Ursa.Themes.Semi/Controls/KeyGestureInput.axaml +++ b/src/Ursa.Themes.Semi/Controls/KeyGestureInput.axaml @@ -57,9 +57,10 @@ Margin="0,0,8,0" HorizontalAlignment="Right" Command="{Binding $parent[u:KeyGestureInput].Clear}" + Content="{DynamicResource IconButtonClearData}" Focusable="False" IsVisible="False" - Theme="{DynamicResource InputClearButton}" /> + Theme="{DynamicResource InnerIconButton}" /> diff --git a/src/Ursa.Themes.Semi/Controls/NumericUpDown.axaml b/src/Ursa.Themes.Semi/Controls/NumericUpDown.axaml index 31824c8..bbdf6af 100644 --- a/src/Ursa.Themes.Semi/Controls/NumericUpDown.axaml +++ b/src/Ursa.Themes.Semi/Controls/NumericUpDown.axaml @@ -4,29 +4,9 @@ xmlns:u="https://irihi.tech/ursa"> - - - - - - - - - - - - - - - + @@ -52,6 +32,7 @@ FontSize="{TemplateBinding FontSize}" Foreground="{TemplateBinding Foreground}" InnerLeftContent="{TemplateBinding InnerLeftContent}" + InnerRightContent="{TemplateBinding InnerRightContent}" TextWrapping="NoWrap" Theme="{DynamicResource NonErrorTextBox}" Watermark="{TemplateBinding Watermark}" /> @@ -68,7 +49,8 @@ Command="{Binding $parent[u:NumericUpDown].Clear}" Focusable="False" IsVisible="False" - Theme="{StaticResource InputClearButton}" /> + Content="{DynamicResource IconButtonClearData}" + Theme="{DynamicResource InnerIconButton}" /> @@ -83,5 +65,12 @@ + + + diff --git a/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs b/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs index ed0a380..e69d800 100644 --- a/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs +++ b/src/Ursa/Controls/NumericUpDown/NumericUpDownBase.cs @@ -17,7 +17,7 @@ namespace Ursa.Controls; [TemplatePart(PART_Spinner, typeof(ButtonSpinner))] [TemplatePart(PART_TextBox, typeof(TextBox))] [TemplatePart(PART_DragPanel, typeof(Panel))] -public abstract class NumericUpDown : TemplatedControl, IClearControl +public abstract class NumericUpDown : TemplatedControl, IClearControl, IInnerContentControl { public const string PART_Spinner = "PART_Spinner"; public const string PART_TextBox = "PART_TextBox"; @@ -62,8 +62,9 @@ public abstract class NumericUpDown : TemplatedControl, IClearControl set => SetValue(HorizontalContentAlignmentProperty, value); } - public static readonly StyledProperty InnerLeftContentProperty = AvaloniaProperty.Register( - nameof(InnerLeftContent)); + public static readonly StyledProperty InnerLeftContentProperty = + AvaloniaProperty.Register( + nameof(InnerLeftContent)); public object? InnerLeftContent { @@ -71,6 +72,16 @@ public abstract class NumericUpDown : TemplatedControl, IClearControl set => SetValue(InnerLeftContentProperty, value); } + public static readonly StyledProperty InnerRightContentProperty = + AvaloniaProperty.Register( + nameof(InnerRightContent)); + + public object? InnerRightContent + { + get => GetValue(InnerRightContentProperty); + set => SetValue(InnerRightContentProperty, value); + } + public static readonly StyledProperty WatermarkProperty = AvaloniaProperty.Register( nameof(Watermark));