Skip to content

Commit e0c7613

Browse files
committed
Initial commit
0 parents  commit e0c7613

1,329 files changed

Lines changed: 143120 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.gitattributes‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

‎.gitignore‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Object files
5+
*.o
6+
*.ko
7+
*.obj
8+
*.elf
9+
10+
# Linker output
11+
*.ilk
12+
*.map
13+
*.exp
14+
15+
# Precompiled Headers
16+
*.gch
17+
*.pch
18+
19+
# Libraries
20+
*.lib
21+
*.a
22+
*.la
23+
*.lo
24+
25+
# Shared objects (inc. Windows DLLs)
26+
*.dll
27+
*.so
28+
*.so.*
29+
*.dylib
30+
31+
# Executables
32+
*.exe
33+
*.out
34+
*.app
35+
*.i*86
36+
*.x86_64
37+
*.hex
38+
39+
# Debug files
40+
*.dSYM/
41+
*.su
42+
*.idb
43+
*.pdb
44+
45+
# Kernel Module Compile Results
46+
*.mod*
47+
*.cmd
48+
.tmp_versions/
49+
modules.order
50+
Module.symvers
51+
Mkfile.old
52+
dkms.conf

‎AcrylicSettingsWindow.xaml‎

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Window
3+
x:Class="NoteUI.AcrylicSettingsWindow"
4+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
Title="Acrylic">
7+
8+
<Grid x:Name="RootGrid">
9+
<Grid.RowDefinitions>
10+
<RowDefinition Height="Auto"/>
11+
<RowDefinition Height="*"/>
12+
</Grid.RowDefinitions>
13+
14+
<!-- Title bar -->
15+
<Grid x:Name="TitleBar" Grid.Row="0" Height="36" Padding="8,0">
16+
<Grid x:Name="DragBar" Background="Transparent"
17+
PointerPressed="DragBar_PointerPressed"
18+
PointerMoved="DragBar_PointerMoved"
19+
PointerReleased="DragBar_PointerReleased"/>
20+
21+
<TextBlock Text="Acrylic personnalis&#233;" FontSize="12"
22+
VerticalAlignment="Center" Margin="4,0,0,0"
23+
Foreground="{ThemeResource TextFillColorSecondaryBrush}"
24+
IsHitTestVisible="False"/>
25+
26+
<Button HorizontalAlignment="Right" VerticalAlignment="Center"
27+
Background="Transparent" BorderThickness="0"
28+
Padding="8,6" Click="Close_Click"
29+
ToolTipService.ToolTip="Fermer">
30+
<FontIcon Glyph="&#xE711;" FontSize="11"/>
31+
</Button>
32+
</Grid>
33+
34+
<!-- Content -->
35+
<ScrollViewer Grid.Row="1" Padding="16,4,16,16">
36+
<StackPanel Spacing="18">
37+
38+
<!-- Tint Opacity -->
39+
<StackPanel Spacing="2">
40+
<Grid>
41+
<TextBlock Text="Opacit&#233; de teinte" FontSize="12"
42+
Foreground="{ThemeResource TextFillColorSecondaryBrush}"/>
43+
<TextBlock x:Name="TintOpacityValue" HorizontalAlignment="Right"
44+
FontSize="12" Foreground="{ThemeResource TextFillColorTertiaryBrush}"/>
45+
</Grid>
46+
<Slider x:Name="TintOpacitySlider" Minimum="0" Maximum="1"
47+
StepFrequency="0.01"
48+
ValueChanged="Slider_ValueChanged"/>
49+
</StackPanel>
50+
51+
<!-- Luminosity Opacity -->
52+
<StackPanel Spacing="2">
53+
<Grid>
54+
<TextBlock Text="Luminosit&#233;" FontSize="12"
55+
Foreground="{ThemeResource TextFillColorSecondaryBrush}"/>
56+
<TextBlock x:Name="LuminosityValue" HorizontalAlignment="Right"
57+
FontSize="12" Foreground="{ThemeResource TextFillColorTertiaryBrush}"/>
58+
</Grid>
59+
<Slider x:Name="LuminositySlider" Minimum="0" Maximum="1"
60+
StepFrequency="0.01"
61+
ValueChanged="Slider_ValueChanged"/>
62+
</StackPanel>
63+
64+
<!-- Tint Color -->
65+
<StackPanel Spacing="4">
66+
<TextBlock Text="Couleur de teinte" FontSize="12"
67+
Foreground="{ThemeResource TextFillColorSecondaryBrush}"/>
68+
<Grid ColumnSpacing="8">
69+
<Grid.ColumnDefinitions>
70+
<ColumnDefinition Width="*"/>
71+
<ColumnDefinition Width="Auto"/>
72+
</Grid.ColumnDefinitions>
73+
<TextBox x:Name="TintColorBox" Text="#000000" FontSize="12"
74+
MaxLength="7" TextChanged="ColorBox_TextChanged"/>
75+
<Border x:Name="TintColorPreview" Grid.Column="1"
76+
Width="32" Height="32" CornerRadius="4"
77+
BorderThickness="1"
78+
BorderBrush="{ThemeResource ControlStrokeColorDefaultBrush}"/>
79+
</Grid>
80+
</StackPanel>
81+
82+
<!-- Fallback Color -->
83+
<StackPanel Spacing="4">
84+
<TextBlock Text="Couleur de repli" FontSize="12"
85+
Foreground="{ThemeResource TextFillColorSecondaryBrush}"/>
86+
<Grid ColumnSpacing="8">
87+
<Grid.ColumnDefinitions>
88+
<ColumnDefinition Width="*"/>
89+
<ColumnDefinition Width="Auto"/>
90+
</Grid.ColumnDefinitions>
91+
<TextBox x:Name="FallbackColorBox" Text="#000000" FontSize="12"
92+
MaxLength="7" TextChanged="ColorBox_TextChanged"/>
93+
<Border x:Name="FallbackColorPreview" Grid.Column="1"
94+
Width="32" Height="32" CornerRadius="4"
95+
BorderThickness="1"
96+
BorderBrush="{ThemeResource ControlStrokeColorDefaultBrush}"/>
97+
</Grid>
98+
</StackPanel>
99+
100+
<!-- Kind -->
101+
<StackPanel Spacing="4">
102+
<TextBlock Text="Style" FontSize="12"
103+
Foreground="{ThemeResource TextFillColorSecondaryBrush}"/>
104+
<Grid ColumnSpacing="6">
105+
<Grid.ColumnDefinitions>
106+
<ColumnDefinition Width="*"/>
107+
<ColumnDefinition Width="*"/>
108+
</Grid.ColumnDefinitions>
109+
<Button x:Name="BaseButton" Content="Base"
110+
HorizontalAlignment="Stretch" CornerRadius="4"
111+
Click="Kind_Click" Tag="Base"/>
112+
<Button x:Name="ThinButton" Content="Thin" Grid.Column="1"
113+
HorizontalAlignment="Stretch" CornerRadius="4"
114+
Click="Kind_Click" Tag="Thin"/>
115+
</Grid>
116+
</StackPanel>
117+
118+
</StackPanel>
119+
</ScrollViewer>
120+
</Grid>
121+
</Window>

