- Add Theme Editor

- Add Subtitle font style combobox
This commit is contained in:
DB p 2024-05-14 17:58:32 +09:00
parent 2e3b61cec6
commit a628bc58b7
6 changed files with 402 additions and 85 deletions

View file

@ -176,8 +176,6 @@ namespace Flow.Launcher.Core.Resource
}
if (dict["ItemTitleStyle"] is Style resultItemStyle &&
dict["ItemSubTitleStyle"] is Style resultSubItemStyle &&
dict["ItemSubTitleSelectedStyle"] is Style resultSubItemSelectedStyle &&
dict["ItemTitleSelectedStyle"] is Style resultItemSelectedStyle &&
dict["ItemHotkeyStyle"] is Style resultHotkeyItemStyle &&
dict["ItemHotkeySelectedStyle"] is Style resultHotkeyItemSelectedStyle)
@ -189,9 +187,25 @@ namespace Flow.Launcher.Core.Resource
Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch };
Array.ForEach(
new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle, resultHotkeyItemStyle, resultHotkeyItemSelectedStyle }, o
new[] { resultItemStyle, resultItemSelectedStyle, resultHotkeyItemStyle, resultHotkeyItemSelectedStyle }, o
=> Array.ForEach(setters, p => o.Setters.Add(p)));
}
if (
dict["ItemSubTitleStyle"] is Style resultSubItemStyle &&
dict["ItemSubTitleSelectedStyle"] is Style resultSubItemSelectedStyle)
{
Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(Settings.ResultSubFont));
Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(Settings.ResultSubFontStyle));
Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(Settings.ResultSubFontWeight));
Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(Settings.ResultSubFontStretch));
Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch };
Array.ForEach(
new[] { resultSubItemStyle,resultSubItemSelectedStyle}, o
=> Array.ForEach(setters, p => o.Setters.Add(p)));
}
/* Ignore Theme Window Width and use setting */
var windowStyle = dict["WindowStyle"] as Style;
var width = Settings.WindowSize;

View file

@ -69,6 +69,10 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public string ResultFontStyle { get; set; }
public string ResultFontWeight { get; set; }
public string ResultFontStretch { get; set; }
public string ResultSubFont { get; set; } = FontFamily.GenericSansSerif.Name;
public string ResultSubFontStyle { get; set; }
public string ResultSubFontWeight { get; set; }
public string ResultSubFontStretch { get; set; }
public bool UseGlyphIcons { get; set; } = true;
public bool UseAnimation { get; set; } = true;
public bool UseSound { get; set; } = true;

View file

@ -38,7 +38,7 @@
mc:Ignorable="d">
<!-- WindowChrome -->
<WindowChrome.WindowChrome>
<WindowChrome CaptionHeight="8" ResizeBorderThickness="0 4 32 32" />
<WindowChrome CaptionHeight="9" ResizeBorderThickness="32 4 32 32" />
</WindowChrome.WindowChrome>
<Window.Resources>
<converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter" />
@ -213,6 +213,7 @@
<TextBox
x:Name="QueryTextSuggestionBox"
Height="{Binding MainWindowHeight, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
FontSize="{Binding QueryBoxFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsEnabled="False"
Style="{DynamicResource QuerySuggestionBoxStyle}">
<TextBox.Text>
@ -228,6 +229,7 @@
Height="{Binding MainWindowHeight, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
AllowDrop="True"
AutomationProperties.Name="{Binding Results.SelectedItem.Result.Title}"
FontSize="{Binding QueryBoxFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
InputMethod.PreferredImeConversionMode="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEConversionModeConverter}}"
InputMethod.PreferredImeState="{Binding StartWithEnglishMode, Converter={StaticResource BoolToIMEStateConverter}}"
PreviewDragOver="OnPreviewDragOver"

View file

@ -173,8 +173,10 @@
<TextBlock
x:Name="Title"
Grid.Row="0"
VerticalAlignment="Center"
Margin="0,0,0,1"
VerticalAlignment="Bottom"
DockPanel.Dock="Left"
FontSize="{Binding ResultItemFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsEnabled="False"
Style="{DynamicResource ItemTitleStyle}"
Text="{Binding Result.Title}"
@ -191,6 +193,9 @@
<TextBlock
x:Name="SubTitle"
Grid.Row="1"
Margin="0,1,0,0"
VerticalAlignment="Top"
FontSize="{Binding ResultSubItemFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsEnabled="False"
Style="{DynamicResource ItemSubTitleStyle}"
Text="{Binding Result.SubTitle}"
@ -205,6 +210,7 @@
<!-- 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}" />

