From 661480e55c957295aebdabd7374ae197dae6a6d4 Mon Sep 17 00:00:00 2001 From: Jumar Macato Date: Wed, 12 Aug 2020 20:59:01 +0800 Subject: [PATCH] polish --- samples/ControlCatalog/Pages/TextBoxPage.xaml | 21 ++--------- .../Presenters/TextPresenter.cs | 16 ++++---- src/Avalonia.Controls/TextBox.cs | 10 ++--- src/Avalonia.Themes.Fluent/TextBox.xaml | 37 +++++++++++++++++-- 4 files changed, 49 insertions(+), 35 deletions(-) diff --git a/samples/ControlCatalog/Pages/TextBoxPage.xaml b/samples/ControlCatalog/Pages/TextBoxPage.xaml index 8dc947c298..256212eaf1 100644 --- a/samples/ControlCatalog/Pages/TextBoxPage.xaml +++ b/samples/ControlCatalog/Pages/TextBoxPage.xaml @@ -2,22 +2,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="ControlCatalog.Pages.TextBoxPage"> - - - - TextBox A control into which the user can input text @@ -36,6 +20,7 @@ @@ -54,8 +39,8 @@ - - + + resm fonts diff --git a/src/Avalonia.Controls/Presenters/TextPresenter.cs b/src/Avalonia.Controls/Presenters/TextPresenter.cs index ef33ac19f6..1cd7e11564 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 ShowPasswordCharProperty = - AvaloniaProperty.Register(nameof(ShowPasswordChar), true); + public static readonly StyledProperty ShowPasswordTextProperty = + AvaloniaProperty.Register(nameof(ShowPasswordText)); public static readonly StyledProperty PasswordCharProperty = AvaloniaProperty.Register(nameof(PasswordChar)); @@ -78,7 +78,7 @@ namespace Avalonia.Controls.Presenters static TextPresenter() { AffectsRender(SelectionBrushProperty); - AffectsMeasure(TextProperty, PasswordCharProperty, ShowPasswordCharProperty, + AffectsMeasure(TextProperty, PasswordCharProperty, ShowPasswordTextProperty, 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, ShowPasswordCharProperty.Changed + SelectionForegroundBrushProperty.Changed, PasswordCharProperty.Changed, ShowPasswordTextProperty.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 ShowPasswordChar + public bool ShowPasswordText { - get => GetValue(ShowPasswordCharProperty); - set => SetValue(ShowPasswordCharProperty, value); + get => GetValue(ShowPasswordTextProperty); + set => SetValue(ShowPasswordTextProperty, value); } public IBrush SelectionBrush @@ -435,7 +435,7 @@ namespace Avalonia.Controls.Presenters var text = Text; - if (PasswordChar != default(char) && ShowPasswordChar) + if (PasswordChar != default(char) && !ShowPasswordText) { result = CreateFormattedTextInternal(_constraint, new string(PasswordChar, text?.Length ?? 0)); } diff --git a/src/Avalonia.Controls/TextBox.cs b/src/Avalonia.Controls/TextBox.cs index 08e4e923f5..489937147f 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 ShowPasswordCharProperty = - AvaloniaProperty.Register(nameof(ShowPasswordChar)); + public static readonly StyledProperty ShowPasswordTextProperty = + AvaloniaProperty.Register(nameof(ShowPasswordText)); struct UndoRedoState : IEquatable { @@ -347,10 +347,10 @@ namespace Avalonia.Controls set { SetValue(InnerRightContentProperty, value); } } - public bool ShowPasswordChar + public bool ShowPasswordText { - get { return GetValue(ShowPasswordCharProperty); } - set { SetValue(ShowPasswordCharProperty, value); } + get { return GetValue(ShowPasswordTextProperty); } + set { SetValue(ShowPasswordTextProperty, value); } } public TextWrapping TextWrapping diff --git a/src/Avalonia.Themes.Fluent/TextBox.xaml b/src/Avalonia.Themes.Fluent/TextBox.xaml index 0735b83014..3b66e7f09e 100644 --- a/src/Avalonia.Themes.Fluent/TextBox.xaml +++ b/src/Avalonia.Themes.Fluent/TextBox.xaml @@ -1,6 +1,14 @@ 0,0,0,4 + + + + + + + + - + + + + +