Skip to content

Commit

Permalink
Misc UI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed Dec 25, 2024
1 parent e83bd51 commit fa6f49d
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 80 deletions.
81 changes: 42 additions & 39 deletions HandheldCompanion/Views/Pages/ProfilesPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,17 @@ private void MultimediaManager_Initialized()
});
}

private bool HasRSRSupport = false;
private bool HasAFMFSupport = false;
private bool HasScalingModeSupport = false;
private bool HasIntegerScalingSupport = false;
private bool HasGPUScalingSupport = false;
private bool IsGPUScalingEnabled = false;

private void GPUManager_Hooked(GPU GPU)
{
bool HasRSRSupport = false;
bool HasAFMFSupport = false;
HasRSRSupport = false;
HasAFMFSupport = false;

if (GPU is AMDGPU amdGPU)
{
Expand All @@ -104,25 +111,17 @@ private void GPUManager_Hooked(GPU GPU)
GPU.IntegerScalingChanged += OnIntegerScalingChanged;
GPU.GPUScalingChanged += OnGPUScalingChanged;

bool HasScalingModeSupport = GPU.HasScalingModeSupport();
bool HasIntegerScalingSupport = GPU.HasIntegerScalingSupport();
bool HasGPUScalingSupport = GPU.HasGPUScalingSupport();
bool IsGPUScalingEnabled = GPU.GetGPUScaling();
HasScalingModeSupport = GPU.HasScalingModeSupport();
HasIntegerScalingSupport = GPU.HasIntegerScalingSupport();
HasGPUScalingSupport = GPU.HasGPUScalingSupport();
IsGPUScalingEnabled = GPU.GetGPUScaling();

// UI thread (async)
Application.Current.Dispatcher.BeginInvoke(() =>
{
// GPU-specific settings
StackProfileRSR.Visibility = GPU is AMDGPU ? Visibility.Visible : Visibility.Collapsed;
StackProfileAFMF.Visibility = GPU is AMDGPU ? Visibility.Visible : Visibility.Collapsed;

StackProfileRSR.IsEnabled = HasGPUScalingSupport && IsGPUScalingEnabled && HasRSRSupport;
StackProfileAFMF.IsEnabled = HasAFMFSupport;

StackProfileGPUScaling.IsEnabled = HasGPUScalingSupport;
StackProfileIS.IsEnabled = HasGPUScalingSupport && IsGPUScalingEnabled && HasIntegerScalingSupport;
StackProfileRIS.IsEnabled = HasGPUScalingSupport; // check if processor is AMD should be enough
GPUScalingComboBox.IsEnabled = HasScalingModeSupport;
StackProfileRSR.Visibility = GPUManager.GetCurrent() is AMDGPU ? Visibility.Visible : Visibility.Collapsed;
StackProfileAFMF.Visibility = GPUManager.GetCurrent() is AMDGPU ? Visibility.Visible : Visibility.Collapsed;
});
}

Expand All @@ -140,51 +139,55 @@ private void GPUManager_Unhooked(GPU GPU)
// UI thread
Application.Current.Dispatcher.Invoke(() =>
{
// GPU-specific settings
StackProfileRSR.Visibility = Visibility.Collapsed;
StackProfileAFMF.Visibility = Visibility.Collapsed;

StackProfileRSR.IsEnabled = false;
StackProfileAFMF.IsEnabled = false;
StackProfileGPUScaling.IsEnabled = false;
StackProfileIS.IsEnabled = false;
GPUScalingToggle.IsEnabled = false;
StackProfileRIS.IsEnabled = false;
GPUScalingComboBox.IsEnabled = false;
});
}

