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.

Merge remote-tracking branch 'upstream/main' into feature/zip-gesture-and-fixes

gtxPrime2c8e2d1e15cd
diff --cc src/Filee.App/Controls/DonutMenu.cs
index bcc84dcb,2011d339..ef14328d
--- a/src/Filee.App/Controls/DonutMenu.cs
+++ b/src/Filee.App/Controls/DonutMenu.cs
@@@ -135,8 -131,8 +135,7 @@@ public sealed partial class DonutMenu
AffectsMeasure<DonutMenu>(OuterRadiusProperty, ReserveSubRingProperty);
AffectsRender<DonutMenu>(HoleRatioProperty, SliceOpacityProperty, CenterTitleProperty, CenterSubtitleProperty,
IsEditModeProperty, SliceBrushProperty, SliceBorderBrushProperty, CenterBrushProperty, AccentBrushProperty,
-- OnAccentBrushProperty, ForegroundProperty, SecondaryForegroundProperty, SuccessBrushProperty, CornerRadiusProperty,
- IsMaterialYouProperty);
- CenterHintProperty, CenterHintWheelProperty);
++ IsMaterialYouProperty, CenterHintProperty, CenterHintWheelProperty);
ItemsProperty.Changed.AddClassHandler<DonutMenu>((d, _) => d.OnItemsChanged());
}
@@@ -911,61 -912,55 +929,92 @@@
private void DrawCenter(DrawingContext context, Point center, double r1, Typeface bold, Typeface regular)
{
- var pulse = 1 + _centerPulse.Value * 0.06;
+ var pulse = 1 + _centerPulse.Value * (IsMaterialYou ? 0.08 : 0.06);
var radius = (r1 - 6) * pulse;
var cancelHot = _externalCenterHot;
+
+ if (IsMaterialYou)
+ DrawCenterShadow(context, center, radius);
+
context.DrawEllipse(CenterBrush, BorderPen(), center, radius, radius);
if (cancelHot)
- context.DrawEllipse(WithOpacity(DangerBrush, 0.18), null, center, radius, radius);
+ context.DrawEllipse(WithOpacity(DangerBrush, IsMaterialYou ? 0.32 : 0.18), null, center, radius, radius);
var maxWidth = radius * 1.6;
- var title = MakeText(CenterTitle ?? "", bold, 14, Foreground, maxWidth, maxLines: 2);
- var subtitle = MakeText(CenterSubtitle ?? "", regular, 11.5, cancelHot ? DangerBrush : SecondaryForeground, maxWidth, maxLines: 2);
+ var title = MakeText(CenterTitle ?? "", bold, IsMaterialYou ? 14.5 : 14, Foreground, maxWidth, maxLines: 2);
+ var subtitle = MakeText(CenterSubtitle ?? "", regular, IsMaterialYou ? 10.5 : 11.5, cancelHot ? DangerBrush : SecondaryForeground, maxWidth, maxLines: 2);
+ var hasSubtitle = !string.IsNullOrEmpty(CenterSubtitle);
- var total = title.Height + (hasSubtitle ? subtitle.Height + (IsMaterialYou ? 4 : 2) : 0);
+ // "Tab ↻ back": small, under the rest, a little narrower (the hub is round).
+ var hint = string.IsNullOrEmpty(CenterHint) ? null : MakeText(CenterHint, regular, 10.5, SecondaryForeground, maxWidth * 0.85);
- var total = title.Height + (string.IsNullOrEmpty(CenterSubtitle) ? 0 : subtitle.Height + 2) + (hint is null ? 0 : hint.Height + 5);
++ var total = title.Height + (hasSubtitle ? subtitle.Height + (IsMaterialYou ? 4 : 2) : 0) + (hint is null ? 0 : hint.Height + 5);
var y = center.Y - total / 2;
DrawCentered(context, title, center.X, y);
+ y += title.Height;
- if (!string.IsNullOrEmpty(CenterSubtitle))
+
+ if (hasSubtitle)
{
- var subY = y + title.Height + (IsMaterialYou ? 3 : 2);
- DrawCentered(context, subtitle, center.X, y + 2);
- y += subtitle.Height + 2;
++ var subY = y + (IsMaterialYou ? 3 : 2);
+ if (IsMaterialYou)
+ {
+ var padX = 7.0;
+ var padY = 2.0;
+ var badgeW = Math.Min(maxWidth, subtitle.Width + padX * 2);
+ var badgeH = subtitle.Height + padY * 2;
+ var badgeRect = new RoundedRect(new Rect(center.X - badgeW / 2, subY, badgeW, badgeH), badgeH / 2);
+ context.DrawRectangle(WithOpacity(AccentBrush, 0.18), null, badgeRect);
+ DrawCentered(context, MakeText(CenterSubtitle!, regular, 10, Foreground, badgeW), center.X, subY + padY);
+ }
+ else
+ {
+ DrawCentered(context, subtitle, center.X, subY);
+ }
++ y += subtitle.Height + (IsMaterialYou ? 4 : 2);
+ }
++
+ if (hint is not null)
+ {
+ using (context.PushOpacity(0.85))
+ {
+ if (!CenterHintWheel)
+ {
+ DrawCentered(context, hint, center.X, y + 5);
+ }
+ else
+ {
+ // A small mouse in front: "🖱 ↻ back" when the wheel flips and no key does.
+ const double iconWidth = 7, gap = 4;
+ var left = center.X - (hint.Width + iconWidth + gap) / 2;
+ DrawMouse(context, new Rect(left, y + 5 + (hint.Height - 10) / 2, iconWidth, 10), SecondaryForeground);
+ DrawCentered(context, hint, center.X + (iconWidth + gap) / 2, y + 5);
+ }
+ }
}
}
+ private static void DrawCenterShadow(DrawingContext context, Point center, double radius)
+ {
+ var shadowRadius = radius + 9;
+ var brush = new RadialGradientBrush
+ {
+ GradientStops =
+ {
+ new GradientStop(Color.FromArgb(0, 0, 0, 0), 0),
+ new GradientStop(Color.FromArgb(0, 0, 0, 0), (radius - 4) / shadowRadius),
+ new GradientStop(Color.FromArgb(42, 0, 0, 0), (radius + 1) / shadowRadius),
+ new GradientStop(Color.FromArgb(0, 0, 0, 0), 1),
+ },
+ };
+ context.DrawEllipse(brush, null, new Point(center.X, center.Y + 2), shadowRadius, shadowRadius);
+ }
+
+ /// <summary>An outline of a mouse with its wheel, filling <paramref name="box"/>.</summary>
+ private static void DrawMouse(DrawingContext context, Rect box, IBrush? brush)
+ {
+ var pen = new Pen(brush, 1.1);
+ context.DrawRectangle(null, pen, box, box.Width / 2, box.Width / 2);
+ context.DrawLine(pen, new Point(box.Center.X, box.Top + 2), new Point(box.Center.X, box.Top + 4.5));
+ }
+
private void DrawLabel(DrawingContext context, DonutItem item, Point center, double radius, double angle,
double maxWidth, double maxHeight, Typeface bold, Typeface regular, bool hot)
{
diff --cc src/Filee.App/Services/ThemeService.cs
index 7b1a899d,5b6d715b..77d396d0
--- a/src/Filee.App/Services/ThemeService.cs
+++ b/src/Filee.App/Services/ThemeService.cs
@@@ -119,199 -60,36 +123,195 @@@ public sealed class ThemeServic
};
// 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);
+ var accent = Color.TryParse(theme.Accent, out var parsed) ? parsed : Color.Parse(isM3 ? "#6750A4" : "#7F77DD");
+
+ var isDarkVariant = theme.Mode switch
+ {
+ ThemeMode.Dark => true,
+ ThemeMode.Light => false,
+ _ => app.ActualThemeVariant == ThemeVariant.Dark
+ };
+
+ if (isM3)
+ {
+ var lightM3 = MaterialYouPalette.Generate(accent, isDark: false);
+ var darkM3 = MaterialYouPalette.Generate(accent, isDark: true);
+ var activeM3 = isDarkVariant ? darkM3 : lightM3;
+
+ res["AccentColor"] = activeM3.Primary;
+ res["AccentBrush"] = new SolidColorBrush(activeM3.Primary);
+ res["AccentSoftBrush"] = new SolidColorBrush(activeM3.PrimaryContainer);
+ res["AccentFaintBrush"] = new SolidColorBrush(activeM3.SecondaryContainer);
+ res["AccentStrongBrush"] = new SolidColorBrush(activeM3.OnPrimaryContainer);
+ res["OnAccentBrush"] = new SolidColorBrush(activeM3.OnPrimary);
+
+ res["PrimaryContainerBrush"] = new SolidColorBrush(activeM3.PrimaryContainer);
+ res["OnPrimaryContainerBrush"] = new SolidColorBrush(activeM3.OnPrimaryContainer);
+ res["SecondaryContainerBrush"] = new SolidColorBrush(activeM3.SecondaryContainer);
+ res["OnSecondaryContainerBrush"] = new SolidColorBrush(activeM3.OnSecondaryContainer);
+ res["SurfaceBrush"] = new SolidColorBrush(activeM3.SurfaceContainer);
+ res["PageBrush"] = new SolidColorBrush(activeM3.SurfaceContainerLowest);
+ res["SurfaceAltBrush"] = new SolidColorBrush(activeM3.SurfaceContainerHigh);
+ res["SurfaceContainerBrush"] = new SolidColorBrush(activeM3.SurfaceContainer);
+ res["SurfaceContainerLowBrush"] = new SolidColorBrush(activeM3.SurfaceContainerLow);
+ res["SurfaceContainerHighBrush"] = new SolidColorBrush(activeM3.SurfaceContainerHigh);
+ res["SurfaceContainerHighestBrush"] = new SolidColorBrush(activeM3.SurfaceContainerHighest);
+ res["SubtleBorderBrush"] = new SolidColorBrush(activeM3.OutlineVariant);
+ res["TextPrimaryBrush"] = new SolidColorBrush(activeM3.OnSurface);
+ res["TextSecondaryBrush"] = new SolidColorBrush(activeM3.OnSurfaceVariant);
+ res["DangerBrush"] = new SolidColorBrush(activeM3.Danger);
+ res["SuccessBrush"] = new SolidColorBrush(activeM3.Success);
+ res["WarningBrush"] = new SolidColorBrush(activeM3.Warning);
+ res["CardShadow"] = activeM3.CardShadow;
+ res["DropZoneBackgroundBrush"] = new SolidColorBrush(activeM3.SurfaceContainerLow);
+ res["DropZoneBorderBrush"] = new SolidColorBrush(activeM3.OutlineVariant);
+
+ res["SystemAccentColor"] = activeM3.Primary;
+ res["SystemAccentColorLight1"] = Shade(activeM3.Primary, 0.15);
+ res["SystemAccentColorLight2"] = Shade(activeM3.Primary, 0.30);
+ res["SystemAccentColorLight3"] = Shade(activeM3.Primary, 0.45);
+ res["SystemAccentColorDark1"] = Shade(activeM3.Primary, -0.15);
+ res["SystemAccentColorDark2"] = Shade(activeM3.Primary, -0.30);
+ res["SystemAccentColorDark3"] = Shade(activeM3.Primary, -0.45);
+
+ // Fluent control brush keys harmonized with M3 roles
+ res["SliderTrackFill"] = new SolidColorBrush(activeM3.Primary);
+ res["SliderTrackValueFill"] = new SolidColorBrush(activeM3.Primary);
+ res["SliderThumbBackground"] = new SolidColorBrush(activeM3.Primary);
+ res["SliderThumbBorderBrush"] = new SolidColorBrush(activeM3.Primary);
+ res["SliderTrackBackground"] = new SolidColorBrush(activeM3.SurfaceContainerHighest);
+ res["ProgressBarTrackFill"] = new SolidColorBrush(activeM3.Primary);
+ res["ProgressBarBackground"] = new SolidColorBrush(activeM3.SurfaceContainerHighest);
+ res["ProgressBarProgress"] = new SolidColorBrush(activeM3.Primary);
+ res["ToggleSwitchFillOn"] = new SolidColorBrush(activeM3.Primary);
+ res["ToggleSwitchFillOff"] = new SolidColorBrush(activeM3.SurfaceContainerHighest);
+ res["ToggleSwitchKnobFillOn"] = new SolidColorBrush(activeM3.OnPrimary);
+ res["ToggleSwitchKnobFillOff"] = new SolidColorBrush(activeM3.Outline);
+ res["ToggleSwitchStrokeOff"] = new SolidColorBrush(activeM3.Outline);
+ res["CheckBoxCheckBackgroundFillChecked"] = new SolidColorBrush(activeM3.Primary);
+ res["CheckBoxCheckBackgroundStrokeChecked"] = new SolidColorBrush(activeM3.Primary);
+ res["CheckBoxCheckGlyphForegroundChecked"] = new SolidColorBrush(activeM3.OnPrimary);
+ res["AccentButtonBackground"] = new SolidColorBrush(activeM3.Primary);
+ res["AccentButtonForeground"] = new SolidColorBrush(activeM3.OnPrimary);
+ res["AccentButtonBackgroundPointerOver"] = new SolidColorBrush(activeM3.Secondary);
+ res["AccentButtonForegroundPointerOver"] = new SolidColorBrush(activeM3.OnSecondary);
+ res["AccentButtonBackgroundPressed"] = new SolidColorBrush(activeM3.PrimaryContainer);
+ res["AccentButtonForegroundPressed"] = new SolidColorBrush(activeM3.OnPrimaryContainer);
+
+ // "Softness": Material You expressive pill and rounded containers
+ var r = Math.Clamp(theme.CornerRadius, 0, 28);
+ res["SoftRadius"] = new CornerRadius(Math.Max(16, r));
+ res["SoftRadiusSmall"] = new CornerRadius(12);
+ res["SoftRadiusLarge"] = new CornerRadius(24);
+ res["PillRadius"] = new CornerRadius(999);
+ res["ControlCornerRadius"] = new CornerRadius(12);
+ res["OverlayCornerRadius"] = new CornerRadius(20);
+
+ ApplyMaterialYouTheme(res, ThemeVariant.Light, lightM3, custom?.Light);
+ ApplyMaterialYouTheme(res, ThemeVariant.Dark, darkM3, custom?.Dark);
+ }
+ else
+ {
+ res["AccentColor"] = accent;
+ res["AccentBrush"] = new SolidColorBrush(accent);
+ res["AccentSoftBrush"] = new SolidColorBrush(accent, isDarkVariant ? 0.22 : 0.16);
+ res["AccentFaintBrush"] = new SolidColorBrush(accent, isDarkVariant ? 0.12 : 0.08);
+ res["AccentStrongBrush"] = new SolidColorBrush(isDarkVariant
+ ? (MaterialYouPalette.Luminance(accent) > 0.45 ? accent : Shade(accent, 0.35))
+ : (MaterialYouPalette.Luminance(accent) < 0.45 ? accent : Shade(accent, -0.35)));
+ res["OnAccentBrush"] = new SolidColorBrush(MaterialYouPalette.TextOn(accent));
+ 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);
+
+ res["DropZoneBackgroundBrush"] = isDarkVariant
+ ? new SolidColorBrush(Color.Parse("#252523"))
+ : new SolidColorBrush(Color.Parse("#F5F3ED"));
+ res["DropZoneBorderBrush"] = new SolidColorBrush(accent, 0.25);
+
+ res["AccentButtonBackground"] = res["AccentBrush"];
+ res["AccentButtonForeground"] = res["OnAccentBrush"];
+ res["AccentButtonBackgroundPointerOver"] = res["AccentStrongBrush"];
+ res["AccentButtonForegroundPointerOver"] = res["OnAccentBrush"];
+ res["AccentButtonBackgroundPressed"] = res["AccentFaintBrush"];
+ res["AccentButtonForegroundPressed"] = res["OnAccentBrush"];
+
+ // Clean up M3 Fluent overrides if present
+ res.Remove("SliderTrackFill");
+ res.Remove("SliderTrackValueFill");
+ res.Remove("SliderThumbBackground");
+ res.Remove("SliderThumbBorderBrush");
+ res.Remove("SliderTrackBackground");
+ res.Remove("ProgressBarTrackFill");
+ res.Remove("ProgressBarBackground");
+ res.Remove("ProgressBarProgress");
+ res.Remove("ToggleSwitchFillOn");
+ res.Remove("ToggleSwitchFillOff");
+ res.Remove("ToggleSwitchKnobFillOn");
+ res.Remove("ToggleSwitchKnobFillOff");
+ res.Remove("ToggleSwitchStrokeOff");
+ res.Remove("CheckBoxCheckBackgroundFillChecked");
+ res.Remove("CheckBoxCheckBackgroundStrokeChecked");
+ res.Remove("CheckBoxCheckGlyphForegroundChecked");
+
+ 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["PillRadius"] = new CornerRadius(999);
+ res["ControlCornerRadius"] = new CornerRadius(Math.Round(r * 0.55));
+ res["OverlayCornerRadius"] = new CornerRadius(r);
+
+ ApplyCustom(res, ThemeVariant.Light, custom?.Light);
+ ApplyCustom(res, ThemeVariant.Dark, custom?.Dark);
+ }
- // 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}");
+ res["AppFontFamily"] = FontFamily.Parse(FontFamilies(language));
- // Application.Resources is searched before the styles, so these theme dictionaries win over Soft.axaml's.
- ApplyCustom(res, ThemeVariant.Light, custom?.Light);
- ApplyCustom(res, ThemeVariant.Dark, custom?.Dark);
+ // Update all active windows
+ lock (s_openWindows)
+ {
+ s_openWindows.RemoveAll(r => !r.TryGetTarget(out _));
+ foreach (var r in s_openWindows)
+ if (r.TryGetTarget(out var window))
+ window.Classes.Set("material-you", isM3);
+ }
+ if (app.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
+ {
+ foreach (var window in desktop.Windows)
+ window.Classes.Set("material-you", isM3);
+ }
+
+ Motion.Configure(theme.ReduceMotion, () => _platform.PrefersReducedMotion);
+ }
+
+ /// <summary>Applies Material You generated colors to the theme dictionary for one variant.</summary>
+ private static void ApplyMaterialYouTheme(IResourceDictionary res, ThemeVariant variant, MaterialYouPalette m3, IReadOnlyDictionary<string, string>? custom)
+ {
+ var dict = new ResourceDictionary
+ {
+ ["PageBrush"] = new SolidColorBrush(m3.SurfaceContainerLowest),
+ ["SurfaceBrush"] = new SolidColorBrush(m3.Surface),
+ ["SurfaceAltBrush"] = new SolidColorBrush(m3.SurfaceContainerHigh),
+ ["SubtleBorderBrush"] = new SolidColorBrush(m3.OutlineVariant),
+ ["TextPrimaryBrush"] = new SolidColorBrush(m3.OnSurface),
+ ["TextSecondaryBrush"] = new SolidColorBrush(m3.OnSurfaceVariant),
+ ["DangerBrush"] = new SolidColorBrush(m3.Danger),
+ ["SuccessBrush"] = new SolidColorBrush(m3.Success),
+ ["WarningBrush"] = new SolidColorBrush(m3.Warning),
+ ["CardShadow"] = m3.CardShadow,
+ };
+
+ // Custom colours from theme.json take precedence if present
+ foreach (var (name, value) in custom ?? new Dictionary<string, string>())
+ if (CustomBrushKeys.TryGetValue(name, out var key) && Color.TryParse(value, out var color))
+ dict[key] = new SolidColorBrush(color);
- Motion.Configure(theme.ReduceMotion, () => platform.PrefersReducedMotion);
+ res.ThemeDictionaries[variant] = dict;
}
/// <summary>Replaces (or, with no colours, removes) the user's colours for one variant.</summary>