refactor: completely overhaul app icon management for cleaner workflow

This commit is contained in:
VewDev
2025-09-01 14:24:48 +02:00
parent ab4567d0a2
commit 362fbf08a2
3 changed files with 85 additions and 38 deletions

View File

@@ -3,11 +3,13 @@ using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using FluentAvalonia.UI.Windowing;
using Ryujinx.Ava.Common.Locale;
using Ryujinx.Ava.Systems.Configuration;
using Ryujinx.Ava.UI.Controls;
using Ryujinx.Common;
using System.Threading.Tasks;
namespace Ryujinx.Ava.UI.Windows
@@ -39,7 +41,8 @@ namespace Ryujinx.Ava.UI.Windows
TitleBar.Height = titleBarHeight.Value;
}
Icon = RyujinxLogo.Bitmap;
Icon = RyujinxLogo.CurrentLogoBitmap.Value;
RyujinxLogo.CurrentLogoBitmap.Event += WindowIconChanged_Event;
}
private void LocaleChanged()
@@ -53,6 +56,12 @@ namespace Ryujinx.Ava.UI.Windows
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.SystemChrome | ExtendClientAreaChromeHints.OSXThickTitleBar;
}
private void WindowIconChanged_Event(object _, ReactiveEventArgs<Bitmap> rArgs) => UpdateIcon(rArgs.NewValue);
private void UpdateIcon(Bitmap newIcon)
{
Icon = newIcon;
}
}
public abstract class StyleableWindow : Window
@@ -73,7 +82,8 @@ namespace Ryujinx.Ava.UI.Windows
LocaleManager.Instance.LocaleChanged += LocaleChanged;
LocaleChanged();
Icon = new WindowIcon(RyujinxLogo.Bitmap);
Icon = new WindowIcon(RyujinxLogo.CurrentLogoBitmap.Value);
RyujinxLogo.CurrentLogoBitmap.Event += WindowIconChanged_Event;
}
private void LocaleChanged()
@@ -87,5 +97,11 @@ namespace Ryujinx.Ava.UI.Windows
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.SystemChrome | ExtendClientAreaChromeHints.OSXThickTitleBar;
}
private void WindowIconChanged_Event(object _, ReactiveEventArgs<Bitmap> rArgs) => UpdateIcon(rArgs.NewValue);
private void UpdateIcon(Bitmap newIcon)
{
Icon = new WindowIcon(newIcon);
}
}
}