0
0
Fork 0
mirror of https://github.com/GreemDev/Ryujinx.git synced 2024-12-22 22:45:46 +00:00

UI: Fix diaglog popups doubling the window controls and laying text over the menu bar.

This commit is contained in:
Evan Husted 2024-10-17 11:51:40 -05:00
parent 045f9a39bb
commit 430073817c
21 changed files with 75 additions and 60 deletions

View file

@ -122,7 +122,7 @@ namespace Ryujinx.Ava.UI.Applet
{ {
try try
{ {
MainWindow.ViewModel.AppHost.NpadManager.BlockInputUpdates(); _parent.ViewModel.AppHost.NpadManager.BlockInputUpdates();
var response = await SwkbdAppletDialog.ShowInputDialog(LocaleManager.Instance[LocaleKeys.SoftwareKeyboard], args); var response = await SwkbdAppletDialog.ShowInputDialog(LocaleManager.Instance[LocaleKeys.SoftwareKeyboard], args);
if (response.Result == UserResult.Ok) if (response.Result == UserResult.Ok)
@ -144,7 +144,7 @@ namespace Ryujinx.Ava.UI.Applet
}); });
dialogCloseEvent.WaitOne(); dialogCloseEvent.WaitOne();
MainWindow.ViewModel.AppHost.NpadManager.UnblockInputUpdates(); _parent.ViewModel.AppHost.NpadManager.UnblockInputUpdates();
userText = error ? null : inputText; userText = error ? null : inputText;
@ -154,7 +154,7 @@ namespace Ryujinx.Ava.UI.Applet
public void ExecuteProgram(Switch device, ProgramSpecifyKind kind, ulong value) public void ExecuteProgram(Switch device, ProgramSpecifyKind kind, ulong value)
{ {
device.Configuration.UserChannelPersistence.ExecuteProgram(kind, value); device.Configuration.UserChannelPersistence.ExecuteProgram(kind, value);
MainWindow.ViewModel.AppHost?.Stop(); _parent.ViewModel.AppHost?.Stop();
} }
public bool DisplayErrorAppletDialog(string title, string message, string[] buttons) public bool DisplayErrorAppletDialog(string title, string message, string[] buttons)

View file

@ -129,7 +129,7 @@ namespace Ryujinx.Ava.UI.Applet
Dispatcher.UIThread.Post(() => Dispatcher.UIThread.Post(() =>
{ {
_hiddenTextBox.Clear(); _hiddenTextBox.Clear();
MainWindow.ViewModel.RendererHostControl.Focus(); _parent.ViewModel.RendererHostControl.Focus();
_parent = null; _parent = null;
}); });

