mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-02 10:43:31 +00:00
Profiles - Fixed PerLayerBrush clip rendering issue on transform
Profile service - Store the active profile whenever it changes
This commit is contained in:
parent
fb93ad16fe
commit
f21ade955d
@ -30,10 +30,13 @@ namespace Artemis.Core.Plugins.LayerBrush.Abstract
|
|||||||
// We don't want translations on this canvas because that'll displace the LEDs, translations are applied to the points of each LED instead
|
// We don't want translations on this canvas because that'll displace the LEDs, translations are applied to the points of each LED instead
|
||||||
Layer.ExcludeCanvasFromTranslation(canvas, true);
|
Layer.ExcludeCanvasFromTranslation(canvas, true);
|
||||||
|
|
||||||
// Apply a translated version of the shape as the clipping mask
|
if (Layer.General.ResizeMode == LayerResizeMode.Normal)
|
||||||
var shapePath = new SKPath(Layer.LayerShape.Path);
|
{
|
||||||
Layer.IncludePathInTranslation(shapePath, true);
|
// Apply a translated version of the shape as the clipping mask
|
||||||
canvas.ClipPath(shapePath);
|
var shapePath = new SKPath(Layer.LayerShape.Path);
|
||||||
|
Layer.IncludePathInTranslation(shapePath, true);
|
||||||
|
canvas.ClipPath(shapePath);
|
||||||
|
}
|
||||||
|
|
||||||
using var pointsPath = new SKPath();
|
using var pointsPath = new SKPath();
|
||||||
using var ledPaint = new SKPaint();
|
using var ledPaint = new SKPaint();
|
||||||
|
|||||||
@ -87,7 +87,7 @@
|
|||||||
"$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage",
|
"$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage",
|
||||||
"PluginGuid": "ffffffff-ffff-ffff-ffff-ffffffffffff",
|
"PluginGuid": "ffffffff-ffff-ffff-ffff-ffffffffffff",
|
||||||
"Path": "General.ResizeMode",
|
"Path": "General.ResizeMode",
|
||||||
"Value": "0",
|
"Value": "1",
|
||||||
"KeyframesEnabled": false,
|
"KeyframesEnabled": false,
|
||||||
"KeyframeEntities": {
|
"KeyframeEntities": {
|
||||||
"$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib",
|
"$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib",
|
||||||
|
|||||||
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Artemis.Core.Events;
|
using Artemis.Core.Events;
|
||||||
|
using Artemis.Core.Exceptions;
|
||||||
using Artemis.Core.Models.Profile;
|
using Artemis.Core.Models.Profile;
|
||||||
using Artemis.Core.Models.Surface;
|
using Artemis.Core.Models.Surface;
|
||||||
using Artemis.Core.Plugins.Abstract;
|
using Artemis.Core.Plugins.Abstract;
|
||||||
@ -58,6 +59,8 @@ namespace Artemis.Core.Services.Storage
|
|||||||
public ProfileDescriptor CreateProfileDescriptor(ProfileModule module, string name)
|
public ProfileDescriptor CreateProfileDescriptor(ProfileModule module, string name)
|
||||||
{
|
{
|
||||||
var profileEntity = new ProfileEntity {Id = Guid.NewGuid(), Name = name, PluginGuid = module.PluginInfo.Guid};
|
var profileEntity = new ProfileEntity {Id = Guid.NewGuid(), Name = name, PluginGuid = module.PluginInfo.Guid};
|
||||||
|
_profileRepository.Add(profileEntity);
|
||||||
|
|
||||||
return new ProfileDescriptor(module, profileEntity);
|
return new ProfileDescriptor(module, profileEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,10 +70,15 @@ namespace Artemis.Core.Services.Storage
|
|||||||
return profileDescriptor.ProfileModule.ActiveProfile;
|
return profileDescriptor.ProfileModule.ActiveProfile;
|
||||||
|
|
||||||
var profileEntity = _profileRepository.Get(profileDescriptor.Id);
|
var profileEntity = _profileRepository.Get(profileDescriptor.Id);
|
||||||
|
if (profileEntity == null)
|
||||||
|
throw new ArtemisCoreException($"Cannot find profile named: {profileDescriptor.Name} ID: {profileDescriptor.Id}");
|
||||||
|
|
||||||
var profile = new Profile(profileDescriptor.ProfileModule, profileEntity);
|
var profile = new Profile(profileDescriptor.ProfileModule, profileEntity);
|
||||||
InstantiateProfile(profile);
|
InstantiateProfile(profile);
|
||||||
|
|
||||||
profileDescriptor.ProfileModule.ChangeActiveProfile(profile, _surfaceService.ActiveSurface);
|
profileDescriptor.ProfileModule.ChangeActiveProfile(profile, _surfaceService.ActiveSurface);
|
||||||
|
SaveActiveProfile(profileDescriptor.ProfileModule);
|
||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,16 +88,32 @@ namespace Artemis.Core.Services.Storage
|
|||||||
return profileDescriptor.ProfileModule.ActiveProfile;
|
return profileDescriptor.ProfileModule.ActiveProfile;
|
||||||
|
|
||||||
var profileEntity = _profileRepository.Get(profileDescriptor.Id);
|
var profileEntity = _profileRepository.Get(profileDescriptor.Id);
|
||||||
|
if (profileEntity == null)
|
||||||
|
throw new ArtemisCoreException($"Cannot find profile named: {profileDescriptor.Name} ID: {profileDescriptor.Id}");
|
||||||
|
|
||||||
var profile = new Profile(profileDescriptor.ProfileModule, profileEntity);
|
var profile = new Profile(profileDescriptor.ProfileModule, profileEntity);
|
||||||
InstantiateProfile(profile);
|
InstantiateProfile(profile);
|
||||||
|
|
||||||
await profileDescriptor.ProfileModule.ChangeActiveProfileAnimated(profile, _surfaceService.ActiveSurface);
|
await profileDescriptor.ProfileModule.ChangeActiveProfileAnimated(profile, _surfaceService.ActiveSurface);
|
||||||
|
SaveActiveProfile(profileDescriptor.ProfileModule);
|
||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearActiveProfile(ProfileModule module)
|
public void ClearActiveProfile(ProfileModule module)
|
||||||
{
|
{
|
||||||
module.ChangeActiveProfile(null, _surfaceService.ActiveSurface);
|
module.ChangeActiveProfile(null, _surfaceService.ActiveSurface);
|
||||||
|
SaveActiveProfile(module);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveActiveProfile(ProfileModule module)
|
||||||
|
{
|
||||||
|
var profileEntities = _profileRepository.GetByPluginGuid(module.PluginInfo.Guid);
|
||||||
|
foreach (var profileEntity in profileEntities)
|
||||||
|
{
|
||||||
|
profileEntity.IsActive = module.ActiveProfile.EntityId == profileEntity.Id;
|
||||||
|
_profileRepository.Save(profileEntity);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task ClearActiveProfileAnimated(ProfileModule module)
|
public async Task ClearActiveProfileAnimated(ProfileModule module)
|
||||||
@ -103,7 +127,7 @@ namespace Artemis.Core.Services.Storage
|
|||||||
|
|
||||||
// If the given profile is currently active, disable it first (this also disposes it)
|
// If the given profile is currently active, disable it first (this also disposes it)
|
||||||
if (profile.Module.ActiveProfile == profile)
|
if (profile.Module.ActiveProfile == profile)
|
||||||
profile.Module.ChangeActiveProfile(null, _surfaceService.ActiveSurface);
|
ClearActiveProfile(profile.Module);
|
||||||
else
|
else
|
||||||
profile.Dispose();
|
profile.Dispose();
|
||||||
|
|
||||||
|
|||||||
@ -286,10 +286,12 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
|
|||||||
Profiles.AddRange(_profileService.GetProfileDescriptors(Module).OrderBy(d => d.Name));
|
Profiles.AddRange(_profileService.GetProfileDescriptors(Module).OrderBy(d => d.Name));
|
||||||
|
|
||||||
// Populate the selected profile
|
// Populate the selected profile
|
||||||
SelectedProfile = Profiles.FirstOrDefault(p => p.IsLastActiveProfile);
|
var lastActiveProfile = Profiles.FirstOrDefault(p => p.IsLastActiveProfile) ?? Profiles.FirstOrDefault();
|
||||||
|
if (lastActiveProfile != null)
|
||||||
if (SelectedProfile != null)
|
{
|
||||||
|
SelectedProfile = lastActiveProfile;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Create a default profile if there is none
|
// Create a default profile if there is none
|
||||||
var defaultProfile = _profileService.CreateProfileDescriptor(Module, "Default");
|
var defaultProfile = _profileService.CreateProfileDescriptor(Module, "Default");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user