Skip to content

Commit 270f5b3

Browse files
committed
Base Structure for fluent window
1 parent 3e9a0e2 commit 270f5b3

File tree

6 files changed

+48
-18
lines changed

6 files changed

+48
-18
lines changed

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using static Flow.Launcher.Core.Resource.Theme.ParameterTypes;
1616
using System.Runtime.InteropServices;
1717
using System.Windows.Interop;
18+
using System.Diagnostics;
1819

1920
namespace Flow.Launcher.Core.Resource
2021
{
@@ -119,8 +120,9 @@ public void RefreshFrame()
119120

120121
// Remove OS minimizing/maximizing animation
121122
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_TRANSITIONS_FORCEDISABLED, 3);
123+
122124
//Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR, 0x00FF0000);
123-
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3);
125+
//Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3);
124126
SetBlurForWindow();
125127
}
126128

@@ -131,53 +133,61 @@ public void RefreshFrame()
131133
/// </summary>
132134
public void SetBlurForWindow()
133135
{
136+
134137
//SetWindowAccent();
135138
var dict = GetThemeResourceDictionary(Settings.Theme);
136139
var windowBorderStyle = dict["WindowBorderStyle"] as Style;
140+
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3);
137141
if (BlurEnabled)
138142
{
143+
//mainWindow.WindowStyle = WindowStyle.SingleBorderWindow;
144+
BlurColor(BlurMode());
139145
windowBorderStyle.Setters.Remove(windowBorderStyle.Setters.OfType<Setter>().FirstOrDefault(x => x.Property.Name == "Background"));
140146
windowBorderStyle.Setters.Add(new Setter(Border.BackgroundProperty, new SolidColorBrush(Colors.Transparent)));
141-
//mainWindow.WindowStyle = WindowStyle.SingleBorderWindow;
142147
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3);
143-
BlurColor(BlurMode());
144148
}
145149
else
146150
{
147-
mainWindow.WindowStyle = WindowStyle.None;
148-
if (windowBorderStyle.Setters.OfType<Setter>().FirstOrDefault(x => x.Property.Name == "Background") != null)
149-
{
150-
windowBorderStyle.Setters.Add(windowBorderStyle.Setters.OfType<Setter>().FirstOrDefault(x => x.Property.Name == "Background"));
151-
}
151+
//mainWindow.WindowStyle = WindowStyle.None;
152+
//if (windowBorderStyle.Setters.OfType<Setter>().FirstOrDefault(x => x.Property.Name == "Background") != null)
153+
//{
154+
// windowBorderStyle.Setters.Add(windowBorderStyle.Setters.OfType<Setter>().FirstOrDefault(x => x.Property.Name == "Background"));
155+
//}
152156
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 1);
153157
}
154158
UpdateResourceDictionary(dict);
155159
}
156160

157161
public void BlurColor(string Color)
158162
{
163+
159164
if (Color == "Light")
160165
{
166+
//mainWindow.Background = new SolidColorBrush(defaultBGcolor.Value);
161167
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 0);
162168
}
163169
else if (Color == "Dark")
164170
{
171+
//mainWindow.Background = new SolidColorBrush(darkBGcolor.Value);
165172
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 1);
166173
}
167174
else /* Case of "Auto" Blur Type Theme */
168175
{
169176
//if (_isDarkTheme())
170177
//{
178+
// mainWindow.Background = new SolidColorBrush(darkBGcolor.Value);
171179
// Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 1);
172180
//}
173181
//else
174182
//{
183+
// mainWindow.Background = new SolidColorBrush(defaultBGcolor.Value);
175184
// Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 0);
176185
//}
177-
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 1);
178-
}
186+
//mainWindow.Background = new SolidColorBrush(Colors.Red);
187+
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 1); }
179188

180189
}
190+
181191
public bool IsBlurTheme()
182192
{
183193
if (Environment.OSVersion.Version >= new Version(6, 2))
@@ -207,6 +217,24 @@ public string BlurMode()
207217
return null;
208218
}
209219

220+
//public SolidColorBrush BGColor(string colorBgKey)
221+
//{
222+
// var defaultBG = Application.Current.TryFindResource("DefaultBG");
223+
// var darkBG = Application.Current.TryFindResource("DarkBG");
224+
225+
// if (colorBgKey == "")
226+
// {
227+
// var resource = Application.Current.TryFindResource("BlurMode");
228+
229+
// if (resource is string)
230+
// return (SolidColorBrush)resource;
231+
232+
// return new SolidColorBrush(Colors.DarkGray);
233+
// }
234+
235+
// return null;
236+
//}
237+
210238
#endregion
211239

