-
-
Notifications
You must be signed in to change notification settings - Fork 455
Modern Themes #704
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modern Themes #704
Changes from 64 commits
3a0594f
0c47557
b07a437
7789c1c
c6f1a00
53c04fd
f07a009
4ced995
f83212a
c227ba3
3bc3563
46917ea
3e25030
91d21a7
505b4cb
8eba28f
f1bfa5c
9d10b7f
bb7b0cd
ecb0cac
6a58576
136f227
c89d277
49f00f5
8e93969
6048de4
6211275
c32ae79
2b7855c
39b53d9
2144577
03d134d
6e047e0
e7b4dd1
df3c5bf
89f4f5d
1621f34
92f0041
c1b0929
832405a
1c96f04
ca179be
ed5bd5b
4e01019
d084793
e201df9
6c43a48
a5534ca
d1e7b4e
1948ec5
88a9767
10accd5
d902a1e
e14bb23
1b1a81d
12f95d1
25b5f30
8aaeb85
66e722b
1149ff5
c74a2db
763cab8
54145d7
5f0df98
04a10ed
4f19355
1d746c2
42dda34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,11 +145,9 @@ private ResourceDictionary CurrentThemeResourceDictionary() | |
| public ResourceDictionary GetResourceDictionary() | ||
| { | ||
| var dict = CurrentThemeResourceDictionary(); | ||
|
|
||
| Style queryBoxStyle = dict["QueryBoxStyle"] as Style; | ||
| Style querySuggestionBoxStyle = dict["QuerySuggestionBoxStyle"] as Style; | ||
|
|
||
| if (queryBoxStyle != null && querySuggestionBoxStyle != null) | ||
|
|
||
| if (dict["QueryBoxStyle"] is Style queryBoxStyle && | ||
| dict["QuerySuggestionBoxStyle"] is Style querySuggestionBoxStyle) | ||
| { | ||
| var fontFamily = new FontFamily(Settings.QueryBoxFont); | ||
| var fontStyle = FontHelper.GetFontStyleFromInvariantStringOrNormal(Settings.QueryBoxFontStyle); | ||
|
|
@@ -174,19 +172,19 @@ public ResourceDictionary GetResourceDictionary() | |
| querySuggestionBoxStyle.Setters.Add(new Setter(TextBox.FontStretchProperty, fontStretch)); | ||
| } | ||
|
|
||
| Style resultItemStyle = dict["ItemTitleStyle"] as Style; | ||
| Style resultSubItemStyle = dict["ItemSubTitleStyle"] as Style; | ||
| Style resultItemSelectedStyle = dict["ItemTitleSelectedStyle"] as Style; | ||
| Style resultSubItemSelectedStyle = dict["ItemSubTitleSelectedStyle"] as Style; | ||
| if (resultItemStyle != null && resultSubItemStyle != null && resultSubItemSelectedStyle != null && resultItemSelectedStyle != null) | ||
| if (dict["ItemTitleStyle"] is Style resultItemStyle && | ||
| dict["ItemSubTitleStyle"] is Style resultSubItemStyle && | ||
| dict["ItemSubTitleSelectedStyle"] is Style resultSubItemSelectedStyle && | ||
| dict["ItemTitleSelectedStyle"] is Style resultItemSelectedStyle && | ||
| dict["ItemHotkeySelectedStyle"] is Style resultHotkeyItemSelectedStyle) | ||
| { | ||
| Setter fontFamily = new Setter(TextBlock.FontFamilyProperty, new FontFamily(Settings.ResultFont)); | ||
| Setter fontStyle = new Setter(TextBlock.FontStyleProperty, FontHelper.GetFontStyleFromInvariantStringOrNormal(Settings.ResultFontStyle)); | ||
| Setter fontWeight = new Setter(TextBlock.FontWeightProperty, FontHelper.GetFontWeightFromInvariantStringOrNormal(Settings.ResultFontWeight)); | ||
| Setter fontStretch = new Setter(TextBlock.FontStretchProperty, FontHelper.GetFontStretchFromInvariantStringOrNormal(Settings.ResultFontStretch)); | ||
|
|
||
| Setter[] setters = { fontFamily, fontStyle, fontWeight, fontStretch }; | ||
| Array.ForEach(new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p))); | ||
| Array.ForEach(new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle, resultHotkeyItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p))); | ||
| } | ||
|
|
||
| var windowStyle = dict["WindowStyle"] as Style; | ||
|
|
@@ -236,17 +234,19 @@ private string GetThemePath(string themeName) | |
|
|
||
| public void AddDropShadowEffectToCurrentTheme() | ||
| { | ||
| var dict = CurrentThemeResourceDictionary(); | ||
| var dict = GetResourceDictionary(); | ||
|
|
||
| var windowBorderStyle = dict["WindowBorderStyle"] as Style; | ||
|
|
||
| var effectSetter = new Setter(); | ||
| effectSetter.Property = Border.EffectProperty; | ||
| effectSetter.Value = new DropShadowEffect | ||
| var effectSetter = new Setter | ||
| { | ||
| Opacity = 0.9, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you provide a screenshot for people to check the effect of this change?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| ShadowDepth = 2, | ||
| BlurRadius = 15 | ||
| Property = Border.EffectProperty, | ||
| Value = new DropShadowEffect | ||
| { | ||
| Opacity = 0.4, | ||
| ShadowDepth = 2, | ||
| BlurRadius = 15 | ||
| } | ||
| }; | ||
|
|
||
| var marginSetter = windowBorderStyle.Setters.FirstOrDefault(setterBase => setterBase is Setter setter && setter.Property == Border.MarginProperty) as Setter; | ||
|
|
@@ -261,7 +261,7 @@ public void AddDropShadowEffectToCurrentTheme() | |
| } | ||
| else | ||
| { | ||
| var baseMargin = (Thickness) marginSetter.Value; | ||
| var baseMargin = (Thickness)marginSetter.Value; | ||
| var newMargin = new Thickness( | ||
| baseMargin.Left + ShadowExtraMargin, | ||
| baseMargin.Top + ShadowExtraMargin, | ||
|
|
@@ -282,8 +282,8 @@ public void RemoveDropShadowEffectFromCurrentTheme() | |
|
|
||
| var effectSetter = windowBorderStyle.Setters.FirstOrDefault(setterBase => setterBase is Setter setter && setter.Property == Border.EffectProperty) as Setter; | ||
| var marginSetter = windowBorderStyle.Setters.FirstOrDefault(setterBase => setterBase is Setter setter && setter.Property == Border.MarginProperty) as Setter; | ||
| if(effectSetter != null) | ||
|
|
||
| if (effectSetter != null) | ||
| { | ||
| windowBorderStyle.Setters.Remove(effectSetter); | ||
| } | ||
|
|
@@ -371,11 +371,11 @@ private bool IsBlurTheme() | |
| private void SetWindowAccent(Window w, AccentState state) | ||
| { | ||
| var windowHelper = new WindowInteropHelper(w); | ||
|
|
||
| // this determines the width of the main query window | ||
| w.Width = mainWindowWidth; | ||
| windowHelper.EnsureHandle(); | ||
|
|
||
| var accent = new AccentPolicy { AccentState = state }; | ||
| var accentStructSize = Marshal.SizeOf(accent); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Globalization; | ||
| using System.Linq; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
| using System.Windows; | ||
| using System.Windows.Data; | ||
| using System.Windows.Media; | ||
| using System.Windows.Documents; | ||
| using System.Windows.Shapes; | ||
|
|
||
| // For Clipping inside listbox item | ||
|
|
||
| namespace Flow.Launcher.Converters | ||
| { | ||
| public class BorderClipConverter : IMultiValueConverter | ||
| { | ||
| public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) | ||
| { | ||
| if (values.Length == 3 && values[0] is double && values[1] is double && values[2] is CornerRadius) | ||
jjw24 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| var width = (double)values[0]; | ||
| var height = (double)values[1]; | ||
| Path myPath = new Path(); | ||
| if (width < Double.Epsilon || height < Double.Epsilon) | ||
| { | ||
| return Geometry.Empty; | ||
| } | ||
| var radius = (CornerRadius)values[2]; | ||
| var radiusHeight = radius.TopLeft; | ||
|
|
||
| // Drawing Round box for bottom round, and rect for top area of listbox. | ||
| var corner = new RectangleGeometry(new Rect(0, 0, width, height), radius.TopLeft, radius.TopLeft); | ||
| var box = new RectangleGeometry(new Rect(0, 0, width, radiusHeight), 0, 0); | ||
|
|
||
| GeometryGroup myGeometryGroup = new GeometryGroup(); | ||
| myGeometryGroup.Children.Add(corner); | ||
| myGeometryGroup.Children.Add(box); | ||
|
|
||
| CombinedGeometry c1 = new CombinedGeometry(GeometryCombineMode.Union, corner, box); | ||
| myPath.Data = c1; | ||
|
|
||
| myPath.Data.Freeze(); | ||
| return myPath.Data; | ||
| } | ||
|
|
||
| return DependencyProperty.UnsetValue; | ||
| } | ||
|
|
||
| public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) | ||
| { | ||
| throw new NotSupportedException(); | ||
| } | ||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ | |
| d:DataContext="{d:DesignInstance vm:MainViewModel}"> | ||
| <Window.Resources> | ||
| <converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter"/> | ||
| <converters:BorderClipConverter x:Key="BorderClipConverter"/> | ||
| </Window.Resources> | ||
| <Window.InputBindings> | ||
| <KeyBinding Key="Escape" Command="{Binding EscCommand}"></KeyBinding> | ||
|
|
@@ -45,6 +46,8 @@ | |
| <KeyBinding Key="U" Modifiers="Ctrl" Command="{Binding SelectPrevPageCommand}"></KeyBinding> | ||
| <KeyBinding Key="Home" Modifiers="Alt" Command="{Binding SelectFirstResultCommand}"></KeyBinding> | ||
| <KeyBinding Key="O" Modifiers="Ctrl" Command="{Binding LoadContextMenuCommand}"></KeyBinding> | ||
| <KeyBinding Key="Right" Command="{Binding LoadContextMenuCommand}"></KeyBinding> | ||
| <KeyBinding Key="Left" Command="{Binding EscCommand}"></KeyBinding> | ||
| <KeyBinding Key="H" Modifiers="Ctrl" Command="{Binding LoadHistoryCommand}"></KeyBinding> | ||
| <KeyBinding Key="Enter" Modifiers="Ctrl+Shift" Command="{Binding OpenResultCommand}"></KeyBinding> | ||
| <KeyBinding Key="Enter" Modifiers="Shift" Command="{Binding LoadContextMenuCommand}"></KeyBinding> | ||
|
|
@@ -62,13 +65,12 @@ | |
| <KeyBinding Key="D9" Modifiers="{Binding OpenResultCommandModifiers}" Command="{Binding OpenResultCommand}" CommandParameter="8"></KeyBinding> | ||
| </Window.InputBindings> | ||
| <Grid> | ||
| <Border Style="{DynamicResource WindowBorderStyle}" MouseDown="OnMouseDown" CornerRadius="5" > | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. Probably a screenshot for this change may be better. (probably visual studio has xaml hot reload so this can be done easily).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Radius could not be changed in the theme because that code first. The setting was removed to allow the theme to be managed. Depending on the theme xaml., it will be round or square. |
||
| <Border Style="{DynamicResource WindowBorderStyle}" MouseDown="OnMouseDown"> | ||
| <StackPanel Orientation="Vertical"> | ||
| <Grid> | ||
| <TextBox x:Name="QueryTextSuggestionBox" | ||
| Style="{DynamicResource QuerySuggestionBoxStyle}" | ||
| IsEnabled="False" | ||
| Margin="18,0,56,0"> | ||
| IsEnabled="False"> | ||
| <TextBox.Text> | ||
| <MultiBinding Converter="{StaticResource QuerySuggestionBoxConverter}"> | ||
| <Binding ElementName="QueryTextBox" Path="Text"/> | ||
|
|
@@ -82,34 +84,67 @@ | |
| PreviewDragOver="OnPreviewDragOver" | ||
| AllowDrop="True" | ||
| Visibility="Visible" | ||
| Background="Transparent" | ||
| Margin="18,0,56,0"> | ||
| Background="Transparent"> | ||
| <TextBox.ContextMenu> | ||
| <ContextMenu> | ||
| <MenuItem Command="ApplicationCommands.Cut"/> | ||
| <MenuItem Command="ApplicationCommands.Copy"/> | ||
| <MenuItem Command="ApplicationCommands.Paste"/> | ||
| <Separator /> | ||
| <MenuItem Header="Settings" Click="OnContextMenusForSettingsClick" /> | ||
| <MenuItem Header="{DynamicResource flowlauncher_settings}" Click="OnContextMenusForSettingsClick" /> | ||
| <MenuItem Command="{Binding EscCommand}" Header="Close"/> | ||
| </ContextMenu> | ||
| </TextBox.ContextMenu> | ||
| </TextBox> | ||
| <svgc:SvgControl Source="{Binding Image}" HorizontalAlignment="Right" Width="42" Height="42" | ||
| Background="Transparent"/> | ||
| <Canvas Style="{DynamicResource SearchIconPosition}"> | ||
| <Path Data="{DynamicResource SearchIconImg}" Style="{DynamicResource SearchIconStyle}" Margin="0" Stretch="Fill"/> | ||
| </Canvas> | ||
| </Grid> | ||
| <Line x:Name="ProgressBar" HorizontalAlignment="Right" | ||
|
|
||
| <Grid> | ||
| <Rectangle Width="Auto" HorizontalAlignment="Stretch" Style="{DynamicResource SeparatorStyle}" /> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the height cannot be given, a rectangle was used instead of a separator. |
||
| <Line x:Name="ProgressBar" HorizontalAlignment="Right" | ||
| Style="{DynamicResource PendingLineStyle}" Visibility="{Binding ProgressBarVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" | ||
| Y1="0" Y2="0" X2="100" Height="2" Width="752" StrokeThickness="1"> | ||
| </Line> | ||
| <ContentControl> | ||
| <flowlauncher:ResultListBox x:Name="ResultListBox" DataContext="{Binding Results}" PreviewMouseDown="OnPreviewMouseButtonDown" /> | ||
| </ContentControl> | ||
| <ContentControl> | ||
| <flowlauncher:ResultListBox DataContext="{Binding ContextMenu}" PreviewMouseDown="OnPreviewMouseButtonDown" /> | ||
| </ContentControl> | ||
| <ContentControl> | ||
| <flowlauncher:ResultListBox DataContext="{Binding History}" PreviewMouseDown="OnPreviewMouseButtonDown" /> | ||
| </ContentControl> | ||
| Y1="0" Y2="0" X1="0" X2="100" Height="2" Width="752" StrokeThickness="1"> | ||
| </Line> | ||
| </Grid> | ||
|
|
||
| <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> | ||
| <ContentControl> | ||
| <flowlauncher:ResultListBox x:Name="ResultListBox" DataContext="{Binding Results}" PreviewMouseDown="OnPreviewMouseButtonDown" /> | ||
| </ContentControl> | ||
| </Border> | ||
| <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> | ||
| <ContentControl> | ||
| <flowlauncher:ResultListBox DataContext="{Binding ContextMenu}" PreviewMouseDown="OnPreviewMouseButtonDown" x:Name="ContextMenu"/> | ||
| </ContentControl> | ||
| </Border> | ||
| <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> | ||
| <ContentControl> | ||
| <flowlauncher:ResultListBox DataContext="{Binding History}" PreviewMouseDown="OnPreviewMouseButtonDown" x:Name="History"/> | ||
| </ContentControl> | ||
| </Border> | ||
| </StackPanel> | ||
| </Border> | ||
| </Grid> | ||
|
|
||

Uh oh!
There was an error while loading. Please reload this page.