1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Profiles - Fixed PerLayerBrush clip rendering issue on transform

Profile service - Store the active profile whenever it changes
This commit is contained in:
SpoinkyNL 2020-08-10 23:37:33 +02:00
parent fb93ad16fe
commit f21ade955d
4 changed files with 39 additions and 10 deletions

View File

@ -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
Layer.ExcludeCanvasFromTranslation(canvas, true);
// Apply a translated version of the shape as the clipping mask
var shapePath = new SKPath(Layer.LayerShape.Path);
Layer.IncludePathInTranslation(shapePath, true);
canvas.ClipPath(shapePath);
if (Layer.General.ResizeMode == LayerResizeMode.Normal)
{
// Apply a translated version of the shape as the clipping mask
var shapePath = new SKPath(Layer.LayerShape.Path);
Layer.IncludePathInTranslation(shapePath, true);
canvas.ClipPath(shapePath);
}
using var pointsPath = new SKPath();
using var ledPaint = new SKPaint();

View File

@ -87,7 +87,7 @@
"$type": "Artemis.Storage.Entities.Profile.PropertyEntity, Artemis.Storage",
"PluginGuid": "ffffffff-ffff-ffff-ffff-ffffffffffff",
"Path": "General.ResizeMode",
"Value": "0",
"Value": "1",
"KeyframesEnabled": false,
"KeyframeEntities": {
"$type": "System.Collections.Generic.List`1[[Artemis.Storage.Entities.Profile.KeyframeEntity, Artemis.Storage]], System.Private.CoreLib",

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Artemis.Core.Events;
using Artemis.Core.Exceptions;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Abstract;
@ -58,6 +59,8 @@ namespace Artemis.Core.Services.Storage
public ProfileDescriptor CreateProfileDescriptor(ProfileModule module, string name)
{
var profileEntity = new ProfileEntity {Id = Guid.NewGuid(), Name = name, PluginGuid = module.PluginInfo.Guid};
_profileRepository.Add(profileEntity);
return new ProfileDescriptor(module, profileEntity);
}
@ -67,10 +70,15 @@ namespace Artemis.Core.Services.Storage
return profileDescriptor.ProfileModule.ActiveProfile;
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);
InstantiateProfile(profile);
profileDescriptor.ProfileModule.ChangeActiveProfile(profile, _surfaceService.ActiveSurface);
SaveActiveProfile(profileDescriptor.ProfileModule);
return profile;
}
@ -80,16 +88,32 @@ namespace Artemis.Core.Services.Storage
return profileDescriptor.ProfileModule.ActiveProfile;
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);
InstantiateProfile(profile);
await profileDescriptor.ProfileModule.ChangeActiveProfileAnimated(profile, _surfaceService.ActiveSurface);
SaveActiveProfile(profileDescriptor.ProfileModule);
return profile;
}
public void ClearActiveProfile(ProfileModule module)
{
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)
@ -103,7 +127,7 @@ namespace Artemis.Core.Services.Storage
// If the given profile is currently active, disable it first (this also disposes it)
if (profile.Module.ActiveProfile == profile)
profile.Module.ChangeActiveProfile(null, _surfaceService.ActiveSurface);
ClearActiveProfile(profile.Module);
else
profile.Dispose();

View File

@ -286,11 +286,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
Profiles.AddRange(_profileService.GetProfileDescriptors(Module).OrderBy(d => d.Name));
// Populate the selected profile
SelectedProfile = Profiles.FirstOrDefault(p => p.IsLastActiveProfile);
if (SelectedProfile != null)
var lastActiveProfile = Profiles.FirstOrDefault(p => p.IsLastActiveProfile) ?? Profiles.FirstOrDefault();
if (lastActiveProfile != null)
{
SelectedProfile = lastActiveProfile;
return;
}
// Create a default profile if there is none
var defaultProfile = _profileService.CreateProfileDescriptor(Module, "Default");
Profiles.Add(defaultProfile);