View file

@ -1919,87 +1919,302 @@
TextAlignment="left" />
</Border>
<StackPanel
Grid.Row="1"
Margin="0"
Background="{Binding PreviewBackground}">
<StackPanel
Margin="0,30,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<Border
Width="{Binding WindowWidthSize}"
Margin="0"
SnapsToDevicePixels="True"
Style="{DynamicResource WindowBorderStyle}"
UseLayoutRounding="True">
<Border Style="{DynamicResource WindowRadius}">
<Border.Clip>
<MultiBinding Converter="{StaticResource BorderClipConverter}">
<Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" />
<Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" />
<Binding Path="CornerRadius" RelativeSource="{RelativeSource Self}" />
</MultiBinding>
</Border.Clip>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Border Grid.Row="0">
<TextBox
x:Name="QueryTextBox"
IsHitTestVisible="False"
IsReadOnly="True"
Style="{DynamicResource QueryBoxStyle}"
Text="{DynamicResource hiThere}" />
<Grid Grid.Row="1">
<Border Background="{Binding PreviewBackground}" CornerRadius="6">
<DockPanel LastChildFill="True">
<StackPanel
Width="Auto"
Background="Transparent"
DockPanel.Dock="Right"
Orientation="Horizontal">
<ToggleButton
x:Name="Editor"
Margin="8"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Content="Edit"
ToolTip="Show details" />
<!-- Theme Size Editor -->
<Border
Padding="0,0,0,0"
Background="{DynamicResource Color00B}"
BorderBrush="{DynamicResource Color03B}"
BorderThickness="1"
CornerRadius="0 5 5 0">
<Border.Style>
<Style TargetType="{x:Type Border}">
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=Editor, Path=IsChecked}" Value="False">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<ScrollViewer
Height="400"
ScrollViewer.CanContentScroll="True"
VirtualizingStackPanel.IsVirtualizing="True"
VirtualizingStackPanel.ScrollUnit="Pixel">
<StackPanel>
<Slider
Name="WindowHeightValue"
Width="140"
Margin="8"
VerticalAlignment="Center"
ui:ControlHelper.Header="Search Bar Height"
AutoToolTipPlacement="TopLeft"
IsMoveToPointEnabled="True"
IsSnapToTickEnabled="True"
Maximum="60"
Minimum="20"
TickFrequency="2"
Value="{Binding WindowHeightSize, Mode=TwoWay}" />
<Separator
Width="Auto"
BorderThickness="1"
Style="{StaticResource SettingSeparatorStyle}" />
<Slider
Name="QueryBoxFontSize"
Width="140"
Margin="8,8,8,0"
VerticalAlignment="Center"
ui:ControlHelper.Header="Query Box Font"
AutoToolTipPlacement="TopLeft"
IsMoveToPointEnabled="True"
IsSnapToTickEnabled="True"
Maximum="{Binding ElementName=WindowHeightValue, Path=Value, UpdateSourceTrigger=PropertyChanged}"
Minimum="10"
TickFrequency="1"
Value="{Binding queryBoxFontSize, Mode=TwoWay}" />
<ComboBox
Width="150"
Margin="8,4,8,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
IsSynchronizedWithCurrentItem="False"
ItemsSource="{Binding Source={StaticResource SortedFonts}}"
SelectedItem="{Binding SelectedQueryBoxFont}" />
<ComboBox
Width="150"
Margin="8"
HorizontalAlignment="Center"
VerticalAlignment="Top"
ItemsSource="{Binding SelectedQueryBoxFont.FamilyTypefaces}"
SelectedItem="{Binding SelectedQueryBoxFontFaces}">
<ComboBox.ItemTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding AdjustedFaceNames}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Value}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Separator
Width="Auto"
BorderThickness="1"
Style="{StaticResource SettingSeparatorStyle}" />
<Slider
Name="ItemHeightValue"
Width="140"
Margin="8,8,8,0"
VerticalAlignment="Center"
ui:ControlHelper.Header="Item Height"
AutoToolTipPlacement="TopLeft"
IsMoveToPointEnabled="True"
IsSnapToTickEnabled="True"
Maximum="100"
Minimum="30"
TickFrequency="2"
Value="{Binding ItemHeightSize, Mode=TwoWay}" />
<Separator
Width="Auto"
BorderThickness="1"
Style="{StaticResource SettingSeparatorStyle}" />
<Slider
Name="resultItemFontSize"
Width="140"
Margin="8,8,8,0"
VerticalAlignment="Center"
ui:ControlHelper.Header="Item Title Font"
AutoToolTipPlacement="TopLeft"
IsMoveToPointEnabled="True"
IsSnapToTickEnabled="True"
Maximum="80"
Minimum="10"
TickFrequency="1"
Value="{Binding resultItemFontSize, Mode=TwoWay}" />
<ComboBox
Width="140"
Margin="8,4,8,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
IsSynchronizedWithCurrentItem="False"
ItemsSource="{Binding Source={StaticResource SortedFonts}}"
SelectedItem="{Binding SelectedResultFont}" />
<ComboBox
Width="140"
Margin="8,4,8,8"
HorizontalAlignment="Center"
VerticalAlignment="Top"
ItemsSource="{Binding SelectedResultFont.FamilyTypefaces}"
SelectedItem="{Binding SelectedResultFontFaces}">
<ComboBox.ItemTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding AdjustedFaceNames}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Value}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Separator
Width="Auto"
BorderThickness="1"
Style="{StaticResource SettingSeparatorStyle}" />
<Slider
Name="resultSubItemFontSize"
Width="140"
Margin="8,8,8,0"
VerticalAlignment="Center"
ui:ControlHelper.Header="Item Subtitle Font"
AutoToolTipPlacement="TopLeft"
IsMoveToPointEnabled="True"
IsSnapToTickEnabled="True"
Maximum="80"
Minimum="6"
TickFrequency="1"
Value="{Binding resultSubItemFontSize, Mode=TwoWay}" />
<ComboBox
Width="140"
Margin="8,4,8,0"
HorizontalAlignment="Center"
VerticalAlignment="Top"
IsSynchronizedWithCurrentItem="False"
ItemsSource="{Binding Source={StaticResource SortedFonts}}"
SelectedItem="{Binding SelectedResultSubFont}" />
<ComboBox
Width="140"
Margin="8,4,8,8"
HorizontalAlignment="Center"
VerticalAlignment="Top"
ItemsSource="{Binding SelectedResultSubFont.FamilyTypefaces}"
SelectedItem="{Binding SelectedResultSubFontFaces}">
<ComboBox.ItemTemplate>
<DataTemplate>
<ItemsControl ItemsSource="{Binding AdjustedFaceNames}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Value}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<Separator
Width="Auto"
BorderThickness="1"
Style="{StaticResource SettingSeparatorStyle}" />
<Button
Width="140"
Margin="8"
HorizontalAlignment="Center">
Reset
</Button>
</StackPanel>
</ScrollViewer>
</Border>
</StackPanel>
<StackPanel VerticalAlignment="Center" DockPanel.Dock="Left">
<Border
Width="400"
Margin="40,30,0,30"
SnapsToDevicePixels="True"
Style="{DynamicResource WindowBorderStyle}"
UseLayoutRounding="True">
<Border Style="{DynamicResource WindowRadius}">
<Border.Clip>
<MultiBinding Converter="{StaticResource BorderClipConverter}">
<Binding Path="ActualWidth" RelativeSource="{RelativeSource Self}" />
<Binding Path="ActualHeight" RelativeSource="{RelativeSource Self}" />
<Binding Path="CornerRadius" RelativeSource="{RelativeSource Self}" />
</MultiBinding>
</Border.Clip>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Border Grid.Row="0">
<TextBox
x:Name="QueryTextBox"
Height="{Binding WindowHeightSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
FontSize="{Binding queryBoxFontSize, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
IsHitTestVisible="False"
IsReadOnly="True"
Style="{DynamicResource QueryBoxStyle}"
Text="{DynamicResource hiThere}" />
</Border>
<StackPanel
x:Name="ClockPanel"
IsHitTestVisible="False"
Style="{DynamicResource ClockPanel}"
Visibility="Visible">
<TextBlock
x:Name="ClockBox"
Style="{DynamicResource ClockBox}"
Text="{Binding ClockText}"
Visibility="{Binding Settings.UseClock, Converter={StaticResource BoolToVisibilityConverter}}" />
<TextBlock
x:Name="DateBox"
Style="{DynamicResource DateBox}"
Text="{Binding DateText}"
Visibility="{Binding Settings.UseDate, Converter={StaticResource BoolToVisibilityConverter}}" />
</StackPanel>
<Canvas Style="{DynamicResource SearchIconPosition}">
<Path
Margin="0"
Data="{DynamicResource SearchIconImg}"
Stretch="Fill"
Style="{DynamicResource SearchIconStyle}" />
</Canvas>
<Border Grid.Row="1" Margin="0,0,0,0">
<Rectangle
Width="Auto"
HorizontalAlignment="Stretch"
Style="{DynamicResource SeparatorStyle}"
Visibility="Visible" />
</Border>
<ContentControl Grid.Row="2">
<flowlauncher:ResultListBox
DataContext="{Binding PreviewResults, Mode=OneTime}"
IsHitTestVisible="False"
Visibility="Visible" />
</ContentControl>
</Grid>
</Border>
<StackPanel
x:Name="ClockPanel"
IsHitTestVisible="False"
Style="{DynamicResource ClockPanel}"
Visibility="Visible">
<TextBlock
x:Name="ClockBox"
Style="{DynamicResource ClockBox}"
Text="{Binding ClockText}"
Visibility="{Binding Settings.UseClock, Converter={StaticResource BoolToVisibilityConverter}}" />
<TextBlock
x:Name="DateBox"
Style="{DynamicResource DateBox}"
Text="{Binding DateText}"
Visibility="{Binding Settings.UseDate, Converter={StaticResource BoolToVisibilityConverter}}" />
</StackPanel>
<Canvas Style="{DynamicResource SearchIconPosition}">
<Path
Margin="0"
Data="{DynamicResource SearchIconImg}"
Stretch="Fill"
Style="{DynamicResource SearchIconStyle}" />
</Canvas>
<Border Grid.Row="1" Margin="0,0,0,0">
<Rectangle
Width="Auto"
HorizontalAlignment="Stretch"
Style="{DynamicResource SeparatorStyle}"
Visibility="Visible" />
</Border>
<ContentControl Grid.Row="2">
<flowlauncher:ResultListBox
DataContext="{Binding PreviewResults, Mode=OneTime}"
IsHitTestVisible="False"
Visibility="Visible" />
</ContentControl>
</Grid>
</Border>
</Border>
</StackPanel>
</StackPanel>
</Border>
</StackPanel>
</DockPanel>
</Border>
</Grid>
<StackPanel Grid.Row="2" VerticalAlignment="Top">
<Border Margin="0,12,0,0" Style="{DynamicResource SettingGroupBox}">