View file

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace Ryujinx.Ava.UI.Applet namespace Ryujinx.Ava.UI.Applet
{ {
internal partial class ErrorAppletWindow : StyleableWindow internal partial class ErrorAppletWindow : StyleableAppWindow
{ {
private readonly Window _owner; private readonly Window _owner;
private object _buttonResponse; private object _buttonResponse;

View file

@ -85,7 +85,7 @@ namespace Ryujinx.Ava.UI.Helpers
} }
public static Task<UserResult> ShowDeferredContentDialog( public static Task<UserResult> ShowDeferredContentDialog(
StyleableWindow window, Window window,
string title, string title,
string primaryText, string primaryText,
string secondaryText, string secondaryText,

View file

@ -47,7 +47,7 @@ namespace Ryujinx.Ava.UI.Models
TitleId = info.ProgramId; TitleId = info.ProgramId;
UserId = info.UserId; UserId = info.UserId;
var appData = MainWindow.ViewModel.Applications.FirstOrDefault(x => x.IdString.Equals(TitleIdString, StringComparison.OrdinalIgnoreCase)); var appData = MainWindow.MainWindowViewModel.Applications.FirstOrDefault(x => x.IdString.Equals(TitleIdString, StringComparison.OrdinalIgnoreCase));
InGameList = appData != null; InGameList = appData != null;

View file

@ -33,7 +33,7 @@ namespace Ryujinx.Ava.UI.ViewModels
private readonly string _amiiboJsonPath; private readonly string _amiiboJsonPath;
private readonly byte[] _amiiboLogoBytes; private readonly byte[] _amiiboLogoBytes;
private readonly HttpClient _httpClient; private readonly HttpClient _httpClient;
private readonly StyleableWindow _owner; private readonly StyleableAppWindow _owner;
private Bitmap _amiiboImage; private Bitmap _amiiboImage;
private List<AmiiboApi> _amiiboList; private List<AmiiboApi> _amiiboList;
@ -49,7 +49,7 @@ namespace Ryujinx.Ava.UI.ViewModels
private static readonly AmiiboJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions()); private static readonly AmiiboJsonSerializerContext _serializerContext = new(JsonHelper.GetDefaultSerializerOptions());
public AmiiboWindowViewModel(StyleableWindow owner, string lastScannedAmiiboId, string titleId) public AmiiboWindowViewModel(StyleableAppWindow owner, string lastScannedAmiiboId, string titleId)
{ {
_owner = owner; _owner = owner;

View file

@ -244,7 +244,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
_mainWindow.InputManager.GamepadDriver.OnGamepadConnected += HandleOnGamepadConnected; _mainWindow.InputManager.GamepadDriver.OnGamepadConnected += HandleOnGamepadConnected;
_mainWindow.InputManager.GamepadDriver.OnGamepadDisconnected += HandleOnGamepadDisconnected; _mainWindow.InputManager.GamepadDriver.OnGamepadDisconnected += HandleOnGamepadDisconnected;
MainWindow.ViewModel.AppHost?.NpadManager.BlockInputUpdates(); _mainWindow.ViewModel.AppHost?.NpadManager.BlockInputUpdates();
_isLoaded = false; _isLoaded = false;
@ -357,18 +357,12 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
private void HandleOnGamepadDisconnected(string id) private void HandleOnGamepadDisconnected(string id)
{ {
Dispatcher.UIThread.Post(() => Dispatcher.UIThread.Post(LoadDevices);
{
LoadDevices();
});
} }
private void HandleOnGamepadConnected(string id) private void HandleOnGamepadConnected(string id)
{ {
Dispatcher.UIThread.Post(() => Dispatcher.UIThread.Post(LoadDevices);
{
LoadDevices();
});
} }
private string GetCurrentGamepadId() private string GetCurrentGamepadId()
@ -847,7 +841,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
} }
} }
MainWindow.ViewModel.AppHost?.NpadManager.ReloadConfiguration(newConfig, ConfigurationState.Instance.Hid.EnableKeyboard, ConfigurationState.Instance.Hid.EnableMouse); _mainWindow.ViewModel.AppHost?.NpadManager.ReloadConfiguration(newConfig, ConfigurationState.Instance.Hid.EnableKeyboard, ConfigurationState.Instance.Hid.EnableMouse);
// Atomically replace and signal input change. // Atomically replace and signal input change.
// NOTE: Do not modify InputConfig.Value directly as other code depends on the on-change event. // NOTE: Do not modify InputConfig.Value directly as other code depends on the on-change event.
@ -879,7 +873,7 @@ namespace Ryujinx.Ava.UI.ViewModels.Input
_mainWindow.InputManager.GamepadDriver.OnGamepadConnected -= HandleOnGamepadConnected; _mainWindow.InputManager.GamepadDriver.OnGamepadConnected -= HandleOnGamepadConnected;
_mainWindow.InputManager.GamepadDriver.OnGamepadDisconnected -= HandleOnGamepadDisconnected; _mainWindow.InputManager.GamepadDriver.OnGamepadDisconnected -= HandleOnGamepadDisconnected;
MainWindow.ViewModel.AppHost?.NpadManager.UnblockInputUpdates(); _mainWindow.ViewModel.AppHost?.NpadManager.UnblockInputUpdates();
SelectedGamepad?.Dispose(); SelectedGamepad?.Dispose();

View file

@ -95,26 +95,23 @@ namespace Ryujinx.Ava.UI.Views.Main
if (VisualRoot is MainWindow window) if (VisualRoot is MainWindow window)
{ {
Window = window; DataContext = ViewModel = window.ViewModel;
} }
ViewModel = MainWindow.ViewModel;
DataContext = ViewModel;
} }
private async void StopEmulation_Click(object sender, RoutedEventArgs e) private async void StopEmulation_Click(object sender, RoutedEventArgs e)
{ {
await MainWindow.ViewModel.AppHost?.ShowExitPrompt().OrCompleted()!; await ViewModel.AppHost?.ShowExitPrompt().OrCompleted()!;
} }
private void PauseEmulation_Click(object sender, RoutedEventArgs e) private void PauseEmulation_Click(object sender, RoutedEventArgs e)
{ {
MainWindow.ViewModel.AppHost?.Pause(); ViewModel.AppHost?.Pause();
} }
private void ResumeEmulation_Click(object sender, RoutedEventArgs e) private void ResumeEmulation_Click(object sender, RoutedEventArgs e)
{ {
MainWindow.ViewModel.AppHost?.Resume(); ViewModel.AppHost?.Resume();
} }
public async void OpenSettings(object sender, RoutedEventArgs e) public async void OpenSettings(object sender, RoutedEventArgs e)
@ -178,7 +175,7 @@ namespace Ryujinx.Ava.UI.Views.Main
Window.VirtualFileSystem, Window.VirtualFileSystem,
ViewModel.AppHost.Device.Processes.ActiveApplication.ProgramIdText, ViewModel.AppHost.Device.Processes.ActiveApplication.ProgramIdText,
name, name,
MainWindow.ViewModel.SelectedApplication.Path).ShowDialog(Window); ViewModel.SelectedApplication.Path).ShowDialog(Window);
ViewModel.AppHost.Device.EnableCheats(); ViewModel.AppHost.Device.EnableCheats();
} }
@ -186,7 +183,7 @@ namespace Ryujinx.Ava.UI.Views.Main
private void ScanAmiiboMenuItem_AttachedToVisualTree(object sender, VisualTreeAttachmentEventArgs e) private void ScanAmiiboMenuItem_AttachedToVisualTree(object sender, VisualTreeAttachmentEventArgs e)
{ {
if (sender is MenuItem) if (sender is MenuItem)
ViewModel.IsAmiiboRequested = MainWindow.ViewModel.AppHost.Device.System.SearchingForAmiibo(out _); ViewModel.IsAmiiboRequested = ViewModel.AppHost.Device.System.SearchingForAmiibo(out _);
} }
private async void InstallFileTypes_Click(object sender, RoutedEventArgs e) private async void InstallFileTypes_Click(object sender, RoutedEventArgs e)

