1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 13:28:33 +00:00

Added configuration to disable transparency in profiles which prevents profiles below from rendering

This commit is contained in:
Darth Affe 2023-08-07 21:16:31 +02:00
parent 2621542479
commit 0783671db7
4 changed files with 50 additions and 16 deletions

View File

@ -27,6 +27,7 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable
private bool _isMissingModule;
private bool _isSuspended;
private bool _fadeInAndOut;
private bool _allowTransparency = true;
private Module? _module;
private string _name;
@ -175,6 +176,16 @@ public class ProfileConfiguration : BreakableModel, IStorageModel, IDisposable
set => SetAndNotify(ref _fadeInAndOut, value);
}
/// <summary>
/// Gets or sets a boolean indicating whether this profile allows transparency.
/// If <c>true</c>, transparency is enabled and layers below are rendered; if <c>false</c> this profile is rendered on top of solid black and profiles below are not rendered.
/// </summary>
public bool AllowTransparency
{
get => _allowTransparency;
set => SetAndNotify(ref _allowTransparency, value);
}
/// <summary>
/// Gets or sets the module this profile uses
/// </summary>

View File

@ -125,7 +125,7 @@ internal class ProfileService : IProfileService
profileConfiguration.IsSuspended = true;
}
}
// If suspension was changed, save the category
if (before != profileConfiguration.IsSuspended)
SaveProfileCategory(profileConfiguration.Category);
@ -258,23 +258,16 @@ internal class ProfileService : IProfileService
return;
// Iterate the children in reverse because the first category must be rendered last to end up on top
for (int i = _profileCategories.Count - 1; i > -1; i--)
IEnumerable<Profile> profilesToRender = GetProfilesToRender(_profileCategories).Reverse();
foreach (Profile profile in profilesToRender)
{
ProfileCategory profileCategory = _profileCategories[i];
for (int j = profileCategory.ProfileConfigurations.Count - 1; j > -1; j--)
try
{
try
{
ProfileConfiguration profileConfiguration = profileCategory.ProfileConfigurations[j];
// Ensure all criteria are met before rendering
bool fadingOut = profileConfiguration.Profile?.ShouldDisplay == false && profileConfiguration.Profile?.Opacity > 0;
if (!profileConfiguration.IsSuspended && !profileConfiguration.IsMissingModule && (profileConfiguration.ActivationConditionMet || fadingOut))
profileConfiguration.Profile?.Render(canvas, SKPointI.Empty, null);
}
catch (Exception e)
{
_renderExceptions.Add(e);
}
profile.Render(canvas, SKPointI.Empty, null);
}
catch (Exception e)
{
_renderExceptions.Add(e);
}
}
@ -282,6 +275,23 @@ internal class ProfileService : IProfileService
}
}
private static IEnumerable<Profile> GetProfilesToRender(IEnumerable<ProfileCategory> profileCategories)
{
IEnumerable<Profile?> profiles = profileCategories.SelectMany(x => x.ProfileConfigurations).Select(x => x.Profile);
foreach (Profile? profile in profiles)
if (profile != null)
{
bool fadingOut = profile.ShouldDisplay == false && profile.Opacity > 0;
if (!profile.Configuration.IsSuspended && !profile.Configuration.IsMissingModule && (profile.Configuration.ActivationConditionMet || fadingOut))
{
yield return profile;
if (!profile.Configuration.AllowTransparency)
break;
}
}
}
public ReadOnlyCollection<ProfileCategory> ProfileCategories
{
get

View File

@ -120,6 +120,10 @@
<CheckBox VerticalAlignment="Bottom" IsChecked="{CompiledBinding FadeInAndOut}" ToolTip.Tip="Smoothly animates in and out when the profile activation conditions change.">
Fade when enabling and disabling
</CheckBox>
<CheckBox VerticalAlignment="Bottom" IsChecked="{CompiledBinding AllowTransparency}" ToolTip.Tip="Allow layers from below to shine through transparent leds.">
Allow layers from below to shine through transparent leds
</CheckBox>
</StackPanel>
</Border>

View File

@ -30,6 +30,7 @@ public class ProfileConfigurationEditViewModel : DialogViewModelBase<ProfileConf
private Hotkey? _disableHotkey;
private Hotkey? _enableHotkey;
private bool _fadeInAndOut;
private bool _allowTransparency;
private ProfileConfigurationHotkeyMode _hotkeyMode;
private ProfileConfigurationIconType _iconType;
private ProfileConfiguration _profileConfiguration;
@ -60,6 +61,7 @@ public class ProfileConfigurationEditViewModel : DialogViewModelBase<ProfileConf
_iconType = _profileConfiguration.Icon.IconType;
_hotkeyMode = _profileConfiguration.HotkeyMode;
_fadeInAndOut = _profileConfiguration.FadeInAndOut;
_allowTransparency = _profileConfiguration.AllowTransparency;
if (_profileConfiguration.EnableHotkey != null)
_enableHotkey = new Hotkey {Key = _profileConfiguration.EnableHotkey.Key, Modifiers = _profileConfiguration.EnableHotkey.Modifiers};
if (_profileConfiguration.DisableHotkey != null)
@ -124,6 +126,12 @@ public class ProfileConfigurationEditViewModel : DialogViewModelBase<ProfileConf
set => RaiseAndSetIfChanged(ref _fadeInAndOut, value);
}
public bool AllowTransparency
{
get => _allowTransparency;
set => RaiseAndSetIfChanged(ref _allowTransparency, value);
}
public ObservableCollection<ProfileModuleViewModel?> Modules { get; }
public ProfileModuleViewModel? SelectedModule
@ -162,6 +170,7 @@ public class ProfileConfigurationEditViewModel : DialogViewModelBase<ProfileConf
ProfileConfiguration.EnableHotkey = EnableHotkey;
ProfileConfiguration.DisableHotkey = DisableHotkey;
ProfileConfiguration.FadeInAndOut = FadeInAndOut;
ProfileConfiguration.AllowTransparency = AllowTransparency;
await SaveIcon();