Skip to content

Commit

Permalink
Merge pull request #2836 from Wox-launcher/bao
Browse files Browse the repository at this point in the history
better text highlight effect
  • Loading branch information
bao-qian authored Apr 22, 2020
2 parents 936be21 + a3f0442 commit 87f5d9b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 50 deletions.
11 changes: 9 additions & 2 deletions Wox/Converters/HighlightTextConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Windows;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;

namespace Wox.Converters
{
Expand All @@ -30,11 +31,17 @@ public object Convert(object[] value, Type targetType, object parameter, Culture
var currentCharacter = text.Substring(i, 1);
if (this.ShouldHighlight(highlightData, i))
{
textBlock.Inlines.Add(new Bold(new Run(currentCharacter)));
textBlock.Inlines.Add((new Run(currentCharacter)
{
FontWeight = FontWeights.Bold
}));
}
else
{
textBlock.Inlines.Add(new Run(currentCharacter));
textBlock.Inlines.Add(new Run(currentCharacter)
{
Foreground = Brushes.LightGray
});
}
}
return textBlock;
Expand Down
5 changes: 3 additions & 2 deletions Wox/ResultListBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</Grid.RowDefinitions>
<TextBlock Style="{DynamicResource ItemTitleStyle}" DockPanel.Dock="Left"
VerticalAlignment="Center" ToolTip="{Binding Result.Title}" x:Name="Title"
Text="{Binding Result.Title}">
RenderOptions.ClearTypeHint="Enabled" >
<vm:ResultsViewModel.FormattedText>
<MultiBinding Converter="{StaticResource HighlightTextConverter}">
<Binding Path="Result.Title" />
Expand All @@ -57,7 +57,8 @@
</vm:ResultsViewModel.FormattedText>
</TextBlock>
<TextBlock Style="{DynamicResource ItemSubTitleStyle}" ToolTip="{Binding Result.SubTitle}"
Grid.Row="1" x:Name="SubTitle" Text="{Binding Result.SubTitle}">
Grid.Row="1" x:Name="SubTitle"
RenderOptions.ClearTypeHint="Enabled" >
<vm:ResultsViewModel.FormattedText>
<MultiBinding Converter="{StaticResource HighlightTextConverter}">
<Binding Path="Result.SubTitle" />
Expand Down
29 changes: 21 additions & 8 deletions Wox/Themes/Base.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@
<Setter Property="CaretBrush" Value="#E3E0E3" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<ScrollViewer x:Name="PART_ContentHost" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"
Background="{TemplateBinding Background}">
<ScrollViewer.ContentTemplate>
<DataTemplate>
<Grid Background="{Binding Background, ElementName=PART_ContentHost}" RenderOptions.ClearTypeHint="Enabled">
<ContentPresenter Content="{Binding Path=Content, ElementName=PART_ContentHost}"></ContentPresenter>
</Grid>
</DataTemplate>
</ScrollViewer.ContentTemplate>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="BaseWindowBorderStyle" TargetType="{x:Type Border}">
<Setter Property="BorderThickness" Value="0" />
Expand All @@ -30,21 +48,16 @@
<!-- Item Style -->
<Style x:Key="BaseItemTitleStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#FFFFF8" />
<Setter Property="FontSize" Value="16" />
<Setter Property="FontSize" Value="18" />
<Setter Property="FontWeight" Value="Medium" />
</Style>
<Style x:Key="BaseItemSubTitleStyle" TargetType="{x:Type TextBlock}" >
<Setter Property="Foreground" Value="#D9D9D4" />
</Style>
<Style x:Key="BaseItemNumberStyle" TargetType="{x:Type TextBlock}">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Center" />
<Setter Property="Margin" Value="3 0 0 0" />
<Setter Property="FontSize" Value="22" />
</Style>

<Style x:Key="BaseItemTitleSelectedStyle" TargetType="{x:Type TextBlock}" >
<Setter Property="Foreground" Value="#FFFFF8" />
<Setter Property="FontSize" Value="16" />
<Setter Property="FontSize" Value="18" />
<Setter Property="FontWeight" Value="Medium" />
</Style>
<Style x:Key="BaseItemSubTitleSelectedStyle" TargetType="{x:Type TextBlock}" >
Expand Down
6 changes: 2 additions & 4 deletions Wox/Themes/Gray.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
<Style x:Key="PendingLineStyle" BasedOn="{StaticResource BasePendingLineStyle}" TargetType="{x:Type Line}" />
<Style x:Key="ItemTitleStyle" BasedOn="{StaticResource BaseItemTitleStyle}" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#333333" />
<Setter Property="FontWeight" Value="Bold" />
</Style>
<Style x:Key="ItemNumberStyle" BasedOn="{StaticResource BaseItemNumberStyle}" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#A6A6A6" />
<Setter Property="FontWeight" Value="Medium" />
</Style>

<Style x:Key="ItemSubTitleStyle" BasedOn="{StaticResource BaseItemSubTitleStyle}" TargetType="{x:Type TextBlock}">
<Setter Property="Foreground" Value="#A6A6A6" />
</Style>
Expand Down
34 changes: 0 additions & 34 deletions azure-pipelines.yml

This file was deleted.

0 comments on commit 87f5d9b

Please sign in to comment.