From 2a11f6801ca791152f4d910288cd25a7d5a221df Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Wed, 12 Aug 2020 21:35:59 +0800 Subject: [PATCH] address review --- samples/ControlCatalog/Pages/TextBoxPage.xaml | 5 ++-- .../Presenters/TextPresenter.cs | 16 ++++++------- src/Avalonia.Controls/TextBox.cs | 10 ++++---- src/Avalonia.Themes.Fluent/TextBox.xaml | 24 +++++++------------ 4 files changed, 23 insertions(+), 32 deletions(-) diff --git a/samples/ControlCatalog/Pages/TextBoxPage.xaml b/samples/ControlCatalog/Pages/TextBoxPage.xaml index 256212eaf1..099d40b3de 100644 --- a/samples/ControlCatalog/Pages/TextBoxPage.xaml +++ b/samples/ControlCatalog/Pages/TextBoxPage.xaml @@ -20,7 +20,7 @@ @@ -39,8 +39,7 @@ - - + resm fonts diff --git a/src/Avalonia.Controls/Presenters/TextPresenter.cs b/src/Avalonia.Controls/Presenters/TextPresenter.cs index 1cd7e11564..0841030aaa 100644 --- a/src/Avalonia.Controls/Presenters/TextPresenter.cs +++ b/src/Avalonia.Controls/Presenters/TextPresenter.cs @@ -14,8 +14,8 @@ namespace Avalonia.Controls.Presenters o => o.CaretIndex, (o, v) => o.CaretIndex = v); - public static readonly StyledProperty ShowPasswordTextProperty = - AvaloniaProperty.Register(nameof(ShowPasswordText)); + public static readonly StyledProperty RevealPasswordTextProperty = + AvaloniaProperty.Register(nameof(RevealPasswordText)); public static readonly StyledProperty PasswordCharProperty = AvaloniaProperty.Register(nameof(PasswordChar)); @@ -78,7 +78,7 @@ namespace Avalonia.Controls.Presenters static TextPresenter() { AffectsRender(SelectionBrushProperty); - AffectsMeasure(TextProperty, PasswordCharProperty, ShowPasswordTextProperty, + AffectsMeasure(TextProperty, PasswordCharProperty, RevealPasswordTextProperty, TextAlignmentProperty, TextWrappingProperty, TextBlock.FontSizeProperty, TextBlock.FontStyleProperty, TextBlock.FontWeightProperty, TextBlock.FontFamilyProperty); @@ -87,7 +87,7 @@ namespace Avalonia.Controls.Presenters TextBlock.FontSizeProperty.Changed, TextBlock.FontStyleProperty.Changed, TextBlock.FontWeightProperty.Changed, TextBlock.FontFamilyProperty.Changed, SelectionStartProperty.Changed, SelectionEndProperty.Changed, - SelectionForegroundBrushProperty.Changed, PasswordCharProperty.Changed, ShowPasswordTextProperty.Changed + SelectionForegroundBrushProperty.Changed, PasswordCharProperty.Changed, RevealPasswordTextProperty.Changed ).AddClassHandler((x, _) => x.InvalidateFormattedText()); CaretIndexProperty.Changed.AddClassHandler((x, e) => x.CaretIndexChanged((int)e.NewValue)); @@ -213,10 +213,10 @@ namespace Avalonia.Controls.Presenters set => SetValue(PasswordCharProperty, value); } - public bool ShowPasswordText + public bool RevealPasswordText { - get => GetValue(ShowPasswordTextProperty); - set => SetValue(ShowPasswordTextProperty, value); + get => GetValue(RevealPasswordTextProperty); + set => SetValue(RevealPasswordTextProperty, value); } public IBrush SelectionBrush @@ -435,7 +435,7 @@ namespace Avalonia.Controls.Presenters var text = Text; - if (PasswordChar != default(char) && !ShowPasswordText) + if (PasswordChar != default(char) && !RevealPasswordText) { result = CreateFormattedTextInternal(_constraint, new string(PasswordChar, text?.Length ?? 0)); } diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 489937147f..0e0d053d88 100644 --- a/src/Avalonia.Controls/TextBox.cs +++ b/src/Avalonia.Controls/TextBox.cs @@ -101,8 +101,8 @@ namespace Avalonia.Controls public static readonly StyledProperty InnerRightContentProperty = AvaloniaProperty.Register(nameof(InnerRightContent)); - public static readonly StyledProperty ShowPasswordTextProperty = - AvaloniaProperty.Register(nameof(ShowPasswordText)); + public static readonly StyledProperty RevealPasswordTextProperty = + AvaloniaProperty.Register(nameof(RevealPasswordText)); struct UndoRedoState : IEquatable { @@ -347,10 +347,10 @@ namespace Avalonia.Controls set { SetValue(InnerRightContentProperty, value); } } - public bool ShowPasswordText + public bool RevealPasswordText { - get { return GetValue(ShowPasswordTextProperty); } - set { SetValue(ShowPasswordTextProperty, value); } + get { return GetValue(RevealPasswordTextProperty); } + set { SetValue(RevealPasswordTextProperty, value); } } public TextWrapping TextWrapping diff --git a/src/Avalonia.Themes.Fluent/TextBox.xaml b/src/Avalonia.Themes.Fluent/TextBox.xaml index 8bc8d38c01..bd10fbbe51 100644 --- a/src/Avalonia.Themes.Fluent/TextBox.xaml +++ b/src/Avalonia.Themes.Fluent/TextBox.xaml @@ -10,11 +10,11 @@ 0,0,0,4 - + - + @@ -96,7 +96,7 @@ TextAlignment="{TemplateBinding TextAlignment}" TextWrapping="{TemplateBinding TextWrapping}" PasswordChar="{TemplateBinding PasswordChar}" - ShowPasswordText="{TemplateBinding ShowPasswordText}" + RevealPasswordText="{TemplateBinding RevealPasswordText}" SelectionBrush="{TemplateBinding SelectionBrush}" SelectionForegroundBrush="{TemplateBinding SelectionForegroundBrush}" CaretBrush="{TemplateBinding CaretBrush}" @@ -166,28 +166,20 @@ - - - -