- Fix ImageIcon Size when Selected Situation

- Fix Preview in setting window
- Add ImageIcon Width property
This commit is contained in:
DB p 2023-01-09 10:42:05 +09:00
parent a92ebf5756
commit ed526e3486
4 changed files with 87 additions and 104 deletions

View file

@ -9,11 +9,11 @@
xmlns:svgc="http://sharpvectors.codeplex.com/svgc/"
xmlns:ui="http://schemas.modernwpf.com/2019"
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
d:DataContext="{d:DesignInstance Type=vm:MainViewModel}"
Name="FlowMainWindow"
Title="Flow Launcher"
MinWidth="{Binding MainWindowWidth, Mode=OneWay}"
MaxWidth="{Binding MainWindowWidth, Mode=OneWay}"
d:DataContext="{d:DesignInstance Type=vm:MainViewModel}"
AllowDrop="True"
AllowsTransparency="True"
Background="Transparent"
@ -38,9 +38,9 @@
<converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter" />
<converters:BorderClipConverter x:Key="BorderClipConverter" />
<converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter" />
<converters:BoolToIMEConversionModeConverter x:Key="BoolToIMEConversionModeConverter"/>
<converters:BoolToIMEStateConverter x:Key="BoolToIMEStateConverter"/>
<converters:StringToKeyBindingConverter x:Key="StringToKeyBindingConverter"/>
<converters:BoolToIMEConversionModeConverter x:Key="BoolToIMEConversionModeConverter" />
<converters:BoolToIMEStateConverter x:Key="BoolToIMEStateConverter" />
<converters:StringToKeyBindingConverter x:Key="StringToKeyBindingConverter" />
</Window.Resources>
<Window.InputBindings>
<KeyBinding Key="Escape" Command="{Binding EscCommand}" />
@ -180,11 +180,11 @@
<KeyBinding
Key="F12"
Command="{Binding ToggleGameModeCommand}"
Modifiers="Ctrl"/>
Modifiers="Ctrl" />
<KeyBinding
Key="{Binding PreviewHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='key'}"
Command="{Binding TogglePreviewCommand}"
Modifiers="{Binding PreviewHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='modifiers'}"/>
Modifiers="{Binding PreviewHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='modifiers'}" />
</Window.InputBindings>
<Grid>
<Border MouseDown="OnMouseDown" Style="{DynamicResource WindowBorderStyle}">
@ -207,12 +207,12 @@
<TextBox
x:Name="QueryTextBox"
AllowDrop="True"
InputMethod.PreferredImeConversionMode="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEConversionModeConverter}}"
InputMethod.PreferredImeState="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEStateConverter}}"
PreviewDragOver="OnPreviewDragOver"
PreviewKeyUp="QueryTextBox_KeyUp"
Style="{DynamicResource QueryBoxStyle}"
Text="{Binding QueryText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
InputMethod.PreferredImeConversionMode="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEConversionModeConverter}}"
InputMethod.PreferredImeState="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEStateConverter}}"
Visibility="Visible">
<TextBox.CommandBindings>
<CommandBinding Command="ApplicationCommands.Copy" Executed="OnCopy" />
@ -273,9 +273,6 @@
<Grid>
<Image
x:Name="PluginActivationIcon"
Width="32"
Height="32"
Margin="0,0,18,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Panel.ZIndex="2"
@ -403,10 +400,10 @@
VerticalAlignment="Stretch"
Style="{DynamicResource PreviewArea}"
Visibility="{Binding PreviewVisible, Converter={StaticResource BoolToVisibilityConverter}}">
<Border
Style="{DynamicResource PreviewBorderStyle}"
<Border
d:DataContext="{d:DesignInstance vm:ResultViewModel}"
DataContext="{Binding SelectedItem, ElementName=ResultListBox}"
Style="{DynamicResource PreviewBorderStyle}"
Visibility="{Binding ShowDefaultPreview}">
<Grid
Margin="20,0,10,0"
@ -478,10 +475,10 @@
</StackPanel>
</Grid>
</Border>
<Border
<Border
d:DataContext="{d:DesignInstance vm:ResultViewModel}"
DataContext="{Binding SelectedItem, ElementName=ResultListBox}"
Style="{DynamicResource PreviewBorderStyle}"
Style="{DynamicResource PreviewBorderStyle}"
Visibility="{Binding ShowCustomizedPreview}">
<ContentControl Content="{Binding Result.PreviewPanel.Value}" />
</Border>

