fix: fix Borderless TextBox pointerover style.

This commit is contained in:
rabbitism 2022-12-24 15:18:03 +08:00 committed by Dong Bin
parent 78e3dd2dc8
commit ca9e7865d3
2 changed files with 54 additions and 18 deletions

View File

@ -1,16 +1,20 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith> <Design.PreviewWith>
<StackPanel <StackPanel
Width="200" Margin="20" Width="200"
Margin="20"
Spacing="20"> Spacing="20">
<TextBox <TextBox
Classes="clearButton" Text="Hello" Classes="clearButton"
Text="Hello"
Theme="{StaticResource BorderlessTextBox}" /> Theme="{StaticResource BorderlessTextBox}" />
<TextBox <TextBox
Classes="Large" Text="Hello" Classes="Large"
Text="Hello"
Theme="{StaticResource BorderlessTextBox}" /> Theme="{StaticResource BorderlessTextBox}" />
<TextBox <TextBox
Classes="Small" Text="Hello" Classes="Small"
Text="Hello"
Theme="{StaticResource BorderlessTextBox}" /> Theme="{StaticResource BorderlessTextBox}" />
</StackPanel> </StackPanel>
</Design.PreviewWith> </Design.PreviewWith>
@ -25,7 +29,8 @@
<Label Background="Transparent"> <Label Background="Transparent">
<Label.Content> <Label.Content>
<PathIcon <PathIcon
Width="16" Height="16" Width="16"
Height="16"
Data="{DynamicResource TextBoxClearButtonData}" Data="{DynamicResource TextBoxClearButtonData}"
Foreground="{TemplateBinding Foreground}" /> Foreground="{TemplateBinding Foreground}" />
</Label.Content> </Label.Content>
@ -44,11 +49,13 @@
<!-- Background must be transparent or hit test will fail --> <!-- Background must be transparent or hit test will fail -->
<Panel Background="Transparent"> <Panel Background="Transparent">
<PathIcon <PathIcon
Width="16" Height="16" Width="16"
Height="16"
Data="{DynamicResource PasswordBoxRevealButtonData}" Data="{DynamicResource PasswordBoxRevealButtonData}"
IsVisible="{Binding $parent[ToggleButton].IsChecked, Converter={x:Static BoolConverters.Not}}" /> IsVisible="{Binding $parent[ToggleButton].IsChecked, Converter={x:Static BoolConverters.Not}}" />
<PathIcon <PathIcon
Width="16" Height="16" Width="16"
Height="16"
Data="{DynamicResource PasswordBoxHideButtonData}" Data="{DynamicResource PasswordBoxHideButtonData}"
IsVisible="{Binding $parent[ToggleButton].IsChecked}" /> IsVisible="{Binding $parent[ToggleButton].IsChecked}" />
</Panel> </Panel>
@ -122,12 +129,14 @@
</Panel> </Panel>
</ScrollViewer> </ScrollViewer>
<Button <Button
Name="PART_ClearButton" Grid.Column="2" Name="PART_ClearButton"
Grid.Column="2"
Command="{Binding $parent[TextBox].Clear}" Command="{Binding $parent[TextBox].Clear}"
IsVisible="False" IsVisible="False"
Theme="{StaticResource InputClearButton}" /> Theme="{StaticResource InputClearButton}" />
<ToggleButton <ToggleButton
Name="PART_RevealButton" Grid.Column="3" Name="PART_RevealButton"
Grid.Column="3"
Margin="4,0,0,0" Margin="4,0,0,0"
IsChecked="{TemplateBinding RevealPassword, IsChecked="{TemplateBinding RevealPassword,
Mode=TwoWay}" Mode=TwoWay}"
@ -183,6 +192,7 @@
<Setter Property="TextBox.BorderBrush" Value="{DynamicResource TextBoxBorderlessDefaultBorderBrush}" /> <Setter Property="TextBox.BorderBrush" Value="{DynamicResource TextBoxBorderlessDefaultBorderBrush}" />
<Style Selector="^:pointerover"> <Style Selector="^:pointerover">
<Setter Property="TextBox.Background" Value="{DynamicResource TextBoxBorderlessPointeroverBackground}" /> <Setter Property="TextBox.Background" Value="{DynamicResource TextBoxBorderlessPointeroverBackground}" />
<Setter Property="TextBox.BorderBrush" Value="{DynamicResource TextBoxBorderlessPointeroverBorderBrush}" />
</Style> </Style>
<Style Selector="^:focus"> <Style Selector="^:focus">
<Setter Property="TextBox.Background" Value="{DynamicResource TextBoxBorderlessPointeroverBackground}" /> <Setter Property="TextBox.Background" Value="{DynamicResource TextBoxBorderlessPointeroverBackground}" />