private void OnRSRStateChanged(bool Supported, bool Enabled, int Sharpness)
private void UpdateGraphicsSettingsUI()
{
// UI thread
Application.Current.Dispatcher.Invoke(() =>
// UI thread (async)
Application.Current.Dispatcher.BeginInvoke(() =>
{
StackProfileRSR.IsEnabled = Supported;
StackProfileRSR.IsEnabled = HasRSRSupport;
StackProfileAFMF.IsEnabled = HasAFMFSupport;
StackProfileGPUScaling.IsEnabled = HasGPUScalingSupport;
StackProfileIS.IsEnabled = HasIntegerScalingSupport;
StackProfileRIS.IsEnabled = HasGPUScalingSupport; // check if processor is AMD should be enough
GPUScalingComboBox.IsEnabled = HasScalingModeSupport;
});
}

private void OnRSRStateChanged(bool Supported, bool Enabled, int Sharpness)
{
HasRSRSupport = Supported;
UpdateGraphicsSettingsUI();
}

private void OnAFMFStateChanged(bool Supported, bool Enabled)
{
// UI thread
Application.Current.Dispatcher.Invoke(() =>
{
StackProfileAFMF.IsEnabled = Supported;
});
HasAFMFSupport = Supported;
UpdateGraphicsSettingsUI();
}

private void OnGPUScalingChanged(bool Supported, bool Enabled, int Mode)
{
// UI thread
Application.Current.Dispatcher.Invoke(() =>
{
GPUScalingToggle.IsEnabled = Supported;
StackProfileRIS.IsEnabled = Supported; // check if processor is AMD should be enough
StackProfileRSR.IsEnabled = Supported;
StackProfileIS.IsEnabled = Supported;
});
HasGPUScalingSupport = Supported;
UpdateGraphicsSettingsUI();
}

private void OnIntegerScalingChanged(bool Supported, bool Enabled)
{
// UI thread
Application.Current.Dispatcher.Invoke(() =>
{
StackProfileIS.IsEnabled = Supported;
});
HasIntegerScalingSupport = Supported;
UpdateGraphicsSettingsUI();
}

private void RTSS_Updated(PlatformStatus status)
Expand Down
84 changes: 43 additions & 41 deletions HandheldCompanion/Views/QuickPages/QuickProfilesPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,17 @@ private void MultimediaManager_Initialized()
});
}

private bool HasRSRSupport = false;
private bool HasAFMFSupport = false;
private bool HasScalingModeSupport = false;
private bool HasIntegerScalingSupport = false;
private bool HasGPUScalingSupport = false;
private bool IsGPUScalingEnabled = false;

