allow main query window's width to be dynamic

This commit is contained in:
Jeremy 2021-06-29 09:21:53 +10:00
parent aa34a0202d
commit b5272ddb47
6 changed files with 24 additions and 5 deletions

View file

@ -30,6 +30,8 @@ namespace Flow.Launcher.Core.Resource
public bool BlurEnabled { get; set; }
private double mainWindowWidth;
public Theme()
{
_themeDirectories.Add(DirectoryPath);
@ -187,6 +189,21 @@ namespace Flow.Launcher.Core.Resource
Array.ForEach(new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p)));
}
var windowStyle = dict["WindowStyle"] as Style;
var width = windowStyle?.Setters.OfType<Setter>().Where(x => x.Property.Name == "Width")
.Select(x => x.Value).FirstOrDefault();
if (width == null)
{
windowStyle = dict["BaseWindowStyle"] as Style;
width = windowStyle?.Setters.OfType<Setter>().Where(x => x.Property.Name == "Width")
.Select(x => x.Value).FirstOrDefault();
}
mainWindowWidth = (double)width;
return dict;
}
@ -354,8 +371,11 @@ namespace Flow.Launcher.Core.Resource
private void SetWindowAccent(Window w, AccentState state)
{
var windowHelper = new WindowInteropHelper(w);
w.Width = 750;
// 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);

View file

@ -60,7 +60,7 @@
<KeyBinding Key="D8" Modifiers="{Binding OpenResultCommandModifiers}" Command="{Binding OpenResultCommand}" CommandParameter="7"></KeyBinding>
<KeyBinding Key="D9" Modifiers="{Binding OpenResultCommandModifiers}" Command="{Binding OpenResultCommand}" CommandParameter="8"></KeyBinding>
</Window.InputBindings>
<Grid Width="750">
<Grid>
<Border Style="{DynamicResource WindowBorderStyle}" MouseDown="OnMouseDown" CornerRadius="5" >
<StackPanel Orientation="Vertical">
<Grid>

View file

@ -46,6 +46,8 @@
<Setter Property="Padding" Value="8 10 8 8" />
</Style>
<Style x:Key="BaseWindowStyle" TargetType="{x:Type Window}">
<Setter Property="Width" Value="750" />
<Setter Property="RenderOptions.ClearTypeHint" Value="Enabled"/>
</Style>
<Style x:Key="BasePendingLineStyle" TargetType="{x:Type Line}">

View file

@ -25,7 +25,6 @@
</Style>
<Style x:Key="WindowStyle" BasedOn="{StaticResource BaseWindowStyle}" TargetType="{x:Type Window}">
<Setter Property="Width" Value="750" /> <!-- This is used to set the blur width only -->
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="Black" Opacity="0.6"/>

View file

@ -25,7 +25,6 @@
</Style>
<Style x:Key="WindowStyle" BasedOn="{StaticResource BaseWindowStyle}" TargetType="{x:Type Window}">
<Setter Property="Width" Value="750" /> <!-- This is used to set the blur width only -->
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="Black" Opacity="0.3"/>

View file

@ -23,7 +23,6 @@
</Style>
<Style x:Key="WindowStyle" BasedOn="{StaticResource BaseWindowStyle}" TargetType="{x:Type Window}">
<Setter Property="Width" Value="750" /> <!-- This is used to set the blur width only -->
<Setter Property="Background">
<Setter.Value>
<SolidColorBrush Color="White" Opacity="0.5"/>