View file

@ -49,6 +49,9 @@ namespace Flow.Launcher.ViewModel
case nameof(Settings.WindowSize):
OnPropertyChanged(nameof(WindowWidthSize));
break;
case nameof(Settings.WindowHeightSize):
OnPropertyChanged(nameof(WindowHeightSize));
break;
case nameof(Settings.UseDate):
case nameof(Settings.DateFormat):
OnPropertyChanged(nameof(DateText));
@ -450,6 +453,34 @@ namespace Flow.Launcher.ViewModel
}
}
public double WindowHeightSize
{
get => Settings.WindowHeightSize;
set => Settings.WindowHeightSize = value;
}
public double ItemHeightSize
{
get => Settings.ItemHeightSize;
set => Settings.ItemHeightSize = value;
}
public double queryBoxFontSize
{
get => Settings.QueryBoxFontSize;
set => Settings.QueryBoxFontSize = value;
}
public double resultItemFontSize
{
get => Settings.ResultItemFontSize;
set => Settings.ResultItemFontSize = value;
}
public double resultSubItemFontSize
{
get => Settings.ResultSubItemFontSize;
set => Settings.ResultSubItemFontSize = value;
}
public class ColorScheme
{
public string Display { get; set; }
@ -838,6 +869,51 @@ namespace Flow.Launcher.ViewModel
}
}
public FontFamily SelectedResultSubFont
{
get
{
if (Fonts.SystemFontFamilies.Count(o =>
o.FamilyNames.Values != null &&
o.FamilyNames.Values.Contains(Settings.ResultSubFont)) > 0)
{
var font = new FontFamily(Settings.ResultSubFont);
return font;
}
else
{
var font = new FontFamily("Segoe UI");
return font;
}
}
set
{
Settings.ResultSubFont = value.ToString();
ThemeManager.Instance.ChangeTheme(Settings.Theme);
}
}
public FamilyTypeface SelectedResultSubFontFaces
{
get
{
var typeface = SyntaxSugars.CallOrRescueDefault(
() => SelectedResultSubFont.ConvertFromInvariantStringsOrNormal(
Settings.ResultSubFontStyle,
Settings.ResultSubFontWeight,
Settings.ResultSubFontStretch
));
return typeface;
}
set
{
Settings.ResultSubFontStretch = value.Stretch.ToString();
Settings.ResultSubFontWeight = value.Weight.ToString();
Settings.ResultSubFontStyle = value.Style.ToString();
ThemeManager.Instance.ChangeTheme(Settings.Theme);
}
}
public string ThemeImage => Constant.QueryTextBoxIconImagePath;
#endregion