View File

@ -1,25 +1,51 @@
<ResourceDictionary <ResourceDictionary
xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=System.Runtime"> xmlns:sys="clr-namespace:System;assembly=System.Runtime">
<SolidColorBrush x:Key="TextBoxDefaultBorderBrush" Color="#C6CACD" /> <SolidColorBrush x:Key="TextBoxDefaultBorderBrush" Color="#C6CACD" />
<SolidColorBrush x:Key="TextBoxDefaultBackground" Color="Transparent" /> <SolidColorBrush x:Key="TextBoxDefaultBackground" Color="Transparent" />
<SolidColorBrush x:Key="TextBoxFocusBackground" Opacity="0.05" Color="#E6E8EA" /> <SolidColorBrush
x:Key="TextBoxFocusBackground"
Opacity="0.05"
Color="#E6E8EA" />
<SolidColorBrush x:Key="TextBoxPointerOverBorderBrush" Color="#0062D6" /> <SolidColorBrush x:Key="TextBoxPointerOverBorderBrush" Color="#0062D6" />
<SolidColorBrush x:Key="TextBoxFocusBorderBrush" Color="#004FB3" /> <SolidColorBrush x:Key="TextBoxFocusBorderBrush" Color="#004FB3" />
<SolidColorBrush x:Key="TextBoxForeground" Color="#1C1F23" /> <SolidColorBrush x:Key="TextBoxForeground" Color="#1C1F23" />
<SolidColorBrush x:Key="TextBoxWatermarkForeground" Color="#1C1F23" /> <SolidColorBrush x:Key="TextBoxWatermarkForeground" Color="#1C1F23" />
<SolidColorBrush x:Key="TextBoxInnerForeground" Opacity="0.62" Color="#1C1F23" /> <SolidColorBrush
x:Key="TextBoxInnerForeground"
Opacity="0.62"
Color="#1C1F23" />
<SolidColorBrush x:Key="TextBoxButtonDefaultForeground" Opacity="0.2" Color="#2E3238" /> <SolidColorBrush
<SolidColorBrush x:Key="TextBoxButtonPointerOverForeground" Opacity="0.4" Color="#2E3238" /> x:Key="TextBoxButtonDefaultForeground"
Opacity="0.2"
Color="#2E3238" />
<SolidColorBrush
x:Key="TextBoxButtonPointerOverForeground"
Opacity="0.4"
Color="#2E3238" />
<SolidColorBrush x:Key="TextBoxDisabledBackground" Opacity="0.04" Color="#403238" /> <SolidColorBrush
<SolidColorBrush x:Key="TextBoxDisabledForeground" Opacity="0.35" Color="#1C1F23" /> x:Key="TextBoxDisabledBackground"
Opacity="0.04"
Color="#403238" />
<SolidColorBrush
x:Key="TextBoxDisabledForeground"
Opacity="0.35"
Color="#1C1F23" />
<SolidColorBrush x:Key="TextBoxDisabledBorderBrush" Color="#E6E8EA" /> <SolidColorBrush x:Key="TextBoxDisabledBorderBrush" Color="#E6E8EA" />
<SolidColorBrush x:Key="TextBoxBorderlessDefaultBackground" Opacity="0.05" Color="#2E3238" /> <SolidColorBrush
x:Key="TextBoxBorderlessDefaultBackground"
Opacity="0.05"
Color="#2E3238" />
<SolidColorBrush x:Key="TextBoxBorderlessDefaultBorderBrush" Color="Transparent" /> <SolidColorBrush x:Key="TextBoxBorderlessDefaultBorderBrush" Color="Transparent" />
<SolidColorBrush x:Key="TextBoxBorderlessPointeroverBackground" Opacity="0.09" Color="#2E3238" /> <SolidColorBrush
x:Key="TextBoxBorderlessPointeroverBackground"
Opacity="0.09"
Color="#2E3238" />
<SolidColorBrush x:Key="TextBoxBorderlessPointeroverBorderBrush" Color="Transparent" />
<sys:Double x:Key="TextBoxDefaultHeight">30</sys:Double> <sys:Double x:Key="TextBoxDefaultHeight">30</sys:Double>
<sys:Double x:Key="TextBoxSmallHeight">22</sys:Double> <sys:Double x:Key="TextBoxSmallHeight">22</sys:Double>