private void GPUManager_Hooked(GPU GPU)
{
bool HasRSRSupport = false;
bool HasAFMFSupport = false;
HasRSRSupport = false;
HasAFMFSupport = false;

if (GPU is AMDGPU amdGPU)
{
Expand All @@ -187,28 +194,18 @@ private void GPUManager_Hooked(GPU GPU)
GPU.IntegerScalingChanged += OnIntegerScalingChanged;
GPU.GPUScalingChanged += OnGPUScalingChanged;

bool HasScalingModeSupport = GPU.HasScalingModeSupport();
bool HasIntegerScalingSupport = GPU.HasIntegerScalingSupport();
bool HasGPUScalingSupport = GPU.HasGPUScalingSupport();
bool IsGPUScalingEnabled = GPU.GetGPUScaling();
HasScalingModeSupport = GPU.HasScalingModeSupport();
HasIntegerScalingSupport = GPU.HasIntegerScalingSupport();
HasGPUScalingSupport = GPU.HasGPUScalingSupport();
IsGPUScalingEnabled = GPU.GetGPUScaling();

// UI thread (async)
Application.Current.Dispatcher.BeginInvoke(() =>
{
// GPU-specific settings
StackProfileRSR.Visibility = GPU is AMDGPU ? Visibility.Visible : Visibility.Collapsed;
StackProfileAFMF.Visibility = GPU is AMDGPU ? Visibility.Visible : Visibility.Collapsed;
StackProfileRSR.Visibility = GPUManager.GetCurrent() is AMDGPU ? Visibility.Visible : Visibility.Collapsed;
StackProfileAFMF.Visibility = GPUManager.GetCurrent() is AMDGPU ? Visibility.Visible : Visibility.Collapsed;
IntegerScalingTypeGrid.Visibility = GPU is IntelGPU ? Visibility.Visible : Visibility.Collapsed;

StackProfileRSR.IsEnabled = HasGPUScalingSupport && IsGPUScalingEnabled && HasRSRSupport;
StackProfileAFMF.IsEnabled = HasAFMFSupport;

StackProfileGPUScaling.IsEnabled = HasGPUScalingSupport;
StackProfileIS.IsEnabled = HasGPUScalingSupport && IsGPUScalingEnabled && HasIntegerScalingSupport;
StackProfileRIS.IsEnabled = HasGPUScalingSupport; // check if processor is AMD should be enough
GPUScalingComboBox.IsEnabled = HasScalingModeSupport;

CurrentDeviceName.Text = GPU.adapterInformation.Details.Description;
});
}

Expand All @@ -226,51 +223,56 @@ private void GPUManager_Unhooked(GPU GPU)
// UI thread
Application.Current.Dispatcher.Invoke(() =>
{
// GPU-specific settings
StackProfileRSR.Visibility = Visibility.Collapsed;
StackProfileAFMF.Visibility = Visibility.Collapsed;
IntegerScalingTypeGrid.Visibility = Visibility.Collapsed;

StackProfileRSR.IsEnabled = false;
StackProfileAFMF.IsEnabled = false;
StackProfileGPUScaling.IsEnabled = false;
StackProfileIS.IsEnabled = false;
GPUScalingToggle.IsEnabled = false;
StackProfileRIS.IsEnabled = false;
GPUScalingComboBox.IsEnabled = false;
});
}

private void OnRSRStateChanged(bool Supported, bool Enabled, int Sharpness)
private void UpdateGraphicsSettingsUI()
{
// UI thread
Application.Current.Dispatcher.Invoke(() =>
// UI thread (async)
Application.Current.Dispatcher.BeginInvoke(() =>
{
StackProfileRSR.IsEnabled = Supported;
StackProfileRSR.IsEnabled = HasRSRSupport;
StackProfileAFMF.IsEnabled = HasAFMFSupport;
StackProfileGPUScaling.IsEnabled = HasGPUScalingSupport;
StackProfileIS.IsEnabled = HasIntegerScalingSupport;
StackProfileRIS.IsEnabled = HasGPUScalingSupport; // check if processor is AMD should be enough
GPUScalingComboBox.IsEnabled = HasScalingModeSupport;
});
}

private void OnRSRStateChanged(bool Supported, bool Enabled, int Sharpness)
{
HasRSRSupport = Supported;
UpdateGraphicsSettingsUI();
}

private void OnAFMFStateChanged(bool Supported, bool Enabled)
{
// UI thread
Application.Current.Dispatcher.Invoke(() =>
{
StackProfileAFMF.IsEnabled = Supported;
});
HasAFMFSupport = Supported;
UpdateGraphicsSettingsUI();
}

private void OnGPUScalingChanged(bool Supported, bool Enabled, int Mode)
{
// UI thread
Application.Current.Dispatcher.Invoke(() =>
{
GPUScalingToggle.IsEnabled = Supported;
StackProfileRIS.IsEnabled = Supported; // check if processor is AMD should be enough
StackProfileRSR.IsEnabled = Supported;
StackProfileIS.IsEnabled = Supported;
});
HasGPUScalingSupport = Supported;
UpdateGraphicsSettingsUI();
}

private void OnIntegerScalingChanged(bool Supported, bool Enabled)
{
// UI thread
Application.Current.Dispatcher.Invoke(() =>
{
StackProfileIS.IsEnabled = Supported;
});
HasIntegerScalingSupport = Supported;
UpdateGraphicsSettingsUI();
}

private void RTSS_Updated(PlatformStatus status)
Expand Down

0 comments on commit fa6f49d

Please sign in to comment.