View file

@ -1,4 +1,5 @@
<ListBox x:Class="Flow.Launcher.ResultListBox"
<ListBox
x:Class="Flow.Launcher.ResultListBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converter="clr-namespace:Flow.Launcher.Converters"
@ -43,7 +44,8 @@
</ControlTemplate>
</Button.Template>
<Button.Content>
<Grid Margin="0"
<Grid
Margin="0"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Cursor="Hand"
@ -54,32 +56,30 @@
<converter:OpenResultHotkeyVisibilityConverter x:Key="OpenResultHotkeyVisibilityConverter" />
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="60" />
<ColumnDefinition Style="{DynamicResource ImageAreaWidth}" />
<ColumnDefinition Width="9*" />
<ColumnDefinition Width="Auto"
MinWidth="8" />
<ColumnDefinition Width="Auto" MinWidth="8" />
</Grid.ColumnDefinitions>
<StackPanel x:Name="HotkeyArea"
<StackPanel
x:Name="HotkeyArea"
Grid.Column="2"
Margin="0,0,10,0"
VerticalAlignment="Center"
Visibility="{Binding ShowOpenResultHotkey}">
<TextBlock x:Name="Hotkey"
<TextBlock
x:Name="Hotkey"
Margin="12,0,12,0"
Padding="0,0,0,0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Style="{DynamicResource ItemHotkeyStyle}">
<TextBlock.Visibility>
<Binding
Converter="{StaticResource ResourceKey=OpenResultHotkeyVisibilityConverter}"
RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}" />
<Binding Converter="{StaticResource ResourceKey=OpenResultHotkeyVisibilityConverter}" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}" />
</TextBlock.Visibility>
<TextBlock.Text>
<MultiBinding StringFormat="{}{0}+{1}">
<Binding Path="OpenResultModifiers" />
<Binding Converter="{StaticResource ResourceKey=OrdinalConverter}"
RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}" />
<Binding Converter="{StaticResource ResourceKey=OrdinalConverter}" RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=ListBoxItem}" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
@ -91,37 +91,37 @@
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border x:Name="Bullet"
<Border
x:Name="Bullet"
Grid.Column="0"
Style="{DynamicResource BulletStyle}" />
<Border Grid.Column="1"
<Border
Grid.Column="1"
Margin="9,0,0,0"
BorderBrush="Transparent"
BorderThickness="1">
<Image x:Name="ImageIcon"
Style="{DynamicResource ImageIconStyle}"
<Image
x:Name="ImageIcon"
Margin="0,0,0,0"
HorizontalAlignment="Center"
IsHitTestVisible="False"
RenderOptions.BitmapScalingMode="Fant"
Source="{Binding Image, TargetNullValue={x:Null}}"
Stretch="Uniform"
Style="{DynamicResource ImageIconStyle}"
Visibility="{Binding ShowIcon}">
<Image.Clip>
<EllipseGeometry
Center="{Binding ElementName=ImageIcon, Path=ActualWidth, Converter={StaticResource DiameterToCenterPointConverter}}">
<EllipseGeometry Center="{Binding ElementName=ImageIcon, Path=ActualWidth, Converter={StaticResource DiameterToCenterPointConverter}}">
<EllipseGeometry.RadiusX>
<MultiBinding Converter="{StaticResource IconRadiusConverter}">
<Binding ElementName="ImageIcon"
Path="ActualWidth" />
<Binding ElementName="ImageIcon" Path="ActualWidth" />
<Binding Path="Result.RoundedIcon" />
</MultiBinding>
</EllipseGeometry.RadiusX>
<EllipseGeometry.RadiusY>
<MultiBinding Converter="{StaticResource IconRadiusConverter}">
<Binding ElementName="ImageIcon"
Path="ActualWidth" />
<Binding ElementName="ImageIcon" Path="ActualWidth" />
<Binding Path="Result.RoundedIcon" />
</MultiBinding>
</EllipseGeometry.RadiusY>
@ -129,11 +129,13 @@
</Image.Clip>
</Image>
</Border>
<Border Grid.Column="1"
<Border
Grid.Column="1"
Margin="9,0,0,0"
BorderBrush="Transparent"
BorderThickness="0">
<TextBlock x:Name="GlyphIcon"
<TextBlock
x:Name="GlyphIcon"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="{Binding Glyph.FontFamily}"
@ -143,35 +145,33 @@
</Border>
</Grid>
<Grid Grid.Column="1"
<Grid
Grid.Column="1"
Margin="6,0,10,0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition x:Name="SubTitleRowDefinition"
Height="Auto" />
<RowDefinition x:Name="SubTitleRowDefinition" Height="Auto" />
</Grid.RowDefinitions>
<ProgressBar x:Name="progressbarResult"
<ProgressBar
x:Name="progressbarResult"
Grid.Row="0"
Foreground="{Binding Result.ProgressBarColor}"
Value="{Binding ResultProgress, Mode=OneWay}">
<ProgressBar.Style>
<Style BasedOn="{StaticResource ProgressBarResult}"
TargetType="ProgressBar">
<Setter Property="Visibility"
Value="Visible" />
<Style BasedOn="{StaticResource ProgressBarResult}" TargetType="ProgressBar">
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<DataTrigger Binding="{Binding Result.ProgressBar}"
Value="{x:Null}">
<Setter Property="Visibility"
Value="Collapsed" />
<DataTrigger Binding="{Binding Result.ProgressBar}" Value="{x:Null}">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</ProgressBar.Style>
</ProgressBar>
<TextBlock x:Name="Title"
<TextBlock
x:Name="Title"
Grid.Row="0"
VerticalAlignment="Center"
DockPanel.Dock="Left"
@ -188,7 +188,8 @@
</MultiBinding>
</vm:ResultsViewModel.FormattedText>
</TextBlock>
<TextBlock x:Name="SubTitle"
<TextBlock
x:Name="SubTitle"
Grid.Row="1"
IsEnabled="False"
Style="{DynamicResource ItemSubTitleStyle}"
@ -203,27 +204,12 @@
</Button>
<!-- a result item height is 52 including margin -->
<DataTemplate.Triggers>
<DataTrigger
Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}"
Value="True">
<Setter TargetName="Bullet"
Property="Style"
Value="{DynamicResource ItemBulletSelectedStyle}" />
<Setter TargetName="Title"
Property="Style"
Value="{DynamicResource ItemTitleSelectedStyle}" />
<Setter TargetName="SubTitle"
Property="Style"
Value="{DynamicResource ItemSubTitleSelectedStyle}" />
<Setter TargetName="Hotkey"
Property="Style"
Value="{DynamicResource ItemHotkeySelectedStyle}" />
<Setter TargetName="ImageIcon"
Property="Style"
Value="{DynamicResource ItemImageSelectedStyle}" />
<Setter TargetName="GlyphIcon"
Property="Style"
Value="{DynamicResource ItemGlyphSelectedStyle}" />
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
<Setter TargetName="Bullet" Property="Style" Value="{DynamicResource ItemBulletSelectedStyle}" />
<Setter TargetName="Title" Property="Style" Value="{DynamicResource ItemTitleSelectedStyle}" />
<Setter TargetName="SubTitle" Property="Style" Value="{DynamicResource ItemSubTitleSelectedStyle}" />
<Setter TargetName="Hotkey" Property="Style" Value="{DynamicResource ItemHotkeySelectedStyle}" />
<Setter TargetName="GlyphIcon" Property="Style" Value="{DynamicResource ItemGlyphSelectedStyle}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
@ -231,28 +217,24 @@
<!-- http://stackoverflow.com/questions/16819577/setting-background-color-or-wpf-4-0-listbox-windows-8/#16820062 -->
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<EventSetter Event="MouseEnter"
Handler="OnMouseEnter" />
<EventSetter Event="MouseMove"
Handler="OnMouseMove" />
<Setter Property="Height"
Value="{DynamicResource ResultItemHeight}" />
<Setter Property="Margin"
Value="0" />
<Setter Property="Padding"
Value="0" />
<Setter Property="BorderThickness"
Value="0" />
<EventSetter Event="MouseEnter" Handler="OnMouseEnter" />
<EventSetter Event="MouseMove" Handler="OnMouseMove" />
<Setter Property="Height" Value="{DynamicResource ResultItemHeight}" />
<Setter Property="Margin" Value="0" />
<Setter Property="Padding" Value="0" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border x:Name="Bd"
<Border
x:Name="Bd"
Margin="{DynamicResource ItemMargin}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="{DynamicResource ItemRadius}"
SnapsToDevicePixels="True">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
<ContentPresenter
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
@ -260,14 +242,9 @@
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected"
Value="True">
<Setter TargetName="Bd"
Property="Background"
Value="{DynamicResource ItemSelectedBackgroundColor}" />
<Setter TargetName="Bd"
Property="BorderBrush"
Value="{DynamicResource ItemSelectedBackgroundColor}" />
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource ItemSelectedBackgroundColor}" />
<Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource ItemSelectedBackgroundColor}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>