‎AcrylicSettingsWindow.xaml.cs‎

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
using System.Runtime.InteropServices;
2+
using Microsoft.UI.Composition.SystemBackdrops;
3+
using Microsoft.UI.Xaml;
4+
using Microsoft.UI.Xaml.Controls;
5+
using Microsoft.UI.Xaml.Input;
6+
using Microsoft.UI.Xaml.Media;
7+
8+
namespace NoteUI;
9+
10+
public sealed partial class AcrylicSettingsWindow : Window
11+
{
12+
private readonly Action<BackdropSettings> _onSettingsChanged;
13+
private bool _suppressChanges = true;
14+
private string _currentKind = "Base";
15+
16+
private DesktopAcrylicController? _acrylicController;
17+
private SystemBackdropConfiguration? _configSource;
18+
19+
private bool _isDragging;
20+
private POINT _dragStartCursor;
21+
private Windows.Graphics.PointInt32 _dragStartPos;
22+
23+
public AcrylicSettingsWindow(BackdropSettings settings, Action<BackdropSettings> onSettingsChanged)
24+
{
25+
_onSettingsChanged = onSettingsChanged;
26+
27+
this.InitializeComponent();
28+
29+
ExtendsContentIntoTitleBar = true;
30+
var presenter = WindowHelper.GetOverlappedPresenter(this);
31+
presenter.SetBorderAndTitleBar(false, false);
32+
presenter.IsResizable = false;
33+
34+
WindowHelper.RemoveWindowBorder(this);
35+
AppWindow.Resize(new Windows.Graphics.SizeInt32(280, 440));
36+
WindowShadow.Apply(this);
37+
38+
var iconPath = Path.Combine(AppContext.BaseDirectory, "app.ico");
39+
if (File.Exists(iconPath))
40+
AppWindow.SetIcon(iconPath);
41+
42+
var theme = AppSettings.LoadThemeSetting();
43+
AppSettings.ApplyThemeToWindow(this, theme);
44+
45+
// Apply acrylic to this window too (live preview)
46+
AppSettings.ApplyToWindow(this, settings, ref _acrylicController, ref _configSource);
47+
48+
LoadSettings(settings);
49+
50+
this.Closed += (_, _) =>
51+
{
52+
_acrylicController?.Dispose();
53+
AppSettings.SaveBackdropSettings(BuildSettings());
54+
};
55+
}
56+
57+
public void SetPosition(int x, int y)
58+
{
59+
AppWindow.Move(new Windows.Graphics.PointInt32(x, y));
60+
}
61+
62+
private void LoadSettings(BackdropSettings s)
63+
{
64+
_suppressChanges = true;
65+
TintOpacitySlider.Value = s.TintOpacity;
66+
LuminositySlider.Value = s.LuminosityOpacity;
67+
TintColorBox.Text = s.TintColor;
68+
FallbackColorBox.Text = s.FallbackColor;
69+
_currentKind = s.Kind;
70+
UpdateKindButtons();
71+
UpdateDisplayValues();
72+
UpdateColorPreviews();
73+
_suppressChanges = false;
74+
}
75+
76+
private BackdropSettings BuildSettings() => new(
77+
"acrylic_custom",
78+
TintOpacitySlider.Value,
79+
LuminositySlider.Value,
80+
TintColorBox.Text,
81+
FallbackColorBox.Text,
82+
_currentKind);
83+
84+
private void ApplyChanges()
85+
{
86+
if (_suppressChanges) return;
87+
var settings = BuildSettings();
88+
AppSettings.SaveBackdropSettings(settings);
89+
AppSettings.ApplyToWindow(this, settings, ref _acrylicController, ref _configSource);
90+
_onSettingsChanged(settings);
91+
}
92+
93+
private void UpdateDisplayValues()
94+
{
95+
if (TintOpacityValue == null || LuminosityValue == null) return;
96+
TintOpacityValue.Text = TintOpacitySlider.Value.ToString("F2");
97+
LuminosityValue.Text = LuminositySlider.Value.ToString("F2");
98+
}
99+
100+
private void UpdateColorPreviews()
101+
{
102+
if (TintColorPreview == null || FallbackColorPreview == null) return;
103+
try
104+
{
105+
var tint = AppSettings.ParseColor(TintColorBox.Text);
106+
TintColorPreview.Background = new SolidColorBrush(tint);
107+
}
108+
catch { }
109+
try
110+
{
111+
var fb = AppSettings.ParseColor(FallbackColorBox.Text);
112+
FallbackColorPreview.Background = new SolidColorBrush(fb);
113+
}
114+
catch { }
115+
}
116+
117+
private void UpdateKindButtons()
118+
{
119+
if (BaseButton == null || ThinButton == null) return;
120+
var selected = (Brush)Application.Current.Resources["AccentFillColorDefaultBrush"];
121+
var normal = new SolidColorBrush(Microsoft.UI.Colors.Transparent);
122+
BaseButton.Background = _currentKind == "Base" ? selected : normal;
123+
ThinButton.Background = _currentKind == "Thin" ? selected : normal;
124+
}
125+
126+
// ── Events ──────────────────────────────────────────────────
127+
128+
private void Slider_ValueChanged(object sender,
129+
Microsoft.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
130+
{
131+
UpdateDisplayValues();
132+
ApplyChanges();
133+
}
134+
135+
private void ColorBox_TextChanged(object sender, TextChangedEventArgs e)
136+
{
137+
UpdateColorPreviews();
138+
var text = ((TextBox)sender).Text;
139+
if (text.StartsWith('#') && text.Length == 7)
140+
ApplyChanges();
141+
}
142+
143+
private void Kind_Click(object sender, RoutedEventArgs e)
144+
{
145+
_currentKind = ((Button)sender).Tag as string ?? "Base";
146+
UpdateKindButtons();
147+
ApplyChanges();
148+
}
149+
150+
private void Close_Click(object sender, RoutedEventArgs e) => this.Close();
151+
152+
// ── Drag ────────────────────────────────────────────────────
153+
154+
[DllImport("user32.dll")]
155+
private static extern bool GetCursorPos(out POINT lpPoint);
156+
157+
[StructLayout(LayoutKind.Sequential)]
158+
private struct POINT { public int X, Y; }
159+
160+
private void DragBar_PointerPressed(object sender, PointerRoutedEventArgs e)
161+
{
162+
_isDragging = true;
163+
GetCursorPos(out _dragStartCursor);
164+
_dragStartPos = AppWindow.Position;
165+
((UIElement)sender).CapturePointer(e.Pointer);
166+
}
167+
168+
private void DragBar_PointerMoved(object sender, PointerRoutedEventArgs e)
169+
{
170+
if (!_isDragging) return;
171+
GetCursorPos(out var current);
172+
AppWindow.Move(new Windows.Graphics.PointInt32(
173+
_dragStartPos.X + (current.X - _dragStartCursor.X),
174+
_dragStartPos.Y + (current.Y - _dragStartCursor.Y)));
175+
}
176+
177+
private void DragBar_PointerReleased(object sender, PointerRoutedEventArgs e)
178+
{
179+
_isDragging = false;
180+
((UIElement)sender).ReleasePointerCapture(e.Pointer);
181+
}
182+
}

0 commit comments

Comments
 (0)