Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

Soft look shared: Filee's own control styles leave Soft.axaml

KnifeLemonc9866f4758b9
diff --git a/src/Filee.App/App.axaml b/src/Filee.App/App.axaml
index fbc42fe1..dc1640fd 100644
--- a/src/Filee.App/App.axaml
+++ b/src/Filee.App/App.axaml
@@ -22,6 +22,7 @@
<Application.Styles>
<FluentTheme />
<StyleInclude Source="avares://Filee/Styles/Soft.axaml" />
+ <StyleInclude Source="avares://Filee/Styles/Controls.axaml" />
<StyleInclude Source="avares://Filee/Styles/TagEditor.axaml" />
</Application.Styles>
</Application>
diff --git a/src/Filee.App/Controls/DonutMenu.cs b/src/Filee.App/Controls/DonutMenu.cs
index 29ef8627..dd1eca9c 100644
--- a/src/Filee.App/Controls/DonutMenu.cs
+++ b/src/Filee.App/Controls/DonutMenu.cs
@@ -68,7 +68,7 @@ public sealed partial class DonutMenu : Control
public static readonly StyledProperty<bool> ReserveSubRingProperty =
AvaloniaProperty.Register<DonutMenu, bool>(nameof(ReserveSubRing));
- /// <summary>The theme's softness (Styles/Soft.axaml binds SoftRadius): rounds the corners of the slices.</summary>
+ /// <summary>The theme's softness (Styles/Controls.axaml binds SoftRadius): rounds the corners of the slices.</summary>
public static readonly StyledProperty<CornerRadius> CornerRadiusProperty =
AvaloniaProperty.Register<DonutMenu, CornerRadius>(nameof(CornerRadius));
diff --git a/src/Filee.App/Services/SoftPalette.cs b/src/Filee.App/Services/SoftPalette.cs
new file mode 100644
index 00000000..e2ee9b93
--- /dev/null
+++ b/src/Filee.App/Services/SoftPalette.cs
@@ -0,0 +1,79 @@
+// The resources behind Filee's look that are computed rather than written in Styles/Soft.axaml: the accent colour
+// with its shades, the corner radii and the UI font order. ThemeService applies them with the user's choices; the
+// installer (src/Filee.Setup links this file) applies the defaults, so Setup looks like the app.
+
+using Avalonia;
+using Avalonia.Controls;
+using Avalonia.Media;
+
+namespace Filee.App.Services;
+
+internal static class SoftPalette
+{
+ /// <summary>The default accent colour (the first swatch of the Theme page).</summary>
+ public const string DefaultAccent = "#7F77DD";
+
+ /// <summary>The default corner radius (ThemeSettings.CornerRadius).</summary>
+ public const double DefaultCornerRadius = 16;
+
+ /// <summary>Embedded Noto fonts (see build/fetch-fonts.ps1). Missing files fall back to system fonts.</summary>
+ private const string Latin = "fonts:Filee#Noto Sans";
+ private const string Korean = "fonts:Filee#Noto Sans KR";
+ private const string Chinese = "fonts:Filee#Noto Sans SC";
+ private const string Devanagari = "fonts:Filee#Noto Sans Devanagari";
+ private const string SystemFallbacks =
+ "Segoe UI, Nirmala UI, Malgun Gothic, Microsoft YaHei, PingFang SC, Apple SD Gothic Neo, Kohinoor Devanagari, sans-serif";
+
+ /// <summary>Accent colour + derived shades. Fluent controls read the System* keys.</summary>
+ public static void ApplyAccent(IResourceDictionary res, Color accent)
+ {
+ res["AccentColor"] = accent;
+ res["AccentBrush"] = new SolidColorBrush(accent);
+ res["AccentSoftBrush"] = new SolidColorBrush(accent, 0.18);
+ res["AccentFaintBrush"] = new SolidColorBrush(accent, 0.09);
+ res["AccentStrongBrush"] = new SolidColorBrush(Shade(accent, -0.25));
+ res["OnAccentBrush"] = new SolidColorBrush(Luminance(accent) > 0.6 ? Color.Parse("#1F1E1D") : Colors.White);
+ res["SystemAccentColor"] = accent;
+ res["SystemAccentColorLight1"] = Shade(accent, 0.15);
+ res["SystemAccentColorLight2"] = Shade(accent, 0.30);
+ res["SystemAccentColorLight3"] = Shade(accent, 0.45);
+ res["SystemAccentColorDark1"] = Shade(accent, -0.15);
+ res["SystemAccentColorDark2"] = Shade(accent, -0.30);
+ res["SystemAccentColorDark3"] = Shade(accent, -0.45);
+ }
+
+ /// <summary>"Softness": one radius drives every control.</summary>
+ public static void ApplyCornerRadius(IResourceDictionary res, double radius)
+ {
+ var r = Math.Clamp(radius, 0, 28);
+ res["SoftRadius"] = new CornerRadius(r);
+ res["SoftRadiusSmall"] = new CornerRadius(Math.Round(r * 0.55));
+ res["SoftRadiusLarge"] = new CornerRadius(Math.Round(r * 1.35));
+ res["ControlCornerRadius"] = new CornerRadius(Math.Round(r * 0.55));
+ res["OverlayCornerRadius"] = new CornerRadius(r);
+ }
+
+ /// <summary>
+ /// The UI font for <paramref name="language"/>. Han characters look different in Korean and Chinese fonts: the
+ /// UI language's font comes first.
+ /// </summary>
+ public static FontFamily FontFamilyFor(string language)
+ {
+ var cjk = language.StartsWith("zh", StringComparison.OrdinalIgnoreCase)
+ ? $"{Chinese}, {Korean}"
+ : $"{Korean}, {Chinese}";
+ return FontFamily.Parse($"{Latin}, {Devanagari}, {cjk}, {SystemFallbacks}");
+ }
+
+ /// <summary>Lightens (amount &gt; 0) or darkens (amount &lt; 0) a colour.</summary>
+ public static Color Shade(Color c, double amount)
+ {
+ byte Mix(byte v) => amount >= 0
+ ? (byte)Math.Round(v + (255 - v) * amount)
+ : (byte)Math.Round(v * (1 + amount));
+ return Color.FromArgb(c.A, Mix(c.R), Mix(c.G), Mix(c.B));
+ }
+
+ /// <summary>Relative luminance 0..1 (sRGB approximation).</summary>
+ public static double Luminance(Color c) => (0.2126 * c.R + 0.7152 * c.G + 0.0722 * c.B) / 255.0;
+}
diff --git a/src/Filee.App/Services/ThemeService.cs b/src/Filee.App/Services/ThemeService.cs
index 30889d3f..86a85ecf 100644
--- a/src/Filee.App/Services/ThemeService.cs
+++ b/src/Filee.App/Services/ThemeService.cs
@@ -18,14 +18,6 @@ public sealed class ThemeService(IPlatformServices platform)
public static readonly IReadOnlyList<string> Swatches =
["#7F77DD", "#1D9E75", "#D85A30", "#378ADD", "#D4537E", "#BA7517", "#639922", "#5F5E5A"];
- /// <summary>Embedded Noto fonts (see build/fetch-fonts.ps1). Missing files fall back to system fonts.</summary>
- private const string Latin = "fonts:Filee#Noto Sans";
- private const string Korean = "fonts:Filee#Noto Sans KR";
- private const string Chinese = "fonts:Filee#Noto Sans SC";
- private const string Devanagari = "fonts:Filee#Noto Sans Devanagari";
- private const string SystemFallbacks =
- "Segoe UI, Nirmala UI, Malgun Gothic, Microsoft YaHei, PingFang SC, Apple SD Gothic Neo, Kohinoor Devanagari, sans-serif";
-
/// <summary>
/// theme.json colour names → the brushes in Styles/Soft.axaml they replace. Must cover exactly
/// <see cref="CustomTheme.Keys"/> (a test checks).
@@ -55,35 +47,10 @@ public sealed class ThemeService(IPlatformServices platform)
_ => ThemeVariant.Default,
};
- // Accent colour + derived shades. Fluent controls read the System* keys.
- var accent = Color.TryParse(theme.Accent, out var parsed) ? parsed : Color.Parse("#7F77DD");
- res["AccentColor"] = accent;
- res["AccentBrush"] = new SolidColorBrush(accent);
- res["AccentSoftBrush"] = new SolidColorBrush(accent, 0.18);
- res["AccentFaintBrush"] = new SolidColorBrush(accent, 0.09);
- res["AccentStrongBrush"] = new SolidColorBrush(Shade(accent, -0.25));
- res["OnAccentBrush"] = new SolidColorBrush(Luminance(accent) > 0.6 ? Color.Parse("#1F1E1D") : Colors.White);
- res["SystemAccentColor"] = accent;
- res["SystemAccentColorLight1"] = Shade(accent, 0.15);
- res["SystemAccentColorLight2"] = Shade(accent, 0.30);
- res["SystemAccentColorLight3"] = Shade(accent, 0.45);
- res["SystemAccentColorDark1"] = Shade(accent, -0.15);
- res["SystemAccentColorDark2"] = Shade(accent, -0.30);
- res["SystemAccentColorDark3"] = Shade(accent, -0.45);
-
- // "Softness": one radius drives every control.
- var r = Math.Clamp(theme.CornerRadius, 0, 28);
- res["SoftRadius"] = new CornerRadius(r);
- res["SoftRadiusSmall"] = new CornerRadius(Math.Round(r * 0.55));
- res["SoftRadiusLarge"] = new CornerRadius(Math.Round(r * 1.35));
- res["ControlCornerRadius"] = new CornerRadius(Math.Round(r * 0.55));
- res["OverlayCornerRadius"] = new CornerRadius(r);
-
- // Han characters look different in Korean and Chinese fonts: put the UI language's font first.
- var cjk = language.StartsWith("zh", StringComparison.OrdinalIgnoreCase)
- ? $"{Chinese}, {Korean}"
- : $"{Korean}, {Chinese}";
- res["AppFontFamily"] = FontFamily.Parse($"{Latin}, {Devanagari}, {cjk}, {SystemFallbacks}");
+ // Accent colour + derived shades, corner radii and the font order (shared with the installer).
+ SoftPalette.ApplyAccent(res, Color.TryParse(theme.Accent, out var parsed) ? parsed : Color.Parse(SoftPalette.DefaultAccent));
+ SoftPalette.ApplyCornerRadius(res, theme.CornerRadius);
+ res["AppFontFamily"] = SoftPalette.FontFamilyFor(language);
// Application.Resources is searched before the styles, so these theme dictionaries win over Soft.axaml's.
ApplyCustom(res, ThemeVariant.Light, custom?.Light);
@@ -107,14 +74,8 @@ public sealed class ThemeService(IPlatformServices platform)
}
/// <summary>Lightens (amount &gt; 0) or darkens (amount &lt; 0) a colour.</summary>
- public static Color Shade(Color c, double amount)
- {
- byte Mix(byte v) => amount >= 0
- ? (byte)Math.Round(v + (255 - v) * amount)
- : (byte)Math.Round(v * (1 + amount));
- return Color.FromArgb(c.A, Mix(c.R), Mix(c.G), Mix(c.B));
- }
+ public static Color Shade(Color c, double amount) => SoftPalette.Shade(c, amount);
/// <summary>Relative luminance 0..1 (sRGB approximation).</summary>
- public static double Luminance(Color c) => (0.2126 * c.R + 0.7152 * c.G + 0.0722 * c.B) / 255.0;
+ public static double Luminance(Color c) => SoftPalette.Luminance(c);
}
diff --git a/src/Filee.App/Styles/Controls.axaml b/src/Filee.App/Styles/Controls.axaml
new file mode 100644
index 00000000..2894ad81
--- /dev/null
+++ b/src/Filee.App/Styles/Controls.axaml
@@ -0,0 +1,19 @@
+<!-- Styles for Filee's own controls, kept out of Soft.axaml, which the installer shares. -->
+<Styles xmlns="https://github.com/avaloniaui"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:c="using:Filee.App.Controls">
+
+ <!-- ───────── Donut control colours ───────── -->
+ <Style Selector="c|DonutMenu">
+ <Setter Property="SliceBrush" Value="{DynamicResource SurfaceBrush}" />
+ <Setter Property="SliceBorderBrush" Value="{DynamicResource SubtleBorderBrush}" />
+ <Setter Property="CornerRadius" Value="{DynamicResource SoftRadius}" />
+ <Setter Property="CenterBrush" Value="{DynamicResource SurfaceBrush}" />
+ <Setter Property="AccentBrush" Value="{DynamicResource AccentBrush}" />
+ <Setter Property="OnAccentBrush" Value="{DynamicResource OnAccentBrush}" />
+ <Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
+ <Setter Property="SecondaryForeground" Value="{DynamicResource TextSecondaryBrush}" />
+ <Setter Property="DangerBrush" Value="{DynamicResource DangerBrush}" />
+ <Setter Property="SuccessBrush" Value="{DynamicResource SuccessBrush}" />
+ </Style>
+</Styles>
diff --git a/src/Filee.App/Styles/Soft.axaml b/src/Filee.App/Styles/Soft.axaml
index d70cebf2..41ae3ae9 100644
--- a/src/Filee.App/Styles/Soft.axaml
+++ b/src/Filee.App/Styles/Soft.axaml
@@ -2,10 +2,11 @@
Filee "soft" look: rounded corners, gentle surfaces, springy press feedback.
Colours that depend on light/dark live in ThemeDictionaries below; the accent colour, corner radii and
the UI font are written at runtime by ThemeService (so users can customise them).
+ Only Avalonia's own controls here: Filee's installer (src/Filee.Setup) links this file to look like the app.
+ Styles for Filee's own controls go into Controls.axaml.
-->
<Styles xmlns="https://github.com/avaloniaui"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:c="using:Filee.App.Controls">
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Styles.Resources>
<ResourceDictionary>
@@ -205,20 +206,6 @@
<Setter Property="Background" Value="{DynamicResource AccentSoftBrush}" />
</Style>
- <!-- ───────── Donut control colours ───────── -->
- <Style Selector="c|DonutMenu">
- <Setter Property="SliceBrush" Value="{DynamicResource SurfaceBrush}" />
- <Setter Property="SliceBorderBrush" Value="{DynamicResource SubtleBorderBrush}" />
- <Setter Property="CornerRadius" Value="{DynamicResource SoftRadius}" />
- <Setter Property="CenterBrush" Value="{DynamicResource SurfaceBrush}" />
- <Setter Property="AccentBrush" Value="{DynamicResource AccentBrush}" />
- <Setter Property="OnAccentBrush" Value="{DynamicResource OnAccentBrush}" />
- <Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
- <Setter Property="SecondaryForeground" Value="{DynamicResource TextSecondaryBrush}" />
- <Setter Property="DangerBrush" Value="{DynamicResource DangerBrush}" />
- <Setter Property="SuccessBrush" Value="{DynamicResource SuccessBrush}" />
- </Style>
-
<!-- ───────── Page content fade-in (keyframes can't animate RenderTransform, so Margin slides) ───────── -->
<Style Selector="ContentControl.page > :is(Control)">
<Style.Animations>