212240
private void MakeSureThemeDirectoriesExist()
@@ -252,8 +280,8 @@ public bool ChangeTheme(string theme)
252280
if (Settings.UseDropShadowEffect && !BlurEnabled)
253281
AddDropShadowEffectToCurrentTheme();
254282

255-
Win32Helper.SetBlurForWindow(Application.Current.MainWindow, BlurEnabled);
256-
//Win32Helper.SetMicaForWindow(Application.Current.MainWindow, BlurEnabled);
283+
//Win32Helper.SetBlurForWindow(Application.Current.MainWindow, BlurEnabled);
284+
SetBlurForWindow();
257285
}
258286
catch (DirectoryNotFoundException)
259287
{

Flow.Launcher/MainWindow.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
d:DataContext="{d:DesignInstance Type=vm:MainViewModel}"
1717
AllowDrop="True"
1818
AllowsTransparency="False"
19-
Background="#DB213C95"
19+
Background="#E12E2E2E"
2020
Closing="OnClosing"
2121
Deactivated="OnDeactivated"
2222
Icon="Images/app.png"
@@ -213,7 +213,7 @@
213213
Modifiers="{Binding CycleHistoryDownHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='modifiers'}" />
214214
</Window.InputBindings>
215215

216-
<Border MouseDown="OnMouseDown">
216+
<Border MouseDown="OnMouseDown" Style="{DynamicResource WindowBorderStyle}">
217217
<StackPanel Orientation="Vertical">
218218
<Grid>
219219
<Border MinHeight="30" Style="{DynamicResource QueryBoxBgStyle}">

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ public MainWindow(Settings settings, MainViewModel mainVM)
6161

6262
InitSoundEffects();
6363
DataObject.AddPastingHandler(QueryTextBox, OnPaste);
64-
6564
this.Loaded += (_, _) =>
6665
{
6766
var handle = new WindowInteropHelper(this).Handle;
@@ -107,6 +106,7 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b
107106
return IntPtr.Zero;
108107
}
109108

109+
110110
private void OnResizeEnd()
111111
{
112112
int shadowMargin = 0;
@@ -181,7 +181,6 @@ private void OnInitialized(object sender, EventArgs e)
181181

182182
private void OnLoaded(object sender, RoutedEventArgs _)
183183
{
184-
// Remove OS minimizing/maximizing animation
185184
ThemeManager.Instance.RefreshFrame();
186185

187186
// MouseEventHandler

Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public Theme.ThemeData SelectedTheme
3939

4040
if (ThemeManager.Instance.BlurEnabled && Settings.UseDropShadowEffect)
4141
DropShadowEffect = false;
42+
ThemeManager.Instance.RefreshFrame();
4243
}
4344
}
4445

Flow.Launcher/Themes/BlurBlack.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<ResourceDictionary.MergedDictionaries>
1111
<ResourceDictionary Source="pack://application:,,,/Themes/Base.xaml" />
1212
</ResourceDictionary.MergedDictionaries>
13-
1413
<system:Boolean x:Key="ThemeBlurEnabled">True</system:Boolean>
14+
<system:String x:Key="BlurMode">Auto</system:String>
1515
<Style x:Key="WindowRadius" TargetType="{x:Type Border}">
1616
<Setter Property="CornerRadius" Value="0" />
1717
</Style>

Flow.Launcher/Themes/Win11Light.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!--
22
Name: Windows 11
33
IsDark: True
4-
HasBlur: False
4+
HasBlur: True
55
-->
66
<ResourceDictionary
77
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
@@ -12,6 +12,8 @@
1212
<ResourceDictionary.MergedDictionaries>
1313
<ResourceDictionary Source="pack://application:,,,/Themes/Base.xaml" />
1414
</ResourceDictionary.MergedDictionaries>
15+
<system:Boolean x:Key="ThemeBlurEnabled">True</system:Boolean>
16+
<system:String x:Key="BlurMode">Auto</system:String>
1517
<Style
1618
x:Key="BulletStyle"
1719
BasedOn="{StaticResource BaseBulletStyle}"

0 commit comments

Comments
 (0)