View file

@ -26,16 +26,15 @@ namespace Ryujinx.Ava.UI.Views.Main
if (VisualRoot is MainWindow window) if (VisualRoot is MainWindow window)
{ {
Window = window; Window = window;
DataContext = window.ViewModel;
} }
DataContext = MainWindow.ViewModel;
} }
private void VsyncStatus_PointerReleased(object sender, PointerReleasedEventArgs e) private void VsyncStatus_PointerReleased(object sender, PointerReleasedEventArgs e)
{ {
MainWindow.ViewModel.AppHost.ToggleVSync(); Window.ViewModel.AppHost.ToggleVSync();
Logger.Info?.Print(LogClass.Application, $"VSync toggled to: {MainWindow.ViewModel.AppHost.Device.EnableDeviceVsync}"); Logger.Info?.Print(LogClass.Application, $"VSync toggled to: {Window.ViewModel.AppHost.Device.EnableDeviceVsync}");
} }
private void DockedStatus_PointerReleased(object sender, PointerReleasedEventArgs e) private void DockedStatus_PointerReleased(object sender, PointerReleasedEventArgs e)
@ -57,9 +56,9 @@ namespace Ryujinx.Ava.UI.Views.Main
private void VolumeStatus_OnPointerWheelChanged(object sender, PointerWheelEventArgs e) private void VolumeStatus_OnPointerWheelChanged(object sender, PointerWheelEventArgs e)
{ {
// Change the volume by 5% at a time // Change the volume by 5% at a time
float newValue = MainWindow.ViewModel.Volume + (float)e.Delta.Y * 0.05f; float newValue = Window.ViewModel.Volume + (float)e.Delta.Y * 0.05f;
MainWindow.ViewModel.Volume = newValue switch Window.ViewModel.Volume = newValue switch
{ {
< 0 => 0, < 0 => 0,
> 1 => 1, > 1 => 1,

View file

@ -22,12 +22,11 @@ namespace Ryujinx.Ava.UI.Views.Main
{ {
base.OnAttachedToVisualTree(e); base.OnAttachedToVisualTree(e);
if (VisualRoot is MainWindow) if (VisualRoot is MainWindow window)
{ {
ViewModel = MainWindow.ViewModel; DataContext = ViewModel = window.ViewModel;
} }
DataContext = ViewModel;
} }
public void Sort_Checked(object sender, RoutedEventArgs args) public void Sort_Checked(object sender, RoutedEventArgs args)

View file

@ -1,4 +1,4 @@
<window:StyleableWindow <window:StyleableAppWindow
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@ -72,4 +72,4 @@
Click="CancelButton_Click" /> Click="CancelButton_Click" />
</Grid> </Grid>
</Grid> </Grid>
</window:StyleableWindow> </window:StyleableAppWindow>

View file

@ -5,7 +5,7 @@ using Ryujinx.UI.Common.Models.Amiibo;
namespace Ryujinx.Ava.UI.Windows namespace Ryujinx.Ava.UI.Windows
{ {
public partial class AmiiboWindow : StyleableWindow public partial class AmiiboWindow : StyleableAppWindow
{ {
public AmiiboWindow(bool showAll, string lastScannedAmiiboId, string titleId) public AmiiboWindow(bool showAll, string lastScannedAmiiboId, string titleId)
{ {

View file

@ -1,4 +1,4 @@
<window:StyleableWindow <window:StyleableAppWindow
x:Class="Ryujinx.Ava.UI.Windows.CheatWindow" x:Class="Ryujinx.Ava.UI.Windows.CheatWindow"
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -123,4 +123,4 @@
</DockPanel> </DockPanel>
</DockPanel> </DockPanel>
</Grid> </Grid>
</window:StyleableWindow> </window:StyleableAppWindow>

View file

@ -14,7 +14,7 @@ using System.Linq;
namespace Ryujinx.Ava.UI.Windows namespace Ryujinx.Ava.UI.Windows
{ {
public partial class CheatWindow : StyleableWindow public partial class CheatWindow : StyleableAppWindow
{ {
private readonly string _enabledCheatsPath; private readonly string _enabledCheatsPath;
public bool NoCheatsFound { get; } public bool NoCheatsFound { get; }

View file

@ -1,4 +1,4 @@
<window:StyleableWindow <window:StyleableAppWindow
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@ -11,15 +11,15 @@
x:Class="Ryujinx.Ava.UI.Windows.ContentDialogOverlayWindow" x:Class="Ryujinx.Ava.UI.Windows.ContentDialogOverlayWindow"
Title="ContentDialogOverlayWindow" Title="ContentDialogOverlayWindow"
Focusable="False"> Focusable="False">
<window:StyleableWindow.Styles> <window:StyleableAppWindow.Styles>
<Style Selector="ui|ContentDialog /template/ Panel#LayoutRoot"> <Style Selector="ui|ContentDialog /template/ Panel#LayoutRoot">
<Setter Property="Background" <Setter Property="Background"
Value="Transparent" /> Value="Transparent" />
</Style> </Style>
</window:StyleableWindow.Styles> </window:StyleableAppWindow.Styles>
<ui:ContentDialog Name="ContentDialog" <ui:ContentDialog Name="ContentDialog"
IsPrimaryButtonEnabled="True" IsPrimaryButtonEnabled="True"
IsSecondaryButtonEnabled="True" IsSecondaryButtonEnabled="True"
IsVisible="False" IsVisible="False"
Focusable="True"/> Focusable="True"/>
</window:StyleableWindow> </window:StyleableAppWindow>

View file

@ -9,7 +9,7 @@ namespace Ryujinx.Ava.UI.Windows
{ {
InitializeComponent(); InitializeComponent();
TransparencyLevelHint = new[] { WindowTransparencyLevel.Transparent }; TransparencyLevelHint = [WindowTransparencyLevel.Transparent];
WindowStartupLocation = WindowStartupLocation.Manual; WindowStartupLocation = WindowStartupLocation.Manual;
SystemDecorations = SystemDecorations.None; SystemDecorations = SystemDecorations.None;
ExtendClientAreaTitleBarHeightHint = 0; ExtendClientAreaTitleBarHeightHint = 0;

View file

@ -1,4 +1,4 @@
<window:StyleableWindow <window:StyleableAppWindow
x:Class="Ryujinx.Ava.UI.Windows.MainWindow" x:Class="Ryujinx.Ava.UI.Windows.MainWindow"
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -200,4 +200,4 @@
Grid.Row="2" /> Grid.Row="2" />
</Grid> </Grid>
</Grid> </Grid>
</window:StyleableWindow> </window:StyleableAppWindow>

View file

@ -35,9 +35,11 @@ using System.Threading.Tasks;
namespace Ryujinx.Ava.UI.Windows namespace Ryujinx.Ava.UI.Windows
{ {
public partial class MainWindow : StyleableWindow public partial class MainWindow : StyleableAppWindow
{ {
internal static MainWindowViewModel ViewModel { get; private set; } internal static MainWindowViewModel MainWindowViewModel { get; private set; }
public MainWindowViewModel ViewModel { get; }
internal readonly AvaHostUIHandler UiHandler; internal readonly AvaHostUIHandler UiHandler;
@ -69,7 +71,7 @@ namespace Ryujinx.Ava.UI.Windows
public MainWindow() public MainWindow()
{ {
DataContext = ViewModel = new MainWindowViewModel(); DataContext = ViewModel = MainWindowViewModel = new MainWindowViewModel();
InitializeComponent(); InitializeComponent();
Load(); Load();
@ -78,8 +80,8 @@ namespace Ryujinx.Ava.UI.Windows
ViewModel.Title = App.FormatTitle(); ViewModel.Title = App.FormatTitle();
TitleBar.ExtendsContentIntoTitleBar = true; //TitleBar.ExtendsContentIntoTitleBar = true;
TitleBar.TitleBarHitTestType = TitleBarHitTestType.Complex; //TitleBar.TitleBarHitTestType = TitleBarHitTestType.Complex;
// NOTE: Height of MenuBar and StatusBar is not usable here, since it would still be 0 at this point. // NOTE: Height of MenuBar and StatusBar is not usable here, since it would still be 0 at this point.

View file

@ -1,4 +1,4 @@
<window:StyleableWindow <window:StyleableAppWindow
x:Class="Ryujinx.Ava.UI.Windows.SettingsWindow" x:Class="Ryujinx.Ava.UI.Windows.SettingsWindow"
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia" xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
@ -127,4 +127,4 @@
Command="{Binding ApplyButton}" /> Command="{Binding ApplyButton}" />
</ReversibleStackPanel> </ReversibleStackPanel>
</Grid> </Grid>
</window:StyleableWindow> </window:StyleableAppWindow>

View file

@ -8,7 +8,7 @@ using System;
namespace Ryujinx.Ava.UI.Windows namespace Ryujinx.Ava.UI.Windows
{ {
public partial class SettingsWindow : StyleableWindow public partial class SettingsWindow : StyleableAppWindow
{ {
internal SettingsViewModel ViewModel { get; set; } internal SettingsViewModel ViewModel { get; set; }

View file

@ -11,7 +11,31 @@ using System.Reflection;
namespace Ryujinx.Ava.UI.Windows namespace Ryujinx.Ava.UI.Windows
{ {
public class StyleableWindow : AppWindow public class StyleableAppWindow : AppWindow
{
public StyleableAppWindow()
{
WindowStartupLocation = WindowStartupLocation.CenterOwner;
TransparencyLevelHint = [WindowTransparencyLevel.None];
LocaleManager.Instance.LocaleChanged += LocaleChanged;
LocaleChanged();
}
private void LocaleChanged()
{
FlowDirection = LocaleManager.Instance.IsRTL() ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
}
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);
ExtendClientAreaChromeHints = ExtendClientAreaChromeHints.SystemChrome | ExtendClientAreaChromeHints.OSXThickTitleBar;
}
}
public class StyleableWindow : Window
{ {
public StyleableWindow() public StyleableWindow()
{ {