View file

@ -1821,7 +1821,7 @@
</Border.Clip>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="54" />
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
@ -2438,7 +2438,7 @@
<Border Margin="0,8,0,0" Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource previewHotkey}"/>
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource previewHotkey}" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource previewHotkeyToolTip}" />
</StackPanel>
<flowlauncher:HotkeyControl

View file

@ -9,7 +9,7 @@
<!-- Further font customisations are dynamically loaded in Theme.cs -->
<system:Double x:Key="ResultItemHeight">52</system:Double>
<Style x:Key="BaseBulletStyle" TargetType="{x:Type Border}" />
<Style
x:Key="BulletStyle"
@ -19,11 +19,9 @@
x:Key="ItemBulletSelectedStyle"
BasedOn="{StaticResource BaseBulletStyle}"
TargetType="{x:Type Border}" />
<Style
x:Key="ImageIconStyle"
TargetType="{x:Type Image}">
<Setter Property="Height" Value="32"/>
<Setter Property="Width" Value="32"/>
<Style x:Key="ImageIconStyle" TargetType="{x:Type Image}">
<Setter Property="Height" Value="32" />
<Setter Property="Width" Value="32" />
</Style>
<Style x:Key="BaseQueryBoxStyle" TargetType="{x:Type TextBox}">
@ -433,6 +431,9 @@
</DataTrigger>
</Style.Triggers>
</Style>
<Style x:Key="ImageAreaWidth" TargetType="{x:Type ColumnDefinition}">
<Setter Property="Width" Value="60" />
</Style>
<Style
x:Key="PreviewGlyph"
BasedOn="{StaticResource BasePreviewGlyph}"
@ -472,6 +473,14 @@
</Style.Triggers>
</Style>
<!-- for classic themes -->
<Style x:Key="PluginActivationIcon" TargetType="{x:Type Image}">
<Setter Property="Width" Value="32" />
<Setter Property="Height" Value="32" />
<Setter Property="Margin" Value="0,0,18,0" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
<Style x:Key="SearchIconStyle" TargetType="{x:Type Path}">
<Setter Property="Fill" Value="#555555" />
<Setter Property="Width" Value="32" />